2009 Sep 09 5:59 AM
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
2009 Sep 09 6:13 AM
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
2009 Sep 09 6:17 AM
Hi Shweta,
Welcome to SCN, you code seems to be good, what is the issue that you are having.
Regards,
Himanshu
2009 Sep 12 10:23 AM
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
2009 Sep 12 10:28 AM
Hi Swetha,
Please check are you using SY-SUBRC = 0 OR SY-SUBRC NE 0.
Please change it to Sy-subrc ne 0.
Sas
2009 Sep 09 6:31 AM
Hi Swetha,
I believe, your code is correct, lets know whats the issue, you are facing.
Rgds,
Sripal
2009 Sep 09 6:33 AM
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
2009 Sep 09 7:01 AM
2009 Sep 09 7:26 AM
2009 Sep 09 7:30 AM
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
2009 Sep 12 3:50 PM
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
2009 Sep 12 4:02 PM
Hi Climens,
Whats the difference between Swetha code and yours???
Except select count(*)
Regards
sas
2009 Sep 12 4:45 PM
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