Inner join example in SAP-ABAP

Go down

Inner join example in SAP-ABAP

Post  Admin on Wed Mar 14, 2012 1:05 am

Code:
*&---------------------------------------------------------------------*
*& Report  ZSU_INNERJOIN_FOR3
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZSU_INNERJOIN_FOR3.

tables :mara,marc,mard.
types  :begin of t_mar,
        matnr type matnr,
        mbrsh type mbrsh,
        mtart type mtart,
        werks type werks_d,
        pstat type pstat_d,
        lgort type lgort_d,
        end of t_mar.
 types :tt_mar type standard table of t_mar.
 data  :lw_mar type t_mar,
        lt_mar type tt_mar.
 select-options : s_matnr for mara-matnr.
*---------inner ioin to fetch data from mara,marc,mard-----------
select mara~matnr
      mara~mbrsh
      mara~mtart
      marc~werks
      marc~pstat
      mard~lgort
      into table lt_mar
      from mara inner join marc on mara~matnr = marc~matnr
                inner join mard on  marc~matnr = mard~matnr
      where mara~matnr in s_matnr.

  if sy-subrc = 0.
  loop at lt_mar into lw_mar.
  write :/ lw_mar-matnr,
          lw_mar-mbrsh,
          lw_mar-mtart,
          lw_mar-werks,
          lw_mar-pstat,
          lw_mar-lgort.

  endloop.
  else.
  write :/ 'invalid data entered'.
  endif.

Admin
Admin

Posts : 92
Join date : 2012-01-26

http://mysaplab.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum