2007 Sep 28 8:40 AM
Hi experts,
I have 2 internal tables i_sddoc, i_konv. In one internal table (i_sddoc) I have 10 rows with identical knumw and posnr.
I need to get the lines from the other internal table (i_konv), when 2 fields are the same (knumw and posnr). In i_konv there are multiply records with the same knumw and kposn.
I'm not allowed to use embedded loops because the table have a size category 4 with thousands of items. So have can I select the lines from i_konv?
If you have further question to be able to answer me, please let me know.
Hi experts,
I have 2 internal tables i_sddoc, i_konv. In one internal table (i_sddoc) I have 10 rows with identical knumw and posnr.
I need to get the lines from the other internal table (i_konv), when 2 fields are the same (knumw and posnr). In i_konv there are multiply records with the same knumw and kposn.
I'm not allowed to use embedded loops because the table have a size category 4 with thousands of items. So have can I select the lines from i_konv?
If you have further question to be able to answer me, please let me know.
2007 Sep 28 8:43 AM
Hi,
Use this for ref...
loop at i_sddoc.
read table i_konv with key posnr = i_sddoc-posnr
knumv = i_sddoc-knumv.
if sy-subrc = 0.
do ur procvessing
endif.
endloop.
reward if helpful,
Karthik
2007 Sep 28 8:46 AM
It is not good, because it only get 1 row from i_konv when it founds the same kunmw and posnr. I would need all.
2007 Sep 28 8:47 AM
Do you mean to say like the header values are in i_sddoc and line item value are in i_konv
2007 Sep 28 8:49 AM
white,
in that case, you will have to use a nested loop on konv where posnr & knumv = i_sddoc posnr & knumv. I mean
loop at i_sddoc.
loop at i_konv where key posnr = i_sddoc-posnr
and knumv = i_sddoc-knumv.
do ur procvessing
endloop.
endloop.
2007 Sep 28 8:51 AM
Karthik it would be okay, but if I have a very large internal table then it would run for a very long time, so that's why I don't want to use embedded loops.
have you got any other idea?
2007 Sep 28 8:54 AM
Hello varalakshmi,
Yes it's similar. Because I have knumv and posnr in i_sddoc, and I have to find all the lines in the other table i_konv which fits to it. The key between my 2 internal table is knumw and posnr, but I have more than 1 records in konv with the same knumv and posnr.
2007 Sep 28 8:56 AM
Hi White Stripes,
Without embedded loop i do not think your requirement is possibel.
For better performance you can use INDEX in your inner loop.
SORT i_konv
BY knumw
posnr.
LOOP AT i_sddoc
INTO wa_sddoc.
READ TABLE i_konv
INTO wa_konv
with key knumw = wa_sddoc-knumw
AND posnr = wa_sddoc-posnr
BINARY SEARCH.
z_tabix = sy-tabix.
loop at i_konv
into wa_konv
from z_index.
APPEND wa_konv TO it_output.
endloop.
ENDLOOP.
2007 Sep 28 8:43 AM
Hi
fetch the data from VBAK and VBAP into ITAB1
Take the VBAK-KNUMV and VBAP-POSNR and pass to
KONV-KNUMV and KONV-KPOSN and fetch the data from KONV
and separate the data based on the required KSCHL field
Regards
Anji
2007 Sep 28 8:48 AM
Hello Anji,
kschl is not obligatory in this case, so what should I do in this case?
2007 Sep 28 8:45 AM
Refer the below code.
SORT i_konv
BY knumw
posnr.
LOOP AT i_sddoc
INTO wa_sddoc.
loop at i_konv
into wa_konv.
where knumw = wa_sddoc-knumw
AND posnr = wa_sddoc-posnr.
READ TABLE i_konv
INTO wa_konv.
APPEND wa_konv TO it_output.
endloop.
ENDLOOP.
Check this code
Regards,
Mukesh Kumar
Message was edited by:
mukesh kumar
2007 Sep 28 9:08 AM
I am sorry but have to be a bit harsh, so many answers not one which is useful!
The last one is on the right track but still wrong:
SORT i_konv BY knumw posnr.
LOOP AT i_sddoc INTO wa_sddoc.
READ TABLE i_konv INTO wa_konv
with key knumw = wa_sddoc-knumw
AND posnr = wa_sddoc-posnr
BINARY SEARCH.
z_tabix = sy-tabix.
the loop from index is the trick for several hits !!!
loop at i_konv into wa_konv from z_index.
the exit is missing, then it will still loop half of the table !!!!!
IF NOT ( wa_konv-knumw = wa_sddoc-knumw
AND wa_konv-posnr = wa_sddoc-posnr ).
EXIT.
ENDIIF
there is a loop why another read ???
READ TABLE i_konv INTO wa_konv
APPEND wa_konv TO it_output.
ENDLOOP.
ENDLOOP.
For more information please read my recent blog:
/people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables
> allowed to use embedded loops because the table have a size category 4
internal table don't have size categories, if you have a lot of data, more than
you can put into memory, then you must process in packages.
But then you must take care, that both packages contain the lines which belong together.
Siegfried
2007 Sep 28 9:51 AM
The solution is the following. I have to sort all two tables according to knumv and posnr. Then I have to make a loop at konv, then read the table sddoc with key knumv and kposn. So Without sorting the 2 table it doesn't give right results.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |