‎2006 Aug 29 8:52 PM
I want to be able to create a extract file of the data in the BKPF and BSEG tables. I need to create one line that contains a combination of fields from each table. I am thinking that I have to select the data that I need from the BKPF table into a work table and select the data that I need from the BSEG using the document number field from the BKPF as part of the selection into another work table. after I get the two work tables, I am going to have to read the BKPF table and move the fileds that I want to a third table and then read every entry in the bseg work table that matches the document number and move those field to the third work table. after that is completed, I will a one table that has data from both tables. is this the correct way to handle this. if there is a easier way to perform this operation, could someone please let me know
thanks in advance for the help.
‎2006 Aug 29 8:57 PM
Hi Timothy,
this would suffice.
data: itab like bkpf occurs 0 with header line.
data: itab1 like bseg occurs o with header line.
SELECT * FROM BKPF INTO TABLE itab
WHERE BUKRS EQ P_BUKRS AND
BELNR IN S_BELNR AND
GJAHR IN S_GJAHR.
SELECT * FROM BSEG INTO TABLE ITAB1
FOR ALL ENTRIES IN ITAB
WHERE BUKRS eq ITAB-BUKRS
AND BELNR eq ITAB-BELNR
AND GJAHR eq ITAB-GJAHR.
Regards,
Vivek
‎2006 Aug 29 8:56 PM
Since BSEG is a cluster table, that's probably about right but it depends on what data you are retrieving and what you are using as your selection criteria. There are alternate index tables if you are selecting by customer, vendor, etc.
‎2006 Aug 29 8:57 PM
Hi Timothy,
this would suffice.
data: itab like bkpf occurs 0 with header line.
data: itab1 like bseg occurs o with header line.
SELECT * FROM BKPF INTO TABLE itab
WHERE BUKRS EQ P_BUKRS AND
BELNR IN S_BELNR AND
GJAHR IN S_GJAHR.
SELECT * FROM BSEG INTO TABLE ITAB1
FOR ALL ENTRIES IN ITAB
WHERE BUKRS eq ITAB-BUKRS
AND BELNR eq ITAB-BELNR
AND GJAHR eq ITAB-GJAHR.
Regards,
Vivek
‎2006 Aug 29 9:11 PM
Much of the work may have been done for you already. Are you familiar with the secondary index tables:
BSIS
BSAS
BSID
BSAD
BSIK
BSAK
Each of these tables have data from BKPF and BSEG.
Rob