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

dynamic required field check

former_member194669
Active Contributor
0 Likes
1,094

Hi,

I have custom module pool with 5 screens. The fields displayed in the screen are from table MARA.

and also i have custom table with following fields

MATERIAL TYPE

FIELD NAME

FIELD NAME1

while user press SAVE button, then i need to validate screen field from module pool with above mentioned table.

ie in screen i have field MDESC with material type 01, in the custom table i have an entry like this way

01 MDESC

then the screen field MDESC in module pool is mandatory.

How to do this? This validation need to done only on SAVE

aRs

Hi,

I have custom module pool with 5 screens. The fields displayed in the screen are from table MARA.

and also i have custom table with following fields

MATERIAL TYPE

FIELD NAME

FIELD NAME1

while user press SAVE button, then i need to validate screen field from module pool with above mentioned table.

ie in screen i have field MDESC with material type 01, in the custom table i have an entry like this way

01 MDESC

then the screen field MDESC in module pool is mandatory.

How to do this? This validation need to done only on SAVE

aRs

5 REPLIES 5
Read only

Former Member
0 Likes
895

HI,

Try this logic..

IN PAI...

If sy-ucomm = 'OSAV'.

Chain.

  • do ur validation on screen.

check for ur fields.

if mtype = '01'.

if mdesc is initial.

message: 'Field is mandatory'.

endif.

endif.

Endchain.

Endif.

Regards

SAB

Read only

Former Member
0 Likes
895

Hi,

In your custom table you will have the values to make it mandatory or not right??

Thanks,

Naren

Read only

Former Member
0 Likes
895

Hi

LOOP AT SCREEN.
  SELECT SINGLE * FROM ZTABLE WHERE MATERIAL_TYPE = <....>
                                                            AND FIELDNAME = SCREEN-FIELD.
  IF SY-SUBRC = 0.
* --> DO your validation
  ENDIF.
ENDLOOP.

Max

Read only

former_member194669
Active Contributor
0 Likes
895

Naren,

In my custom table i have only material type and fieldname. Actually my requirement is if the screen field is not filled then system should check the custom table whether the fieldname is found, then that field in the screen is mandatory.

Thanks

aRs

Read only

Former Member
0 Likes
895

Hi,

Okay...I have assumed that for material type 01 you will have more than one field that requires to be mandatory..

Check this..

Create a module in PAI..

MODULE USER_COMMAND INPUT.

CASE sy-ucomm.

WHEN 'SAVE'. <b>" Function code for save..</b>

<b>* Get the values from the custom table ZTABLE and move it to the internal table

  • T_ZTABLE</b>

SELECT * FROM ZTABLE

INTO TABLE T_ZTABLE

WHERE MATERIAL_TYPE = '01'. " I am assuming 01

<b>* Process the records.</b>

LOOP AT T_ZTABLE.

<b>* Get the field value dynamically</b>

ASSIGN (T_ZTABLE-FIELDNAME) TO <FS>.

CHECK sy-subrc = 0.

IF <FS> IS INITIAL.

<b>* Error message..the field is mandatory.</b>

MESSAGE E208(00) WITH T_ZTABLE-FIELDNAME ' Is required'.

ENDIF.

ENDLOOP.

ENDMODULE.

Hope this helps.

Thanks,

Naren