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

Outer Join

Former Member
0 Likes
1,226

Hi all

i have two tables BSEG and SKAT.

For a company code(BUKRS) i need to select Account number (HKONT) from BSEG table and after that for that particular (Account number) HKONT i need to select the TXT50 from SKAT table.BUt i couldnt see any common fields in BSEG and SKAT and i tried using outer join which i was not successful.Please provide me the particular piece of code where i can retrieve the data.If its about outer join please provide me the code for the above condition.Am also mention the structure below.

DATA:BEGIN OF ty_hkont occurs 0,

HKONT TYPE BSEG-HKONT,

SAKNR TYPE SKAT-SAKNR,

TXT50 TYPE SKAT-TXT50,

END OF ty_hkont.

With Regards

Vijay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,018

i think u need to find dependent tables for both of them

7 REPLIES 7
Read only

Former Member
0 Likes
1,019

i think u need to find dependent tables for both of them

Read only

0 Likes
1,018

hi

can u name any dependent.because when i used the outer join i got BSEG not a clustered table.Please help

vijay

Read only

former_member386202
Active Contributor
0 Likes
1,018

Hi,

U cant use joins on cluster table and BSEG is a cluster table . SO use FOR ALL ENTRIES for that

&----


*& Form sub_read_bseg

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM sub_read_bseg.

IF NOT it_bsak[] IS INITIAL.

*--Select data from BSEG table

SELECT belnr

gjahr

shkzg

kostl

hkont

ebeln

ebelp

FROM bseg

INTO CORRESPONDING FIELDS OF TABLE it_bseg

FOR ALL ENTRIES IN it_bsak

WHERE belnr EQ it_bsak-belnr

AND gjahr EQ it_bsak-gjahr

AND shkzg EQ 'S'.

IF sy-subrc EQ 0.

*--Sort table by accounting document

SORT it_bseg BY belnr.

ENDIF.

ENDIF.

ENDFORM. " sub_read_bseg

Regards,

prashant

Read only

0 Likes
1,018

hi prahsant

that was good but what about the data that is to be selected from SKAT table.

With Regards

Vijay

Read only

Former Member
0 Likes
1,018

Hi Vijay,

Try this code.

Select hkont

from bseg

into ty-hkont-hkont

where <companycodefieldname> eq 'BUKRS'.

select single txt50

from skat

into ty-hkont-txt50

where hkont eq ty-hkont-hkont.

append ty-hkont.

endselect.

endselect.

Plz Reward if useful,

Mahi.

Read only

Former Member
0 Likes
1,018

Hi,

I think you can use two select statements instead of joins.Joins always lower the performance of your code. It makes your code look simple and the performance also would be good.

Read only

Former Member
0 Likes
1,018

Well you can find SAKNR in BSEG which is there in SKAT table also ...so you can use join and get the result you want

Prince