5 Nov 2008

DTP filer Routine

Following is the example of routine written in DTP filter.
While writing the logic of l_t_range-SIGN,l_t_range-OPTION,l_t_range-LOW etc. we should write l_t_range-Fieldname also here...

data: l_idx like sy-tabix.
read table l_t_range with key
fieldname = 'PLANT'.
l_idx = sy-tabix.

DATA : IT_PLANT LIKE TABLE OF /BI0/PPLANT.
data : it_plant_wa type /BI0/PPLANT.
DATA : IT_COUNTRY LIKE TABLE OF /BI0/PCOUNTRY.

CLEAR IT_COUNTRY.
CLEAR IT_PLANT.

SELECT * FROM /BI0/PCOUNTRY INTO TABLE IT_COUNTRY WHERE /BIC/ZMARKET2
= 'USA'.

IF IT_COUNTRY[] IS NOT INITIAL.
SELECT * FROM /BI0/PPLANT
INTO TABLE IT_PLANT
FOR ALL ENTRIES IN
IT_COUNTRY
WHERE COUNTRY = IT_COUNTRY-COUNTRY.
ENDIF.

LOOP AT IT_PLANT INTO IT_PLANT_WA.
l_t_range-low = IT_PLANT_WA-PLANT.
l_t_range-Fieldname = 'PLANT'.
l_t_range-SIGN = 'I'.
l_t_range-OPTION = 'EQ'.
append l_t_range.
ENDLOOP.

if l_idx <> 0.
modify l_t_range index l_idx.
else.
append l_t_range.
endif.
p_subrc = 0.

No comments: