‎2009 Dec 10 7:35 AM
Hi
In the below code Exportdata internal table contains10 fields with 4 line items 10,20,40,50 records.all the 10 fields contain data
IT_EKKO_ekpo has 8 fields with 5 line items 10,20,30,40,50.all the 8 filedls contain data.
export data is having 2 extra fields with data compared to IT_ekko_ekpo.
my intension is to add the 30th line item from IT_ekko_ekpo into exportdata with the 2 extra fields data as initial .
Ater my code though the line item 30 is sucessfully inserted into exportdata with 8 fields data , all the other line items are also having data in only 8fields. the 9th and 10th field data for line items 10, 20, 40, 50 are missing.
How can I solve this issue, I want the other line items apart from 30 to contain the 10 fields data and line item 30 to contain 8 fields data after I append the exportdata table.
LOOP AT IT_EKKO_EKPO INTO wa_ekko_ekpo.
READ TABLE exportdata
INTO wa_exportdata
WITH KEY ebeln = wa_ekko_ekpo-ebeln
ebelp = wa_ekko_ekpo-ebelP
BINARY SEARCH.
IF syst-subrc NE 0.
wa_exportdata-ebeln = wa_ekko_ekpo-ebeln.
wa_exportdata-ebelp = wa_ekko_ekpo-ebelp.
wa_exportdata-konnr = wa_ekko_ekpo-konnr.
wa_exportdata-ktpnr = wa_ekko_ekpo-ktpnr.
wa_exportdata-werks = wa_ekko_ekpo-werks.
wa_exportdata-menge = wa_ekko_ekpo-menge.
wa_exportdata-netpr = wa_ekko_ekpo-netpr.
wa_exportdata-lgort = wa_ekko_ekpo-lgort.
APPEND wa_exportdata TO exportdata.
CLEAR: wa_exportdata.
ENDIF.
ENDLOOP.
SORT exportdata BY ebeln ebelp.
‎2009 Dec 10 7:40 AM
Hello
If you use BINARY SEARCH in READ statement you must sort table.
Two ways:
1. Declare table exportdata as sorted table and use INSERT instead of APPEND.
2. Modify code:
...
APPEND wa_exportdata TO exportdata.
SORT exportdata BY ebeln ebelp. " add this
CLEAR: wa_exportdata.
ENDIF.
ENDLOOP.
‎2009 Dec 10 8:09 AM
Hi,
Before appending just write the two additional fields also and pass initial values to it.
This might solve the problem.
‎2009 Dec 10 8:12 AM
Hi Selina,
Please check whether you sorted the internal table Exportdata by EBELN EBELP before you do a Binary search on the table.
If you have done this, and still facing the problem, Please post the structures of both internal tables IT_EKKO_ekpo and Exportdata.