Google Search - Blog...........

ABAP - Calling A Transacton From ALV Grid/List Report

REPORT Z_TEST001.
TYPE-POOLS: slis.
tables: rseg.

DATA: begin of TAB_ARSEG occurs 0.
INCLUDE STRUCTURE RSEG.
DATA: END OF TAB_ARSEG.
DATA: T_FIELDCAT TYPE slis_t_fieldcat_alv.
DATA: c_user_command TYPE slis_formname VALUE 'USER_COMMAND'.

START-OF-SELECTION.

select * from rseg into table tab_arseg .

END-OF-SELECTION.

perform build_fieldcat.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_buffer_active = space
i_callback_program = sy-repid
I_CALLBACK_USER_COMMAND = c_user_command
IT_FIELDCAT = T_FIELDCAT[]
TABLES
T_OUTTAB = TAB_ARSEG .

**&------------------------------------------------------------------
**& Form USER_COMMAND
**&------------------------------------------------------------------

FORM USER_COMMAND USING F_UCOMM LIKE SY-UCOMM
I_SELFIELD TYPE SLIS_SELFIELD.

DATA: F_SUBRC LIKE SY-SUBRC,
s_arseg like tab_arseg.
READ TABLE tab_arseg INDEX i_selfield-tabindex INTO s_arseg.

CASE F_UCOMM.
WHEN '&IC1'.
CASE i_SELFIELD-SEL_TAB_FIELD.
WHEN 'TAB_ARSEG-BELNR'.
CHECK NOT S_ARSEG-BELNR IS INITIAL.
SET PARAMETER ID 'RBN' FIELD S_ARSEG-BELNR.
SET PARAMETER ID 'GJR' FIELD S_ARSEG-GJAHR.
CALL TRANSACTION 'MIR4' AND SKIP FIRST SCREEN.
ENDCASE.
ENDCASE.
ENDFORM.

**&------------------------------------------------------------------
**& Form build_fieldcat
**&------------------------------------------------------------------

FORM build_fieldcat .
DATA: FIELDCAT TYPE SLIS_FIELDCAT_ALV.
CLEAR FIELDCAT.
FIELDCAT-FIELDNAME = 'BELNR'.
FIELDCAT-TABNAME = 'TAB_ARSEG'.
FIELDCAT-REF_TABNAME = 'RSEG'.
FIELDCAT-REF_FIELDNAME = 'BELNR'.
fieldcat-hotspot = 'X'.
FIELDCAT-COL_POS = 1.
APPEND FIELDCAT TO t_fieldcat.

CLEAR FIELDCAT.
FIELDCAT-FIELDNAME = 'GJAHR'.
FIELDCAT-TABNAME = 'TAB_ARSEG'.
FIELDCAT-REF_TABNAME = 'RSEG'.
FIELDCAT-REF_FIELDNAME = 'GJAHR'.
FIELDCAT-COL_POS = 2.
APPEND FIELDCAT TO t_fieldcat.

ENDFORM. " build_fieldcat


ALSO READ:

- Simple ALV Grid/List With Save Layout.

- Checkbox In ALV Program.

- ALV Header With Logo.

- Including Line After Subtotal In ALV Display.

..... Back To Index On ALV List/ Grid Display.

..... Back To MAIN INDEX.


No comments:

Post a Comment