07-18-2015 3:57 PM
Hi all,
I want to differentiate between events 'At selection-screen' and 'At selection-screen on <field>'.
I am attaching a file here. In that I have used event 'At selection-screen on s_vbeln'. But the field s_ebeln is also getting validated.
I think only that s_vbeln should be validated as we are specifically mentioning it. But why s_ebeln is getting validated in the process.
Your help is appreciated.
Regards,
larry.
07-18-2015 8:37 PM
Hi Larry,
If you want to validate only s_vbeln then, under event At Selection-screen on s_vbeln you should keep only part of code which is validating the sales order number under the event At Selection-screen on s_vbeln.
In your code both sales order validation and purchase order validation are happening under the same event AT SELECTION-SCREEN ON S_VBELN.
You can write something like this
AT SELECTION-SCREEN ON S_EBELN.
SELECT SINGLE EBELN FROM EKKO INTO V_EBELN WHERE EBELN IN S_EBELN.
IF SY-SUBRC <> 0.
MESSAGE 'PO DOES NOT EXIST' TYPE 'I'.
ELSE.
MESSAGE 'PO EXISTS' TYPE 'I'.
ENDIF.
AT SELECTION-SCREEN ON S_VBELN.
SELECT SINGLE VBELN FROM VBAK INTO V_VBELN WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE 'SALES ORDER DOES NOT EXIST' TYPE 'I'.
ELSE.
MESSAGE 'SALES ORDER EXISTS' TYPE 'I'.
ENDIF.
coming to the differences between At selection-screen' and 'At selection-screen on <field>...
Please check the below link
Selection Screen Events in ABAP - ABAP Development - SCN Wiki
Rewrad if helpful.
Regards,
Vasu Gunuputi.
07-18-2015 6:23 PM
Hi Larry,
Validation code should be after AT SELECTION-SCREEN ON S_VBELN.
Also if you wish stop further processing then you should write STOP.
Do hope that you understood.
----------------------------------------------------------
REPORT ZR_FIELD_VALIDATION.
DATA: V_EBELN TYPE EKKO-EBELN,
V_VBELN TYPE VBAK-VBELN.
SELECT-OPTIONS: S_EBELN FOR V_EBELN,
S_VBELN FOR V_VBELN.
SELECT SINGLE EBELN FROM EKKO INTO V_EBELN WHERE EBELN IN S_EBELN.
IF SY-SUBRC <> 0.
MESSAGE 'PO DOES NOT EXIST' TYPE 'I'.
ELSE.
MESSAGE 'PO EXISTS' TYPE 'I'.
ENDIF.
AT SELECTION-SCREEN ON S_VBELN.
SELECT SINGLE VBELN FROM VBAK INTO V_VBELN WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE 'SALES ORDER DOES NOT EXIST' TYPE 'I'.
STOP.
ELSE.
MESSAGE 'SALES ORDER EXISTS' TYPE 'I'.
ENDIF.
07-18-2015 8:37 PM
Hi Larry,
If you want to validate only s_vbeln then, under event At Selection-screen on s_vbeln you should keep only part of code which is validating the sales order number under the event At Selection-screen on s_vbeln.
In your code both sales order validation and purchase order validation are happening under the same event AT SELECTION-SCREEN ON S_VBELN.
You can write something like this
AT SELECTION-SCREEN ON S_EBELN.
SELECT SINGLE EBELN FROM EKKO INTO V_EBELN WHERE EBELN IN S_EBELN.
IF SY-SUBRC <> 0.
MESSAGE 'PO DOES NOT EXIST' TYPE 'I'.
ELSE.
MESSAGE 'PO EXISTS' TYPE 'I'.
ENDIF.
AT SELECTION-SCREEN ON S_VBELN.
SELECT SINGLE VBELN FROM VBAK INTO V_VBELN WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE 'SALES ORDER DOES NOT EXIST' TYPE 'I'.
ELSE.
MESSAGE 'SALES ORDER EXISTS' TYPE 'I'.
ENDIF.
coming to the differences between At selection-screen' and 'At selection-screen on <field>...
Please check the below link
Selection Screen Events in ABAP - ABAP Development - SCN Wiki
Rewrad if helpful.
Regards,
Vasu Gunuputi.