Cargar un fichero EXCEL a un TXT en SAP

Hola,

necesito pasar un fichero EXCEL a un fichero plano TXT en SAP para despues pasarlo a una estructura y trabajarlo.

He utilzado varias maneras, pero de momento ningún me funciona:

*** CALL FUNCTION ‘ALSM_EXCEL_TO_INTERNAL_TABLE’
*** EXPORTING
*** filename = LV_FILENAME
****COLUMNA DONDE SE EMPIEZA A BUSCAR DATOS
*** i_begin_col = 1
****RENGLÓN DONDE SE EMPIEZA A BUSCAR DATOS
*** i_begin_row = 4
****COLUMNA DONDE TERMINA DE BUSCAR DATOS
*** i_end_col = 7
****RENGLÓN DONDE TERMINA DE BUSCAR DATOS
*** i_end_row = 200
*** TABLES
****TABLA INTERNA DONDE ME REGRESA LOS DATOS
*** intern = it_excel
*** EXCEPTIONS
*** inconsistent_parameters = 1
*** upload_ole = 2
*** OTHERS = 3.

Otra

*** CALL FUNCTION ‘TEXT_CONVERT_XLS_TO_SAP’
*** EXPORTING
*** i_line_header = ‘X’ "Si dejan este campo te quita una linea de tu archivo como header
*** i_tab_raw_data = it_raw " WORK TABLE
*** i_filename = LV_FILENAME
*** TABLES
*** i_tab_converted_data = IT_TEXTO "ACTUAL DATA
*** EXCEPTIONS
*** conversion_failed = 1
*** OTHERS = 2.

y la última:

CALL FUNCTION 'GUI_UPLOAD’
EXPORTING
filename = P_P_FILE
TABLES
data_tab = GT_ZPST013.
IF sy-subrc <> 0.

  • Implement suitable error handling here
    ENDIF.

Ninguna obtengo lo que quiero.

Muchas gracias de antemano.

Saludos
Luis

A ver si se entiende.
Subis un XLS, queres pasarlo a TXT y procesarlo en SAP? En dónde? Con qué programa?

1 me gusta

Te dejo uno que utilizo como base para leer un Excel y manipularlo mira el ejemplo que te dejo …
El Excel debe contener p.e:
Nombre | ApPaterno | ApMaterno
Armando HDEZ Mateu

Código:

*&---------------------------------------------------------------------*
*& Report  ZAHM_EXCEL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

report  zahm_excel.

types:
      begin of ty_archivo,
        nombre(20) type c,
        ap(20) type c,
        am(20) type c,
      end of ty_archivo.

data: it_archivo type standard table of ty_archivo,
      wa_archivo type ty_archivo.

*&---------------------------------------------------------------------*
*& SCREEN
*&---------------------------------------------------------------------*
selection-screen begin of block b1 with frame title text-001.
parameters:
          p_root type char255.
selection-screen end   of block b1.

at selection-screen on value-request for p_root.
  perform ruta_pc.

start-of-selection.
  perform leer_archivo changing it_archivo.
  loop at it_archivo into wa_archivo.
    write: / 'Nombre: ' ,wa_archivo-nombre, 'apellido', wa_archivo-ap.
  endloop.

*&---------------------------------------------------------------------*
*&      Form  RUTA_PC
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form ruta_pc .
  data: l_ruta type filetable,
        l_file type string,
        l_rc   type i.

  call method cl_gui_frontend_services=>file_open_dialog
    exporting
      window_title            = 'Ruta de Archivo'
    changing
      file_table              = l_ruta
      rc                      = l_rc
    exceptions
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      not_supported_by_gui    = 4
      others                  = 5.
  if sy-subrc = 0.
    read table l_ruta into l_file index 1.
    p_root = l_file.
  endif.
endform.                    " RUTA_PC
*&---------------------------------------------------------------------*
*&      Form  LEER_ARCHIVO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form leer_archivo changing p_tabla type standard table.
  type-pools: truxs.
  data:
    tl_raw       type truxs_t_text_data,
    vl_filename  type rlgrap-filename.

  vl_filename = p_root.

  call function 'TEXT_CONVERT_XLS_TO_SAP'
    exporting
      i_line_header        = 'X'
      i_tab_raw_data       = tl_raw
      i_filename           = vl_filename
    tables
      i_tab_converted_data = p_tabla[]
    exceptions
      conversion_failed    = 1
      others               = 2.

  if sy-subrc <> 0.
    "
  endif.

endform.                    " LEER_ARCHIVO

Saludos!,
Armando Mateu.

1 me gusta

Muchas gracias Armando!!!

ya lo he probado y me funciona muy bien!!! Un placer conocerte!!!

Saludos
Luis

1 me gusta

Este tema se cerró automáticamente 7 días después del último post. No se permiten nuevas respuestas.