‎2007 Jun 05 2:47 AM
hi friends,
i have a scenario,
an itab is already filled up, i need to change only one field
depending up on the other field condition is satisfied.
if itab-field1 = 'A'.
itab-field2 = 10.
else.
itab-field2 = 20.
endif.
no other field should be touched, how to do with work area.
i thought of coding like this.
loop at itab into wa_itab .
if wa_itab-field1 = 'A'.
wa_itab-field2 = 10.
else.
wa_itab-field2 = 20.
endif.
modify itab with wa_itab transporting field2.
endloop.
or is there a better way of doing this with replace all comand.
‎2007 Jun 05 3:01 AM
Hi saritha,
There is nothing wrong with this code and it is ok to use.
If you still want some modification you can use index while modifying the internal table.
loop at itab into wa_itab .
if wa_itab-field1 = 'A'.
wa_itab-field2 = 10.
else.
wa_itab-field2 = 20.
endif.
<b>modify itab INDEX sy-tabix FROM wa_itab transporting field2.</b>
endloop.
Reward points if useful.
Regards,
Atish
‎2007 Jun 05 3:01 AM
Hi saritha,
There is nothing wrong with this code and it is ok to use.
If you still want some modification you can use index while modifying the internal table.
loop at itab into wa_itab .
if wa_itab-field1 = 'A'.
wa_itab-field2 = 10.
else.
wa_itab-field2 = 20.
endif.
<b>modify itab INDEX sy-tabix FROM wa_itab transporting field2.</b>
endloop.
Reward points if useful.
Regards,
Atish
‎2007 Jun 05 3:08 AM
just use modify itab from wa ,no need to have transporting syntax.
‎2007 Jun 05 3:11 AM
What you wrote is correct, you can also use like this.
loop at itab into wa_itab .
if wa_itab-field1 = 'A'.
wa_itab-field2 = 10.
else.
wa_itab-field2 = 20.
endif.
<b> MODIFY itab FROM wa_itab INDEX sy-tabix
TRANSPORTING field 2 WHERE field1 = 'A'.</b>
*modify itab with wa_itab transporting field2.
endloop.
Reward points if useful.
Regards,
SaiRam