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: 

On change of

Former Member
0 Kudos

How to use else part and more than one field in '' on change of "?pls give an example.

7 REPLIES 7

Former Member
0 Kudos

Hi Khanna,

The pseudo control structure ON CHANGE OF - ENDON is not permitted in ABAP Objects.

ABAP Objects error message at:

ON CHANGE OF f.

...

ENDON.

Correct syntax:

DATA g LIKE f.

IF f <> g.

...

g = f.

ENDIF.

Reason:

The system internally creates a global invisible work field which cannot be controlled by the program. You are recommended to declare your own work field and process it with the IF control structure.

Thanks,

Vidyashree

Former Member
0 Kudos

if <condition>

statements

else

statements

endif.

U cant use more than 1 field in On change of .

Former Member
0 Kudos

hi,

to use more than1 field try using

on change of field1 field2.

-- code

endon.

reward points if helpful..

former_member188827
Active Contributor
0 Kudos

on change of ..

endon.

if dis block is not true it wont be executed and u can code da else part outside dat block which 'll be automatically executed....

Former Member
0 Kudos

<b>On Change of:</b>

<b>Effect:</b>

The statements ON CHANGE OF and ENDON, which are forbidden in classes, define a control structure that can contain a statement block statement_block. After ON CHANGE OF, any number of data objects dobj1, dobj2... of any data type can be added..

<b>Example:</b>

In a SELECT loop, a statement block should only be executed if the content of the column CARRID has changed.

DATA spfli_wa TYPE spfli.

SELECT *

FROM spfli

INTO spfli_wa

ORDER BY carrid.

...

ON CHANGE OF spfli_wa-carrid.

...

ENDON.

...

ENDSELECT

Former Member

Former Member
0 Kudos

Hi,

Check this code.Surely this will help u.

DATA:l_v_rbukrs TYPE bukrs,

l_v_racct TYPE racct,

l_v_rcntr TYPE kostl,

l_v_rtcur TYPE rtcur,

l_v_ryear TYPE ryear,

l_v_prctr TYPE prctr.

loop at i_faglflext into wa_faglflext

l_v_rbukrs = wa_faglflext-rbukrs.

l_v_racct = wa_faglflext-racct.

l_v_rcntr = wa_faglflext-rcntr.

l_v_rtcur = wa_faglflext-rtcur.

l_v_ryear = wa_faglflext-ryear.

l_v_prctr = wa_faglflext-prctr.

IF v_bukrs NE l_v_rbukrs OR v_racct NE l_v_racct OR

v_rcntr NE l_v_rcntr OR v_rtcur NE l_v_rtcur.

statements

else.

statements

endif.

v_bukrs = l_v_rbukrs.

v_racct = l_v_racct.

v_rcntr = l_v_rcntr.

v_rtcur = l_v_rtcur.

v_ryear = l_v_ryear.

v_prctr = l_v_prctr.

endloop.

<b>Reward if Useful.</b>

Regards

Shibin