‎2009 Nov 25 7:29 AM
Hi guriji,
i have written one query.but this not working properly.
loop at itab .
read table itab2 WITH key kostl = itab-fictr.
if itab-fictr = itab2-kostl .
read table itab2 with key hkont = temp_acc_code .
if sy-subrc = 0 .
itab-dmbtr = itab2-dmbtr .
endif .
modify itab transporting dmbtr .
endif.
endloop.
whhen internal table iab2 reads with kostl it reds only last kostl and based on that it will not show output. the read condition i am stuck because in itab2 suppose there are 5 kostl (cost center ex. 1910,1000,1100,1090,1600) .in this case it reads only 1600 and check . it will not consider remaining 4 kostl.
plz tell me what is problem in my query.
thanks.
‎2009 Nov 25 7:41 AM
hi friend
thanks & regards
surender
sort itab2 by kostl hkont .
loop at itab.
read table itab2 into wt_tab2 with key kostl = itab-fictr
hkont = itab-temp_acc_code binary search.
if sy-subrc eq 0.
itab-dmbtr = wt_tab2-dmbtr.
modify itab.
endif.
endloop.
‎2009 Nov 25 7:36 AM
Check this
loop at itab .
v_tabix = sy-tabix.
read table itab2 WITH key kostl = itab-fictr
hkont = temp_acc_code .
if sy-subrc = 0 .
itab-dmbtr = itab2-dmbtr .
modify itab transporting dmbtr index v_tabix.
endif.
endloop.
a®
‎2009 Nov 25 7:41 AM
hi friend
thanks & regards
surender
sort itab2 by kostl hkont .
loop at itab.
read table itab2 into wt_tab2 with key kostl = itab-fictr
hkont = itab-temp_acc_code binary search.
if sy-subrc eq 0.
itab-dmbtr = wt_tab2-dmbtr.
modify itab.
endif.
endloop.
‎2009 Nov 25 10:25 AM
hi
in this read table statement it checks only one condition but i want to check both condition.ie
read table itab2 with key kostl = itab-fictr
hkont = itab-acc_code binary search.
it checks one condition and based on this it modify the table..
thanks..
‎2009 Nov 25 10:30 AM
Hello can you tell how the internal tables holds the data before entering the loop.
Edited by: ksd on Nov 25, 2009 4:03 PM
‎2009 Nov 25 8:03 AM
Your code is correct and will work properly but is not optimised.
Check you value of itab-fictr as the values KOSTL fetched from itab2 depends on this . If itab-fictr = 1600 , then only last record of itab2 will be read and other four records will not be considered.
Hope you get it .
‎2009 Nov 25 8:13 AM
loop at itab .
l_tabix = sy-yabix.
read table itab2 WITH key kostl = itab-fictr
fictr = itab-kostl
hkont = temp_acc_code transporting dmbtr.
check sy-subrc = 0.
itab-dmbtr = itab2-dmbtr .
modify itab index l_tabix transporting dmbtr .
endloop.