Application Development 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: 

Selection-Screen: Date Defaulted or User Specified?

Former Member
0 Kudos

On the selection-screen I want it to default to today's date - 90 days. So I have the fllowing code that works:

SELECTION-SCREEN BEGIN OF BLOCK process WITH FRAME TITLE text-001.

SELECTION-SCREEN SKIP 1.

PARAMETER: s_datum LIKE sy-datum OBLIGATORY.

SELECTION-SCREEN END OF BLOCK process.

AT SELECTION-SCREEN OUTPUT.

s_datum = sy-datum - 90.

The problem is I also want the user to be able to enter a date. But it keeps getting wiped out by my AT SELECTION-SCREEN OUTPUT event.

How do I work around this so it either defaults to sy-datum - 90 days, or the user can enter his own date?

Thank-You.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

For example, test this short program.



REPORT  zrich_0001.

PARAMETERS: p_datum TYPE sy-datum.

INITIALIZATION.

  p_datum = sy-datum - 90.

START-OF-SELECTION.

  WRITE:/ p_datum.

It defaults the date 90 days ago, you can then change it to whatever, and execute the report. It will then write whatever date you had entered in the parameter.

Regards

RIch HEilman

18 REPLIES 18

Former Member
0 Kudos

Hi,

data:date type sy-datum.

date = sy-datum - 90.

use PARAMETER: s_datum LIKE sy-datum OBLIGATORY default date.

rgds,

bharat.

Former Member
0 Kudos

Hi,

Write like this and see

s_datum = sy-datum - 90.

SELECTION-SCREEN BEGIN OF BLOCK process WITH FRAME TITLE text-001.

SELECTION-SCREEN SKIP 1.

PARAMETER: s_datum LIKE sy-datum OBLIGATORY.

SELECTION-SCREEN END OF BLOCK process.

Initialization:

s_datum = sy-datum - 90.

reward if useful

regards,

Anji

Former Member
0 Kudos

Hi

SELECTION-SCREEN BEGIN OF BLOCK process WITH FRAME TITLE text-001.

SELECTION-SCREEN SKIP 1.

PARAMETER: s_datum LIKE sy-datum OBLIGATORY.

SELECTION-SCREEN END OF BLOCK process.

<b>INITIALIZATION.</b>

s_datum = sy-datum - 90.

instead of At selection screen output put ur code in initilization part.

Regards

Haritha.

alex_m
Active Contributor
0 Kudos

Use DEFAULT addition in parameter decleration.

Former Member
0 Kudos

hi,

change your code as below

SELECTION-SCREEN BEGIN OF BLOCK process WITH FRAME TITLE text-001.

SELECTION-SCREEN SKIP 1.

PARAMETER: s_datum LIKE sy-datum OBLIGATORY.

SELECTION-SCREEN END OF BLOCK process.

AT SELECTION-SCREEN OUTPUT.

<b> LOOP AT SCREEN.

if s_datum is initial.

s_datum = sy-datum - 90.

endif.

MODIFY SCREEN.

ENDLOOP.</b>

hope it solves your problem

regards,

Navneeth.K

0 Kudos

Hi Tom,

Did the above code solve your purpose.

regards,

Navneeth.K

0 Kudos

Hello Navneeth.

It did partially in that this will work.

My only contention is that when the user sees the selection screen, the sy-datum - 90 is not displayed it ionly gerts displayed i the background when the field is empty. I am thinking it is probably just as easy to create a transaction that uses a variant with sy-datum - 90, and they can replace the date if they want to.

0 Kudos

Hi Tom,

currently wat happens is when the selection screen comes the value for s_datum is given by default and when the user changes it then the s_datum is assigned that value. now, what is your proper reqmnt can u give me some example how you want it.

regards,

Navneeth.K

0 Kudos

I am going with a custom transaction for the user to execute with the date logic in the variant, then the date (date - 90 days) displayed on the screen at execution, and the date can be over written and stay that way by the user if they want.

Thank-You Everybody!

0 Kudos

Tom, I am ready confused as to why you are jumping thru hoops on this one. If you simply want to default the date in the parameter as sy-datum - 90, then simply do so in the INITIALIZATION event of your report program, this is set once, and then the user could change it to whatever, but could simply execpt the default date. Is this not the requirement?

Regards,

Rich Heilman

0 Kudos

Rich,

Your code does populate the date as sy-datum - 90 days on the selection screen. However, when I execute the job, and put my own date in the selection screen, it gets wiped out and goes back to sy-datum - 90 days during initialization.

Thank-You.

0 Kudos

did you append the select option

INITIALIZATION.     
  s_datum = sy-datum - 90.
  append s_datum. "<----here

0 Kudos

oh it looks like it is a paramter then no need to qppend

0 Kudos

Tom, I don't believe it. Post your code.

Regards,

RIch Heilman

0 Kudos

Rich,

It worked....elementary mistake...."start-of-selection" was missing.

Thank-You!

0 Kudos

Ahhh yes, START-OF-SELECTION is always important, especially when using other event blocks.

Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You should only need to do it in the INITIALIZATION event.

REPORT  zrich_0001.


SELECTION-SCREEN BEGIN OF BLOCK process WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP 1.
PARAMETER: s_datum LIKE sy-datum OBLIGATORY.
SELECTION-SCREEN END OF BLOCK process.

INITIALIZATION.    "<--  HERE

  s_datum = sy-datum - 90.

Regards,

RIch Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

For example, test this short program.



REPORT  zrich_0001.

PARAMETERS: p_datum TYPE sy-datum.

INITIALIZATION.

  p_datum = sy-datum - 90.

START-OF-SELECTION.

  WRITE:/ p_datum.

It defaults the date 90 days ago, you can then change it to whatever, and execute the report. It will then write whatever date you had entered in the parameter.

Regards

RIch HEilman