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

About inner join problem

Former Member
0 Likes
1,601

Hi Friends,

I have given the innerjoin between BKPF & BSEG tables,

And i am fetching BUKRS, BELNR,GJAHR, BLART,BLDAT,BUDAT fields from BKPF and BUZEi from BSEG table, but it is showing error as u cannot create inner join for BSEG table,

Kindly help me on this .

Thanks & Regards,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,366

This message was moderated.

10 REPLIES 10
Read only

Former Member
0 Likes
1,366

Hi,

Yes. JOINS are not allowed in Cluster tables.

Fetch the values separately.

Cheers

Kothand

Read only

Former Member
0 Likes
1,367

This message was moderated.

Read only

Former Member
0 Likes
1,366

Hi Ravi C,

Tyr it like the below example and rewards point if useful to u.

select belnr gjahr bukrs blart bldat budat from bkpf into table itab_bkpf where budat in p_date and bukrs in p_bukrs.

if not itab_bkpf[] is initial.

select belnr buzei from bseg into table itab_bseg for all entries in itab_bkpf where belnr eq itab_bkpf-belnr and gjahr eq itab_bkpf-gjahr.

endif.

Note: using bseg table may affect in performance.

regards

sankar.

Read only

0 Likes
1,366

Hi,

I using the code like this,

It displaying the output without displaying any data in BUZEI field, Even i have given the field name in the field catalog.

Could u plz help me on this,

Waiting for ur reply.

TYPES : BEGIN OF T_BKPF,

BUKRS TYPE BKPF-BUKRS,

BELNR TYPE BKPF-BELNR,

GJAHR TYPE BKPF-GJAHR,

BLART TYPE BKPF-BLART,

BLDAT TYPE BKPF-BLDAT,

BUDAT TYPE BKPF-BUDAT,

BUZEI TYPE BSEG-BUZEI,

END OF T_BKPF.

types: begin of t_bseg,

BUKRS TYPE BSEG-BUKRS,

BELNR TYPE BSEG-BELNR,

GJAHR TYPE BSEG-GJAHR,

end of t_bseg.

DATA : it_bkpf TYPE STANDARD TABLE OF t_bkpf with header line,

  • wa_bkpf TYPE t_bkpf,

it_bseg type standard table of t_bseg.

  • wa_bseg type t_bseg.

select bukrs belnr gjahr from bseg into table it_bseg.

perform data_retrieval_bseg.

perform data_retrieval.

form data_retrieval_bseg .

select buzei from bseg into table it_bkpf.

endform. " data_retrieval_bseg

&----


*& Form DATA_RETRIEVAL

&----


form data_retrieval.

IF it_bseg[] IS NOT INITIAL.

select bukrs belnr gjahr blart bldat budat from bkpf into

table it_bkpf for all entries in it_bseg

where bukrs = it_bseg-bukrs

and belnr = it_bseg-belnr

and gjahr = it_bseg-gjahr.

endif.

endform.

Read only

0 Likes
1,366

Hi Ravi,

the mistake which was done by you that, in recent version of SAP, BUZEI field is not available in the table BKPF. it is available

from the table BSEG. So, try to fetch BUZEI from BSEG, not from BKPF.

hopefully this will help you to solve you to solve the issue. another thing, try to write the codes as per the event firing.

<points begging removed by moderator>

Regards

Mrinmoy

Edited by: Thomas Zloch on Jun 15, 2011 1:30 PM

Read only

0 Likes
1,366

Hi,

Why ur wirting one more select query for getting BUZEI from BSEG table. right the code like below


TYPES : BEGIN OF T_BKPF,
BUKRS TYPE BKPF-BUKRS,
BELNR TYPE BKPF-BELNR,
GJAHR TYPE BKPF-GJAHR,
BLART TYPE BKPF-BLART,
BLDAT TYPE BKPF-BLDAT,
BUDAT TYPE BKPF-BUDAT,
*BUZEI TYPE BSEG-BUZEI,"comment the BUZEI here
END OF T_BKPF.

types: begin of t_bseg,
BUKRS TYPE BSEG-BUKRS,
BELNR TYPE BSEG-BELNR,
GJAHR TYPE BSEG-GJAHR,
BUZEI TYPE BSEG-BUZEI," add the field here
end of t_bseg.

DATA : it_bkpf TYPE STANDARD TABLE OF t_bkpf with header line,
* wa_bkpf TYPE t_bkpf,
it_bseg type standard table of t_bseg.
* wa_bseg type t_bseg.

select bukrs belnr gjahr BUZEI "add the BUZEI here
     from bseg into table it_bseg.

*perform data_retrieval_bseg."comment the perform
perform data_retrieval.

*form data_retrieval_bseg .
*select buzei from bseg into table it_bkpf."no need to call one more select query
*endform. " data_retrieval_bseg

form data_retrieval.

IF it_bseg[] IS NOT INITIAL.
select bukrs belnr gjahr blart bldat budat from bkpf into
table it_bkpf for all entries in it_bseg
where bukrs = it_bseg-bukrs
and belnr = it_bseg-belnr
and gjahr = it_bseg-gjahr.
endif.
endform.

Regards,

Dhina..

Read only

0 Likes
1,366

Check the date of the OP before anyone else jumps in

Rob

Read only

Former Member
0 Likes
1,366

Hi,

Being BSEG a Cluster Table, so you cannot write the JOINS on it, instead of this get BKPF details and fetch the relavent details from the BSEG.

Read only

Former Member
0 Likes
1,366

hello,

as BSEG is a cluster table u cannot use join for it , it also affects the performance.

do like this as BSEG data is segregrated to different tables based on customer , vendor and GL.

for customer use tables BSID, BSAD

for vendor use tables BSIK,BSAK

for GL use tables BSIS, BSAS.

Based on ur requirement see from which table u can get that data. and use Join for BKPF and corresponding table.

Rgds.,

subash

Read only

0 Likes
1,366

Hi,

And i am fetching BUKRS, BELNR,GJAHR, BLART,BLDAT,BUDAT fields from BKPF and BUZEi from BSEG

exactly what they said before. BSEG is the cluster table we cant use JOINS condition when we are fetching the data from cluster table and transparent tables. on that situation we have to use FOR ALL ENTRIES performance wise which is best one

just try this code.

select bukrs belnr gjahr blart bldat budat

into table i_bkpf

from bkpf

where <condition>.

if not i_bkpf[] is initial.

select buzei

into table i_bseg

from bseg for all entries in i_bkpf

where bukrs = i_bkpf-bukrs

and belnr = i_bkpf-belnr

and gjahr = i_bkpf-gjahr..

endif.

regards.

sriram.