Application Development 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: 

Select statement

Former Member
0 Kudos

Hi All,

I am reading data from seven tables and here is my select statement but it returns 4 instead. When i take report to QEC it doesn't execute certain material, please help me out.

SELECT maramatnr maraernam maraaenam maramtart maraersda maralaeda

maravpsta marapstat maralvorm marazzltxt marameins maramatkl

marabismt maraextwg maraspart maralabor maramstae maranormt

marawrkst maraekwsl maramprof marastoff marckordb marcwebaz

marckzkri marckautb marcdispr marcdispo marcdismm marcdisls

marcmabst marcminbe marcwerks marcekgrp marcmmsta marcplifz

marcfhori marcsobsl marcmtvfp marcmaabc marcprctr marceprio

marcsernp mardlabst mardlgpbe mardlgort marambrsh mdmaberid

mdmalagpr mdmaplifzx mbewbwtty mbewbklas mbewvprsv mbewverpr

mbewpeinh mbewstprs mbewbwtar maktmaktx s032mbwbest s032wbwbest

FROM mara JOIN mard ON maramatnr = mardmatnr

JOIN marc ON mardmatnr = marcmatnr

JOIN mdma ON maramatnr = mdmamatnr

JOIN mbew ON maramatnr = mbewmatnr

JOIN makt ON maramatnr = maktmatnr

JOIN s032 ON marcwerks = s032werks

INTO CORRESPONDING FIELDS OF TABLE i_tab

WHERE mara~ernam IN s_ernam

AND mara~ersda IN s_ersda

AND mara~aenam IN s_aenam

AND mara~laeda IN s_laeda

AND mara~matnr IN s_matnr

AND marc~werks IN s_werks

AND mard~lgort IN s_lgort

AND mara~mtart IN s_mtart

AND mara~lvorm IN s_lvorm

AND mbew~bklas IN s_bklas

AND mdma~lagpr IN s_lagpr

AND mara~wrkst IN s_wrkst.

SORT i_tab BY matnr.

DELETE ADJACENT DUPLICATES FROM i_tab COMPARING matnr.

Regards,

Fred

8 REPLIES 8

former_member181995
Active Contributor
0 Kudos

Fantastic

0 Kudos

But it doesn't give me the results i want...

Former Member
0 Kudos

hi

you shouldn't use join for more than 3 tables...

instead use FOR ALL ENTRIES

0 Kudos

You mean the whole select statement is correct i should only include for all entries, it not please sent me sample code...

Former Member
0 Kudos

Fred

When you use Inner Join between the tables.... all tables should have corresponding foreign key entries as per the Join.. If any one of those tables doesn't have the entry, it will exclude the record...

I would suggest to go for Left outer join... and you may filter the data further as per the requirement..

Thanks

Amol Lohade

0 Kudos

If you can send me the code as im not familiar with left outer join.

Former Member
0 Kudos

hi

instead try doing by creating views for this

and use it directly in programs

with regards

s.janagar

0 Kudos

I only use view to check the relationship between the tables, i do not know much about views, please help me with the views.