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

Modifying an internal table field

Former Member
0 Likes
4,799

Hi All !!

I have to modify one field 'flag' of the internal table based on the selection of another internal table.

That is.. I have to modify flag of ITAB1 only if the entries of ITAB1 satisfy the fields of another internal table ITAB2.

ITAB1 contains the field of internal table ITAB2.I tried by this method...

loop at ITAB1 into wa_ITAB1.

lv_index = SY-INDEX.

loop at ITAB2 into wa_ITAB2.

if wa_ITAB1-F1 eq wa_ITAB2-F1 and wa_ITAB1-F2 eq wa_ITAB1-F2 and wa_ITAB1-F3 eq wa_ITAB2-F3.

wa_ITAB1-flag = "X".

modify ITAB1 from wa_ITAB1 index lv_index.

endloop.

endloop.

IS IT POSSIBLE TO AVOID NESTED LOOPS.

Please help..

thanks in advance...

Prabhas.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
727

Hi,

You can avoid this nested loop with the READ TABLE statement.

Try the following ...

loop at ITAB1 into wa_ITAB1.

clear wa_itab2.

read table itab2 into wa_itab2 with key F1 = wa_itab1-F1

and F2 = wa_itab1-F2

and F3 = wa_itab3-F3.

if sy-subrc = 0.

wa_ITAB1-flag = "X".

modify ITAB1 from wa_ITAB1 transporting flag

where F1 = wa_itab1-F1 and

F2 = wa_itab1-F2 and

F3 = wa_itab1-F3.

endif.

clear wa_itab1.

endloop.

Regards,

Shanthi.P

            • Reward points if useful *****

Edited by: shanthi ps on Jan 26, 2008 12:19 PM

3 REPLIES 3
Read only

Former Member
0 Likes
728

Hi,

You can avoid this nested loop with the READ TABLE statement.

Try the following ...

loop at ITAB1 into wa_ITAB1.

clear wa_itab2.

read table itab2 into wa_itab2 with key F1 = wa_itab1-F1

and F2 = wa_itab1-F2

and F3 = wa_itab3-F3.

if sy-subrc = 0.

wa_ITAB1-flag = "X".

modify ITAB1 from wa_ITAB1 transporting flag

where F1 = wa_itab1-F1 and

F2 = wa_itab1-F2 and

F3 = wa_itab1-F3.

endif.

clear wa_itab1.

endloop.

Regards,

Shanthi.P

            • Reward points if useful *****

Edited by: shanthi ps on Jan 26, 2008 12:19 PM

Read only

0 Likes
727

Hi,

we can change though modify or update key word.

Regards,

SUBASH.

Read only

Former Member
0 Likes
727

Hi,

Yes, you can do it by using READ statement. While modifying the itab1 use index.

loop at ITAB1 into wa_ITAB1.

lv_index = SY-INDEX.

Read ITAB2 into wa_ITAB2 with key F1 = wa_ITAB1-F1 and F2 = wa_ITAB1-F2 and F3 eq wa_ITAB1-F3.

IF sy-subrc = 0.

wa_ITAB1-flag = "X".

modify ITAB1 from wa_ITAB1 TRANSPORTING flag index lv_index.

Endif.

endloop.