ALVABAP LIST VIEWER Step by step… 6. ALV da soporte a la mayoría de los informes estándares de ABAP R/3. gs_layout-detail_popup = 'X'. Process call back events. Contiene una serie de módulos de funciones que podrían ser añadidos a los códigos de los programas.p2 text *----------------------------------------------------------------------* FORM build_layout . También puede añadir aspectos de interfaz a los report. IF sy-subrc <> 0. ENDFORM. FUNCIONES ALV. Build event catalogs. 5. "Optimizar ancho del listado gs_layout-zebra = 'X'. start ALV con los módulos. "Mostrar líneas tipo cebra. ENDIF. Para incluir ALV en un report: 1. Declarar data areas. Declarar internal table. 3. *&---------------------------------------------------------------------* *& Form BUILD_LAYOUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-. MESSAGE i799(cu) WITH 'Error creando el ALV'(008) 'Código'(009) sy-subrc. gs_layout-colwidth_optimize = 'X'. 2. 7. "Mostrar opción de información detalle ENDFORM. " BUILD_LAYOUT *&---------------------------------------------------------------------* *& Form call_alv *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->ALV_EMPLOYEE text *----------------------------------------------------------------------* FORM call_alv TABLES alv_employee. Build field catalogs. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = z_pruebareportalv is_layout = gs_layout it_fieldcat = gt_fieldcat[] TABLES t_outtab = i_aux EXCEPTIONS program_error =1 OTHERS = 2. Select data into internal table. 4.Libretilla MarcosJ Miguel Jesús Fernández ALV (ABAP LIST VIEWER). "call_alv *&---------------------------------------------------------------------* *& Form BUILD_HEADER *&---------------------------------------------------------------------* 2 . fieldcat_ln-seltext_l ='COMMENTS'(008). fieldcat_ln-seltext_l ='Correct Execution'(007).Libretilla MarcosJ Miguel Jesús Fernández * text *----------------------------------------------------------------------* * --> p1 text * <-. gs_sort-fieldname = 'SAP_SD_SEQNR'. fieldcat_ln-seltext_l ='Time'(005). REFRESH gt_fieldcat. gs_sort-up = 'X'. fieldcat_ln-fieldname = 'STREET_&_HOUSEN'. fieldcat_ln-fieldname = 'CITY'. fieldcat_ln-seltext_l ='COMMENTS'(008). gs_sort-spos = 7. APPEND fieldcat_ln TO gt_fieldcat. APPEND fieldcat_ln TO gt_fieldcat. APPEND fieldcat_ln TO gt_fieldcat. fieldcat_ln-seltext_l = 'Date'(002). APPEND fieldcat_ln TO gt_fieldcat. CLEAR gs_sort. * explain field description to alv CLEAR gt_fieldcat. ENDFORM. fieldcat_ln-seltext_l = 'NAME'(003). APPEND fieldcat_ln TO gt_fieldcat. fieldcat_ln-fieldname = 'NAME'.p2 text *----------------------------------------------------------------------* FORM build_header . APPEND fieldcat_ln TO gt_fieldcat. fieldcat_ln-fieldname = 'PERNR'. fieldcat_ln-fieldname = 'LASTNAME'. fieldcat_ln-seltext_l ='Correlative Number'(006). APPEND gs_sort TO gt_sort. APPEND fieldcat_ln TO gt_fieldcat. fieldcat_ln-fieldname = 'BIRTH_DATE'. * data sorting and subtotal DATA: gs_sort TYPE slis_sortinfo_alv. " BUILD_HEADER 3 . fieldcat_ln-fieldname = 'COUNTRY'. Para darle un formato a ese campo cogeremos campos de los distintos infotipos. 1 Transacción SE11.Libretilla MarcosJ Miguel Jesús Fernández CREACIÓN DE ESTRUCTURAS1 Abriremos la transacción se11. Ahora haremos clic en “create”. comprobaremos el component type(presionando F1 sobre el campo y clickando en las herramientas) y lo pondremos en la misma fila que nuestro component. Tras esto guardaremos y la estructura estará creada. Ahora le pondremos una pequeña descripción a nuestra estructura. por ejemplo. *Para crear una tabla en ABAP a partir de una estructura utilizaremos el siguente trozo de código: DATA: tabla TYPE estructura. Tras esto comenzaremos a ponerle los campos que deseemos en la columna “component”. Escogeremos la opción “DATA TYPE” y le pondremos nombre. si cogemos el campo nombre buscaremos un infotipo que contenga ese campo. 4 . Escogeremos la opción “structure” y continuaremos. ” 2 En el WHERE ponemos esta condición para que sólo nos muestre los empleados activos.” … Recuperamos la información de los infotipos haciendo una consulta y almacenando los resultados en cada una de las tablas que hemos creado: “SELECT * FROM pa0000 INTO TABLE i_pa0000 WHERE2 begda <= sy-datum3 AND endda >= sy-datum. si necesitamos los infotipos 0002 y 0006 haríamos 3 tablas.” 3 5 . 4 Esta condición hace que se recorra el subtipo 1 del infotipo 6. es decir. Z_PRUEBAREPORTALV Para comenzar con ello debemos crear nuestra estructura en la transacción se11 como se dijo anteriormente. Para hacerlo menos complejo creo una constante llamada subty1 con el valor ‘0001’: “CONSTANTS: c_subty1 LIKE pa0006-subty VALUE '1'. Ahora crearemos una tabla(i_aux) interna del programa con el formato de la estructura que creamos anteriormente. DATUM es una variable del sistema que almacena la fecha actual. una para cada uno: “DATA: i_pa0000 LIKE pa0000 OCCURS 0 WITH HEADER LINE. “DATA: i_aux LIKE estructura_nombre OCCURS 0 WITH HEADER LINE.” “SELECT * FROM pa0006 INTO TABLE i_pa0006 FOR ALL ENTRIES IN i_pa0000 WHERE pernr EQ i_pa0000-pernr AND subty EQ c_subty1 4 AND begda <= sy-datum AND endda >= sy-datum.” Una vez creada esta tabla crearemos otra para cada infotipo al que recurramos y el 0000. “Recoge datos de diferentes infotipos y los almacena en una tabla interna con formato de una estructura previamente creada”.” Para las otras tablas: “SELECT * FROM pa0002 INTO TABLE i_pa0002 FOR ALL ENTRIES IN i_pa0000 WHERE pernr EQ i_pa0000-pernr AND begda <= sy-datum AND endda >= sy-datum.Libretilla MarcosJ Miguel Jesús Fernández PROGRAMA ABAP SIN BASES DE DATOS LÓGICAS. MESSAGE a000(z1) WITH text-001. READ TABLE i_pa0002 WITH KEY pernr = i_pa0000-pernr. es decir. i_aux-city = i_pa0006-ort01.” 5 Lo almacenamos con APPEND 6 . los campos que creamos en nuestra estructura. para evitar redundancias haremos un REFRESH sobre nuestra tabla antes del LOOP y un CLEAR cada vez que entre en el LOOP: “REFRESH i_aux. coger los campos que necesitamos. ENDIF. ENDIF. Para ello haremos un LOOP que recorra toda la p0000 y dos Read Table uno para cada infotipo de los que recogemos datos.5 ENDLOOP. que siempre que haya valores tendrá 0 como valor. i_aux-street_&_housen = i_pa0006-stras.Libretilla MarcosJ Miguel Jesús Fernández Una vez hecho esto y para comprobar que existen valores utilizamos la variable del sistema sy-subrc. ENDIF. READ TABLE i_pa0000 WITH KEY pernr = i_pa0000-pernr. CLEAR i_aux. IF sy-subrc EQ 0. LOOP AT i_pa0000. i_aux-country = i_pa0006-land1. También. i_aux-birth_date = i_pa0002-gbdat. de cada tabla. Ahora lo que nos interesa es.” Así habremos terminado la parte de recorrido de infotipos y almacenamiento en tablas internas. IF sy-subrc EQ 0. APPEND i_aux. i_aux-lastname = i_pa0002-nachn. IF sy-subrc EQ 0. i_aux-pernr = i_pa0000-pernr. READ TABLE i_pa0006 WITH KEY pernr = i_pa0000-pernr.” Tras esta línea recorreremos nuestras otras dos tablas y pondremos el else como: “ELSE. ENDIF. i_aux-name = i_pa0002-vorna. así una vez recorramos la pa0000 escribiremos la condición: “IF sy-subrc eq 0. DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid. * Custom container instance reference DATA gr_ccontainer TYPE REF TO cl_gui_custom_container. i_pa0002 LIKE pa0002 OCCURS 0 WITH HEADER LINE. * Name of the custom control added on the screen DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV'. * * * * PERFORM mostrar_write. SELECT FROM INTO WHERE AND * pa0000 TABLE i_pa0000 begda <= sy-datum endda >= sy-datum.0006. INITIALIZATION. DATA: i_pa0000 LIKE pa0000 OCCURS 0 WITH HEADER LINE.Libretilla MarcosJ Miguel Jesús Fernández CODIGO COMPLETO Z_PRUEBAREPORTALV: *&---------------------------------------------------------------------* *& Report Z_PRUEBAREPORTALV *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT z_pruebareportalv. PERFORM display_alv_funciones. PERFORM retrieve_infotypes. *&---------------------------------------------------------------------* *& Form RETRIEVE_INFOTYPES *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-. IF NOT i_pa0000[] IS INITIAL. TYPE-POOLS: slis. CONSTANTS: c_subty1 LIKE pa0006-subty VALUE '1'. START-OF-SELECTION. i_aux LIKE zprueba_estructura2 OCCURS 0 WITH HEADER LINE. PERFORM display_alv. * Layout structure DATA gs_layout TYPE slis_layout_alv.p2 text *----------------------------------------------------------------------* FORM retrieve_infotypes. ENDIF. *infotypes:0001.0002. * Field catalog DATA gt_fieldcat TYPE slis_t_fieldcat_alv. i_pa0006 LIKE pa0006 OCCURS 0 WITH HEADER LINE. 7 . PERFORM lectura_inserccion. * i_tab LIKE zprueba_estructura2 OCCURS 0 WITH HEADER LINE. END-OF-SELECTION. PERFORM display_alv_funciones tables gt_fieldcat using gs_layout. READ TABLE i_pa0002 WITH KEY pernr = i_pa0000-pernr. ENDLOOP. i_aux-city = i_pa0006-ort01. " LECTURA_INSERCCION *&---------------------------------------------------------------------* 8 . IF sy-subrc EQ 0. MESSAGE a000(z1) WITH text-001.Libretilla MarcosJ Miguel Jesús Fernández IF sy-subrc EQ 0. SELECT * FROM pa0002 INTO TABLE i_pa0002 FOR ALL ENTRIES IN i_pa0000 WHERE pernr EQ i_pa0000-pernr AND begda <= sy-datum AND endda >= sy-datum. IF sy-subrc EQ 0. LOOP AT i_pa0000. " RETRIEVE_INFOTYPES *&---------------------------------------------------------------------* *& Form LECTURA_INSERCCION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-. i_aux-birth_date = i_pa0002-gbdat. ELSE. ENDIF. IF sy-subrc EQ 0.p2 text *----------------------------------------------------------------------* FORM lectura_inserccion. IF sy-subrc EQ 0. ENDFORM. ENDIF. CLEAR i_aux. ENDIF. APPEND i_aux. i_aux-street_&_housen = i_pa0006-stras. i_aux-name = i_pa0002-vorna. REFRESH i_aux. READ TABLE i_pa0006 WITH KEY pernr = i_pa0000-pernr. ENDIF. i_aux-pernr = i_pa0000-pernr. READ TABLE i_pa0000 WITH KEY pernr = i_pa0000-pernr. ENDFORM. i_aux-country = i_pa0006-land1. i_aux-lastname = i_pa0002-nachn. SELECT * FROM pa0006 INTO TABLE i_pa0006 FOR ALL ENTRIES IN i_pa0000 WHERE pernr EQ i_pa0000-pernr AND subty EQ c_subty1 AND begda <= sy-datum AND endda >= sy-datum. ENDIF. ENDIF. 9 . IF sy-subrc <> 0. CALL METHOD gr_alvgrid->refresh_table_display. CREATE OBJECT gr_alvgrid EXPORTING i_parent = gr_ccontainer EXCEPTIONS error_cntl_create = 1 error_cntl_init = 2 error_cntl_link = 3 error_dp_create = 4 OTHERS = 5. IF gr_alvgrid IS INITIAL. ENDFORM. ENDIF. " DISPLAY_ALV *&---------------------------------------------------------------------* *& Form PREPARE_FIELD_CATALOG *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * <--P_GT_FIELDCAT text *----------------------------------------------------------------------* FORM prepare_field_catalog CHANGING p_gt_fieldcat TYPE lvc_t_fcat. * Preparing layout structure * PERFORM prepare_layout CHANGING gs_layout. * EXCEPTIONS * CNTL_ERROR = 1 * CNTL_SYSTEM_ERROR = 2 * CREATE_ERROR = 3 * LIFETIME_ERROR = 4 * LIFETIME_DYNPRO_DYNPRO_LINK = 5 * others = 6. IF sy-subrc <> 0. ELSE. * PERFORM prepare_field_catalog CHANGING gt_fieldcat. * Preparing field catalog. ENDIF.Libretilla MarcosJ Miguel Jesús Fernández *& Form DISPLAY_ALV *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-.p2 text *----------------------------------------------------------------------* FORM display_alv. * create custom container instance CREATE OBJECT gr_ccontainer EXPORTING container_name = gc_custom_control_name. ENDIF. IF sy-subrc <> 0. * * * * * * CALL METHOD gr_alvgrid->set_table_for_first_display EXPORTING is_layout = gs_layout CHANGING it_outtab = i_aux[] it_fieldcatalog = gt_fieldcat. Libretilla MarcosJ * * * * * * * * * * * Miguel Jesús Fernández DATA ls_fcat type lvc_t_fcat. p_gs_layout-zebra = 'X'. p_gs_layout-smalltitle = 'X'. i_aux-lastname. ENDIF. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING I_PROGRAM_NAME = I_INTERNAL_TABNAME = i_structure_name = 'ZPRUEBA_ESTRUCTURA2' I_CLIENT_NEVER_DISPLAY = 'X' I_INCLNAME = I_BYPASSING_BUFFER = I_BUFFER_ACTIVE = CHANGING ct_fieldcat = p_gt_fieldcat[] EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3. WRITE: / i_aux-pernr. p_gs_layout-grid_title = 'ALV report'. IF sy-subrc <> 0. ENDFORM. i_aux-birth_date. " PREPARE_FIELD_CATALOG *&---------------------------------------------------------------------* *& Form PREPARE_LAYOUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * <--P_GS_LAYOUT text *----------------------------------------------------------------------* FORM prepare_layout CHANGING p_gs_layout TYPE lvc_s_layo. LOOP AT i_aux. i_aux-name.p2 text *----------------------------------------------------------------------* FORM mostrar_write . ENDFORM. 10 . " PREPARE_LAYOUT *&---------------------------------------------------------------------* *& Form MOSTRAR_WRITE *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-. CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING I_BUFFER_ACTIVE = i_structure_name = 'ZPRUEBA_ESTRUCTURA2' I_CLIENT_NEVER_DISPLAY = 'X' I_BYPASSING_BUFFER = I_INTERNAL_TABNAME = 'i_aux' CHANGING ct_fieldcat = p_gt_fieldcat[] EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3. endform. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING is_layout = p_gs_layout it_fieldcat = p_gt_fieldcat TABLES t_outtab = i_aux EXCEPTIONS program_error = 1 OTHERS = 2. * * PERFORM show_alv2 tables p_gt_fieldcat using p_gs_layout. CHANGING p_gs_layout. form PREPARE_FIELD_CATALOG2. ENDLOOP. " DISPLAY_ALV_FUNCIONES *&---------------------------------------------------------------------* *& Form PREPARE_FIELD_CATALOG2 *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * <--P_P_GT_FIELDCAT text *----------------------------------------------------------------------* *form PREPARE_FIELD_CATALOG2 tables p_gt_fieldcat. i_aux-country. * * tables p_gt_fieldcat using p_gs_layout. * PERFORM prepare_field_catalog2 tables p_gt_fieldcat. ENDFORM. * PERFORM prepare_layout2 PERFORM prepare_layout2. " SHOW_ALV *&---------------------------------------------------------------------* *& Form DISPLAY_ALV_FUNCIONES *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * <--P_GT_FIELDCAT text * <--P_GS_LAYOUT text *----------------------------------------------------------------------* form DISPLAY_ALV_FUNCIONES. PERFORM prepare_field_catalog2. " MOSTRAR_WRITE *&---------------------------------------------------------------------* *& Form SHOW_ALV *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_P_GT_FIELDCAT text * -->P_P_GS_LAYOUT text *----------------------------------------------------------------------* FORM show_alv USING p_gt_fieldcat p_gs_layout. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING 11 . i_aux-city. PERFORM show_alv2.Libretilla MarcosJ Miguel Jesús Fernández i_aux-street_&_housen. ENDFORM. " PREPARE_FIELD_CATALOG2 *&---------------------------------------------------------------------* *& Form PREPARE_LAYOUT2 *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * <--P_P_GS_LAYOUT text *----------------------------------------------------------------------* *form PREPARE_LAYOUT2 changing p_gs_layout. form PREPARE_LAYOUT2. gs_layout-grid_title = 'ALV report'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING is_layout = gs_layout it_fieldcat = gt_fieldcat TABLES t_outtab = i_aux EXCEPTIONS program_error = 1 OTHERS = 2. gs_layout-smalltitle = 'X'. " PREPARE_LAYOUT2 *&---------------------------------------------------------------------* *& Form SHOW_ALV2 *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_P_GT_FIELDCAT text * -->P_P_GS_LAYOUT text *----------------------------------------------------------------------* form SHOW_ALV2. Miguel Jesús Fernández = = = 'ZPRUEBA_ESTRUCT78URA2' = 'X' = = = = gt_fieldcat[] = 1 = 2 = 3 endform. endform. endform. * * gs_layout-zebra = 'X'. " SHOW_ALV2 12 .Libretilla MarcosJ * * * * * * I_PROGRAM_NAME I_INTERNAL_TABNAME i_structure_name I_CLIENT_NEVER_DISPLAY I_INCLNAME I_BYPASSING_BUFFER I_BUFFER_ACTIVE CHANGING ct_fieldcat EXCEPTIONS inconsistent_interface program_error OTHERS . *CODIGO* ENDLOOP.” 13 . Z_PRUEBAREPORTALV2 Para empezar hemos creado una estructura que contiene campos de diferentes infotipos(z_structuratest).” A continuación recogeremos el pernr y haremos mención a la función de inserción: “INITIALIZATION. APPEND i_aux. i_aux-bank_account = p0009-bankn. i_aux-bank_key = p0009-bankl. i_aux-payroll_area = p0009-bkont. i_aux-personal_area = p0001-werks.” Ahora declaramos la tabla interna en la que almacenaremos los datos: “DATA: i_aux LIKE zstructuretest OCCURS 0 WITH HEADER LINE. i_aux-last_name = p0002-nachn. i_aux-country = p0006-land1.0006. PERFORM lectura_inserccion. *CODIGO* endprovide. i_aux-city = p0006-ort01. i_aux-street_&_housen = p0006-stras.” Siendo el código: “ i_aux-personal_number = p0001-pernr. con provide sería: “provide * from p0000 between pnpbegda and pnpendda. En primer lugar insertamos las tablas a las que hacemos acceso: “TABLES:pernr. i_aux-organizational_key = p0001-vdsk1. i_aux-company_code = p0001-bukrs. END-OF-SELECTION.0001.” Tenemos dos opciones utilizando provide o loop.0002.” Ahora picaremos nuestra function: “FORM lectura_inserccion .Libretilla MarcosJ Miguel Jesús Fernández PROGRAMA ABAP CON BASES DE DATOS LÓGICAS.0009. START-OF-SELECTION. i_aux-payroll_area = p0001-abkrs. i_aux-employee_subgroup = p0001-persk. i_aux-first_name = p0002-vorna. i_aux-employee_group = p0001-persg.” Utilizando loop sería: “LOOP AT p0000 WHERE begda >= pnpbegda AND endda <= pnpendda. “Recoge datos de diferentes infotipos y los almacena en una tabla interna con formato de una estructura previamente creada”.” Luego los infotipos: “INFOTYPES:0000. GET pernr. i_aux-company_code = p0001-bukrs.Libretilla MarcosJ Miguel Jesús Fernández CODIGO COMPLETO Z_PRUEBAREPORTALV2: *&---------------------------------------------------------------------* *& Report Z_PRUEBAREPORTALV2 *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT z_pruebareportalv2 line-SIZE 400.0009.p2 text *----------------------------------------------------------------------* FORM lectura_inserccion . PERFORM display_alv_funciones. START-OF-SELECTION. GET pernr. *podemos usar un loop o un provide para realizar la inserccion de los datos en la *nuestra tabla i_aux. * Asi seria con un provide *provide * from p0000 * between pnpbegda and pnpendda. LOOP AT p0000 WHERE begda >= pnpbegda AND endda <= pnpendda. PERFORM lectura_inserccion. * Name of the custom control added on the screen DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV'. * Layout structure DATA gs_layout TYPE slis_layout_alv. * aqui vendria nuestro codigo * endprovide. END-OF-SELECTION.0006. * Field catalog DATA gt_fieldcat TYPE slis_t_fieldcat_alv. *&---------------------------------------------------------------------* *& Form LECTURA_INSERCCION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-. PERFORM write. DATA: i_aux LIKE zstructuretest OCCURS 0 WITH HEADER LINE. i_aux-personal_area = p0001-werks. INFOTYPES:0000. INITIALIZATION.0001.0002. DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid. i_aux-personal_number = p0001-pernr. TABLES:pernr. * Custom container instance reference DATA gr_ccontainer TYPE REF TO cl_gui_custom_container. 14 . i_aux-employee_subgroup. i_aux-country = p0006-land1. WRITE: / i_aux-personal_number. APPEND i_aux.Libretilla MarcosJ Miguel Jesús Fernández i_aux-employee_group = p0001-persg. i_aux-payroll_area = p0001-abkrs. i_aux-payroll_area. " WRITE *&---------------------------------------------------------------------* *& Form DISPLAY_ALV_FUNCIONES *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * <--P_GT_FIELDCAT text * <--P_GS_LAYOUT text *----------------------------------------------------------------------* form DISPLAY_ALV_FUNCIONES. i_aux-street_&_housen.p2 text *----------------------------------------------------------------------* FORM write . i_aux-payroll_area = p0009-bkont. i_aux-bank_key. i_aux-bank_account. i_aux-organizational_key. 15 . i_aux-last_name = p0002-nachn. i_aux-street_&_housen = p0006-stras. ENDLOOP. i_aux-company_code. DELETE ADJACENT DUPLICATES FROM I_AUX. i_aux-last_name. i_aux-first_name = p0002-vorna. i_aux-employee_subgroup = p0001-persk. i_aux-country. ENDLOOP. i_aux-bank_key = p0009-bankl. ENDFORM. " LECTURA_INSERCCION *&---------------------------------------------------------------------* *& Form WRITE *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-. LOOP AT i_aux. * * tables p_gt_fieldcat using p_gs_layout. i_aux-payroll_area. i_aux-city. i_aux-organizational_key = p0001-vdsk1. i_aux-employee_group. i_aux-city = p0006-ort01. i_aux-first_name. i_aux-bank_account = p0009-bankn. i_aux-personal_area. ENDFORM. * * * * * * CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING I_PROGRAM_NAME = I_INTERNAL_TABNAME = i_structure_name = 'zstructuretest' I_CLIENT_NEVER_DISPLAY = 'X' I_INCLNAME = I_BYPASSING_BUFFER = I_BUFFER_ACTIVE = CHANGING ct_fieldcat = gt_fieldcat[] EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING 16 . endform. gs_layout-grid_title = 'ALV report'.Libretilla MarcosJ Miguel Jesús Fernández * PERFORM prepare_field_catalog2 tables p_gt_fieldcat. * PERFORM prepare_layout2 PERFORM prepare_layout. " PREPARE_LAYOUT *&---------------------------------------------------------------------* *& Form SHOW_ALV *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_P_GT_FIELDCAT text * -->P_P_GS_LAYOUT text *----------------------------------------------------------------------* form SHOW_ALV. * * PERFORM show_alv2 tables p_gt_fieldcat using p_gs_layout. CHANGING p_gs_layout. PERFORM prepare_field_catalog. form PREPARE_FIELD_CATALOG. PERFORM show_alv. form PREPARE_LAYOUT. " PREPARE_FIELD_CATALOG *&---------------------------------------------------------------------* *& Form PREPARE_LAYOUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * <--P_P_GS_LAYOUT text *----------------------------------------------------------------------* *form PREPARE_LAYOUT changing p_gs_layout. " DISPLAY_ALV_FUNCIONES *&---------------------------------------------------------------------* *& Form PREPARE_FIELD_CATALOG *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * <--P_P_GT_FIELDCAT text *----------------------------------------------------------------------* *form PREPARE_FIELD_CATALOG tables p_gt_fieldcat. endform. endform. * * gs_layout-zebra = 'X'. gs_layout-smalltitle = 'X'. Miguel Jesús Fernández = gs_layout = gt_fieldcat = i_aux = 1 = 2.Libretilla MarcosJ is_layout it_fieldcat TABLES t_outtab EXCEPTIONS program_error OTHERS endform. " SHOW_ALV 17 .