abapopensqlsap-selection-screens

Setting SELECT-OPTIONS manually?


I have a program that, among other things, retrieves data from table RESB based on the bdter field, a DATS type. On the selection screen the user either specifies a range or a standard range (start of month - today) is used.

However, if I try to re-use the select-option I created for date in those cases where it isn't filled (the user entered no date range), my changes to this work area don't seem to be recognized when I use it in my select statement.

Relevant code segments follow. After some testing I've concluded that:

Is this known and documented behaviour? I resolved it by creating my own RANGE table, is this what you're always supposed to do? Is there then no way to re-use unset select-options to prevent code duplication?


Solution

  • You only fill the header line of s_bdter. You must also append it:

    " Set the interval.
    s_bdter-sign = 'I'.
    s_bdter-option = 'BT'.
    s_bdter-low = lc_bdter_start.
    s_bdter-high = sy-datum + 30.
    append s_bdter. "<- this was missing
    

    With this, you don't check, if it isn't filled. This check must be done explicit:

    " describe table s_bdter.
    if sy-tfill = 0.
      " Set the interval.
      s_bdter-sign = 'I'.
      s_bdter-option = 'BT'.
      s_bdter-low = lc_bdter_start.
      s_bdter-high = sy-datum + 30.
      append s_bdter. "<- this was missing
    endif. " sy-tfill = 0.
    

    I hope my code has the correct syntax and sy-tfill is the correct value. I can't check it actual. But the principle should be clear.