Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Giving default date range in select-options?

Former Member
0 Likes
6,660

When i do

SELECT-OPTIONS rangeDat FOR VBAK-ERDAT DEFAULT sy-datum TO sy-datum NO-EXTENSION.

I get input screen to enter a range with both low and high values pre-filled with current date.

But if i replace the low sy-datum with a variable as:

DATA lowDate TYPE sy-datum.
lowDate = sy-datum.

SELECT-OPTIONS rangeDat FOR VBAK-ERDAT DEFAULT lowDate TO sy-datum NO-EXTENSION.

then the low value is displayed blank instead of being pre-filled.

Why is this happening?

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
4,674

If you had debugged your program, you could have seen that when the selection screen is displayed, the kernel doesn't go through lowDate initialization.

1) Don't be mistaken by the order of statements, SELECT-OPTIONS is not a classic statement: it's not executed at runtime, it's mostly interpreted when the program is activated to create the "selection screen" object (the "default selection screen" by default, i.e. the dynpro number 1000).

2) Why lowDate is not executed: when a program is started, right before the default selection screen is displayed, the kernel executes the statements placed after three event blocks, in this order:

  • LOAD-OF-PROGRAM
  • INITIALIZATION
  • AT SELECTION-SCREEN OUTPUT

Any statement before these blocks belongs to the event block START-OF-SELECTION, this event is executed only after the selection screen is displayed, if the user presses the Execute button.

3) Solution: for instance, add the statement "INITIALIZATION." before lowDate initialization.

More information: ABAP documentation Flow of an Executable Program

When i do

SELECT-OPTIONS rangeDat FOR VBAK-ERDAT DEFAULT sy-datum TO sy-datum NO-EXTENSION.

I get input screen to enter a range with both low and high values pre-filled with current date.

But if i replace the low sy-datum with a variable as:

DATA lowDate TYPE sy-datum.
lowDate = sy-datum.

SELECT-OPTIONS rangeDat FOR VBAK-ERDAT DEFAULT lowDate TO sy-datum NO-EXTENSION.

then the low value is displayed blank instead of being pre-filled.

Why is this happening?

2 REPLIES 2
Read only

Sandra_Rossi
Active Contributor
4,675

If you had debugged your program, you could have seen that when the selection screen is displayed, the kernel doesn't go through lowDate initialization.

1) Don't be mistaken by the order of statements, SELECT-OPTIONS is not a classic statement: it's not executed at runtime, it's mostly interpreted when the program is activated to create the "selection screen" object (the "default selection screen" by default, i.e. the dynpro number 1000).

2) Why lowDate is not executed: when a program is started, right before the default selection screen is displayed, the kernel executes the statements placed after three event blocks, in this order:

  • LOAD-OF-PROGRAM
  • INITIALIZATION
  • AT SELECTION-SCREEN OUTPUT

Any statement before these blocks belongs to the event block START-OF-SELECTION, this event is executed only after the selection screen is displayed, if the user presses the Execute button.

3) Solution: for instance, add the statement "INITIALIZATION." before lowDate initialization.

More information: ABAP documentation Flow of an Executable Program

Read only

4,674

Neither INITIALIZATION nor AT SELECTION-SCREEN OUTPUT worked. LOAD-OF-PROGRAM worked! Thanks.