2007 Jun 20 4:34 PM
Can get a example of inner joining 3 tables..
2007 Jun 20 4:38 PM
see the example program :
REPORT ZTEST3 line-size 400.
TABLES: EKKO, LFA1, MAKT, EKET, EKPO, cdhdr.
*Data Declaration
*----
TYPES: BEGIN OF FINAL,
ebeln type ekko-ebeln,
BEDAT type ekko-bedat,
lifnr type ekko-lifnr,
ernam type ekko-ernam,
name1 type lfa1-name1,
matnr type ekpo-matnr,
eindt type eket-eindt,
MAKTX type MAKT-MAKTX,
MBLNR type MSEG-MBLNR,
eldat type eket-eldat,
end of FINAL.
DATA: ITAB TYPE STANDARD TABLE OF FINAL INITIAL SIZE 10 WITH HEADER LINE.
all ALV declarations
*----
type-pools: slis. "ALV Declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv with header line,
G_REPID TYPE SY-REPID,
GS_PRINT TYPE SLIS_PRINT_ALV,
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
GT_EVENTS TYPE SLIS_T_EVENT,
GT_SORT TYPE SLIS_T_SORTINFO_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
COL_POS TYPE I.
*----
-----------------SELECTION SCREEN----------------------
selection-screen begin of block b1 with frame title text-001.
select-options podate for EKKO-bedat.
selection-screen end of block b1.
*----
*................... GET DATA..................
SELECT EKKO~EBELN
EKKO~BEDAT
EKKO~LIFNR
EKKO~ERNAM
LFA1~NAME1
MAKT~MATNR
EKET~EINDT
MAKT~MAKTX
MSEG~MBLNR
eket~eldat
INTO CORRESPONDING FIELDS OF ITAB
FROM
( EKKO INNER JOIN LFA1
ON EKKO~LIFNR = LFA1~LIFNR
INNER JOIN MSEG
ON EKKO~EBELN = MSEG~EBELN
INNER JOIN MKPF
ON MSEG~MBLNR = MKPF~MBLNR
INNER JOIN EKPO
ON EKKO~EBELN = EKPO~EBELN
INNER JOIN MAKT
ON EKPO~MATNR = MAKT~MATNR
INNER JOIN EKET
ON EKKO~EBELN = EKET~EBELN
)
WHERE EKKO~BEDAT IN PODATE .
APPEND ITAB. CLEAR ITAB.
ENDSELECT.
*
*LOOP AT ITAB.
at first.
write: / 'VENDOR NO' color 6 INVERSE,' VENDOR NAME' COLOR 6
*INVERSE,48'MATERIAL NO' COLOR 6 INVERSE,67'MATERIAL DESCRIPTION' COLOR 6 INVERSE,108'PO.NUMBER' COLOR 6 INVERSE,119'DATE' COLOR 6 INVERSE,129'CREATED BY' COLOR 6 INVERSE,143'G R NO' COLOR 6 INVERSE, 154'GR DATE' COLOR 6 INVERSE,
*167'DELIVERY DATE PROMISED' COLOR 6 INVERSE.
ULINE.
endat.
*
*
*WRITE:/ ITAB-LIFNR,ITAB-NAME1,ITAB-MATNR,ITAB-MAKTX,ITAB-EBELN,ITAB-BEDAT,ITAB-ERNAM,ITAB-MBLNR, ITAB-ELDAT, ITAB-EINDT, itab-udate.
*
*ENDLOOP.
*
*
CDHDROBJECTCLAS AND CDHDRTCODE EQ 'ME28'.
*LOOP AT ITAB.
*
*
*SELECT * FROM CDHDR WHERE OBJECTid = ITAB-EBELN AND .
*
*ITAB-UDATE = CDHDR-UDATE.
*APPEND ITAB. CLEAR ITAB.
*ENDSELECT.
*ENDLOOP.
*
**----
fieldcatalog-fieldname = 'ebeln'.
fieldcatalog-seltext_m = 'po Number'.
fieldcatalog-col_pos = 0.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'bedat'.
fieldcatalog-seltext_m = 'po date'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'lifnr'.
fieldcatalog-seltext_m = 'vendor no'.
fieldcatalog-col_pos = 2.
fieldcatalog-outputlen = 15.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'ernam'.
fieldcatalog-seltext_m = 'created by'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'name1'.
fieldcatalog-seltext_m = 'vendor name'.
fieldcatalog-col_pos = 4.
fieldcatalog-outputlen = 15.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'matnr'.
fieldcatalog-seltext_m = 'material number'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'eindt'.
fieldcatalog-seltext_m = 'date promised'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'maktx'.
fieldcatalog-seltext_m = 'material desc'.
fieldcatalog-col_pos = 7.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'mblnr'.
fieldcatalog-seltext_m = 'GR no'.
fieldcatalog-col_pos = 8.
fieldcatalog-outputlen = 15.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'eldat'.
fieldcatalog-seltext_m = 'gr date'.
fieldcatalog-col_pos = 9.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
*----
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
it_fieldcat = fieldcatalog[]
is_layout = GS_layout
is_variant = z_template
tables
t_outtab = itab
exceptions
program_error = 1
others = 2.
*----