REPORT ZATERIAL_MASTER_MM60.
TABLES : Mseg,MARA.
TYPE-POOLS: SLIS.
DATA: G_REPID LIKE SY-REPID,
GS_PRINT TYPE SLIS_PRINT_ALV,
T_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
GT_EVENTS TYPE SLIS_T_EVENT,
I_SORT TYPE SLIS_T_SORTINFO_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
GS_CELL TYPE SLIS_LINEINFO,
FIELDCAT_LN LIKE LINE OF GT_FIELDCAT.
DATA : T_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
DATA : IT_EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE.
DATA : L_LIST(105) TYPE C. "Store the Top-of-page headings
DATA : WRK_NAME TYPE T001-BUTXT.
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
DATA : LS_SORT TYPE TABLE OF SLIS_SORTINFO_ALV.
DATA : WA_SORT LIKE LINE OF LS_SORT.
DATA : GS_VARIANT LIKE DISVARIANT,
G_SAVE.
*************************************************
DATA : BEGIN OF itab OCCURS 0,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
aenam TYPE mara-aenam,
mtart TYPE mara-mtart,
LAEDA TYPE mara-LAEDA,
mbrsh TYPE mara-mbrsh,
matkl TYPE mara-matkl,
bismt TYPE mara-bismt,
meins TYPE mara-meins,
ferth TYPE mara-ferth,
SPART TYPE mara-SPART,
XCHPF TYPE mara-XCHPF, "Created On : 22.12.2011 11:30:31
maktx TYPE makt-maktx,
vprsv TYPE mbew-vprsv,
stprs TYPE mbew-stprs,
peinh TYPE mbew-peinh,
bklas TYPE mbew-bklas,
verpr TYPE mbew-verpr,
BWKEY TYPE mbew-BWKEY,
MAABC TYPE MARC-MAABC,
WERKS TYPE MARC-WERKS,
EKGRP TYPE MARC-EKGRP,
DISMM TYPE MARC-DISMM,
DISPO TYPE MARC-DISPO,
QMATV TYPE MARC-QMATV,
SSQSS TYPE MARC-SSQSS,
vtext TYPE tspat-vtext,
spras type tspat-spras,
text(24) TYPE c,
END OF itab.
SELECT-OPTIONS : MATNR FOR mseg-MATNR.
START-OF-SELECTION.
SELECT MATNR
ernam
meins
ferth
SPART
LAEDA
MATKL
MTART
XCHPF
INTO (itab-MATNR,itab-ernam,itab-meins,itab-ferth,ITAB-SPART,ITAB-LAEDA,ITAB-MATKL,ITAB-MTART,ITAB-XCHPF)
FROM mara
WHERE MATNR IN MATNR.
IF itab-XCHPF = 'X' .
itab-text = 'YES'.
ELSEIF itab-XCHPF = ' ' .
itab-text = 'NO' .
ENDIF.
APPEND itab.
ENDSELECT.
LOOP AT itab.
SELECT SINGLE MAKTX FROM MAKT INTO itab-MAKTX
WHERE MATNR EQ itab-MATNR
AND SPRAS EQ 'EN'.
MODIFY itab.
ENDLOOP.
LOOP AT itab.
SELECT SINGLE MAKTX FROM MAKT INTO itab-MAKTX
WHERE MATNR EQ itab-MATNR
AND SPRAS EQ 'EN'.
MODIFY itab.
ENDLOOP.
LOOP AT itab.
SELECT SINGLE vtext FROM tspat INTO itab-vtext
WHERE spart EQ itab-spart
AND SPRAS EQ 'EN'.
MODIFY itab.
ENDLOOP.
LOOP AT itab.
SELECT vprsv stprs peinh bklas verpr FROM mbew INTO (itab-vprsv,itab-stprs,itab-peinh,itab-bklas,itab-verpr)
WHERE MATNR EQ itab-MATNR
and bwkey eq 'BRHP'.
endselect.
MODIFY itab.
ENDLOOP.
LOOP AT itab.
SELECT MAABC DISMM DISPO QMATV SSQSS FROM MARC INTO (itab-MAABC,itab-DISMM,itab-DISPO,itab-QMATV,itab-SSQSS)
WHERE MATNR EQ itab-MATNR AND
werks eq 'BRHP' .
endselect.
IF itab-QMATV = 'X' .
itab-text = 'YES'.
ELSEIF itab-QMATV = ' ' .
itab-text = 'NO' .
ENDIF.
MODIFY itab.
ENDLOOP.
***** TO DISPLAY USING ALV
PERFORM BUILD.
PERFORM GET_EVENTS.
PERFORM SUB_COMMENT_BUILD USING T_LIST_TOP_OF_PAGE.
PERFORM CALL_ALV.
*&------------Form BUILD
FORM BUILD.
DATA: FIELDCAT_IN TYPE SLIS_FIELDCAT_ALV.
REFRESH GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'MATNR'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'MATERIAL NO.'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'MAKTX'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '25'.
FIELDCAT_LN-SELTEXT_L = 'MATERIAL DESC.'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
*
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'MTART'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'MATERIAL TYPE'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'MATKL'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'MATERIAL GRP'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'ERNAM'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'Created by'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'LAEDA'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'LAST CHANGE'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'SPART'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'DIVISION'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'VTEXT'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'DIV TEXT'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'STPRS'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'STD.PRICE'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'VERPR'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'MOVING PRICE'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'VPRSV'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'PRICE CONTROL'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'PEINH'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'PRICE UNIT'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'MAABC'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'ABC IND'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'BKLAS'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'VALUATION CLASS'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'DISMM'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'MRP TYPE'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'XCHPF'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'BACH INDICATOR'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'DISPO'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'MRP CONTROLLER'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'QMATV'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'INSP.SETUP'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-FIELDNAME = 'SSQSS'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'QM CTRL KEY'.
FIELDCAT_LN-NO_ZERO = 'X'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
G_REPID = SY-REPID.
GS_VARIANT-REPORT = G_REPID.
G_SAVE = 'A'.
ENDFORM. "BUILD
*&---------------Form CALL_ALV
DATA T_LAYOUT TYPE SLIS_LAYOUT_ALV.
*&---------------------------------------------------------------------*
*& Form CALL_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM CALL_ALV.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
I_SAVE = G_SAVE
IS_VARIANT = GS_VARIANT
IT_FIELDCAT = GT_FIELDCAT[]
IT_EVENTS = IT_EVENTS[]
TABLES
T_OUTTAB = itab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM. "CALL_ALV
*& Form GET_EVENTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_EVENTS .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = IT_EVENTS[]
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
READ TABLE IT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO IT_EVENTS.
IF SY-SUBRC = 0.
MOVE T_FORMNAME_TOP_OF_PAGE TO IT_EVENTS-FORM.
APPEND IT_EVENTS.
ENDIF.
ENDFORM. " get_events
*&---------------------------------------------------------------------*
*& Form sub_comment_build
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_LIST_TOP_OF_PAGE text
*----------------------------------------------------------------------*
FORM SUB_COMMENT_BUILD USING I_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: LS_LINE TYPE SLIS_LISTHEADER.
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
LS_LINE-INFO = 'xyz Limited'.
APPEND LS_LINE TO I_TOP_OF_PAGE.
LS_LINE-TYP = 'H'.
LS_LINE-INFO = 'Material Master'.
APPEND LS_LINE TO I_TOP_OF_PAGE.
CLEAR: LS_LINE, L_LIST.
LS_LINE-TYP = 'S'.
LS_LINE-INFO = L_LIST.
APPEND LS_LINE TO I_TOP_OF_PAGE.
ENDFORM. " sub_comment_build
*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_LIST_TOP_OF_PAGE.
ENDFORM. "TOP_OF_PAGE