‎2007 Oct 30 9:35 AM
Hi,
I have 2 internal tables ( i_pro & it_pbim ). In my first internal table(i_pro) having matnr. Using this matnr i am feting some values from another table and i populating into 2nd internaltable. but in the loop its feting the records from the table but its not appending the internal table its overwriting the current value from the 2nd internal table.
how to append the values. i pasted my sample code also. plz give me soln urgent point will be sure.
loop at i_pro .
SELECT * FROM pbim
INTO corresponding fields of
TABLE it_pbim
WHERE matnr = i_pro-matnr
AND werks = 'GB06'
AND bedae = 'VSF'
AND vervs = 'X'.
AND loevr = ''.
append it_pbim .
endloop .
point will be sure.
Gowri
‎2007 Oct 30 9:38 AM
Remove dat LOOP ENDLOOP..
jus write
SELECT * FROM pbim
INTO corresponding fields of
TABLE it_pbim
<b>FOR ALL ENTRIES IN</b> it_pro
WHERE matnr = i_pro-matnr
AND werks = 'GB06'
AND bedae = 'VSF'
AND vervs = 'X'.
AND loevr = ''.
This will solve ur query..Reward if helpful
‎2007 Oct 30 9:39 AM
Hi,
Please do not use SELECT statements inside loops as it degrades the performance and is against standards.
Instead you could select all records from table pbim into an internal table in the beginning itself and in the loop read this internal table with key matnr.
Transfer the records into a work area and then append the work area to the final internal table.
Hope it is useful.
Thanks,
Sandeep.
‎2007 Oct 30 9:47 AM
Hi
Dont use select * inside the loop. Use only select single. For your case you can use FOR ALL ENTRIES which is best. No need for loop.
SELECT * FROM pbim
INTO corresponding fields of
TABLE it_pbim
FOR ALL ENTRIES IN it_pro
WHERE matnr = i_pro-matnr
AND werks = 'GB06'
AND bedae = 'VSF'
AND vervs = 'X'.
AND loevr = ''.
Reward points if useful.
Regards,
Murugan Arumugam.
‎2007 Oct 30 9:47 AM
Please try this ...
loop at i_pro .
SELECT * FROM pbim
appending corresponding fields of
TABLE it_pbim
WHERE matnr = i_pro-matnr
AND werks = 'GB06'
AND bedae = 'VSF'
AND vervs = 'X'.
* AND loevr = ''.
endloop .
note: can append to the internal table directly.
p/s: if sure there is no duplicate of it_pro-matnr, you can edit the query using 'for all entries' in order to improve performance.
‎2007 Oct 30 9:59 AM
Hi Gowri Sankar,
Use this...
SELECT * FROM pbim
INTO corresponding fields of
TABLE it_pbim
for all entries in i_pro
WHERE matnr = i_pro-matnr
AND werks = 'GB06'
AND bedae = 'VSF'
AND vervs = 'X'.
append it_pbim.
Reward If Useful.
Regards,
Chitra.
‎2007 Oct 30 10:05 AM
HI,
First populate the first internal table then use FOR ALL ENTRIES to relate the second internal tables . r try READ ITAB by filtering out using the comman fields
like.....
loop at itab1.
read table itab2 where field1 = itab1-field1 field2 = itab1-field2.
endloop.
try this
‎2007 Oct 30 10:17 AM
Hi,
You need to use <b>appending corresponding fields of table it_pbim</b> in your select statement.
loop at i_pro .
SELECT * FROM pbim
appending corresponding fields of
TABLE it_pbim
WHERE matnr = i_pro-matnr
AND werks = 'GB06'
AND bedae = 'VSF'
AND vervs = 'X'.
* AND loevr = ''.
endloop .Thanks,
Sriram Ponna.