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: 

check select-options in selection-screen

Former Member
0 Kudos
3,394

I have two select-options in a selection-screen s_vbeln and p_ebeln with intervals & with extensions. Now i have to check whether values in high or in low are valid or not? I have written the following code to check the validity of the values.

AT SELECTION-SCREEN ON s_vbeln.

IF SY-UCOMM EQ 'ONLI' .

IF NOT s_vbeln[] IS INITIAL.

LOOP AT s_vbeln.

SELECT SINGLE VBELN

FROM VBAK

INTO gs_vbeln

WHERE VBELN EQ s_vbeln-LOW.

IF SY-SUBRC <> 0.

MESSAGE E398(00) WITH 'Invalid Sales Order Number!!'.

ENDIF.

SELECT SINGLE VBELN

FROM VBAK

INTO gs_vbeln

WHERE VBELN EQ s_vbeln-HIGH.

IF SY-SUBRC <> 0.

MESSAGE E398(00) WITH 'Invalid Sales Order Number!!'.

ENDIF.

ENDLOOP.

ENDIF.

ENDIF.

The similar is with p_ebeln which is a field of ekko table.And vbeln is a field of vbak table. if gurus can post the code

for the same.

Regards,

Priya

12 REPLIES 12

former_member506713
Participant
0 Kudos
679

Hi,

you can write like


SELECT SINGLE VBELN
FROM VBAK
INTO gs_vbeln
WHERE VBELN in s_vbeln.

IF SY-SUBRC NE 0.
MESSAGE E398(00) WITH 'Invalid Sales Order Number!!'.
ENDIF.

Regards

Lalit

Edited by: LL D on Sep 9, 2009 10:43 AM

Former Member
0 Kudos
679

Hi Shweta,

Welcome to SCN, you code seems to be good, what is the issue that you are having.

Regards,

Himanshu

0 Kudos
679

my problem is quite interesting.

i have the above code. now if put a valid value in s_vbeln (i.e 35 in low and 464)

"invalid sales order number " is displayed, even they are valid values.

your helpful suggestion is highly appreciated.

regards,

Shweta

0 Kudos
679

Hi Swetha,

Please check are you using SY-SUBRC = 0 OR SY-SUBRC NE 0.

Please change it to Sy-subrc ne 0.

Sas

Former Member
0 Kudos
679

Hi Swetha,

I believe, your code is correct, lets know whats the issue, you are facing.

Rgds,

Sripal

faisal_altaf2
Active Contributor
0 Kudos
679

Hi, Priya,

Test the following Sample Code it will work for you

TABLES: vbak, ekko.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln,
                s_ebeln FOR ekko-ebeln.

AT SELECTION-SCREEN.

  IF NOT s_vbeln[] IS INITIAL.
    SELECT SINGLE * FROM vbak
    WHERE vbeln IN s_vbeln.
    IF sy-subrc NE 0.
      MESSAGE e398(00) WITH 'Invalid Sales Order Number!!'.
    ENDIF.
  ENDIF.

  IF NOT s_ebeln[] IS INITIAL.
    SELECT SINGLE * FROM ekko
    WHERE ebeln IN s_ebeln.
    IF sy-subrc NE 0.
      MESSAGE e398(00) WITH 'Invalid Purchasing Document Number!!'.
    ENDIF.
  ENDIF.

Please Reply if any Issue,

Regards,

Faisal

0 Kudos
679

hi,

you can use this code and as well as this link.. i hope it will be working...

SELECT SINGLE VBELN

FROM VBAK

INTO gs_vbeln

WHERE VBELN in s_vbeln.

IF SY-SUBRC NE 0.

MESSAGE E398(00) WITH 'Invalid Sales Order Number!!'.

ENDIF.

Thanks and Regards,

Ahamed.

Former Member
0 Kudos
679

hi,

you can use this code and as well as this link.. i hope it will be working...

SELECT SINGLE VBELN

FROM VBAK

INTO gs_vbeln

WHERE VBELN in s_vbeln.

IF SY-SUBRC NE 0.

MESSAGE E398(00) WITH 'Invalid Sales Order Number!!'.

ENDIF.

Thanks and Regards,

Ahamed.

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Kudos
679

Hello Shweta,

I have two select-options in a selection-screen s_vbeln and p_ebeln with intervals & with extensions. Now i have to check whether values in high or in low are valid or not?

I donot think this is the correct way of validating a select-option. Your idea when validating a select-option must be to check that there are no valid values for the Range provided by the LOW & HIGH values. Even if you have only 1 valid data, then the processing should carry on.

Your LOW & HIGH values may be incorrect, but in the range provided by these values you have valid data.

Please check what exactly is your requirement.

Cheers,

Suhas

Clemenss
Active Contributor
0 Kudos
679

Hi Shweta,

select-options are represented as internal tables in the system. If the user extends the select-option and enters a couple of values, they should be checked all. So the code should be a little bit enhanced.

To have the cursor positioned a the field with the error, you may use event

AT SELECTION-SCREEN ON s_vbeln.
  PERFORM check_s_vbeln.
*&---------------------------------------------------------------------*
*&      Form  CHECK_S_VBELN
*&---------------------------------------------------------------------*
FORM check_s_vbeln .
  LOOP AT s_vbeln.
    IF s_vbeln-low IS NOT INITIAL.
      SELECT count(*) FROM vbak WHERE vbeln = s_vbeln-low.
        IF sy-subrc <> 0.
          MESSAGE e001(vb) WITH s_vbeln-low.
*   Sales document & does not exist
        ENDIF.
      ENDIF.
      IF s_vbeln-high IS NOT INITIAL.
        SELECT count(*) FROM vbak WHERE vbeln = s_vbeln-high.
          IF sy-subrc <> 0.
            MESSAGE e001(vb) WITH s_vbeln-high.
*   Sales document & does not exist
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " CHECK_S_VBELN

Kind regards,

Clemens

0 Kudos
679

Hi Climens,

Whats the difference between Swetha code and yours???

Except select count(*)

Regards

sas

Clemenss
Active Contributor
0 Kudos
679

Hi,

no big difference, but

Use of event

AT SELECTION-SCREEN ON s_vbeln.

- will position the cursor on the field with the wrong number and mark it in red color

- will disable all other fields in the screen until corrrected

- will execute only if values in the screen are entered or changed

Use of

MESSAGE e001(vb) WITH s_vbeln-low.

and

MESSAGE e001(vb) WITH s_vbeln-high.

will reflect the wrong value in the message. This may be useful if it occurs in a JOB or so.

Regards,

Clemens