SAP program to innerjoin only four fields from VBAK and VBAP standard tables

 Program: 


REPORT ZSM_INNERJOIN6.

'Creation of structure'


types: BEGIN OF str,
  vbeln type vbeln,
  erdat TYPE erdat,
  matwa TYPE matwa,
  pmatn TYPE pmatn,
  END OF str.

  data: it TYPE standard table of str,   
        wa TYPE str.                    'Creation of internal table and work area'

  SELECT vbak~vbeln
         vbak~erdat

         vbap~matwa      'Query to inner join'
         vbap~pmatn

    FROM vbak INNER JOIN vbap ON vbak~vbeln = vbap~vbeln INTO TABLE it.

    if sy-subrc = 0.     'to check if the select query is correct'
      LOOP at it INTO wa.
        WRITE:/ wa-vbeln, wa-erdat, wa-matwa, wa-pmatn.    'Output'
        ENDLOOP.
        ENDIF.



Output: 


                   


                 


Post a Comment

0 Comments