I have an ABAP program with below sample code which should select data from an SAP table based on a date column.
INITIALIZATION.
select-OPTIONS: so_date FOR sy-datum.
START-OF-SELECTION.
so_date-sign = 'I'.
so_date-option = 'BT'.
so_date-low = sy-datum.
so_date-high = '99991231'.
APPEND so_date.
and my select stmt is:
select c1,c2,c3
from <sap_table>
where <date_column> in so_date.
I want to know the purpose of setting so_date-high = '99991231' and how it will behave.
BT
means between. 99991231
is a date in the internal format YYYYMMDD (Year-month-day), it is the 31th december 9999. Your setting of the select option hits any date between today and a date far in the future.
TheG already mentioned: It should be better at INITIALIZATION
, so your selection is already visible on selection-screen and can be modified if you need it.
select-OPTIONS: so_date FOR sy-datum.
INITIALIZATION.
so_date-sign = 'I'.
so_date-option = 'BT'.
so_date-low = sy-datum.
so_date-high = '99991231'.
APPEND so_date.
Remark: This presetting works only in dialogue, not in batch (but when you call it in batch, you can set the default in the variant for the batch job).
But for this easy default values, you should use the default
-option of select-options
:
SELECT-OPTIONS: so_date FOR sy-datum DEFAULT sy-datum to '99991231'.
Or to say 'everything in the future':
SELECT-OPTIONS: so_date FOR sy-datum DEFAULT sy-datum OPTION GE.
GE
means greater equal.