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

make field mandatory through code

Former Member
0 Likes
1,894

Hi All,       I want to a field mandatory thru code, please help me out how to do it with condition which is given below. if PSMERK-ZZACTIVITE = 'AVVT' or PSMERK-ZZFONCTION = 'VTE' then filed  PSMERK-ZZMARKET should be mandary endif. if PSMERK-ZZACTIVITE = '  ' or PSMERK-ZZFONCTION = '  ' show message 'please put some value'  'I'. I am not getting how to do filed PSMERK-ZZMARKET madatory for given condition. Thanks and Regards Sankil

8 REPLIES 8
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,105

Is it standard tcode or custom one..If custom in PAI you can simply display an error message in chain-endchain statement

Nabheet

Read only

0 Likes
1,105

but need to do PSMERK-ZZMARKET filed mandatory for given 2 conditions. i have done like this: IF PSMERK-ZZACTIVITE = 'AVVT' or PSMERK-ZZFONCTION = 'VTE'. PSMERK-ZZMARKET = 'OBLIGATORY' ENDIF. IF PSMERK-ZZACTIVITE = ' ' or PSMERK-ZZFONCTION = ' '. MESSAGE 'PLS PUT SOME VALUE' 'I' ENDIF. The way i have done its right or required some more modification. Thanks and Regards Sankil

Read only

0 Likes
1,105

If ( ( PSMERK-ZZACTIVITE = 'AVVT' or PSMERK-ZZFONCTION = 'VTE' )

or (PSMERK-ZZACTIVITE = ' ' or PSMERK-ZZFONCTION = ' ' ) )

message e000 with text 'Please enter value'.

endif.,

Read only

0 Likes
1,105

Thanks Nabheet

Read only

Former Member
0 Likes
1,105

This message was moderated.

Read only

Former Member
0 Likes
1,105

Hi,

In Module pool

You can do validation in the PAI for the fields

For multiple fields validation you can use CHAIN..ENDCHAIN

Include the fields in a FIELD statement, and enclose it in a CHAIN-ENDCHAIN block statment. Eg. Screen flow logic:  CHAIN. FIELD: SPFLI-CARRID, SPFLI-CONNID. MODULE CHECK_FLIGHT. ENDCHAIN. When an error is found inside a chain, the screen is re-displayed, and all fields found anywhere in the chain are input-enabled. All non-chain fields remain disabled.

In Report .

You can   validate these in

At Selection screen or at selection screen on parameter event.

write the necessray code in these events.

Read only

Former Member
0 Likes
1,105

Hi,

How about this.

TABLES : mara, marc.

SELECT-OPTIONS :s_matnr for mara-matnr,

                 s_mtart for mara-mtart,

                 s_werks for marc-werks.

AT SELECTION-SCREEN.

   If s_matnr is NOT INITIAL and s_mtart is NOT INITIAL.

     If s_werks is INITIAL.

       Set CURSOR FIELD 'S_WERKS-LOW'.

       MESSAGE 'CANNOT BE EMPTY' TYPE 'E'.

     ENDIF.

   ENDIF.

   If s_matnr is  INITIAL and s_mtart is INITIAL and s_werks is INITIAL.

       Set CURSOR FIELD 'S_MATNR-LOW'.

       MESSAGE 'PLEASE PUT SOME VALUE' TYPE 'E'.

   ENDIF.

START-OF-SELECTION.

   WRITE : 'Hello'.


Regards

Read only

Former Member
0 Likes
1,105

Hi

You can make the field mandatory by giving fieldname-required = 'X' or you can put all the fields that has to be filled mandatory in chain.....endchain and print appropriate messages if values entered are wrong.

With regrads

Suneesh