REPORT ZMKT_RPT.
TABLES : Mseg. "Units of Measure for Material
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,
MEINS TYPE MARA-MEINS,
ferth TYPE mara-ferth,
* GEWEI TYPE MARA-GEWEI,
maktx type makt-maktx,
END OF itab.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT_001.
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN COMMENT 1(33) TEXT_200.
SELECT-OPTIONS : MATNR FOR mseg-MATNR.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN : END OF BLOCK B1.
INITIALIZATION.
TEXT_001 = 'Selection....'.
TEXT_200 = 'Material Number'.
START-OF-SELECTION.
SELECT MATNR
meins
ferth
INTO (itab-MATNR,itab-meins,itab-ferth)
FROM mara
WHERE MATNR IN MATNR.
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.
***** 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 = 'FERTH'.
FIELDCAT_LN-TABNAME = 'itab'.
FIELDCAT_LN-just = 'C'.
FIELDCAT_LN-outputlen = '15'.
FIELDCAT_LN-SELTEXT_L = 'PROD/INS MEMO'.
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 = 'PROD.INS MEMO FOR MM03'.
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
No comments:
Post a Comment