✒️ABAP El catálogo ALV automático, los logos, los encabezados y los status GUI
ABAP El catálogo ALV automático, los logos, los encabezados y los status GUI
Creación de catálogo de forma automática:
--------------------------------------------------------------------------------------------
Se utiliza la función REUSE_ALV_FIELDCATALOG_MERGE.
--------------------------------------------------------------------------------------------
Ejemplo:
v_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_programa_name = v_repid
i_internal_tabname = 'TI_USUARIOS'
i_client_never_display = 'X'
i_inclname = v_repid
CHANGING
ct_fieldcat = ti_catalog[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHER = 3.
--------------------------------------------------------------------------------------------
Para poder realizar esto, debemos modificar dos cosas del programa anterior:
------------------------------------------------------------------------------------
Primera:
Cambiar la forma en la que se declara la tabla interna del ALV.
DATA: BEGIN OF ti_usuarios OCCURS 0,
dni LIKE xtabla_usuarios-dni,
nombre_ape LIKE ztabla_usuarios-nombre_ape,
estado_usu LIKE ztabla_usuarios-estado_usu,
direccion LIKE ztabla_usuarios-direccion,
codigo_postal LIKE ztabla_usuarios-codigo_posta,
f_nacimiento LIKE ztabla_usuarios-f_nacimiento,
estado_civil LIKE ztabla_usuarios-estado_civil,
END OF ti_usuarios.
------------------------------------------------------------------------------------
Segunda:
Configurar el editor para que restrinja la cantidad de caracteres de ancho de la pantalla a 72.
Utilidades --> Opciones --> Editor ABAP --> Editor.
Y allí tildamos 'Long. Líneas compatib descend. (72)'.
--------------------------------------------------------------------------------------------
Utilización de logos y encabezados:
--------------------------------------------------------------------------------------------
En ALV Grilla podemos agregarlos.
Para ello:
------------------------------------------------------------------------------------
Declaramos:
ti_header TYPE slis_t_listheader,
st_header TYPE slis_listheader.
------------------------------------------------------------------------------------
Luego llenamos la tabla con, por ejemplo:
DATA: v_fecha(10) TYPE c.
CONCATENATE sy-datum 6(2) sy-datum 4(2) sy-datum(4) INTO v_fecha SEPARATED BY '/'.
st_header-typ = 'H'.
st_header-info = 'Listado de Usuarios'.
APPEND st_header TO ti_header.
CLEAR st_header.
st_header-typ = 'S'.
st_header-key = 'Tipo de reporte: '.
st_header-info = 'ALV'.
APPEND st_header TO ti_header.
CLEAR st_header.
st_header-typ = 'S'.
st_header-key = 'Fecha: '.
st_header-info = v_fecha.
APPEND st_header TO ti_header.
CLEAR st_header.
------------------------------------------------------------------------------------
Hecho esto, en la llamada a la función del ALV agregamos el parámetro I_CALL_TOP_PAGE con el nombre de la subrutina que cargará el contenido del encabezado:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
it_fieldcat = ti_catalogo[]
i_callback_top_of_page = 'TOP_OF_PAGE'
is_layout = st_layout
TABLES
t_outtab = ti_usuarios.
------------------------------------------------------------------------------------
Y finalmente, dentro de la subrutina, utilizamos la función REUSE_ALV_COMMENTARY_WRITE para cargar el encabezado:
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
It_list_commentary = ti_header
i_logo = 'ENJOYSAP_LOGO'.
ENDFORM.
Mediante SE78 o OAER se pueden ver todos los logos del sistema o cargar nuevos.
--------------------------------------------------------------------------------------------
Utilización de Status GUIs:
--------------------------------------------------------------------------------------------
Para usarlas, hay que agregar en la llamada la función del ALV, los parámetros I_CALLBACK_PF_STATUS_SET y I_CALLBACK_USER_COMMAND:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_pf_status_set = 'PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = ti_catalogo[]
i_callback_top_of_page = 'TOP_OF_PAGE'
is_layout = st_layout
TABLES
t_outtab = ti_usuarios.
--------------------------------------------------------------------------------------------
Dentro de la subrutina 'PF_STATUS' seteamos el status:
FORM pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS '0100'.
ENDFORM.
--------------------------------------------------------------------------------------------
Y por último, dentro de la subrutina 'USER_COMMAND' se capturarán las acciones realizadas por el usuario:
FORM user_command USING r_ucomm TYPE syucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN 'USU_ACTI'.
…
WHEN 'USU_INACTI'.
…
ENDCASE.
ENDFORM.
 
 
 
Sobre el autor
Publicación académica de Martin Alejandro Goya, en su ámbito de estudios para la Carrera Consultor ABAP.
Martin Alejandro Goya
Profesión: Ingeniero en Computacion - Argentina - Legajo: CJ13E
✒️Autor de: 49 Publicaciones Académicas
🎓Egresado del módulo:
Certificación Académica de Martin Goya