Skip to Content
1

Set the default value for a date parameter with a variable

May 10, 2017 at 03:15 PM

83

avatar image
Former Member

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?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Horst Keller
May 10, 2017 at 03:46 PM
3

"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.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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!

0