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

Help with a join

Former Member
0 Likes
827

I have the following code and it is giving me a syntax error. I originally had it as a single join (I didn't have coep in it) and it worked. This tells me that the issue is with the second join (coep). I have no idea what it could be.

  SELECT a~bukrs a~budat a~blart a~belnr a~xblnr b~zuonr b~wrbtr b~hkont b~bseg c~gkont
    INTO CORRESPONDING FIELDS OF TABLE it_working FROM 
    ( ( bkpf AS a INNER JOIN bseg AS b ON
      a~bukrs = b~bukrs AND
      a~belnr = b~belnr AND
      a~gjahr = b~gjahr ) INNER JOIN coep as c on 
      b~kokrs = c~kokrs AND
      b~belnr = c~belnr AND
      b~buzei = c~buzei ) WHERE
      a~bukrs = p_bukrs AND
      a~budat IN s_budat AND
      b~zuonr IN s_zuonr AND
      b~kunnr IN s_kunnr AND
      c~kgont = p_gkont.

Do you have any (easy) ideas to get around this?

Regards,

Davis

This is the syntax error:

For pooled tables, cluster tables and projection views, JOIN is not allowed: 'BSEG'

Edited by: Davis on Jul 7, 2008 10:18 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
755

OK, I thought that it would accept a join between bkpf and bseg but in fact it doesn't Am I doing something wrong?

I am now trying:

  SELECT a~bukrs a~budat a~blart a~belnr a~xblnr b~zuonr b~wrbtr b~hkont b~bseg
    INTO CORRESPONDING FIELDS OF TABLE it_working FROM
      bkpf AS a INNER JOIN bseg AS b ON
      a~bukrs = b~bukrs AND
      a~belnr = b~belnr AND
      a~gjahr = b~gjahr WHERE
      a~bukrs = p_bukrs AND
      a~budat IN s_budat AND
      b~zuonr IN s_zuonr AND
      b~kunnr IN s_kunnr.

Regards,

Davis

5 REPLIES 5
Read only

peter_ruiz2
Active Contributor
0 Likes
755

hi davis,

There is no KGONT field in COEP. You might be referring to GKONT.

SELECT abukrs abudat ablart abelnr axblnr bzuonr bwrbtr bhkont bbseg cgkont

INTO CORRESPONDING FIELDS OF TABLE it_working FROM

( ( bkpf AS a INNER JOIN bseg AS b ON

abukrs = bbukrs AND

abelnr = bbelnr AND

agjahr = bgjahr ) INNER JOIN coep as c on

bkokrs = ckokrs AND

bbelnr = cbelnr AND

bbuzei = cbuzei ) WHERE

a~bukrs = p_bukrs AND

a~budat IN s_budat AND

b~zuonr IN s_zuonr AND

b~kunnr IN s_kunnr AND

c~kgont = p_gkont.

regards,

Peter

Read only

0 Likes
755

Peter,

Thanks for pointing that out; I didn't catch it. However, the issue is on the join of BSEG and COEP.

Regards,

Davis

Read only

Former Member
0 Likes
756

OK, I thought that it would accept a join between bkpf and bseg but in fact it doesn't Am I doing something wrong?

I am now trying:

  SELECT a~bukrs a~budat a~blart a~belnr a~xblnr b~zuonr b~wrbtr b~hkont b~bseg
    INTO CORRESPONDING FIELDS OF TABLE it_working FROM
      bkpf AS a INNER JOIN bseg AS b ON
      a~bukrs = b~bukrs AND
      a~belnr = b~belnr AND
      a~gjahr = b~gjahr WHERE
      a~bukrs = p_bukrs AND
      a~budat IN s_budat AND
      b~zuonr IN s_zuonr AND
      b~kunnr IN s_kunnr.

Regards,

Davis

Read only

0 Likes
755

Hi Davis,

You will not be able to use BSEG in a join statement with BKPF for it is a clustered table and BKPF is a transparent table. I suggest you use two SELECT statements for each table or use other tables aside from BSEG. take a look at BSIS, BSAS, BSIK, BSAK, BSID, and BSAD.

regards,

Peter

Read only

Former Member
0 Likes
755

Thanks. I assumed that would be the answer so I went ahead and coded it with three select statements (BKPF leading them) with two being inside their own loop. I then go through the table and use delete statements to get rid of the unwanted records. That isn't the best as far as performance goes but I will see how it works (performance wise) and, if need be, I'll look at other tables.

Regards,

Davis