Scenario:
SAP recommend the customer to use the parallel process in Query designer by 0infoprovider.
In this case, pls notice that the variabe(ZP_INFPR2) is used for Selecting Cubes based on Region.
*------------------------------------------------------------------------*
*- ADD BY ZHANGJ26 on 03/31/2009 for Migration -*
*- This variabe(ZP_INFPR2) is used for Selecting Cubes based on Region -*
*------------------------------------------------------------------------*
CASE i_vnam.
WHEN 'ZP_INFPR2'.
IF i_step = 2 OR i_step = 3.
TYPES:
BEGIN OF ty2_plant,
plant TYPE /bi0/oiplant,
comp_code TYPE /bi0/oicomp_code,
END OF ty2_plant,
BEGIN OF ty2_timeregion,
/bic/zicregcc TYPE /bic/oizicregcc,
/bic/zicregion TYPE /bic/oizicregion,
END OF ty2_timeregion.
DATA: wa2_timeregion TYPE ty2_timeregion,
t2_timeregion TYPE TABLE OF ty2_timeregion,
wa2_plant TYPE ty2_plant,
t2_plant TYPE TABLE OF ty2_plant.
DATA: flag_found2(1) TYPE c. " flag to check for all Cube search or not
* to hold the company codes from the selection screen
DATA:
r2_plant TYPE RANGE OF /bi0/pplant-plant,
r2_compcode TYPE RANGE OF /bic/pzicregcc-/bic/zicregcc,
r2_plant_line LIKE LINE OF r2_plant,
r2_compcode_line LIKE LINE OF r2_plant.
CONSTANTS:
c_inclusive22 TYPE c VALUE 'I', " Inclusive
c_equals22(2) TYPE c VALUE 'EQ'. " Equals
* prepare the range tables for compcode from selection screen
LOOP AT i_t_var_range INTO loc_var_range.
IF loc_var_range-iobjnm = '0PLANT'.
r2_plant_line-sign = loc_var_range-sign.
r2_plant_line-option = loc_var_range-opt.
r2_plant_line-low = loc_var_range-low.
r2_plant_line-high = loc_var_range-high.
APPEND r2_plant_line TO r2_plant.
CLEAR r2_plant_line.
ENDIF.
ENDLOOP.
* CREATE BY ZHANGJ26 03/31/2009
LOOP AT i_t_var_range INTO loc_var_range
WHERE vnam EQ 'ZS_PLANT'.
r2_plant_line-sign = loc_var_range-sign.
r2_plant_line-option = loc_var_range-opt.
r2_plant_line-low = loc_var_range-low.
r2_plant_line-high = loc_var_range-high.
APPEND r2_plant_line TO r2_plant.
CLEAR r2_plant_line.
ENDLOOP.
IF NOT r2_plant[] IS INITIAL.
SELECT plant
comp_code
FROM /bi0/pplant
INTO TABLE t2_plant
WHERE plant IN r2_plant.
IF sy-subrc = 0.
DELETE ADJACENT DUPLICATES FROM t2_plant COMPARING plant.
ENDIF.
ENDIF.
IF NOT t2_plant[] IS INITIAL.
SELECT /bic/zicregcc
/bic/zicregion
FROM /bic/pzicregcc
INTO TABLE t2_timeregion
FOR ALL ENTRIES IN t2_plant
WHERE /bic/zicregcc EQ t2_plant-comp_code.
IF sy-subrc = 0.
flag_found2 = 'X'.
ELSE.
flag_found2 = space.
ENDIF.
ENDIF.
IF flag_found2 = 'X'.
* remove duplications
SORT t2_timeregion BY /bic/zicregion ASCENDING.
DELETE ADJACENT DUPLICATES FROM t2_timeregion COMPARING /bic/zicregcc.
* determine the dataproviders based on the timeregion and the
* variables
CLEAR l_s_range.
l_s_range-sign = c_inclusive22.
l_s_range-opt = c_equals22.
LOOP AT t2_timeregion INTO wa2_timeregion.
IF i_vnam = 'ZP_INFPR2'.
IF wa2_timeregion-/bic/zicregion = '01'. "<-- EMEA <-- Mod-100
l_s_range-low = 'ZIC_DC04'.
APPEND l_s_range TO e_t_range.
ELSEIF wa2_timeregion-/bic/zicregion = '02'. "<-- Americas <-- Mod-100
l_s_range-low = 'ZIC_DC05'.
APPEND l_s_range TO e_t_range.
ELSEIF wa2_timeregion-/bic/zicregion = '03'. "<-- Asia Pac <-- Mod-100
l_s_range-low = 'ZIC_DC06'.
APPEND l_s_range TO e_t_range.
ENDIF.
ENDIF.
ENDLOOP.
ELSE.
* when no Cube has been determined, then use all the 3 region Cubes for
* the BEx variables
IF e_t_range[] IS INITIAL.
* for all 3 region Cubes
IF i_vnam = 'ZP_INFPR2'.
l_s_range-sign = c_inclusive22.
l_s_range-opt = c_equals22.
l_s_range-low = 'ZIC_DC04'.
APPEND l_s_range TO e_t_range.
CLEAR l_s_range.
l_s_range-sign = c_inclusive22.
l_s_range-opt = c_equals22.
l_s_range-low = 'ZIC_DC05'.
APPEND l_s_range TO e_t_range.
CLEAR l_s_range.
l_s_range-sign = c_inclusive22.
l_s_range-opt = c_equals22.
l_s_range-low = 'ZIC_DC06'.
APPEND l_s_range TO e_t_range.
CLEAR l_s_range.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDCASE.
* END BY ZHANGJ26 03/31/2009