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

report -without inner join

Former Member
0 Likes
672

hi,

this is report i created in this i used two tables and used inner join to make relation b/t these tables...

so my doubt is ..if we r using three diff.. tables without inner join we can do this report ......if u can.. plz can u show me wit example...

TABLES: VBAP,VBAK.

DATA : BEGIN OF ITAB OCCURS 0,

vbeln like VBAK-VBELN, "Sales Document No.

kunnr like VBAK-KUNNR,"customerno

VKORG like VBAK-VKORG,"salesorg

audat like VBAK-AUDAT,"documentdate

matnr like VBAP-MATNR,"materialno

netwr like VBAK-NETWR,"netamount

end of itab.

selection-screen : begin of block a1. "SCREEN 500 AS WINDOW..

select-options : KUNNR for VBAK-kunnr.

select-options : VKORG FOR VBAK-vkorg.

select-options : AUDAT for VBAK-audat.

select-options : MATNR for VBAP-matnr.

select-options : NETWR FOR VBAK-netwr.

SELECTION-SCREEN :end of block a1.

SELECT vbakvbeln vbakkunnr vbakvkorg vbakaudat vbapmatnr vbaknetwr into table itab from vbak

INNER JOIN vbap on vbakvbeln = vbapvbeln

where

VBAK~kunnr in kunnr

AND

VBAK~VKORG in VKORG

and vbak~audat in audat

AND vbap~matnr in matnr.

write sy-dbcnt.

write:/ 'CUSTOMERNO' ,20 'SALESORG',40 'DOCUMENTDATE',60 'MATERIAL',80 'NETAMOUNT'.

ULINE.

loop at itab.

write 😕 itab-kunnr,20 itab-vkorg, 40 itab-audat, 60 itab-matnr, 80 itab-netwr.

endloop.

thanx

bhanu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
649

Hi Bhanu,

Use for all entries in this way.

DATA:

t_mara LIKE STANDARD TABLE OF fs_material,

t_marc LIKE STANDARD TABLE OF fs_material1.

SELECT matnr

mtart

INTO CORRESPONDING FIELDS OF TABLE t_mara

FROM mara

WHERE mtart = p_mtart .

SELECT matnr

werks

FROM marc

INTO TABLE t_marc FOR ALL ENTRIES

IN t_mara

WHERE matnr = t_mara-matnr.

This is for 2 table.Use the same logic for 3 table.Take another internal table and do it in the same way.

Much Regards,

Amuktha.

5 REPLIES 5
Read only

Former Member
0 Likes
649

yes, you can have 3 tables in inner join, otherwise you can go for For all entires clause and go for indiviudal table selects.

combine them at the end.

Read only

Former Member
0 Likes
650

Hi Bhanu,

Use for all entries in this way.

DATA:

t_mara LIKE STANDARD TABLE OF fs_material,

t_marc LIKE STANDARD TABLE OF fs_material1.

SELECT matnr

mtart

INTO CORRESPONDING FIELDS OF TABLE t_mara

FROM mara

WHERE mtart = p_mtart .

SELECT matnr

werks

FROM marc

INTO TABLE t_marc FOR ALL ENTRIES

IN t_mara

WHERE matnr = t_mara-matnr.

This is for 2 table.Use the same logic for 3 table.Take another internal table and do it in the same way.

Much Regards,

Amuktha.

Read only

viquar_iqbal
Active Contributor
0 Likes
649

HI

we can use FOR ALL ENTRIES IN

first we get the data into a table itab .

Read only

former_member156446
Active Contributor
0 Likes
649

Refer to this psuedo code

SELECT vbak~vbeln vbak~kunnr vbak~vkorg vbak~audat vbap~matnr vbak~netwr into table itab from vbak
INNER JOIN vbap on vbak~vbeln = vbap~vbeln
where
VBAK~kunnr in kunnr
AND
VBAK~VKORG in VKORG
and vbak~audat in audat
AND vbap~matnr in matnr.

SELECT vbak~vbeln vbak~kunnr vbak~vkorg vbak~audat vbak~netwr vbak~matnr
             into table itab
from vbak
where kunnr in kunnr....


select vbeln matnr 
      into table itab2
from vbap 
for all entries in itab
where vbap~matnr = itab~matnr....

loop at itab assigning <fs_itab>.
 read table itab2 into wa_itab2 with key vbeln = <fs_itab>-vbeln
                                                         matnr = <fs_itab>-matnr.

" your move's to final table
endloop.

Read only

Former Member
0 Likes
649

Hi Bhanu,

Lets assume itab1, itab2 and itab3 are int tables with x,y and z fields. ANd z1, z2 and z3 are databse tables.

Here is the code:


select x y z from z1 into table itab1

IF not itab1 not initial.
select x y z from z2 into table itab2
 for all entries in itab1
  where x = itab1-x.
ENDIF.

IF not itab1 not initial.
select x y z from z3 into table itab3
 for all entries in itab2
  where x = itab2-x.
ENDIF.

Regards,

Sachin