*&---------------------------------------------------------------------*
*& Report Z14841_0001
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Z14841_0001.
TYPE-POOLS: slis.
DATA: fieldcat TYPE slis_t_fieldcat_alv,
fieldcat_ln LIKE LINE OF fieldcat,
sortcat TYPE slis_t_sortinfo_alv,
sortcat_ln LIKE LINE OF sortcat,
eventcat TYPE slis_t_event,
eventcat_ln LIKE LINE OF eventcat.
DATA: col_pos TYPE i.
TABLES: mara.
DATA: BEGIN OF itab OCCURS 10,
matnr LIKE mara-matnr,
mtart LIKE mara-mtart,
bismt LIKE mara-bismt,
END OF itab.
SELECT-OPTIONS: p_matnr FOR mara-matnr.
START-OF-SELECTION.
SELECT matnr mtart bismt
INTO CORRESPONDING FIELDS OF TABLE itab
FROM mara
WHERE matnr IN p_matnr.
ADD 1 TO col_pos.
fieldcat_ln-ref_tabname = 'MARA'.
fieldcat_ln-fieldname = 'MTART'.
fieldcat_ln-key = space.
fieldcat_ln-do_sum = space.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-no_out = space.
fieldcat_ln-qfieldname = space.
fieldcat_ln-hotspot = space.
APPEND fieldcat_ln TO fieldcat.
ADD 1 TO col_pos.
fieldcat_ln-ref_tabname = 'MARA'.
fieldcat_ln-fieldname = 'MATNR'.
fieldcat_ln-key = space.
fieldcat_ln-do_sum = space.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-no_out = space.
fieldcat_ln-qfieldname = space.
fieldcat_ln-hotspot = space.
APPEND fieldcat_ln TO fieldcat.
ADD 1 TO col_pos.
fieldcat_ln-ref_tabname = 'MARA'.
fieldcat_ln-fieldname = 'BISMT'.
fieldcat_ln-key = space.
* DEFINE AN SUM
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-no_out = space.
fieldcat_ln-qfieldname = space.
fieldcat_ln-hotspot = space.
APPEND fieldcat_ln TO fieldcat.
* DEFINE EVENT LIST(Event Catalogs)
eventcat_ln-name = 'TOP_OF_PAGE'.
eventcat_ln-form = 'PAGE_HEADER'.
APPEND eventcat_ln TO eventcat.
* DEFINE ALV CALL Function Module
DATA: pgm LIKE sy-repid.
pgm = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = pgm
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = fieldcat
i_save = 'A'
* it_events = eventcat
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
* DEFINE EVENT OF THE USER CLICKED KEYBOARD.
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
READ TABLE itab INDEX selfield-tabindex.
CHECK sy-subrc = 0.
CASE ucomm.
WHEN '&IC1'.
CASE selfield-sel_tab_field.
MESSAGE 'fdf' TYPE 'I' .
ENDCASE.
ENDCASE.
ENDFORM. "USER_COMMAND
阅读(1464) | 评论(0) | 转发(0) |