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

Input check on selection-Screen

Former Member
0 Likes
8,652

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

1 ACCEPTED SOLUTION
Read only

StMou
Active Participant
0 Likes
4,331

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

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

12 REPLIES 12
Read only

Former Member
0 Likes
4,331

Hi.

Instead of

AT SELECTION-SCREEN ON BLOCK  filterCriteria.

Just give

AT SELECTION-SCREEN.

Regards,

Chandravadan

Read only

0 Likes
4,331

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

Read only

0 Likes
4,331

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

Read only

StMou
Active Participant
0 Likes
4,332

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

Read only

Former Member
0 Likes
4,331

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

Read only

Former Member
0 Likes
4,331

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

Read only

Former Member
0 Likes
4,331

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

Read only

Former Member
0 Likes
4,331

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

Read only

Former Member
0 Likes
4,331

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

Read only

Former Member
0 Likes
4,331

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

Read only

Former Member
0 Likes
4,331

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:)

Read only

Former Member
0 Likes
4,331

Hi,

You can also try this for displaying error mesage in status bar....

Message '...' type 'E' display like 'S'