📘ABAP - Reuse_alv_commentary_write
Definición de Reuse_alv_commentary_write
Es el módulo de funciones estándar del sistema que se utiliza para mostrar el encabezado de un reporte ALV grilla.
Veamos a continuación un ejemplo de la utilización del módulo de funciones REUSE_ALV_COMMENTARY_WRITE en un reporte ALV:
REPORT ZPRUEBA_ALV_HEADER .
tables: ZTABLA_PRUEBA.
TYPE-POOLS: slis.
DATA: it_alv LIKE TABLE OF ZTABLA_PRUEBA WITH HEADER LINE,
gt_catalogo TYPE slis_t_fieldcat_alv WITH HEADER LINE,
wa_header type slis_listheader,
it_header type slis_t_listheader.
*------------------------------------------
START-OF-SELECTION.
*------------------------------------------
SELECT * FROM ZTABLA_PRUEBA
INTO CORRESPONDING FIELDS OF TABLE it_alv.
PERFORM armar_catalogo.
PERFORM llenar_header.
PERFORM top_of_page.
PERFORM armar_reporte.
*&---------------------------------------------------------------------*
*& Form armar_CATALOGO
*&---------------------------------------------------------------------*
Form armar_catalogo.
CLEAR gt_catalogo. "******LIMPIA LA cabecera*********
gt_catalogo-fieldname = 'NROCLI'. "***SIEMPRE EN MAYUSCULA
gt_catalogo-tabname = 'IT_ALV'.
gt_catalogo-ref_tabname = 'ZTABLA_PRUEBA'.
gt_catalogo-ref_fieldname = 'NROCLI'.
APPEND gt_catalogo.
CLEAR gt_catalogo. "******LIMPIA LA cabecera*********
gt_catalogo-fieldname = 'NOMBRE'. "***SIEMPRE EN MAYUSCULA
gt_catalogo-tabname = 'IT_ALV'.
gt_catalogo-ref_tabname = 'ZTABLA_PRUEBA'.
gt_catalogo-ref_fieldname = 'NOMBRE'.
APPEND gt_catalogo.
CLEAR gt_catalogo. "******LIMPIA LA cabecera*********
gt_catalogo-fieldname = 'STRAS'. "***SIEMPRE EN MAYUSCULA
gt_catalogo-tabname = 'IT_ALV'.
gt_catalogo-ref_tabname = 'ZTABLA_PRUEBA'.
gt_catalogo-ref_fieldname = 'STRAS'.
APPEND gt_catalogo.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form armar_reporte
*&---------------------------------------------------------------------*
form armar_reporte.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'ZPRUEBA_ALV_HEADER'
IT_FIELDCAT = gt_catalogo[]
i_callback_top_of_page = 'TOP_OF_PAGE'
TABLES
t_outtab = it_alv.
endform.
*&---------------------------------------------------------------------*
*& Form llenar_header
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM llenar_header.
data: fecha type date.
wa_header-typ = 'H'.
wa_header-info = 'Listado de Sueldos'.
append wa_header to it_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'Tipo de reporte: '.
wa_header-info = 'ALV'.
append wa_header to it_header.
clear wa_header.
write sy-datum to fecha.
wa_header-typ = 'S'.
wa_header-key = 'Fecha: '.
wa_header-info = fecha.
append wa_header to it_header.
clear wa_header.
wa_header-typ = 'A'.
wa_header-info = 'LISTADO DE COMPROBANTES DE FACTURACION'.
append wa_header to it_header.
clear wa_header.
ENDFORM. " llenar_header
*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM top_of_page.
* it_list_commentary Va una tabla interna con los datos que quiero
* poner en la cabecera.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = it_header
I_LOGO = 'LOGO_AGUAS'.
ENDFORM.