Ver Mensaje Individual
  #3  
Viejo 25/01/10, 18:21:29
fcb_richard fcb_richard is offline
Junior Member
 
Fecha de Ingreso: feb 2008
Localización: Venezuela
Mensajes: 4
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.

Úlima edición por fcb_richard fecha: 25/01/10 a las 18:24:06.
Responder Con Cita