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

itab modify command

Former Member
0 Likes
473

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
451

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

3 REPLIES 3
Read only

Former Member
0 Likes
452

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

Read only

Former Member
0 Likes
451

just use modify itab from wa ,no need to have transporting syntax.

Read only

former_member196280
Active Contributor
0 Likes
451

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