Skip to Content
avatar image
Former Member

DTP Selection Criteria Routine

Hi All.

I am trying to use a routine in the selection criteria of a DTP. I use the same code as per Info Package routines. However, although there are no syntax errors, the values for the selection criteria are not generated and the DTP fails with an error. It seems I am missing something. Can some one please give me some sample code. Here is the code I am using:

form compute_CALMONTH

tables l_t_range structure rssdlrange

changing p_subrc like sy-subrc.

  • Insert source code to current selection field

$$ begin of routine - insert your code only below this line -

data: l_idx like sy-tabix.

read table l_t_range with key

fieldname = ' '.

*NOTE: I have also tried to insert CALMONTH between the quotes, but it *makes no difference. ' ' is the way it is generated by default.

l_idx = sy-tabix.

*....

DATA: zdate like sy-datum,

zcalmonth(6) type n.

move sy-datum to zdate.

zcalmonth = zdate(6).

l_t_range-low = zcalmonth.

l_t_range-sign = 'I'.

l_t_range-option = 'EQ'.

if l_idx <> 0.

modify l_t_range index l_idx.

else.

append l_t_range.

endif.

p_subrc = 0.

$$ end of routine - insert your code only before this line -

endform.

Thanks.

Johan Loock

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 23, 2008 at 08:25 AM

    Hi

    Pls try this

    data: l_idx like sy-tabix.

    read table l_t_range with key

    fieldname = 'CALMONTH'.

    l_idx = sy-tabix.

    DATA: zcalmonth(6) type n.

    zcalmonth = sy-datum(6).

    l_t_range-iobjnm = '0CALMONTH'.

    l_t_range-FIELDNAME = 'CALMONTH'.

    l_t_range-low = zcalmonth.

    l_t_range-sign = 'I'.

    l_t_range-option = 'EQ'.

    if l_idx 0.

    modify l_t_range index l_idx.

    else.

    append l_t_range.

    endif.

    p_subrc = 0.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 23, 2008 at 08:11 AM

    Hi Johan,

    I have two suggestions:

    First: Put CALMONTH in the read table statement:

    read table l_t_range with key
      fieldname = 'CALMONTH'.

    If in doubt, in the comment above the 'form compute' you can see the fieldname you have to use. No idea why this was not filled in per default.

    Second: Simply assign sy-datum instead of your type conversion. I find it very strange that you convert to n instead of c. So I would simply use:

    l_t_range-low = sy-datum(6).

    For security reasons I normaly set l_t_range-high too.

    l_t_range-high = sy-datum(6).

    Everything else should work.

    Kind regards,

    Jürgen

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 20, 2008 at 04:34 PM
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 21, 2008 at 05:59 AM

    HI Raj, the Form code was generated by BI and is not changable in the routine. I added only the following lines, the rest being out of my control, except for the modify & append statements at the end:

    DATA: zdate like sy-datum,

    zcalmonth(6) type n.

    move sy-datum to zdate.

    zcalmonth = zdate(6).

    l_t_range-low = zcalmonth.

    l_t_range-sign = 'I'.

    l_t_range-option = 'EQ'.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 24, 2008 at 06:16 AM

    Hi Jürgen/Rohit, thanks for the replies.

    Jürgen, thanks for the programming tips. I am not an Abaper, but but make do with limited knowledge, so I problably do many strange things. I take take note of how I can simplify my code. However that did not change the result of the routine. Even if I hardcode the calmonth like '200807' it did not pick it up.

    Rohit, what you suggested resulted in the routine actually working. More specific, the statement, l_t_range-FIELDNAME = 'CALMONTH', is the one that is required. The other one, l_t_range-iobjnm = '0CALMONTH', makes no difference, whether it is there or not.

    Thanks for you input.

    Regards,

    JL

    Add comment
    10|10000 characters needed characters exceeded