![](/cvo_files/imgs_sap_abap/logos/logo_cvo_academy_it.png)
✒️ABAP POO Otras configuraciones del ALV GRID CONTROL
ABAP POO Otras configuraciones del ALV GRID CONTROL
![ABAP POO Otras configuraciones del ALV GRID CONTROL ABAP POO Otras configuraciones del ALV GRID CONTROL](https://www.cvosoft.com/cvo_files/imgs_sap_abap/og-images/337.jpg)
Ejercicio que venia haciendo.
En Sort, lo modifiqué a descendente.
Interesante que se puedan excluir menú de funciones y submenues...
SPAN {
font-family: "Courier New";
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S32 {
color: #3399FF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}
*&---------------------------------------------------------------------*
*& Report ZPRUEBA_ALV
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZPRUEBA_ALV.
Data:
it_Data Type STANDARD TABLE OF ZTFI001,
wa_Data Type ZTFI001,
ok_code Type sy-ucomm.
Data: " PAra la grilla
it_Sort Type LVC_T_Sort,
wa_sort Type LVC_S_Sort,
wa_layout Type lvc_S_LAYO,
it_catalogo Type lvc_t_fcat,
wa_catalogo Type lvc_s_fcat,
it_Botones Type UI_FUNCTIONS, " botones a excluir
wa_botones Type UI_FUNC,
oGrilla Type REF TO CL_GUI_ALV_GRID,
oContenedor Type REF TO CL_GUI_CUSTOM_CONTAINER.
START-OF-SELECTION.
Perform Seleccion_datos.
END-OF-SELECTION.
CALL SCREEN 0900.
*&---------------------------------------------------------------------*
*& Module CREAR_OBJ_0900 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CREAR_OBJ_0900 OUTPUT.
if oContenedor is initial.
" Creo el contenedor y lo vinculo a la Dynpro
Create Object oContenedor
EXPORTING
Container_name = 'CONTENEDOR'. " Relaciona con contenedor de Dynpro.
" Creo grilla y la vinculo al Contenedor
Create Object oGrilla
EXPORTING
i_parent = oContenedor. " Relaciona con objeto Contenedor
" Indico algunos botones a excluir - Se ven en constantes (atributos) en CL_GUI_ALV_GRID
Clear it_botones.
* wa_botones = cl_gui_alv_grid=>MC_FC_SUM. " suma
* append wa_botones to it_botones.
* wa_botones = cl_gui_alv_grid=>MC_FC_SUBTOT. " subtotales
* append wa_botones to it_botones.
* wa_botones = cl_gui_alv_grid=>MC_FC_FILTER. " filtros
* append wa_botones to it_botones.
" Otra forma...
append cl_gui_alv_grid=>MC_FC_SUM to it_botones.
append cl_gui_alv_grid=>MC_FC_SUBTOT to it_botones.
append cl_gui_alv_grid=>MC_FC_FILTER to it_botones.
" Si se quiere ocultar la barra de herramientas.
"wa_layout-no_toolbar = 'X'.
" Armar Layout
Perform armar_layout.
" Catalogo.
PERFORM armar_catalogo.
" Armar SORT
Perform armar_sort.
" Asigno tabla interna a Grilla.
CALL METHOD oGrilla->set_table_for_first_display
EXPORTING
* i_structure_name = 'ZTFI001' " nombre de la tabla, para tomar datos de la estrucutura. Con catalogo de campos, no usar.
IT_TOOLBAR_EXCLUDING = it_botones
IS_LAYOUT = wa_layout
CHANGING
it_outtab = it_data " Tabla interna con los datos
it_fieldcatalog = it_catalogo " Catalogo de campos.
it_sort = it_sort
EXCEPTIONS
OTHERS = 4. " NRo. de Error.
Else. " Ya existen los objetos
" Muestro grilla
Call METHOD oGrilla->refresh_table_display
EXPORTING
i_soft_refresh = 'X'
EXCEPTIONS
finished = 1
OTHERS = 2.
Endif. " oContenedor
ENDMODULE. " CREAR_OBJ_0900 OUTPUT
*&---------------------------------------------------------------------*
*& Form SELECCION_DATOS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SELECCION_DATOS .
Select *
into table it_Data
from ZTFI001.
ENDFORM. " SELECCION_DATOS
*&---------------------------------------------------------------------*
*& Module SALIR_0900 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE SALIR_0900 INPUT.
oGrilla->free( ).
oContenedor->free( ).
LEAVE PROGRAM.
ENDMODULE. " SALIR_0900 INPUT
FORM armar_catalogo.
Clear it_catalogo.
REFRESH it_catalogo.
Clear wa_catalogo.
wa_catalogo-fieldname = 'ZBUKR'.
wa_catalogo-tabname = 'ZTFI001'.
wa_catalogo-col_pos = 1.
wa_catalogo-outputlen = 4.
wa_catalogo-scrtext_S = 'Soc'.
wa_catalogo-scrtext_M = 'Sociedad'.
wa_catalogo-scrtext_L = 'Sociedad Contable'.
append wa_catalogo to it_catalogo.
Clear wa_catalogo.
wa_catalogo-fieldname = 'HBKID'.
wa_catalogo-tabname = 'ZTFI001'.
wa_catalogo-col_pos = 2.
wa_catalogo-outputlen = 7.
wa_catalogo-scrtext_S = 'Bco'.
wa_catalogo-scrtext_M = 'Banco'.
wa_catalogo-scrtext_L = 'Entidad Bancaria'.
append wa_catalogo to it_catalogo.
Clear wa_catalogo.
wa_catalogo-fieldname = 'CHECT'.
wa_catalogo-tabname = 'ZTFI001'.
wa_catalogo-col_pos = 3.
wa_catalogo-outputlen = 12.
wa_catalogo-scrtext_S = 'Chq'.
wa_catalogo-scrtext_M = 'Cheque'.
wa_catalogo-scrtext_L = 'Nro.Cheque'.
wa_catalogo-JUST = 'R'.
wa_catalogo-no_Zero = 'X'.
append wa_catalogo to it_catalogo.
ENDFORM.
Form armar_layout.
wa_layout-grid_title = 'Titulo de Grilla'.
wa_layout-zebra = 'X'.
wa_layout-cwidth_opt = 'X'.
"wa_layout-no_headers = 'X'. " Quita cabecera a columnas.
wa_layout-sel_mode = 'D'.
wa_layout-detailinit = 'X'.
wa_layout-keyhot = 'X'.
endForm.
Form armar_sort.
Clear wa_sort.
wa_sort-fieldname = 'CHECT'.
wa_sort-spos = 1.
"wa_sort-up = 'X'.
wa_sort-down = 'X'.
append wa_sort to it_sort.
EndForm.
 
 
 
Sobre el autor
Publicación académica de Alfredo César, en su ámbito de estudios para el Máster ABAP POO.
Alfredo César
Profesión: Analista de Sistemas - Argentina - Legajo: RQ48L
✒️Autor de: 33 Publicaciones Académicas
🎓Egresado de los módulos:
Certificación Académica de Alfredo César