I have a ABAP program where I read a file from the local machine into table (T_EXCEL) with 1 field. In this case this is a list of order numbers.
This is working correctly where I am reading in the list (100 orders). I am then trying to do a loop at this table selecting from 3 tables using inner joins to then insert into a different table.
I am only getting the last record from my table T_EXCEL in my table ORDLIST1
Here is my table def for T_EXCEL:
DATA:
BEGIN OF T_EXCEL OCCURS 0,
VBELN LIKE VBAK-VBELN,
END OF T_EXCEL.
************************** and here is my form I am having the issue with
Form Get_SO_List2.
*
SORT T_EXCEL.
*
LOOP AT T_EXCEL.
*
select VBAK~VBELN VBAK~ERDAT VBAK~ERZET VBAK~ERNAM VBAK~AUART
VBAK~AUGRU VBAK~VKORG VBAK~VKGRP VBAK~VKBUR VBAK~VDATU
VBAK~KUNNR VBAK~OBJNR VBAK~FAKSK VBAK~LIFSK VBAK~IHREZ
VBAK~KVGR5
VBUK~ABSTK VBUK~LFSTK VBUK~LFGSK
VBAK~BSTNK VBUK~COSTA
vbap~posnr vbap~matnr vbap~matwa vbap~werks vbap~vstel
vbap~kwmeng vbap~abgru vbap~pstyv vbap~route vbap~netpr
vbap~ktgrm vbap~kondm
INTO TABLE ORDLIST1
FROM ( ( VBAK
INNER JOIN VBUK ON VBUK~VBELN = VBAK~VBELN )
inner join vbap on vbap~vbeln = vbak~vbeln )
WHERE VBAK~VBELN = T_EXCEL-VBELN.
append ordlist1.
clear: vbak, vbuk, vbap.
endloop.
loop at ordlist1.
write:/ 'Ordlist1-SalesOrd - ', ordlist1-salesord.
endloop.
If I place a write statement above the select I do see this is looping through all 100 records, but my table ORDLIST1 only has 1 row populated instead of 100+.
What am I doing wrong?
Thanks!
*******************************************************************************************************
Here is my form where I am looping through T_EXCEL trying to insert the data into my table ORDLIST1.