‎2008 Jul 09 7:57 AM
hi experts,
how to validate a single field in the selection screen, i,e.. if a value in the selection is wrong and all the other values in the selection screen are correct then the curson should should blink at the 'wrong values entered field'. so how to validate it?
‎2008 Jul 09 7:59 AM
Hi,
Below is the simple code which show how to validate selection screen elements...
DATA:
w_matnr TYPE mara-matnr,
w_werks TYPE marc-werks.
PARAMETERS:
p_matnr LIKE mara-matnr, " Material Number
p_werks LIKE marc-werks. " Plant
AT SELECTION-SCREEN .
IF p_matnr IS NOT INITIAL.
SELECT SINGLE matnr
INTO w_matnr
FROM mara
WHERE matnr EQ p_matnr.
CHECK sy-subrc NE 0.
SET CURSOR FIELD 'P_MATNR'.
MESSAGE 'Material Not Valid' TYPE 'E'. " Invalid Material
ENDIF.
IF p_werks IS NOT INITIAL.
SELECT SINGLE werks
INTO w_werks
FROM marc
WHERE werks EQ p_werks.
CHECK sy-subrc NE 0.
SET CURSOR FIELD 'P_WERKS'.
MESSAGE 'Plant Not Valid' TYPE 'E'. " Invalid Plant
ENDIF.Best Regards,
Brijesh
‎2008 Jul 09 7:59 AM
Hi,
Below is the simple code which show how to validate selection screen elements...
DATA:
w_matnr TYPE mara-matnr,
w_werks TYPE marc-werks.
PARAMETERS:
p_matnr LIKE mara-matnr, " Material Number
p_werks LIKE marc-werks. " Plant
AT SELECTION-SCREEN .
IF p_matnr IS NOT INITIAL.
SELECT SINGLE matnr
INTO w_matnr
FROM mara
WHERE matnr EQ p_matnr.
CHECK sy-subrc NE 0.
SET CURSOR FIELD 'P_MATNR'.
MESSAGE 'Material Not Valid' TYPE 'E'. " Invalid Material
ENDIF.
IF p_werks IS NOT INITIAL.
SELECT SINGLE werks
INTO w_werks
FROM marc
WHERE werks EQ p_werks.
CHECK sy-subrc NE 0.
SET CURSOR FIELD 'P_WERKS'.
MESSAGE 'Plant Not Valid' TYPE 'E'. " Invalid Plant
ENDIF.Best Regards,
Brijesh
‎2008 Jul 09 8:30 AM
‎2008 Jul 09 9:38 AM
Hi Venkat,
If ur query is answered, please close the thread .
Best regards,
Brijesh
‎2008 Jul 09 8:01 AM
Hi Venkat,
Define the fields below the event
At Selection-Screen on block.
Regards,
Suresh.S
‎2008 Jul 09 8:01 AM
Hi,
you can validate single field validaions by using this syntax.
at selection-screen on <fieldname parameter/select-option>.
select single * from <dbtable> where condition.
if sy-dubrc ne 0.
error message.
endif.
‎2008 Jul 09 8:04 AM
hi,
For your requirement you can use the selection-screen event at selection-screen on field.
AT SELECTION-SCREEN ON <field>
is triggered when the contents of each individual input field are passed from the selection screen to the ABAP program. The input field <field> can be checked in the corresponding event block. If an error message occurs within this event block, the corresponding field is made ready for input again on the selection screen.
Regards,
Veeresh
‎2008 Jul 09 8:07 AM
Hiii!
Do the validation of that particular field in the event
AT SELECTION-SCREEN ON <field>.
By this event, only this field will be active, in case you put wrong value in it
Regards
Abhijeet Kulshreshtha
‎2008 Jul 09 8:31 AM
Hi,
If you want to validate particular single field the validate in
AT SELECTION-SCREEN ON FIELD <field-name>.
AT SELECTION-SCREEN ON FIELD p_matnr.
if p_matnr is initial.
message e012<message-class-name> .
endif.
So, when you execute this event is triggered and checks the condition . if the P_MATNR fields is empty then it show ERROR message and cursor will be shown in that field. Until you correct that error it will not allow you to go further.
Regards,
Rajitha.
‎2008 Jul 09 9:41 AM
Hello,
To validate a particular screen-field,use the event .
AT SELECTION-SCREEN ON FIELD <field-name>.
Example:-
AT SELECTION-SCREEN ON FIELD p_flight.
if p_flight is initial.
message 'field is empty ' type 'I'.
endif.
IF you execute your program, it checks field p_flight . If p_flight field is empty then gives the message and cursor is placed on p_flight .