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

join two table

Former Member
0 Likes
791

hello sir/medam.

i hane two pooled table BSEG and BSAK then i want joint the field together ..how use get command for that ....nd u have another solution plz tel me..

thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
764

if u r doin sumthin like fb60 then...

use this.....

<b>TABLES: bsik, bsak, bseg.

SELECT-OPTIONS: s_bukrs FOR bsik-bukrs OBLIGATORY,

s_lifnr FOR bsik-lifnr OBLIGATORY.

DATA: BEGIN OF bsik_int OCCURS 0.

INCLUDE STRUCTURE bsik.

DATA: END OF bsik_int.

DATA: BEGIN OF bseg_int OCCURS 0.

INCLUDE STRUCTURE bseg.

DATA: END OF bseg_int.

SELECT * FROM bsik

INTO TABLE bsik_int

WHERE bukrs IN s_bukrs

AND lifnr IN s_lifnr.

SELECT * FROM bsak

APPENDING TABLE bsik_int

WHERE bukrs IN s_bukrs

AND lifnr IN s_lifnr.

SELECT * FROM bseg

INTO TABLE bseg_int

FOR ALL ENTRIES IN bsik_int

WHERE bukrs = bsik_int-bukrs

AND belnr = bsik_int-belnr

AND gjahr = bsik_int-gjahr

AND ebeln = space.</b>

5 REPLIES 5
Read only

gopi_narendra
Active Contributor
0 Likes
764

You can not join BSEG on BSAK.

Since BSEG being a cluster table type.

Instead you can use FOR ALL ENTRIES for the internal table IT_BSAK.

select <FIELDS> from BSAK into table IT_BSAK.

if not it_bsak[] is initial.

select <FIELDS> from BSEG

for all entries in IT_BSAK

into table IT_BSEG

where BELNR = IT_BSAK-BELNR. " Match the common fields together

endif.

Regards

Gopi

Read only

0 Likes
764

1)It is recommended that

first select entries from only one table(say, BKPF), After that, using the internal table,

FOR ALL ENTRIES, and BSEG table,select the relevant entries from BSEG table.

Performance wise, this will be very fast.

2)you can't directly join on BSEG but depending on which data you want to access you might be able to use an alternative table. eg, BSID or BSAD for open or cleared customer items or BSIK/BSAK for open or cleared vendor items.

Read only

0 Likes
764

hello sir

select <FIELDS> from BSAK into table IT_BSAK.

if not it_bsak[] is initial.

select <FIELDS> from BSEG

for all entries in IT_BSAK

into table IT_BSEG

where BELNR = IT_BSAK-BELNR. " Match the common fields together

endif.

in this code, what purpose of if command...plz say detail

regard

mukesh

Read only

Former Member
0 Likes
765

if u r doin sumthin like fb60 then...

use this.....

<b>TABLES: bsik, bsak, bseg.

SELECT-OPTIONS: s_bukrs FOR bsik-bukrs OBLIGATORY,

s_lifnr FOR bsik-lifnr OBLIGATORY.

DATA: BEGIN OF bsik_int OCCURS 0.

INCLUDE STRUCTURE bsik.

DATA: END OF bsik_int.

DATA: BEGIN OF bseg_int OCCURS 0.

INCLUDE STRUCTURE bseg.

DATA: END OF bseg_int.

SELECT * FROM bsik

INTO TABLE bsik_int

WHERE bukrs IN s_bukrs

AND lifnr IN s_lifnr.

SELECT * FROM bsak

APPENDING TABLE bsik_int

WHERE bukrs IN s_bukrs

AND lifnr IN s_lifnr.

SELECT * FROM bseg

INTO TABLE bseg_int

FOR ALL ENTRIES IN bsik_int

WHERE bukrs = bsik_int-bukrs

AND belnr = bsik_int-belnr

AND gjahr = bsik_int-gjahr

AND ebeln = space.</b>

Read only

Former Member
0 Likes
764

thanks a lot for your Rewards!!!