Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

creating table data from multiple tables

Former Member
0 Likes
603

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
512

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

3 REPLIES 3
Read only

Former Member
0 Likes
512

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.

Read only

Former Member
0 Likes
513

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

Read only

Former Member
0 Likes
512

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