‎2007 Dec 12 5:08 AM
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
‎2007 Dec 12 5:15 AM
‎2007 Dec 12 5:15 AM
‎2007 Dec 12 5:16 AM
hi
can u name any dependent.because when i used the outer join i got BSEG not a clustered table.Please help
vijay
‎2007 Dec 12 5:19 AM
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
‎2007 Dec 12 5:21 AM
hi prahsant
that was good but what about the data that is to be selected from SKAT table.
With Regards
Vijay
‎2007 Dec 12 5:20 AM
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.
‎2007 Dec 12 5:23 AM
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.
‎2007 Dec 12 5:24 AM
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