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

SMALL PROBLEM IN USING SELECTION-OPTIONS STATEMENT

Former Member
0 Likes
561

Hello ABAP Gurus,

I am trying to write a simple program that takes 'FROM' and 'TO' dates which will be used to generate a report..

However the requirement is that the 'FROM' date should have a default value that is read from a file and the 'TO' date should have a default value of today's date. The Client wants to option of changing these dates if needed.

However, when I wrote the following program, it first doesn't read the text file for the 'FROM' date and therefore it is by default filling only 'TO' date and leaving the 'FROM' field blank. Can some one please let me konw what I am not doing correctly.

The simple code that i have written is

=======================================================================================

REPORT Z_PROGRAM1.

DATA: DAYSTMP(40),

FROMDATE LIKE SY-DATUM.

DAYSTMP = 'C:\EXTRACTEDDATA\ExtractedDate.txt'.

OPEN DATASET DAYSTMP FOR INPUT IN TEXT MODE ENCODING DEFAULT.

READ DATASET DAYSTMP INTO FROMDATE.

CLOSE DATASET DAYSTMP.

SELECTION-SCREEN: BEGIN OF BLOCK MAIN WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS: S_DATE FOR SY-DATUM DEFAULT FROMDATE TO SY-DATUM

OPTION BT SIGN I.

SELECTION-SCREEN: END OF BLOCK MAIN.

========================================================================================

Any suggestions/feedback will be greatly appreciated.

Thanks

Ram

Edited by: Prasad Ram on Oct 28, 2009 5:34 PM

1 ACCEPTED SOLUTION
Read only

ThomasZloch
Active Contributor
0 Likes
528

You have to put the OPEN DATASET part under event INITIALIZATION, and fill s_date-low and s_date-high there instead of the DEFAULT ... option.

Thomas

4 REPLIES 4
Read only

ThomasZloch
Active Contributor
0 Likes
529

You have to put the OPEN DATASET part under event INITIALIZATION, and fill s_date-low and s_date-high there instead of the DEFAULT ... option.

Thomas

Read only

0 Likes
528

Thomas, Thanks a lot for the solution. It did the trick. I don't know what I would have done without SDN :-). I appreciate your help a lot.

Thanks to others for suggestions regarding posting and I will remember to do that in future.

Thanks

Ram

Read only

Former Member
0 Likes
528

And please dont use ALL CAPS in the subject line.. Please read the forum rules before posting

Read only

Clemenss
Active Contributor
0 Likes
528

... and please use the above <<>> code button after selecting the code with the mouse. Then formatting is preserved and readabilty is enabled.

Many people (including me) refuse to read unformatted coding.

Regards,

Clemens