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

problem in query

Former Member
0 Likes
800

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
758

hi friend



 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.

thanks & regards surender

6 REPLIES 6
Read only

former_member194669
Active Contributor
0 Likes
758

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®

Read only

Former Member
0 Likes
759

hi friend



 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.

thanks & regards surender

Read only

0 Likes
758

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..

Read only

0 Likes
758

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

Read only

Former Member
0 Likes
758

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 .

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
758

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.