PDA

Ver la Versión Completa : Ayuda ALV con Columnas Dinamicas


dchauca
03/05/07, 17:33:01
Hola ..tengo un problema a la hora de crear mi ALV me piden que las columnas a mostrar varien de acuerdo al rango 'centro' ingresado en el select-options, es decir si en el select va desde el 'centro2' al 'centro4' .. muestre las columnas 'centro2' ,'centro3' y 'centro4' respectivamente... :confused:
Desde ya muchas gracias por su ayuda...

Mauricio Hidalgo
03/05/07, 19:45:45
DATA LT_FIELDCATALOG type LVC_T_FCAT. "tabla catalogo
DATA LS_FIELDCATALOG type LVC_S_FCAT. "area de trabajo
DATA new_table type ref to data.

*LLenas la tabla catalogo con los centros involucrados

*Luego creas una tabla interna en funcion de este catalogo.

call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = lt_fieldcatalog
importing
ep_table = new_table
exceptions
generate_subpool_dir_full = 1
others = 2.

*Luego viene la tarea de llenar la tabla de datos new_table

* estableces la variables con la cuales llenaras la tabla del alv en este.
* caso es <l_table>

ASSIGN new_table->* TO <l_table>.
CREATE DATA new_line LIKE LINE OF <l_table>.
ASSIGN new_line->* TO <l_line>.

* Poblar cada campo del registro con
ASSIGN COMPONENT <nombre_campo|posicion> OF STRUCTURE <l_line> TO <l_field>.
<l_field> = 'algun dato'.
..
.
.
*Insertar el registro
INSERT <l_line> INTO TABLE <l_table>.

*y finalmente en el alv
CALL METHOD oAlv->set_table_for_first_display
EXPORTING
is_layout = gs_layout
it_toolbar_excluding = pt_exclude
is_variant = g_variant
CHANGING
it_fieldcatalog = lt_fieldcatalog
it_outtab = <l_table>.


Más ayuda puedes revisar en
https://www.sdn.sap.com/irj/sdn/advancedsearch?QueryString=%64%79%6E%61%6D%69%63%20%74%61%62%6C%65%20%41%4C%56&SearchPluginName=sdn_forums&SelectedCustomProps=resourcetype(value=sdn_forum)