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

select with join

Former Member
0 Likes
723

hello abapers,

below is my scenario,

Extract each entry from DBtab1 for FLD1 in DBtab2-FLD1, and FLD2 in DBtab3-FLD2

sum(FLD3) by FLD2 into

internal tab ITAB (fields FLD2, FLD3).

i thought something like this;

select FLD1 FLD2 sum( FLD3) into ITAB from DBtab1 where FLD1 = DBtab2-FLD1 and FLD2 = DBtab3-FLD2

GROUP by FLD2.

i know this doesnot work, because fld1 should check each and every entry in DBtab2 and same is the case with DBtab3,

i should be using inner or outer join, can some one help.

thank you.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
700

If you want to have SAP write the code for you use the quick viewer to build a join and generate the code.

Run the quuey. Do a system > statuson the result and lift the code.

Quick viewer is either System >services >quick viewer or systemt >quick viewer can't remember which from the session manager transaction.

Also to view the documentation in the abap editor type the word join and hit F1.

5 REPLIES 5
Read only

Former Member
0 Likes
700

Hi saritha,

Either use inner join, or get the data into the internal tables by using FOR ALL ENTRIES.

Regards,

Atish

Read only

Former Member
0 Likes
701

If you want to have SAP write the code for you use the quick viewer to build a join and generate the code.

Run the quuey. Do a system > statuson the result and lift the code.

Quick viewer is either System >services >quick viewer or systemt >quick viewer can't remember which from the session manager transaction.

Also to view the documentation in the abap editor type the word join and hit F1.

Read only

Former Member
0 Likes
700

See the example code :

select matnr shkzg meins sum( fklmg )

into table i_billed

from ( vbrk as k INNER JOIN vbrp as p on kvbeln = pvbeln )

where ( vbtyp = 'M' or "invoice

vbtyp = 'N' ) and "invoice cancellation

k~fkdat in so_vdatu and

matnr in so_matnr and

p~werks = p_werks

group by matnr shkzg meins.

Read only

Former Member
0 Likes
700

Hi,

Its better if u use Inner Join or For All entries.......to join the tables.....

with regards,

madhuri.

Read only

Former Member
0 Likes
700

Hi,

Its better if u use Inner Join or For All entries.......to join the tables.....

with regards,

madhuri.