Application Development 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: 

Issue with validation in chain endchain

Former Member
0 Kudos
526

Hello All,

I've created a screen through screen painter. I've created a table in which I need to put a validation that if 1st field is not empty all other fields in the row should not be blank.

I've out all the fields in chain endchain. The issue , which I am facing is that every time 'ENTER' is pressed on the screen , it always shows only the first field mentioned in chain endchain as RED for error even if it has values . It does not consider the other fields.

CHAIN.

FIELD : p_bin01MODULE check_data.

FIELD : p_frm01 MODULE check_data.

FIELD : p_qty01 MODULE check_data.

endchain.

Please suggest.

Thanks.

7 REPLIES 7

Former Member
0 Kudos
84

Hi,

check below code..

you have list of fields in the table : field1, field2, field3, field4, field5....

CHAIN.

FIELDS: itab-field2,

itab-field3,

itab-field4,

itab-field5 MODULE check_data ON CHAIN-INPUT.

ENDCHAIN.

MODULE check_data ON INPUT.

IF NOT itab-field1 IS INITIAL AND .

( itab-field2 IS INITIAL OR

itab-field3 IS INITIAL OR

itab-field4 IS INITIAL OR

itab-field5 IS INITIAL ).

give a message..........

ENDIF.

ENDMODULE.

0 Kudos
84

Hello Venkat,

I've written the code in a similar manner only .. the problem is whenever there is error in any of the fields , the first field in chain endchain is highlighted rather than the one with the error.

Thanks

0 Kudos
84

Hi,

in that case, between MODULE ....... ENDMODULE. set the cursor.

MODULE check_data ON INPUT.

IF itab-field2 IS INITIAL.

set cursor on field - > field2.

ELSEIF itab-field3 IS INITIAL.

set cursor on field - > field3.

ELSEIF itab-field4 IS INITIAL.

set cursor on field - > field4.

ELSEIF itab-field5 IS INITIAL.

set cursor on field - > field5.

ENDIF.

ENDMODULE

deepak_dhamat
Active Contributor
0 Kudos
84

Hi ,

Just use below code

CHAIN.
FIELD : p_bin01.
FIELD : p_frm01.
FIELD : p_qty01.
endchain.

IN PAI ...

it will check the field and get the cursor on empty field ...write ur logic accordingly

regards

Deepak.

0 Kudos
84

Hello Deepak,

I've tried this. This brings the cursor on the first field in chain endchain every time 'ENTER' is pressed. Even if some other field is empty in that row.

Thanks

0 Kudos
84

Then use Simple Logic of FLAG i.e

IN PAI ....

Perform Validate .

in driving program .

form validate .

if p_bin01 is initial .

flag = 'B' .

elseif p_bin01 is not initial and p_frm01 is initial .

FLAG = 'F' .

elseif p_bin01 is not initial and p_frm01 is not initial and p_qty01 is initial.

FLAG = 'Q' .

endif.

endform .

accoring to flag you can set messages and also set cursor .

OR check CASE SY-UCOMM .

WHEN OTHERS .

Because ENTER is ConSIdered in OTHERS .

regards

Deepak

Former Member
0 Kudos
84

Used attribute required in Screen Painter