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 in Module pool Program

naren112
Explorer
0 Likes
2,580

<b>Hi ,

I created a module pool Program , I hav taken one parameter .. How to do the validation for this paramater in screen .

And if Im taking a set of parameter - how to do the validation ..

Regards,

Narender</b>

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,583

Hi, you just need to put a validation module in the PAI in the screen flow logic. eg if your field is zzz-field1, use a statement in the PAI like this:

FIELD ZZZ-FIELD1 MODULE VALIDATE_FIELD1.

or, to only process conditionally, use

FIELD ZZZ-FIELD1 MODULE VALIDATE_FIELD1 ON INPUT

or

FIELD ZZZ-FIELD1 MODULE VALIDATE_FIELD1 ON REQUEST.

if your module then generates an error message this field will be highlighted for action.

if you have several fields you need to chain them eg ZZZ-FIELD1 and ZZZ-FIELD2:

CHAIN.

FIELD: ZZZ-FIELD1, ZZZ-FIELD2.

MODULE VALIDATE_FIELDS ON CHAIN-INPUT " (or ON CHAIN-REQUEST)

ENDCHAIN.

8 REPLIES 8
Read only

Former Member
0 Likes
1,583

Hi,

Do the validation in the CHAIN...ENDCHAIN stmt.

Regards

Subramanian

Read only

0 Likes
1,583

<b>hi Subramanian ,

Chain Endchain is used for a set of parameter , Just I want to validate a single parameter ...

Regards,

Narender</b>

Read only

0 Likes
1,583

in the PAI..

module check_data.

select single * from <table>

where <tablefield> = <screenfield-value>.

if sy-subrc = 0.

else.

message E000(00) with '<ScreenField-Value> does not exit'.

endif.

endmodule.

in the flow logic for the screen. write as

chain.

field : <screenfield>.

module check_data.

endchain.

Regards

Gopi

Read only

Former Member
0 Likes
1,583

Naren,

Use FIELD field name MODULE MODULE_3.

Pls. Mark if useful.

Read only

Former Member
0 Likes
1,584

Hi, you just need to put a validation module in the PAI in the screen flow logic. eg if your field is zzz-field1, use a statement in the PAI like this:

FIELD ZZZ-FIELD1 MODULE VALIDATE_FIELD1.

or, to only process conditionally, use

FIELD ZZZ-FIELD1 MODULE VALIDATE_FIELD1 ON INPUT

or

FIELD ZZZ-FIELD1 MODULE VALIDATE_FIELD1 ON REQUEST.

if your module then generates an error message this field will be highlighted for action.

if you have several fields you need to chain them eg ZZZ-FIELD1 and ZZZ-FIELD2:

CHAIN.

FIELD: ZZZ-FIELD1, ZZZ-FIELD2.

MODULE VALIDATE_FIELDS ON CHAIN-INPUT " (or ON CHAIN-REQUEST)

ENDCHAIN.

Read only

Former Member
0 Likes
1,583

Hi Narender,

U need to do the validation in PAI event of the screen as below :

PROCESS AFTER INPUT.

MODULE user_command_0100.

      • input check for field cvp number

FIELD : cvp_no. <b>"Screen Field needs to be validated</b>

MODULE show_cv_desc.

And the module definition is as follows :

MODULE show_cv_desc INPUT.

ws_repid = sy-cprog.

ws_num = '1000'.

i_dynfields-fieldname = 'CVP_NO'.

APPEND i_dynfields.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

dyname = ws_repid

dynumb = ws_num

TABLES

dynpfields = i_dynfields

EXCEPTIONS

invalid_abapworkarea = 1

invalid_dynprofield = 2

invalid_dynproname = 3

invalid_dynpronummer = 4

invalid_request = 5

no_fielddescription = 6

invalid_parameter = 7

undefind_error = 8

double_conversion = 9

stepl_not_found = 10

OTHERS = 11.

IF sy-subrc EQ 0.

READ TABLE i_dynfields WITH KEY fieldname = 'CVP_NO'.

IF sy-subrc EQ 0.

cvp_no = i_dynfields-fieldvalue.

ENDIF.

ENDIF.

<b>***********Validation</b>

if cvp_no = '0013'.

message e000(zocm) with 'Wrong Entry'. <b>" If the user enters 0013 for cvp_no</b> endif.

ENDMODULE. " show_cv_desc INPUT

Please do reward helpful answers.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,583

Hi,

In PAI,

FIELD fieldname MODULE validate.

MODULE validate INPUT.

..do the validation here....

ENDMODULE. "Validate INPUT

Read only

Former Member
0 Likes
1,583

in PAI you have to validate the field.

FIELD f1 MODULE m1 [ON INPUT|ON REQUEST].

things in sqare bracket are optional [].

in abap editor it will show

MODULE m1 input.

<do validation code>.

ENDMODULE.

regards

shiba dutta