Sie sind auf Seite 1von 4

REPORT zmara_alv_report.

TYPE-POOLS slis.
TABLES : mara.
TYPES : BEGIN OF ty_mara,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
mtart TYPE mara-mtart,
END OF ty_mara.
DATA : it_mara TYPE STANDARD TABLE OF ty_mara,
wa_mara TYPE ty_mara.
DATA : it1 TYPE slis_t_fieldcat_alv,
wa1 TYPE slis_fieldcat_alv.
DATA : layout TYPE slis_layout_alv.
SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_mara FOR mara-matnr.
PARAMETERS : list RADIOBUTTON GROUP rad1,
grid RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF BLOCK bk1.
IF list = 'X'.
SELECT matnr ersda ernam mtart FROM mara INTO CORRESPONDING FIELDS OF TABLE i
t_mara WHERE matnr IN s_mara.
PERFORM fieldcat USING 'MATNR' 'X' 'MATERIAL NUMBER' 'C2'.
PERFORM fieldcat USING 'ERSDA' '' 'DATE' 'C3'.
PERFORM fieldcat USING 'ERNAM' '' 'NAME' 'C4'.
PERFORM fieldcat USING 'MTART' '' 'MATERIAL TYPE' 'C2'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
*
I_INTERFACE_CHECK
= ' '
*
I_BYPASSING_BUFFER
=
*
I_BUFFER_ACTIVE
= ' '
*
I_CALLBACK_PROGRAM
= ' '
*
I_CALLBACK_PF_STATUS_SET
= ' '
*
I_CALLBACK_USER_COMMAND
= ' '
*
I_STRUCTURE_NAME
=
*
IS_LAYOUT
=
it_fieldcat
= it1
*
IT_EXCLUDING
=
*
IT_SPECIAL_GROUPS
=
*
IT_SORT
=
*
IT_FILTER
=
*
IS_SEL_HIDE
=
*
I_DEFAULT
= 'X'
*
I_SAVE
= ' '
*
IS_VARIANT
=
*
IT_EVENTS
=
*
IT_EVENT_EXIT
=
*
IS_PRINT
=
*
IS_REPREP_ID
=
*
I_SCREEN_START_COLUMN
= 0
*
I_SCREEN_START_LINE
= 0
*
I_SCREEN_END_COLUMN
= 0
*
I_SCREEN_END_LINE
= 0
*
IR_SALV_LIST_ADAPTER
=
*
IT_EXCEPT_QINFO
=
*
I_SUPPRESS_EMPTY_DATA
= ABAP_FALSE
*
IMPORTING
*
E_EXIT_CAUSED_BY_CALLER
=

ES_EXIT_CAUSED_BY_USER
=
TABLES
t_outtab
= it_mara
*
EXCEPTIONS
*
PROGRAM_ERROR
= 1
*
OTHERS
= 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDIF.
IF grid = 'X'.
SELECT matnr ersda ernam mtart FROM mara INTO CORRESPONDING FIELDS OF TABLE it
_mara WHERE matnr IN s_mara.
PERFORM fieldcat USING 'MATNR' 'X' 'MATERIAL NUMBER' 'C2'.
PERFORM fieldcat USING 'ERSDA' '' 'DATE' 'C3'.
PERFORM fieldcat USING 'ERNAM' '' 'NAME' 'C4'.
PERFORM fieldcat USING 'MTART' '' 'MATERIAL TYPE' 'C2'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
*
I_INTERFACE_CHECK
= ' '
*
I_BYPASSING_BUFFER
= ' '
*
I_BUFFER_ACTIVE
= ' '
I_CALLBACK_PROGRAM
= SY-REPID
*
I_CALLBACK_PF_STATUS_SET
= ' '
*
I_CALLBACK_USER_COMMAND
= ' '
i_callback_top_of_page
= 'HEADER'
*
I_CALLBACK_HTML_TOP_OF_PAGE
= ' '
*
I_CALLBACK_HTML_END_OF_LIST
= ' '
*
I_STRUCTURE_NAME
=
*
I_BACKGROUND_ID
= ' '
*
I_GRID_TITLE
=
*
I_GRID_SETTINGS
=
*
IS_LAYOUT
=
it_fieldcat
= IT1
*
IT_EXCLUDING
=
*
IT_SPECIAL_GROUPS
=
*
IT_SORT
=
*
IT_FILTER
=
*
IS_SEL_HIDE
=
*
I_DEFAULT
= 'X'
*
I_SAVE
= ' '
*
IS_VARIANT
=
*
IT_EVENTS
=
*
IT_EVENT_EXIT
=
*
IS_PRINT
=
*
IS_REPREP_ID
=
*
I_SCREEN_START_COLUMN
= 0
*
I_SCREEN_START_LINE
= 0
*
I_SCREEN_END_COLUMN
= 0
*
I_SCREEN_END_LINE
= 0
*
I_HTML_HEIGHT_TOP
= 0
*
I_HTML_HEIGHT_END
= 0
*
IT_ALV_GRAPHICS
=
*
IT_HYPERLINK
=
*
IT_ADD_FIELDCAT
=
*
IT_EXCEPT_QINFO
=
*
IR_SALV_FULLSCREEN_ADAPTER
=
*
IMPORTING

*
*
*
*
*
*

E_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER
TABLES
t_outtab
EXCEPTIONS
PROGRAM_ERROR
OTHERS
.
IF sy-subrc <> 0.
Implement suitable error handling here
ENDIF.

=
=
= it_mara
= 1
= 2

ENDIF.
*&---------------------------------------------------------------------*
*&
Form FIELDCAT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_0105 text
*
-->P_0106 text
*
-->P_0107 text
*
-->P_0108 text
*----------------------------------------------------------------------*
FORM fieldcat USING
value(p_0105)
value(p_0106)
value(p_0107)
value(p_0108).
wa1-fieldname = p_0105.
wa1-key = p_0106.
wa1-seltext_l = p_0107.
wa1-emphasize = p_0108.
APPEND wa1 TO it1.
ENDFORM.

" FIELDCAT

*&---------------------------------------------------------------------*
*&
Form HEADER
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM header.
DATA : it_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader.
*

Title
wa_header-typ = 'H'.
wa_header-info = 'MATERIAL DESCRIPTION'.
APPEND wa_header TO it_header.
CLEAR wa_header.
* DATE
WA_HEADER-TYP = 'S'.
WA_HEADER-KEY = 'DATE'.
CONCATENATE SY-DATUM+6(2)'.'
SY-DATUM+4(2)'.'
SY-DATUM(4) INTO WA_HEADER-INFO. "TODAYS DATE.
APPEND WA_HEADER TO IT_HEADER.
CLEAR : WA_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING

it_list_commentary = it_header
I_LOGO
= 'ENJOYSAP_LOGO'.
I_END_OF_LIST_GRID
=
I_ALV_FORM
=

*
*
.

ENDFORM.