‎2007 Apr 05 8:49 AM
hi every body i want to do validation at the selection screen . i have 12 fields as a select options
can anybody give me the code of how to validate all these fields
1) first all fields will give error when user not enter anything "enter values"
2) when user enter wrong values then it will show " enter rite values"
3) when user enters valid values then it will show " value entered is valid"
my big problem is how i will code so that everything will go perfect for all fields
fields are
1) S_MATNR FOR MSEG-MATNR,
2) S_WERKS FOR MSEG-WERKS,
3) S_LGORT FOR MSEG-LGORT,
4) S_CHARG FOR MSEG-CHARG,
5) S_LIFNR FOR MSEG-LIFNR,
6) S_KUNNR FOR MSEG-KUNNR,
7) S_BWART FOR MSEG-BWART,
😎 S_SOBKZ FOR MSEG-SOBKZ,
9) S_BUDAT FOR MKPF-BUDAT,
10) S_USNAM FOR MKPF-USNAM,
11) S_VGART FOR MKPF-VGART,
12) S_XBLNR FOR MKPF-XBLNR.
plz help me
thanks with regards
pointe will be rewarded
‎2007 Apr 05 8:54 AM
Hi,
Declare the fields with their master tables after declaring those tables with TABLES statement.for few I will give the code, rest you practice.
You have to write this code in AT SELECTION-SCREEN event.
S_WERKS FOR T001W-WERKS,
S_KUNNR FOR KUNNR-KUNNR,
Validation of Customer
clear kna1.
if not s_kunnr is initial.
select kunnr from kna1 up to 1 rows
into kna1-kunnr
where kunnr in s_kunnr.
endselect.
if sy-subrc ne 0.
message e014. " Invalid Customer Number
endif.
endif.
Validation of Plant
clear t001w.
if not s_werks is initial.
select werks from t001w up to 1 rows
into t001w-werks
where werks in s_werks.
endselect.
if sy-subrc ne 0.
message e004. " Invalid Plant Number
endif.
endif.
reward if useful
regards,
Anji
‎2007 Apr 05 8:54 AM
Hi,
Declare the fields with their master tables after declaring those tables with TABLES statement.for few I will give the code, rest you practice.
You have to write this code in AT SELECTION-SCREEN event.
S_WERKS FOR T001W-WERKS,
S_KUNNR FOR KUNNR-KUNNR,
Validation of Customer
clear kna1.
if not s_kunnr is initial.
select kunnr from kna1 up to 1 rows
into kna1-kunnr
where kunnr in s_kunnr.
endselect.
if sy-subrc ne 0.
message e014. " Invalid Customer Number
endif.
endif.
Validation of Plant
clear t001w.
if not s_werks is initial.
select werks from t001w up to 1 rows
into t001w-werks
where werks in s_werks.
endselect.
if sy-subrc ne 0.
message e004. " Invalid Plant Number
endif.
endif.
reward if useful
regards,
Anji
‎2007 Apr 05 8:54 AM
Hi Gaurav ,
Use the event AT SELECTION SCREE ON <Feild Name> for each selection screen element.
For each element perform the following checks.
1. Value has been entered
IF <Feild_name > is initial.
give error message.
endif.
2. Valid value is entered
Select single <feild>
from <table>
where <feild_t> = <feild_name>.
if sy-subrc = 0 .
* Give success message
else
* Give error message
endif.Hope this helps
Regards
Arun
‎2007 Apr 05 8:56 AM
HI gaurav,
U can make all the parameters mandatory by using the OBLIGATORY option.
Using AT SELECTION-SCREEN ON S_MATNR-low.
u can validate the values and print the messages.
Try it it may help u.
Regards,
Ravi G
Message was edited by:
Ravi Kumar Gunda
‎2007 Apr 05 9:02 AM
1. if u want to enter values in all the screen fields, then make them as obligatory fields... it will take care of the message
if u dont want any of the field as required field, then write code in AT SELECTION-SCREEN event... if S_MATNR[] is initial and S_WERKS[] is initial .... then raise the error message "enter values"
2 & 3. You can Validate the fields individually by using AT SELECTION-SCREEN on <field> or you can define the block for a group of fields and then validate them by using AT SELECTION-SCREEN ON BLOCK <Block_name>.
Regards,
Phani.
‎2007 Apr 05 9:18 AM
thanks for your reply can u plz give the exact syntax of "BLOCK" using statement
Thanks
‎2007 Apr 05 9:28 AM
hi
for block u can use this,
SELECTION-SCREEN : BEGIN OF BLOCK B1WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_kunnr FOR kan1-kunnr OBLIGATORY.
PARAMETERS : p_matnr LIKE mara-matnr OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK B1.
Regards
Zarina
‎2007 Apr 05 9:31 AM
Hi Gaurav,
Here it is...
SELECT-OPTIONS sel_opt1 FOR field1.
SELECTION-SCREEN BEGIN OF BLOCK block1.
PARAMETERS: test1(10) TYPE c,
test2(10) TYPE c.
SELECTION-SCREEN END OF BLOCK block1.
AT SELECTION-SCREEN ON BLOCK block1.
MESSAGE i888 WITH 'AT SELECTION-SCREEN'
'ON BLOCK BLOCK1'.
Have a look at the demo program <b>demo_selection_screen_events</b> for more details.
Regards,
Phani
‎2007 Apr 26 4:31 AM