PDA

Ver la Versión Completa : Exportar a Excell


Skadeour
24/05/06, 16:11:12
Hola, sabeis si hay alguna funcion en abap que exporte 1 tabla interna a Excell PERO que permita tener campos numericos en dicha tabla.
Un saludo

franlp2000
25/05/06, 07:21:22
Hola.
No tengo esa función pero se me ocurre algo que a lo mejor te sirve.
lo guardas todo en una tabla plana tipo:

DATA: BEGIN OF it_salida OCCURS 0,
fichero(2000),
END OF it_salida,
w_it_salida LIKE ztabla.
y utilizas la función:

CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = fich_out
filetype = 'ASC'
TABLES
data_tab = it_salida
EXCEPTIONS
OTHERS = 8.
IF sy-subrc NE 0.
WRITE: / ' ** ERROR al grabar el fichero', filename.
EXIT.
ENDIF.
cuando tengas que recuperar este fichero plano para hacer el tratamiento que quieras solo tienes que igualar esta tabla plana con una tabla que te definas tu y que contenga los campos que has guardado. Esto es:

* Tabla interna para la cabecera de tipo C.
DATA: BEGIN OF it_cabecera_texto OCCURS 0,
stype(1) TYPE c VALUE 1,
bsart(4) TYPE c,
lifnr(10) TYPE c,
bedat(8) TYPE c,
ekorg(4) TYPE c,
ekgrp(3) TYPE c,
werks(4) TYPE c,
knttp(1) TYPE c,
kdatb(8) TYPE c,
kdate(8) TYPE c,
ktwrt(18) TYPE c,
ebeln(10) TYPE c,
zterm(4) TYPE c,
END OF it_cabecera_texto.

it_cabecera_texto = w_it_salida.
Y aquí ya tienes todos los campos diferenciados.

Espero que te aclare algo, si tienes cualquier duda pregunta.

saludos

Skadeour
25/05/06, 08:45:31
estamos en las mismas, yo quiero hacer una funcion excell dinamicamente independientemente de los campos que tenga valga para todas las tablas, sin saber k estructura tiene, es decir tu le pasas 1 tabla, y k te genere el excell independientemente que tenga campos numericos o no

carlosalcala
29/05/06, 09:39:52
Hola Skadeour, para subir los datos utlizo los objectos ole de excel y vas volcando los datos dnd te interesa y en el formato que quieras con un loop,
seria algo asi,
CREATE OBJECT g_xlapp 'excel.application'." no flush.
CALL METHOD OF g_xlapp 'Workbooks' = g_workbook."no flush.
CALL METHOD OF g_workbook 'Add'.
CALL METHOD OF g_xlapp 'Worksheets' = g_sheet "no flush
EXPORTING #1 = 1 .
CALL METHOD OF g_sheet 'Activate'.
CALL METHOD OF g_sheet 'cells' = g_cell. "no flush.
posiciona la celda
CALL METHOD OF g_sheet 'Cells' = g_cell no flush
EXPORTING #1 = p_fila
#2 = p_columna.
le das el valor
SET PROPERTY OF g_cell 'Value' = p_valor no flush.
y el formato
CALL METHOD OF g_cell 'Font' = g_fuente no flush.
SET PROPERTY OF g_fuente 'Name' = p_fuente no flush.
SET PROPERTY OF g_fuente 'Bold' = 'True' no flush.
SET PROPERTY OF g_fuente 'Size' = p_tamanio no flush.

if not p_color_cell is initial.
CALL METHOD OF g_cell 'Interior' = g_interior no flush.
SET PROPERTY OF g_interior 'ColorIndex' = p_color_cell no flush.
endif.

if not p_borde is initial.
CALL METHOD OF g_cell 'Borders' = g_border no flush.
SET PROPERTY OF g_border 'LineStyle' = 1 no flush.
endif.

luego para traer los datos prueba con esta función, aunque tengas que indicar los valores máximos de columna y fila pon algun valor el cual no se vaya a llegar,es bastante rápida comparadas con otras

CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_file
i_begin_col = p_scol
i_begin_row = p_srow
i_end_col = p_ecol
i_end_row = p_erow
TABLES
intern = lt_intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.

IF sy-subrc <> 0.

FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE:/ 'Error cargando el archivo'.
EXIT.

Espero que te sea de ayuda, Un saludo