05-10-2017 4:15 PM
Hey everyone,
I want to set a default value for a parameter with a variable, but that doesn't work.
DATA: start_date TYPE sy-datum.
start_date = '20170510'.
PARAMETER: p_sdate TYPE sy-datum OBLIGATORY DEFAULT start_date.
This is just an example, normally the variable 'start_date' is automatically generated depending on the week you select.
The above code sample leaves the paramter field empty when I run my report. I don't understand this, because those two examples work fine:
PARAMETER: p_sdate TYPE sy-datum OBLIGATORY DEFAULT '20170510.
*or
PARAMETER: p_sdate TYPE sy-datum OBLIGATORY DEFAULT sy-datum.
Anyone knows what I'm doing wrong here?
05-10-2017 4:46 PM
"Anyone knows what I'm doing wrong here?"
Yes, of course. You miss one of the most basic features of ABAP, namely that you cannot expect a program to simply process the statements sequentially. First, you must understand the difference between declarations and operational statements. Second, you must know the implicit modularization of any ABAP program and how it is executed by the runtime environment.
Look up how a program is executed after SUBMIT and you'll see, that your assignment is not carried out before sending the selection screen. Debugging also shows that.
Implement the assignment during the INITIALIZATION or the AT SELECTION-SCREEN OUTPUT event and not implicitly during START-OF-SELECTION as you do.
05-10-2017 4:46 PM
"Anyone knows what I'm doing wrong here?"
Yes, of course. You miss one of the most basic features of ABAP, namely that you cannot expect a program to simply process the statements sequentially. First, you must understand the difference between declarations and operational statements. Second, you must know the implicit modularization of any ABAP program and how it is executed by the runtime environment.
Look up how a program is executed after SUBMIT and you'll see, that your assignment is not carried out before sending the selection screen. Debugging also shows that.
Implement the assignment during the INITIALIZATION or the AT SELECTION-SCREEN OUTPUT event and not implicitly during START-OF-SELECTION as you do.
05-10-2017 5:36 PM
Thank you for your quick reply! You're completely right, I really did miss the understanding of this. I looked it up and now everything works fine and just like planned.
Thanks for your help!