Encabezado Columnas ALV

Colapsar
X
 
  • Tiempo
  • Mostrar
Limpiar Todo
nuevos mensajes
  • Rodolfo SAP
    Member
    • jun
    • 89

    #1

    Encabezado Columnas ALV

    Buenas Tardes.

    Estimados compañeros tengo un reporte en ALV Orientado Objetos muy bonito y todo pero queria consultar con ustedes si hay alguna manera de yo poder manipular el encabezado de la columna, ejemplo 4 de mis columnas utilizan el mismo tipo de dato entonces las columnas se repiten algo asi.

    | Importe ML | Importe ML | Importe ML | Importe ML |

    Y lo que necesito es

    | Imp Ene | Imp Feb | Importe Mar | Importe Abr |

    Muchas gracias por su tiempo y espero me puedan dar algunos comentarios.

  • Neo_25
    Member
    • jun
    • 51

    #2
    Justo después de hacer el: CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    recorre el catálogo:

    * FIELD-SYMBOLS: <fs_catalogo> TYPE lvc_s_fcat.

    * CASE <fs_catalogo>-col_pos. "<fs_catalogo>-fieldname
    * WHEN '1' OR '2' OR '8' OR '10'.
    * WHEN 'BUKRS' OR 'BELNR' OR 'DMBTR' OR 'WRBTR'.

    * ----FORMA 1

    * <fs_catalogo>-scrtext_s = text-001. "texto de la columna
    * <fs_catalogo>-scrtext_l = text-001.
    * <fs_catalogo>-scrtext_m = text-001.
    * ---- FIN FORMA 1

    * ----FORMA 2
    * <fs_catalogo>-reptext = text-001.
    * ----FIN FORMA 2

    * ENDCASE.

    Creo q con la forma 2 ya lo haces con una única línea.

    Ya dirás si te sirve

    Comentario

    • fcb_richard
      Junior Member
      • feb
      • 4

      #3
      Buenas tardes Rodolfo SAP,

      Aquí te anexo un código de AVL OO, para que puedas uitilzar cabecera, nombre de columnas y ademas activar las funciones básicas del ALV OO.

      *----------------------------------------------------------------------*
      * ESTRUCTURAS *
      *----------------------------------------------------------------------*
      data:
      begin of wa_alv,
      budat type bkpf-budat, "Fecha Contabilización.
      f_ini type bkpf-xblnr, "Factura Inicial.
      f_fin type bkpf-xblnr, "Factura Final.
      monto type dfkkop-betrh, "Monto.
      belnr type dfkkop-opbel, "No. Documento.
      asunt type char30,
      end of wa_alv.

      *----------------------------------------------------------------------*
      * DATA ALV OBJECT *
      *----------------------------------------------------------------------*
      data:
      gr_table type ref to cl_salv_table,
      gr_functions type ref to cl_salv_functions,
      gr_columns type ref to cl_salv_columns_table,
      gr_column type ref to cl_salv_column_table,
      gr_agg type ref to cl_salv_aggregations,
      gr_sorts type ref to cl_salv_sorts,
      lo_header type ref to cl_salv_form_layout_grid,
      lo_h_label type ref to cl_salv_form_label,
      lo_h_flow type ref to cl_salv_form_layout_flow.

      data:
      color type lvc_s_colo.

      *----------------------------------------------------------------------*
      * CLASS lcl_report DEFINITION *
      *----------------------------------------------------------------------*
      class lcl_report definition.
      public section.
      methods:
      generate_output.
      endclass. "lcl_report DEFINITION.
      *----------------------------------------------------------------------*
      * CLASS lcl_report IMPLEMENTATION *
      *----------------------------------------------------------------------*
      class lcl_report implementation.
      method generate_output.
      try.
      cl_salv_table=>factory( importing r_salv_table = gr_table
      changing t_table = it_alv ).
      catch cx_salv_msg.
      endtry.

      gr_functions = gr_table->get_functions( ).
      gr_functions->set_all( abap_true ).

      * Objeto de Cabecera.
      create object lo_header.

      * Información del Título.
      lo_h_label = lo_header->create_label( row = 1 column = 2 ).
      lo_h_label->set_text( 'UNIVERSIDAD METROPOLITANA' ).

      * Información de Fecha Desde.
      lo_h_label = lo_header->create_label( row = 2 column = 1 ).
      lo_h_label->set_text( 'Fecha Desde:' ).
      lo_h_flow = lo_header->create_flow( row = 2 column = 2 ).
      lo_h_flow->create_text( text = s_budat-low ).

      * Información de Fecha Hasta.
      lo_h_label = lo_header->create_label( row = 3 column = 1 ).
      lo_h_label->set_text( 'Fecha Hasta:' ).
      lo_h_flow = lo_header->create_flow( row = 3 column = 2 ).
      lo_h_flow->create_text( text = s_budat-high ).

      gr_table->set_top_of_list( lo_header ).
      gr_table->set_top_of_list_print( lo_header ).

      try.
      gr_columns = gr_table->get_columns( ).
      gr_column ?= gr_columns->get_column( 'BUDAT' ).
      gr_column->set_long_text( 'Fecha' ).
      gr_column->set_medium_text( 'Fecha' ).
      gr_column->set_short_text( 'Fecha' ).

      gr_columns = gr_table->get_columns( ).
      gr_column ?= gr_columns->get_column( 'F_INI' ).
      gr_column->set_long_text( 'Factura Inicial' ).
      gr_column->set_medium_text( 'Fact. Inicial' ).
      gr_column->set_short_text( 'F. Inicial' ).

      gr_columns = gr_table->get_columns( ).
      gr_column ?= gr_columns->get_column( 'F_FIN' ).
      gr_column->set_long_text( 'Fctura Final' ).
      gr_column->set_medium_text( 'Fact. Final' ).
      gr_column->set_short_text( 'F. Final' ).

      gr_columns = gr_table->get_columns( ).
      gr_column ?= gr_columns->get_column( 'MONTO' ).
      gr_column->set_long_text( 'Ventas' ).
      gr_column->set_medium_text( 'Ventas' ).
      gr_column->set_short_text( 'Ventas' ).

      gr_columns = gr_table->get_columns( ).
      gr_column ?= gr_columns->get_column( 'BELNR' ).
      gr_column->set_long_text( 'Documento' ).
      gr_column->set_medium_text( 'Documento' ).
      gr_column->set_short_text( 'Documento' ).

      gr_columns = gr_table->get_columns( ).
      gr_column ?= gr_columns->get_column( 'ASUNT' ).
      gr_column->set_long_text( 'Concepto' ).
      gr_column->set_medium_text( 'Concepto' ).
      gr_column->set_short_text( 'Concepto' ).
      catch cx_salv_not_found.
      endtry.

      try.
      gr_sorts = gr_table->get_sorts( ).
      gr_sorts->add_sort( columnname = 'BUDAT' subtotal = abap_true ).

      gr_agg = gr_table->get_aggregations( ).
      gr_agg->add_aggregation( 'MONTO' ).
      catch cx_salv_not_found cx_salv_existing cx_salv_data_error.
      endtry.
      endmethod. "generate_output.
      endclass. "lcl_report IMPLEMENTATION.


      Ademas, tambien le incluyo el SORT y AGGREGATIONS que te permiten ordenar, sumar y subdividir la suma por el orden que desees, Espero te sirva.
      Editado por última vez por fcb_richard; 25/01/2010, 18:24:06.

      Comentario

      • Rodolfo SAP
        Member
        • jun
        • 89

        #4
        Gracias ! ! !

        Gracias por sus respuestas y comentarios me han servido de mucha utilidad.

        Realmente se aprecia y pues si algun dia puedo ayudarlos no duden en mandar un MP.

        Saludos.

        Comentario

        Trabajando...