En pocas líneas:
1. Declarar tabla sort
DATA gs_sort TYPE LVC_T_SORT.
2. Llenar tabla sort para los mismos campos del Fieldcat
DATA ls_sort TYPE lvc_s_sort.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'PERNR'.
ls_fieldcat-ref_table = 'PA0001'.
ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO gs_fieldcat.
CLEAR ls_sort.
ls_sort-spos = '01'.
ls_sort-fieldname = 'PERNR'.
ls_sort-up = 'X'. "sort hacia arriba
ls_sort-subtot = 'X'. "subtotal sobre el campo sumado
APPEND ls_sort TO gs_sort.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'BETRG'.
ls_fieldcat-ref_table = 'PA9092'.
ls_fieldcat-cfieldname = 'WAERS'.
ls_fieldcat-do_sum = 'X'.
APPEND ls_fieldcat TO gs_fieldcat.
3. Agregar tabla a función de generación de LVC.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_buffer_active = 'X'
i_callback_program = g_repid
it_fieldcat_lvc = gs_fieldcat[]
is_layout_lvc = gs_layout
it_sort_lvc = gs_sort "<-- ahi
(... etc)
No hay comentarios:
Publicar un comentario