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

how do i join 3 table with the 'join' query ?

Former Member
0 Likes
649

Hello,

i want to join 3 tables -> bsis, bsad and vbrp

the components of the query to be are ,

- select (matnr from vbrp) sum(amount from bsad).

- join bsis and bsad on bsisbukrs = bsadbukrs, bsisbelnr = bsadaugbl and bsisbldat = bsadaugdt.

- where bsisblart = 'DZ' and bsishkont = '123456'.

- join bsad and vbrp on vbrpburks = bsadbukrs, vbrpgjahr = bsadgjahr and vbrpbelnr = bsadbelnr.

The double join query is to be constructed out of the above components.

Thanks,

Shehryar Dahar

6 REPLIES 6
Read only

andreas_mann3
Active Contributor
0 Likes
584

Hi,

you cannot join bsid and bsad

they are mutually exclusive:

bsid = open items

bsad = cleared items

so you can only join the tables on the factura (vbeln)

A.

Message was edited by:

Andreas Mann

Read only

0 Likes
584

Hi Andreas,

Its BSIS, not BSID .

Regards,

Shehryar Dahar

Read only

0 Likes
584

sorry,

so I'd do the foll.:

1) select bsis into itab

2) loop itab

and select bseg with bukrs belnr gjahr and koart 'D' and augbl <> space

and vbrp with vbeln

A.

Read only

Former Member
0 Likes
584

Hello again,

ANybody ?

Regards,

Shehryar Dahar

Read only

Former Member
0 Likes
584

Hi

Try this example with your tables...



select aufk~aufnr afko~rsnum afih~revnr 
       from aufk
            inner join afko
               on aufk~aufnr = afko~aufnr
            inner join afih
               on aufk~aufnr = afih~aufnr into
             corresponding fields of table itab.

Pls reward points if it helps....

Kaki Ravindra

Read only

Former Member
0 Likes
584

c an example....

DATA: BEGIN OF wa,

carrid TYPE spfli-carrid,

connid TYPE spfli-connid,

fldate TYPE sflight-fldate,

bookid TYPE sbook-bookid,

END OF wa,

itab LIKE SORTED TABLE OF wa

WITH UNIQUE KEY carrid connid fldate bookid.

SELECT pcarrid pconnid ffldate bbookid

INTO CORRESPONDING FIELDS OF TABLE itab

FROM ( ( spfli AS p

INNER JOIN sflight AS f ON pcarrid = fcarrid AND

pconnid = fconnid )

INNER JOIN sbook AS b ON bcarrid = fcarrid AND

bconnid = fconnid AND

bfldate = ffldate )

WHERE p~cityfrom = 'FRANKFURT' AND

p~cityto = 'NEW YORK' AND

fseatsmax > fseatsocc.

LOOP AT itab INTO wa.

AT NEW fldate.

WRITE: / wa-carrid, wa-connid, wa-fldate.

ENDAT.

WRITE / wa-bookid.

ENDLOOP.

Ramesh.