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

Setting date parameters with yesterdays date

Former Member
0 Likes
1,076

Hi everyone.

I have a very basic report where I have two date fields as parameters, 'From Date' and 'To Date'.

I want the From date to default to yesterday, and the To date to default to today.

I can set todays date simply by adding DEFAULT sy-datum to the parameter.

But I've been unable to figure out how to set yesterdays date.

I tried adding some code before the parameters eg:

lv_yesterday = sy-datum - 1.

and then add DEFAULT lv_yesterday to the parameter but it doesn't do anything.

Anybody able to help here? Seems rather trivial but no luck so far!

Moderator message - You're right, this is a pretty basic question. Please search before asking - post locked

Edited by: Rob Burbank on Jun 23, 2009 5:21 PM

Moderator message - OK - I'm going to unlock it long enough so that you can mark David's solution as - solved your problem (I'd use INITIALIZATION rather than LOAD-OF-PROGRAM though

Edited by: Rob Burbank on Jun 23, 2009 5:23 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
644

Hello Kieran,

I think you need to calculate the date in the LOAD-OF-PROGRAM event block:


REPORT z_test.

DATA: gv_yesterday TYPE d.

PARAMETERS:
  pa_date TYPE d DEFAULT gv_yesterday.

LOAD-OF-PROGRAM.
  gv_yesterday = sy-datum - 1.

Best regards

David

3 REPLIES 3
Read only

Former Member
0 Likes
645

Hello Kieran,

I think you need to calculate the date in the LOAD-OF-PROGRAM event block:


REPORT z_test.

DATA: gv_yesterday TYPE d.

PARAMETERS:
  pa_date TYPE d DEFAULT gv_yesterday.

LOAD-OF-PROGRAM.
  gv_yesterday = sy-datum - 1.

Best regards

David

Read only

0 Likes
644

Thanks very much. I was searching all yesterday, and really didn't want to ask on here but was left with no choice!

Problem solved.

Read only

0 Likes
644

David - try:

PARAMETERS:
  pa_date TYPE d.

INITIALIZATION.
  pa_date = sy-datum - 1.

Rob