Skip to Content
0
Sep 18, 2006 at 10:59 AM

How to create dynamic ON CHANGE statement? Please help!

29 Views

Hi Experts,

I have a requirement where my ON CHANGE criteria is dynamic. It is based on wa_charakeyfrmt-value which I am reading from a table. If it is 'DO' then ON CHANGE will have wa_errtabcopy-DO. Else if it is 'LI' then ON CHANGE will have wa_errtabcopy-LI. There will be many cases like this. So instead of writing so many IF/ELSE or SWITCH/CASE conditions is it possible to dynamically create ON CHANGE criteria for the last field. See the example code below:

IF wa_charakeyfrmt-value = 'DO'. "On DO change

LOOP AT i_errtabcopy into wa_errtabcopy

WHERE sold_to = wa_errtab-sold_to.

ON CHANGE OF wa_errtabcopy-key_value

OR wa_errtabcopy-rep_created_date

OR wa_errtabcopy-rep_created_time

OR wa_errtabcopy-rep_counter

OR wa_errtabcopy-DO.

ENDON.

ENDLOOP.

ELSEIF wa_charakeyfrmt-value = 'LI'. "On LI change

LOOP AT i_errtabcopy into wa_errtabcopy

WHERE sold_to = wa_errtab-sold_to.

ON CHANGE OF wa_errtabcopy-key_value

OR wa_errtabcopy-rep_created_date

OR wa_errtabcopy-rep_created_time

OR wa_errtabcopy-rep_counter

OR wa_errtabcopy-LI.

ENDON.

ENDLOOP.

|

Thanks

Gopal