Let us consider a scenario where we need to set Filter for some plants in DTP. And these plants input can be editable. For this we can set variables in TVARVC which can be editable in Production system.
For creating variables in TVARVC , GOTO STVARV Tcode
1. Select selection Option tab
2. Click on change mode
3. Create variables
Once the required Plants are set in TVARVC then goto DTP filter and select routine
And write the abap code wich fetch the data from TVARVC and add it to plant filter.
data: l_idx like sy-tabix,
IT_TVARVC TYPE STANDARD TABLE OF TVARVC,
WA_TVARVC type TVARVC,
l_s_range like line of l_t_range.
read table l_t_range with key
fieldname = 'PLANT'.
SELECT * FROM TVARVC INTO CORRESPONDING FIELDS OF TABLE IT_TVARVC
WHERE NAME = 'VAR_PLANT'.
loop at it_tvarvc into wa_tvarvc.
If wa_tvarvc-NAME = 'VAR_PLANT'.
l_s_range-iobjnm = 'PLANT'.
l_s_range-fieldname ='PLANT'.
l_s_range-sign = 'I'.
l_s_range-option = 'EQ'.
l_s_range-low = wa_tvarvc-low.
append l_S_range TO l_T_range .
ENDIF.
ENDLOOP.
p_subrc = 0.
Then save,activate the DTP and execute the DTP.
The entries which we add in TVARVC variable will be available in DTP which is editable.
If we want to add plant range as filter then we need to slightly modify the code.Set the Range in TVARVC Variable.
data: l_idx like sy-tabix, IT_TVARVC TYPE STANDARD TABLE OF TVARVC,
WA_TVARVC type TVARVC,
l_s_range like line of l_t_range.
read table l_t_range with key
fieldname = 'PLANT'.
SELECT * FROM TVARVC INTO CORRESPONDING FIELDS OF TABLE IT_TVARVC
WHERE NAME = 'VAR_PLANT_RANGE'.
loop at it_tvarvc into wa_tvarvc.
If wa_tvarvc-NAME = 'VAR_PLANT_RANGE'.
l_s_range-iobjnm = 'PLANT'.
l_s_range-fieldname ='PLANT'.
l_s_range-sign = 'I'.
l_s_range-option = 'BT'.
l_s_range-low = wa_tvarvc-low.
l_s_range-high = wa_tvarvc-high.
append l_S_range TO l_T_range .
ENDIF.
ENDLOOP.
p_subrc = 0.
Then save,activate the DTP and execute the DTP.
scala training
ReplyDeleteazure devops training
app v training