‎2007 May 29 11:10 AM
Hi,
I have two internal tables with different data. But I have to cobined and make one entry,.
<b>STRUCTURE OF IT_FINAL.</b>
EBELN
EBELP
CNTYPE " Condition type.
TAX.
<b>
structure of it_fina1.</b>
EBELN
EBELP
JIP1
JIP2
JMO1.
ZVAS.
The problem is in the first internal table It_final contains more that one record for a particular EBELN and EBELP.
EBELN EBELP CNTYPE TAX.
185 10 JMO1. 150.
10 JIP1. 120
JIP2 130.
BUT I WANT ONLY ONE RECORD PER EBELN AND EBELP COMBINATIO. LIKE THIS IN THE SECOND INTENAL TABLE IT_FINAL1.
EBELN EBELP JMO1 JIP1 JIP2 ZVAS.
185 10 150 120 130
Can any one write the code please ?
Bye,
Satya.
‎2007 May 29 11:17 AM
Hi,
Data : l_tabix type sy-tabix.
Loop at it_final1 into wa_final1.
l_tabix = sy-tabix.
read table it_final into wa_final with key ebeln = wa_final1-ebeln
ebelp = wa_final1-ebelp
cntype = 'JM01'.
if sy-subrc eq 0.
wa_final1-jm01 = wa_final-tax.
endif.
read table it_final into wa_final with key ebeln = wa_final1-ebeln
ebelp = wa_final1-ebelp
cntype = 'JIP1'.
if sy-subrc eq 0.
wa_final1-jip1 = wa_final-tax.
endif.
read table it_final into wa_final with key ebeln = wa_final1-ebeln
ebelp = wa_final1-ebelp
cntype = 'JIP2'.
if sy-subrc eq 0.
wa_final1-jip2 = wa_final-tax.
endif.
Modify it_final1 from wa_final1 index l_tabix.
endloop.
Best regards,
Prashant
‎2007 May 29 11:20 AM
Hi,
If you put that many read statements performance will decrease.
Apart from that is there any another method by using on change of like that ...
Bye,
Satya.
‎2007 May 29 11:23 AM
Hi
You are not supposed to write the data like that in internal table?
How many condition types for a single EBELN and EBELP will there, how do you know?
In that case if you write each Condition type as one column, how many condition types you will write? one EBELP will have 2 and other will have 5 and other will have 6 condition types, Is there any strict rule that it is only 5 or 6 cond types?
geneally we take the KNUMV field or KNUMH field in both internal tables One in PO data and other in Tax data and use that field to read the tax related data.
Reward points if useful
Regards
Anji
‎2007 May 29 11:23 AM
Data : l_tabix type sy-tabix.
<b>SORT IT_FINAL by EBELN EBELP.</b>
Loop at it_final1 into wa_final1.
l_tabix = sy-tabix.
read table it_final into wa_final with key ebeln = wa_final1-ebeln
ebelp = wa_final1-ebelp
cntype = 'JM01'
<b>BINARY SEARCH</b>.
if sy-subrc eq 0.
wa_final1-jm01 = wa_final-tax.
endif.
read table it_final into wa_final with key ebeln = wa_final1-ebeln
ebelp = wa_final1-ebelp
cntype = 'JIP1'
<b>BINARY SEARCH.</b>
if sy-subrc eq 0.
wa_final1-jip1 = wa_final-tax.
endif.
read table it_final into wa_final with key ebeln = wa_final1-ebeln
ebelp = wa_final1-ebelp
cntype = 'JIP2'
<b>BINARY SEARCH.</b>
if sy-subrc eq 0.
wa_final1-jip2 = wa_final-tax.
endif.
Modify it_final1 from wa_final1 index l_tabix.
endloop.
This is the optimized code. Read statements generally doesnt put that much load on server as compared to select statement inside a loop.