‎2010 Feb 18 8:28 AM
Hi,
I have an internal table with structure as follows
MANDT
KDMAT
VBELN
POSNR
VBTYP
CHARG
ERDAT
Now I need to fill this table from 2 different database tables:
VBAK: VBELN, VBTYP, ERDAT
VBAP: KDMAT, POSNR, CHARG.
Should I have 2 itabs for VBAK and VBAP. And fill the final itab looping thru VBAK and VBAP itabs?
What would be the best way to do this?
Regards,
Sriram.
‎2010 Feb 18 8:40 AM
You can use a [SELECT - join|http://help.sap.com/abapdocu_70/en/ABAPSELECT_JOIN.htm], the choice between JOIN or two SELECT (second via [FOR ALL ENTRIES|http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_ITAB.htm] or[ WHERE|http://help.sap.com/abapdocu_70/en/ABAPWHERE.htm] option) depends on factor like volume of data and selection criteria.
Regards,
Raymond
‎2010 Feb 18 10:05 AM
Hi,
You can use Join statement to fetch data from different DB table at once.
Select AVBELN AVBTYP AERDAT BKDMAT BPOSNR BCHARG
into corresponding fields of table itab
from VBAK as A inner join VBAP as B
ON Avbeln = Bvbeln
Where <condition>.
Regards,
N3