MUNDOSAP

Regresar   MUNDOSAP > DESARROLLO > Programación ABAP IV
Nombre de Usuario
Contraseña
Home Descargas Registrar FAQ Miembros Calendario Buscar Temas de Hoy Marcar Foros Como Leídos




 
Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Viejo 08/07/09, 16:14:28
jeanficetola jeanficetola is offline
Member
 
Fecha de Ingreso: sep 2007
Localización: Venezuela
Mensajes: 64
Como Cargar un Archivo en Excel a una Tabla Interna en SAP

Buenos Dias,

Por favor , alguien tendra un codigo ejemplo de como cargar un archivo en excel a una tabla interna en SAP


gracias y saludos
__________________
Jean Carlos Hernandez Ficetola

Consultor ABAP
INFOGESA S.A , Venezuela
Responder Con Cita
  #2  
Viejo 08/07/09, 16:24:54
patrigir patrigir is offline
Junior Member
 
Fecha de Ingreso: oct 2007
Mensajes: 2
REPORT ZCARGA_CONV_CUENTAS NO STANDARD PAGE HEADING LINE-SIZE 110.


************************************************************************
* Definición variables y tablas
************************************************************************
DATA i_dynfields LIKE dynpread OCCURS 1 WITH HEADER LINE.

DATA: BEGIN OF i_table OCCURS 0,
l_line(100) type c.
DATA: END OF i_table.

************************************************************************
* Definition of parameters and ranges of selection.
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME title text-001.

PARAMETERS: p_file type localfile OBLIGATORY.

SELECTION-SCREEN END OF BLOCK block1.



************************************************************************
* AT SELECTION-SCREEN
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
*subroutine that allows to look for the wished file
PERFORM seleccionar_fichero USING p_file.



************************************************************************
* START-OF-SELECTION. *
************************************************************************
START-OF-SELECTION.

* Carga de datos de la tabla con origen en fichero
perform f_carga_fichero tables i_table
using p_file.

* El contenido de la tabla se pone en la tabla ZPAT_PROVA
perform f_actualizar_tabla tables i_table.





*&---------------------------------------------------------------------*
*& Form SELECCIONAR_FICHERO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_FILE text
*----------------------------------------------------------------------*
FORM SELECCIONAR_FICHERO USING P_P_FILE.

CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_p_file.

ENDFORM. " SELECCIONAR_FICHERO
*&---------------------------------------------------------------------*
*& Form F_CARGA_FICHERO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_I_TABLE text
* -->P_P_FILE text
*----------------------------------------------------------------------*
FORM F_CARGA_FICHERO TABLES i_table STRUCTURE i_table
USING P_P_FILE.

data: v_files type string.

v_files = p_p_file.

refresh i_table.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_files
filetype = 'ASC'
TABLES
data_tab = i_table
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.

if sy-subrc ne 0.
write: /'Not good'.
endif.

ENDFORM. " F_CARGA_FICHERO
*&---------------------------------------------------------------------*
*& Form F_ACTUALIZAR_TABLA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_I_TABLE_L_LINE text
*----------------------------------------------------------------------*
FORM F_ACTUALIZAR_TABLA TABLES P_I_TABLE STRUCTURE i_table.

data: C_TAB TYPE C VALUE cl_abap_char_utilities=>horizontal_tab.


DATA: I_TAB TYPE ZCONV_CUENTAS,
l_tabix type sy-tabix.


loop at P_I_TABLE.

l_tabix = sy-tabix.
split p_i_table-l_line at c_tab into
i_tab-zpcvu
i_tab-ztext
i_tab-zcaes.

i_tab-mandt = sy-mandt.

modify zconv_cuentas from i_tab.

if sy-subrc ne 0.
exit.
endif.

endloop.

ENDFORM. " F_ACTUALIZAR_TABLA
Responder Con Cita
  #3  
Viejo 08/07/09, 16:26:00
patrigir patrigir is offline
Junior Member
 
Fecha de Ingreso: oct 2007
Mensajes: 2
el archivo excel pásalo a .txt !! me olvidé
Responder Con Cita
  #4  
Viejo 08/07/09, 17:14:07
jeanficetola jeanficetola is offline
Member
 
Fecha de Ingreso: sep 2007
Localización: Venezuela
Mensajes: 64
Estoy trabajando con Tecnologia OLE

Tendras un codigo con tecnologia OLE

gracias
__________________
Jean Carlos Hernandez Ficetola

Consultor ABAP
INFOGESA S.A , Venezuela
Responder Con Cita
  #5  
Viejo 08/07/09, 17:21:10
Avatar de DavidXD_XD
DavidXD_XD DavidXD_XD is offline
Moderator
 
Fecha de Ingreso: ago 2006
Localización: Lima - Perú
Mensajes: 1,251
Hola, puedes usar la funcion ALSM_EXCEL_TO_INTERNAL_TABLE y la carga lo hago de la siguiente forma:

Se cargara los datos del excel dentro de la tabla interna me->gt_itab, xsiacaso la estructura de la tabla interna (tab_itab) no tiene importancia, puesto que con la rutina del metodo TRANSFORM_DATA se adapta a cualquier estructura, luego los metodos los puedes reemplazar por FORM normales


Espero te pueda ayudar
__________________
David Carballido Córdova
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Reglas de Mensajes
no puedes crear nuevos temas
no puedes responder temas
no puedes adjuntar archivos
no puedes editar tus mensajes

El código vB está On
Las caritas están On
Código [IMG] está On
Código HTML está Off
Saltar a Foro


Husos Horarios son GMT. La hora en este momento es 19:03:43.


www.mundosap.com 2006 - Spain
software crm, crm on demand, software call center, crm act, crm solutions, crm gratis, crm web