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: 

JOIN Statement alternatives

Former Member
0 Kudos
149

Hi folks, I have a problem with a join statement.basically i am trying to read GL Document data.I have the statement below but when it searches in table PPOIX it only retrieves the first match it finds based on pp0ix-runid = ppdix-runid and pp0ix-tslin = ppdix-linum.What i want to do is get all tslin for each linum found in ppdix. if i leave out pp0ix-tslin = ppdix-linum then i will get every line per runid but i just want lines that are found in ppdix.

SELECT DISTINCT ppdit~hkont

ppdit~kostl

ppoix~pernr

ppoix~betrg

ppoix~waers

INTO TABLE gt_gl_lines

FROM ppdit

JOIN ppdix ON ppdixdocnum = ppditdocnum

AND ppdixdoclin = ppditdoclin

JOIN ppoix ON ppoixrunid = ppdixrunid

AND ppoixtslin = ppdixlinum

WHERE ppdix~runid = gs_gl_docs-runid

AND ppdit~docnum = gs_gl_docs-docnum

AND ppdit~kostl = l_kostl_new.

Edited by: Damien Kesle on Dec 21, 2007 12:21 PM

1 ACCEPTED SOLUTION

Former Member
0 Kudos
58

Did you try by removing DISTINCT key word from your select statment????

2 REPLIES 2

Former Member
0 Kudos
59

Did you try by removing DISTINCT key word from your select statment????

Former Member
0 Kudos
58

Hi

The addition DISTINCT forces a sort on the database server.You should therefore only use it if you are really expecting duplicatesin the result set.

Regards,

Mohan.