Saturday 4 May 2024

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

 Program: 


REPORT ZSM_INNERJOIN6.

'Creation of structure'


typesBEGIN OF str,
  vbeln type vbeln,
  erdat TYPE erdat,
  matwa TYPE matwa,
  pmatn TYPE pmatn,
  END OF str.

  datait 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-vbelnwa-erdatwa-matwawa-pmatn.    'Output'
        ENDLOOP.
        ENDIF.



Output: 


                   


                 


No comments:

Post a Comment