Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9193

Re: Joining three tables with inner join and for all entries

$
0
0

Hi,

 

It is better way to do it in a single select instead of doing one more select and loop.

 

try this way and it should work

 

Maktx should be declared  in your sales internal table

 

IF s_ernam is INITIAL.

    SELECT K~auart K~ernam K~erdat K~vbeln P~pstyv P~posnr P~matnr P~zmeng P~zieme    D~maktx

    FROM vbak AS K INNER JOIN vbap as P on K~vbeln = P~vbeln

    INNER JOIN makt as D  on d~matnr = p~matnr and

                                                  spras = sy-langu.

   

    INTO TABLE sales

    WHERE K~auart in s_auart

    and K~erdat in s_erdat

    and P~pstyv in s_pstyv.

   ELSE.

     SELECT K~auart K~ernam K~erdat K~vbeln P~pstyv P~posnr P~matnr P~zmeng P~zieme

D~maktx

     FROM vbak AS K INNER JOIN vbap as P on K~vbeln = P~vbeln

    INNER JOIN makt as D  on d~matnr = p~matnr and

                                                  spras = sy-langu.

     INTO TABLE sales

     WHERE K~auart in s_auart

     and K~erdat in s_erdat

     and P~pstyv in s_pstyv

     and K~ernam = s_ernam.

   ENDIF

 


Viewing all articles
Browse latest Browse all 9193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>