✒️ABAP El ALV jerárquico y el agrupamiento
ABAP El ALV jerárquico y el agrupamiento
* Ejemplo de ALV en bloques
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 YR01_REUSE_ALV_BLOCK_LIST
*&
*&---------------------------------------------------------------------*
*&Lista materiales y datos asociados con ALV en BLOQUE
*&
*&---------------------------------------------------------------------*
report yr01_reuse_alv_block_list.
*provide tables
tables: mara, makt, mard.
*provide type-pools for ALV
type-pools: slis.
*provide select-options
select-options: s_matnr for mara-matnr.
*provide data objects
data: v_repid type sy-repid,
wa_mara_field type slis_fieldcat_alv, "it is for field catalog
wa_makt_field type slis_fieldcat_alv,
wa_mard_field type slis_fieldcat_alv,
wa_mara type mara,
wa_makt type makt,
wa_mard type mard,
it_mara_field type slis_t_fieldcat_alv,
it_makt_field type slis_t_fieldcat_alv,
it_mard_field type slis_t_fieldcat_alv,
it_mara type table of mara,
it_makt type table of makt,
it_mard type table of mard,
v_layout type slis_layout_alv,
it_events type slis_t_event, "it is for events
wa_events type slis_alv_event.
v_repid = sy-repid.
*provide perform for select the data
perform select_data.
*provide field catalog perform
perform field_cat.
*call the initial function module
call function 'REUSE_ALV_BLOCK_LIST_INIT'
exporting
i_callback_program = v_repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* IT_EXCLUDING =
.
***
*call mara append list
call function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = v_layout
it_fieldcat = it_mara_field[]
i_tabname = 'MARA'
it_events = it_events[]
* IT_SORT =
* I_TEXT = ' '
tables
t_outtab = it_mara
exceptions
program_error = 1
maximum_of_appends_reached = 2
others = 3.
*call makt append list
call function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = v_layout
it_fieldcat = it_makt_field
i_tabname = 'MAKT'
it_events = it_events
* IT_SORT =
* I_TEXT = ' '
tables
t_outtab = it_makt
exceptions
program_error = 1
maximum_of_appends_reached = 2
others = 3.
*call mard append list
call function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = v_layout
it_fieldcat = it_mard_field
i_tabname = 'MARD'
it_events = it_events
* IT_SORT =
* I_TEXT = ' '
tables
t_outtab = it_mard
exceptions
program_error = 1
maximum_of_appends_reached = 2
others = 3.
*display the data
call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'
* EXPORTING
* I_INTERFACE_CHECK = ' '
* IS_PRINT =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2.
.
*&--------------------------------------------------------------------*
*& Form TOP_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
form top_page.
write:/ 'THIS IS BLOCKED ALV REPORT PROGRAM BASED ON 3 BLOCKS' color 5.
endform. "TOP_PAGE
*&---------------------------------------------------------------------*
*& Form FIELD_CAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form field_cat .
wa_mara_field-col_pos = 1.
wa_mara_field-fieldname = 'MATNR'.
wa_mara_field-ref_tabname = 'MARA'.
append wa_mara_field to it_mara_field.
clear wa_mara_field.
wa_mara_field-col_pos = 2.
wa_mara_field-fieldname = 'ERSDA'.
wa_mara_field-ref_tabname = 'MARA'.
append wa_mara_field to it_mara_field.
clear wa_mara_field.
wa_mara_field-col_pos = 3.
wa_mara_field-fieldname = 'ERNAM'.
wa_mara_field-ref_tabname = 'MARA'.
append wa_mara_field to it_mara_field.
clear wa_mara_field.
wa_mara_field-col_pos = 4.
wa_mara_field-fieldname = 'LAEDA'.
wa_mara_field-ref_tabname = 'MARA'.
append wa_mara_field to it_mara_field.
clear wa_mara_field.
*****
wa_makt_field-col_pos = '1'.
wa_makt_field-fieldname = 'MATNR'.
wa_makt_field-ref_tabname = 'MAKT'.
append wa_makt_field to it_makt_field.
clear wa_makt_field.
wa_makt_field-col_pos = 2.
wa_makt_field-fieldname = 'MAKTX'.
wa_makt_field-ref_tabname = 'MAKT'.
append wa_makt_field to it_makt_field.
clear wa_makt_field.
wa_makt_field-col_pos = 3.
wa_makt_field-fieldname = 'MAKTG'.
wa_makt_field-ref_tabname = 'MAKT'.
append wa_makt_field to it_makt_field.
clear wa_makt_field.
*****
wa_mard_field-col_pos = 1.
wa_mard_field-fieldname = 'MATNR'.
wa_mard_field-ref_tabname = 'MARD'.
append wa_mard_field to it_mard_field.
clear wa_mard_field.
wa_mard_field-col_pos = 2.
wa_mard_field-fieldname = 'WERKS'.
wa_mard_field-ref_tabname = 'MARD'.
append wa_mard_field to it_mard_field.
clear wa_mard_field.
wa_mard_field-col_pos = 3.
wa_mard_field-fieldname = 'LGORT'.
wa_mard_field-ref_tabname = 'MARD'.
append wa_mard_field to it_mard_field.
clear wa_mard_field.
wa_events-form = 'TOP_PAGE'.
wa_events-name = 'TOP_OF_PAGE'.
append wa_events to it_events.
endform. " FIELD_CAT
*&---------------------------------------------------------------------*
*& Form SELECT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form select_data .
select *
from mara
into table it_mara
where matnr in s_matnr.
select *
from makt
into table it_makt
where matnr in s_matnr.
select *
from mard
into table it_mard
where matnr in s_matnr.
endform. " SELECT_DATA
Sobre el autor
Publicación académica de Luis Alfredo Lombardi Pizarro, en su ámbito de estudios para la Carrera Consultor ABAP.
Luis Alfredo Lombardi Pizarro
Peru - Legajo: BV21K
✒️Autor de: 100 Publicaciones Académicas
🎓Egresado de los módulos:
- Carrera Consultor en SAP FI Nivel Avanzado
- Carrera Consultor en SAP FI Nivel Inicial
- Carrera Consultor ABAP Nivel Avanzado
- Carrera Consultor ABAP Nivel Inicial
- Máster ABAP Orientado a Objetos