*&---------------------------------------------------------------------* *& Report ZAHM_ALV_DEMO *& *&---------------------------------------------------------------------* *&Descripcion: Mostrar diferentes formas de crear un ALVGrid. *&Programo...: Armando H Mateu. *&Fecha......: 18/08/2015. *&---------------------------------------------------------------------* REPORT ZAHM_ALV_DEMO. include ZAHM_ALV_DEMO_TOP. include ZAHM_ALV_DEMO_SUB. START-OF-SELECTION. PERFORM obtener_datos. PERFORM crear_cabecera. PERFORM crear_catalogo. PERFORM mostrar_cabecera. PERFORM mostrar_reporte.
*&---------------------------------------------------------------------* *& Include ZAHM_ALV_DEMO_TOP *&---------------------------------------------------------------------* *====================================================================== * Tablas * *====================================================================== TABLES: spfli. *====================================================================== * TYPES-POOLS * *====================================================================== TYPE-POOLS: slis. DATA: gt_header TYPE slis_t_listheader, " Tabla con el Título y el Logo wa_header TYPE slis_listheader. " Work Area con el Título "types: slis_t_fieldcat_alv type slis_fieldcat_alv occurs 1. DATA: tg_fieldcat TYPE slis_t_fieldcat_alv, sg_fieldcat TYPE slis_fieldcat_alv, sg_layout TYPE slis_layout_alv. *====================================================================== * TYPES * *====================================================================== TYPES: BEGIN OF ty_spfli, carrid TYPE spfli-carrid, connid TYPE spfli-connid, cityfrom TYPE spfli-cityfrom, END OF ty_spfli. *====================================================================== * TABLAS INTERNAS * *====================================================================== DATA: it_spfli TYPE STANDARD TABLE OF ty_spfli. *====================================================================== * WORK AREA * *====================================================================== *====================================================================== * Variables Globales * *====================================================================== Data: gv_posicion length 2 type n. *====================================================================== * SELECT-OPTIONS AND PARAMETERS * *====================================================================== SELECTION-SCREEN BEGIN OF BLOCK ini1 WITH FRAME TITLE text-001. *SELECT-OPTIONS: s_carrid FOR spfli-carrid OBLIGATORY. PARAMETERS p_carrid TYPE spfli-carrid OBLIGATORY. SELECTION-SCREEN END OF BLOCK ini1.
*&---------------------------------------------------------------------* *& Include ZAHM_ALV_DEMO_SUB *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Form crear_cabecera *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM crear_cabecera . DATA: wa_header TYPE slis_listheader. wa_header-typ = 'H'. wa_header-info = 'Creacion de un ALV Simple'. APPEND wa_header TO gt_header. CLEAR wa_header. wa_header-typ = 'S'. wa_header-key = 'Ejecución:'. CONCATENATE sy-uname(12) ' // ' sy-datum+6(2) '.' sy-datum+4(2) '.' sy-datum(4) ' // ' sy-uzeit(2) ':' sy-uzeit+2(2) ':' sy-uzeit+4(2) INTO wa_header-info. APPEND wa_header TO gt_header. ENDFORM. " crear_cabecera *&---------------------------------------------------------------------* *& Form mostrar_cabecera *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM mostrar_cabecera . * Pasa a la cabecera el logo CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING * I_LOGO = 'ENJOYSAP_LOGO' "Logo it_list_commentary = gt_header. ENDFORM. " mostrar_cabecera *&---------------------------------------------------------------------* *& Form obtener_datos *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM obtener_datos . SELECT carrid connid cityfrom INTO TABLE it_spfli FROM spfli WHERE carrid = p_carrid. ENDFORM. " obtener_datos *&---------------------------------------------------------------------* *& Form crear_catalogo *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM crear_catalogo . CLEAR tg_fieldcat[]. CLEAR gv_posicion. ** ADD 1 TO gv_posicion. CLEAR sg_fieldcat. sg_fieldcat-fieldname = 'CARRID'. sg_fieldcat-tabname = 'it_spfli'. sg_fieldcat-seltext_l = 'ID'. sg_fieldcat-col_pos = gv_posicion. APPEND sg_fieldcat TO tg_fieldcat. ADD 1 TO gv_posicion. CLEAR sg_fieldcat. sg_fieldcat-fieldname = 'CONNID'. sg_fieldcat-tabname = 'it_spfli'. sg_fieldcat-seltext_l = 'Numero de vuelo'. sg_fieldcat-col_pos = gv_posicion. APPEND sg_fieldcat TO tg_fieldcat. ADD 1 TO gv_posicion. CLEAR sg_fieldcat. sg_fieldcat-fieldname = 'CITYFROM'. sg_fieldcat-tabname = 'it_spfli'. sg_fieldcat-seltext_l = 'Ciudad Salida'. sg_fieldcat-col_pos = gv_posicion. APPEND sg_fieldcat TO tg_fieldcat. ENDFORM. " crear_catalogo *&---------------------------------------------------------------------* *& Form Mostrar_reporte *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM mostrar_reporte . sg_layout-colwidth_optimize = 'X'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING is_layout = sg_layout it_fieldcat = tg_fieldcat[] i_callback_program = sy-repid i_callback_top_of_page = 'MOSTRAR_CABECERA' TABLES t_outtab = it_spfli[] EXCEPTIONS program_error = 1 OTHERS = 2. ENDFORM. " Mostrar_reporte
Resultados:
No hay comentarios:
Publicar un comentario