‎2008 Jan 26 10:53 AM
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.
‎2008 Jan 26 11:19 AM
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
‎2008 Jan 26 11:19 AM
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
‎2008 Jan 26 1:17 PM
Hi,
we can change though modify or update key word.
Regards,
SUBASH.
‎2008 Jan 26 11:27 AM
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.