cancel
Showing results for 
Search instead for 
Did you mean: 

DTP Filter routine not working

former_member210674
Participant
0 Kudos

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-c1ac0a44a...

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

Accepted Solutions (1)

Accepted Solutions (1)

RafkeMagic
Active Contributor
0 Kudos

  read table l_t_range with key

       fieldname = ''.

...

l_t_range-fieldname = ' '.


you need to enter a fieldname in the above lines... the first one is not filled in the document either; the other line is not present in your code (but it is in the document as  l_t_range-fieldname = 'FISCPER'. )

joost_peeters2
Participant
0 Kudos

Nice catch Former Member

former_member210674
Participant
0 Kudos

Thanks Raf Boudewijns. Issue resolved

Answers (0)