2010 Mar 13 7:54 PM
Hi all,
Have to make some input checks for my selection screen. The code is as follows:
SELECTION-SCREEN BEGIN OF BLOCK filterCriteria WITH FRAME.
PARAMETERS: matNr TYPE sflight-carrid.
SELECT-OPTIONS: so_lfart for sflight-planetype no INTERVALS,
so_datum for sflight-fldate no-EXTENSION.
SELECTION-SCREEN end of BLOCK filterCriteria.
SELECTION-SCREEN BEGIN OF BLOCK radio WITH FRAME.
PARAMETERS : Kum_St RADIOBUTTON GROUP rbg1 DEFAULT 'X',
Det_St RADIOBUTTON GROUP rbg1.
SELECTION-SCREEN END OF BLOCK radio.
AT SELECTION-SCREEN ON BLOCK filterCriteria.
if matNr = 0.
MESSAGE 'enter matNr' type 'I'.
elseif ( so_datum-low < sy-datum + 730 ) OR ( so_datum-high > sy-datum-low + 365 ).
MESSAGE 'Invalid date' type 'I'.
endif.I want to check that if "matNr" parameter field is empty, it should show a message as above.
Also the so_datum-low entered shouldn't be more than 2 years from the current date and the so_datum-high entered should't be more than 1 year from so_datum-low.
The above code gives me a syntax error. How could I do it the right way.
Also I have saved a variant of this.On running the program is it possible to get the variant directly in the program,so that the selection screen comes up with the variant.
Thanks
P
2010 Mar 13 8:40 PM
Hi,
If you would like that mat nr is always full. Add obligatory in parameters.
For date : create 2 data with your date low and date high.
See this code, I change your code.
TABLES SFLIGHT.
DATA DATUM_LOW TYPE SY-DATUM.
DATA DATUM_HIGH TYPE SY-DATUM.
SELECTION-SCREEN BEGIN OF BLOCK FILTERCRITERIA WITH FRAME.
PARAMETERS: MATNR TYPE SFLIGHT-CARRID OBLIGATORY.
SELECT-OPTIONS: SO_LFART FOR SFLIGHT-PLANETYPE NO INTERVALS,
SO_DATUM FOR SFLIGHT-FLDATE NO-EXTENSION.
SELECTION-SCREEN END OF BLOCK FILTERCRITERIA.
SELECTION-SCREEN BEGIN OF BLOCK RADIO WITH FRAME.
PARAMETERS : KUM_ST RADIOBUTTON GROUP RBG1 DEFAULT 'X',
DET_ST RADIOBUTTON GROUP RBG1.
SELECTION-SCREEN END OF BLOCK RADIO.
******************
* INITIALIZATION *
******************
INITIALIZATION.
DATUM_HIGH = SY-DATUM + 730 .
DATUM_LOW = SY-DATUM + 365 .
AT SELECTION-SCREEN ON BLOCK FILTERCRITERIA.
IF ( ( SO_DATUM-LOW < DATUM_HIGH ) OR ( SO_DATUM-HIGH > DATUM_LOW ) ).
MESSAGE 'Invalid date' TYPE 'I'.
ENDIF.
Rgds
syntax errors are gone.But the date thing is not serving my purpose.
Changed the code as follows:
DATUM_HIGH = SY-DATUM - 730 .
DATUM_LOW = so_datum-low + 365 .
if ( so_datum-low < DATUM_HIGH ) OR ( so_datum-high > DATUM_LOW ) .
MESSAGE 'Invalid date' type 'E'.
endif.If I enter a time range between 1 year(say j01.01.2010 - 03.01.210 ) it is not working .It should work...
working on it.....
any idea....
2010 Mar 13 8:29 PM
Hi.
Instead of
AT SELECTION-SCREEN ON BLOCK filterCriteria.Just give
AT SELECTION-SCREEN.Regards,
Chandravadan
2010 Mar 13 8:33 PM
same error - "Incorrect logical expression. comparison/Select-option can only be followed by AND OR )" on the elseif line.
Edited by: pazzuzu on Mar 13, 2010 9:35 PM
2010 Mar 13 8:48 PM
Try this. This working.
TABLES : sflight.
DATA: v_lowdate type SY-DATUM,
v_highdate type SY-DATUM,
v_comp1 type sy-datum,
v_comp2 type sy-datum.
SELECTION-SCREEN BEGIN OF BLOCK filterCriteria WITH FRAME.
PARAMETERS: matNr TYPE sflight-carrid.
SELECT-OPTIONS: so_lfart for sflight-planetype no INTERVALS,
so_datum for sflight-fldate no-EXTENSION.
SELECTION-SCREEN end of BLOCK filterCriteria.
SELECTION-SCREEN BEGIN OF BLOCK radio WITH FRAME.
PARAMETERS : Kum_St RADIOBUTTON GROUP rbg1 DEFAULT 'X',
Det_St RADIOBUTTON GROUP rbg1.
SELECTION-SCREEN END OF BLOCK radio.
AT SELECTION-SCREEN.
v_lowdate = so_datum-low.
v_highdate = so_datum-high.
V_comp1 = sy-datum + 730.
V_comp2 = v_lowdate + 365.
if matNr = 0.
MESSAGE 'enter matNr' type 'I'.
ELSEIF ( v_lowdate < V_comp1 ) OR v_highdate > V_comp2.
MESSAGE 'Invalid date' type 'I'.
endif.
Regards,
Chandravadan
2010 Mar 13 8:40 PM
Hi,
If you would like that mat nr is always full. Add obligatory in parameters.
For date : create 2 data with your date low and date high.
See this code, I change your code.
TABLES SFLIGHT.
DATA DATUM_LOW TYPE SY-DATUM.
DATA DATUM_HIGH TYPE SY-DATUM.
SELECTION-SCREEN BEGIN OF BLOCK FILTERCRITERIA WITH FRAME.
PARAMETERS: MATNR TYPE SFLIGHT-CARRID OBLIGATORY.
SELECT-OPTIONS: SO_LFART FOR SFLIGHT-PLANETYPE NO INTERVALS,
SO_DATUM FOR SFLIGHT-FLDATE NO-EXTENSION.
SELECTION-SCREEN END OF BLOCK FILTERCRITERIA.
SELECTION-SCREEN BEGIN OF BLOCK RADIO WITH FRAME.
PARAMETERS : KUM_ST RADIOBUTTON GROUP RBG1 DEFAULT 'X',
DET_ST RADIOBUTTON GROUP RBG1.
SELECTION-SCREEN END OF BLOCK RADIO.
******************
* INITIALIZATION *
******************
INITIALIZATION.
DATUM_HIGH = SY-DATUM + 730 .
DATUM_LOW = SY-DATUM + 365 .
AT SELECTION-SCREEN ON BLOCK FILTERCRITERIA.
IF ( ( SO_DATUM-LOW < DATUM_HIGH ) OR ( SO_DATUM-HIGH > DATUM_LOW ) ).
MESSAGE 'Invalid date' TYPE 'I'.
ENDIF.
Rgds
2010 Mar 13 8:55 PM
Thanks a lot stephan ...:).It worked .I can go to sleep peacefully now.
3 qusetions though...
The "Invalid date" message - is it possible to show it in the status bar instead of a message box.
Also how to bring back the input on the time fields because in my program it continues to execute the rémaining of the program in start-of-selection.
>>Also I have saved a variant of this.On running the program is it possible to get the variant directly in the program,so that the
>>selection screen comes up with the variant.
Edited by: pazzuzu on Mar 13, 2010 9:56 PM
Edited by: pazzuzu on Mar 13, 2010 9:58 PM
2010 Mar 13 9:00 PM
The "Invalid date" message - is it possible to show it in the status bar instead of a message box. Also how to bring back the input on the time fields because in my program it continues to execute the rémaining of the program in start-of-selection.
Instead of
MESSAGE 'Invalid date' type 'I'.
Give
MESSAGE 'Invalid date' type 'E'.
Regards,
Chandravadan
2010 Mar 13 9:24 PM
syntax errors are gone.But the date thing is not serving my purpose.
Changed the code as follows:
DATUM_HIGH = SY-DATUM - 730 .
DATUM_LOW = so_datum-low + 365 .
if ( so_datum-low < DATUM_HIGH ) OR ( so_datum-high > DATUM_LOW ) .
MESSAGE 'Invalid date' type 'E'.
endif.If I enter a time range between 1 year(say j01.01.2010 - 03.01.210 ) it is not working .It should work...
working on it.....
any idea....
2010 Mar 13 9:33 PM
It works now.
Changed the code as follows.
INITIALIZATION.
DATUM_HIGH = SY-DATUM - 730 .
DATUM_LOW = SY-DATUM + 365 .
AT SELECTION-SCREEN on so_datum.
DATA DATUM_1 TYPE SY-DATUM.
DATUM_1 = so_datum-low + 365 .
if ( so_datum-low < DATUM_HIGH ) OR ( so_datum-high > DATUM_1 ) .
MESSAGE 'Invalid date' type 'E'.
endif.Any idea abt the variant question.....
2010 Mar 13 11:52 PM
For loading variants use the function module RS_SUPPORT_SELECTIONS, see example here: .
Cheers, harald
p.s.: Looks like you're coming from another programming language, like Java. In ABAP case doesn't matter and one of the really annoying things is that there's no real boolean's and proper support for expressions in IF statements (o.k. ABAP'ers might debate this, but if you know other programming languages and check the ABAP syntax you'll know what I mean...).
2010 Mar 14 5:33 AM
Hi,
Also I have saved a variant of this.On running the program is it possible to get the variant directly in the program,so that the selection screen comes up with the variant.
Make use of INITIALIZATION event to get the values on selection screen as per variant in the code.
Please refer to [INITIALIZATION|http://help.sap.com/saphelp_nw70/helpdata/en/9f/db9a2135c111d1829f0000e829fbfe/content.htm].
Regards,
Chandravadan
2010 Mar 14 7:29 AM
Thank you guys....
Harald, you are right.I am coming from the java world.....Its sometimes a pain with the java syntax in the beginning atleast:)
2010 Mar 15 4:22 AM
Hi,
You can also try this for displaying error mesage in status bar....
Message '...' type 'E' display like 'S'
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |