Skip to Content
0
Nov 06, 2013 at 02:10 PM

DTP Filter routine not working

399 Views

Hello Experts,

I have followed a document from SDN and created routine for a Date field in DTP.

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/80b2db87-639b-2e10-a8b9-c1ac0a44a7a6?QuickLink=index&overridelayout=true&51715701272683

But when I activate it and execute DTP, I dont see the filter condtion generated in the Date field.

Logic is the routine should generate Date range between current date to Date three years before. Below is the code I used

******************************************************************

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

data: zdate_start LIKE sy-datum,
zlv_date LIKE sy-datum,
zdate_end LIKE sy-datum.

clear l_t_range-high.
clear l_t_range-low.
clear zdate_start.
clear zdate_end.

zdate_end = sy-datum.

CALL FUNCTION 'Z_ADD_MONTH_TO_DATE'
EXPORTING
MONTHS = -36
OLDDATE = sy-datum
IMPORTING
NEWDATE = zdate_start.

IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

l_t_range-low = zdate_start.
l_t_range-high = zdate_end.
l_t_range-sign = 'I'.
l_t_range-option = 'BT'.

APPEND l_t_range.
* IF l_idx <> 0.
* MODIFY l_t_range index l_idx.
* ELSE.
* APPEND l_t_range.
* ENDIF.

p_subrc = 0.

***********************************************************************

In above, I have tested the FM Z_ADD_MONTH_TO_DATE separately and it is working correct.

Please can any one help me what should be the reason I am not able to generate dynamic date range ?

Regards,

Gopi R