Application Development and Automation 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: 
Read only

Validation Issue

Former Member
0 Likes
931

Dear Friends,

I have been working on an assignment in which has got 4 or 5 text input fields on a screen. I have to write a validation so that unless the user inputs a value in all these fields his entry should not get saved and he should receive a message to input values in all the fields..

How to go about it..??

Regards,

alok.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
901

As the validation is on all the fields.

writing the obligatory will give message for evry field.

write in the following way

at selection-screen.

CHAIN.

FIELD field1.

FIELD field2.

MODULE SET_validation ON CHAIN-REQUEST.

ENDCHAIN.

MODULE set_validation.

if field1 is not initial and fields2 not initial.

message e001 with 'provide input in all the fields.'

endif.

endmodule.

8 REPLIES 8
Read only

gopi_narendra
Active Contributor
0 Likes
901

Make the fields mandatory using the obligatory key word

parameter : P_VBELN type VBAK-VBELN obligatory.

Regards

- Gopi

Read only

Former Member
0 Likes
901

In the PAI of that screen you write this logic:

Case OK_CODE.

when 'SAVE'.

if field1 eq NULL OR field2 eq NULL OR field3 EQ NULL or field4 EQ Null.

write e101. " Enter all fields

else.

save the data

endif..

- Guru

Reward points for helpful answers

Read only

Former Member
0 Likes
901

HI Alok

You can simply do that by declaring the variables in this way:

parameters: p_fld1(10) type c obligatory,
            p_fld2(10) type c obligatory,
            p_fld3(10) type c obligatory.

Or if you are not using <b>OBLIGATORY</b>, we can achieve the same by below validation:

at selection-screen.
   if p_fld1 is initial or
      p_fld2 is initial or
      p_fld3 is initial.
      message e000(01) with 'Please input values for all paramters:'.
   endif.

Just incase, you are using Module Pool Program

Change the attributes of the field, to make it mandatory:

Proceed as below:

1. SE51

2. Change the layout editor

3. Double click on field to make mandatory.

4. In the window that is opened: Select Program from Attributes tab.

5. In the Input Dropdown list, select option required to make it mandatory.

Hope this helps.

Kind Regards

Eswar

Message was edited by:

Eswar Rao Boddeti

Read only

Former Member
0 Likes
902

As the validation is on all the fields.

writing the obligatory will give message for evry field.

write in the following way

at selection-screen.

CHAIN.

FIELD field1.

FIELD field2.

MODULE SET_validation ON CHAIN-REQUEST.

ENDCHAIN.

MODULE set_validation.

if field1 is not initial and fields2 not initial.

message e001 with 'provide input in all the fields.'

endif.

endmodule.

Read only

Former Member
0 Likes
901

hi,

try using Filed statement.

<b>Checking Single Fields</b>

If you send a warning or error message from a module mod that you called using a FIELDstatement as follows:

<i><b>FIELD f MODULE mod.</b></i>

the corresponding input field on the current screen is made ready for input again, allowing the user to enter a new value. If the field is only checked once, the PAI processing continues directly after the FIELDstatement, and the preceding modules are not called again.

<b>

Checking a Set of Fields</b>

If a warning or an error message is sent in a module mod1 mod2 … that you called within a processing chain:

CHAIN.

FIELD: f1, f2,...

MODULE mod1.

FIELD: g1, g2,...

MODULE mod2.

...

ENDCHAIN.

all of the input fields on the current screen that belong to the processing chain are made ready for input again – including those that are in FIELD statements after the MODULEstatement. All the other fields are not ready for input. Even if a MODULE statement appears within a processing chain, combined with a FIELD statement, all of the input fields in the chain are made ready for input again – not just the field in question. The user can repeat the input. If the fields in the processing chain are only checked once, the PAI processing continues directly after the automatic checks at the CHAINstatement, and the preceding modules are not called again.

for more details check this link

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbaa4735c111d1829f0000e829fbfe/content.htm

Read only

0 Likes
901

Thanks a lot to all of you. I regret that I cann't reward points to all the replies..a limitation of SDN..

Writing If..Endif..and displaying the message worked but the screen remains grey..not ready to accept another entry. My requirement is that as soon as the I display the error message..after pressing the enter key the screen should be ready to accept another entry.

Regards,

Alok.

Read only

0 Likes
901

To make ready for input as soon as entered pressed do the following:-

instead opf using error, use warning followed by STOP.

*At selection-screen

at selection-screen.

perform form_check_restrictions.

FORM form_check_restrictions .

*If the Selection Crieteria not specified

IF S_BUDAT[] is initial AND

S_BWART[] is initial AND

S_CHARG[] is initial AND

S_KUNNR[] is initial AND

S_LGORT[] is initial AND

S_LIFNR[] is initial AND

S_MATNR[] is initial AND

s_extb[] is initial AND

s_misc[] is initial AND

S_SOBKZ[] is initial AND

S_USNAM[] is initial AND

S_VGART[] is initial AND

S_WERKS[] is initial AND

S_XBLNR[] is initial.

MESSAGE 'Selection was not restricted.' TYPE 'W'.

STOP.

ENDIF.

ENDFORM.

Read only

Former Member
0 Likes
901

hi,

try chain fields statement. it will not allow u untill 2 completly fill all fields.

i will even check data type.