Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Left Outer Join

Hi All,

I have a program where in I have to join six tables one of which is a Left Outer Join. Now I have to change that using For All Entries...

Please let me know how to split this Left Outer Join using For All Entries.

Or Is there any other way of doing it? ie., Can I write a Select stmt using Left Outer join and for all entries?

Thanks in adavance for your efforts!!

Regards.

Adapala M.

Tags:
Former Member
Former Member replied

Hi,

Of course, yuou can use JOIN and FOR ALL ENTRIES in single statement.

Following is an example:

  SELECT ek~ebeln
         ep~ebelp
         ek~lifnr
         ek~ekorg
         ek~angnr
         ek~yy28mmjv
         ep~matnr
         ep~werks
 INTO TABLE g_t_ekko_ekpo
 FROM ekko AS ek INNER JOIN ekpo AS ep
   ON ek~ebeln  = ep~ebeln
 WHERE ek~loekz = space
   AND ek~ekorg = p_ekorg
   AND ek~angnr IN so_angnr
   AND ( ( ek~bstyp = 'A' )
    OR (   ek~bstyp = 'K' AND ek~yy28marbeitsver = g_c_x )
       )
   AND ep~loekz = space.

  IF NOT g_t_ekko_ekpo[] IS INITIAL.
    SELECT hdr~matnr
           hdr~werks
           hdr~jahr
           hdr~ekorg
           pos~lifnr
           hdr~yy28m_phek_m
           hdr~yy28m_phek_mpe
           hdr~yy28m_phek_mwaer
           hdr~yy28m_maprs
           hdr~yy28m_maprs_pe
           hdr~yy28m_ergwaer
           hdr~yy28m_zprs_m
           hdr~yy28m_zprs_mpe
           hdr~yy28m_zprs_mwaer
           hdr~yy28m_mviprs
           hdr~yy28m_mviprs_pe
      INTO TABLE g_t_hdr_pos
      FROM y28m_basmat_hdr AS hdr INNER JOIN y28m_basmat_pos AS pos
        ON hdr~matnr =  pos~matnr
       AND hdr~werks =  pos~werks
       AND hdr~jahr  =  pos~jahr
       AND hdr~ekorg =  pos~ekorg
     FOR ALL ENTRIES IN g_t_ekko_ekpo
     WHERE hdr~ekorg =  p_ekorg
       AND hdr~matnr =  g_t_ekko_ekpo-matnr
       AND hdr~werks IN so_werks
       AND hdr~jahr BETWEEN l_f_sjahr AND l_f_ejahr.
  ENDIF.

Regards,

Karuna.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question