jueves, 3 de noviembre de 2016

Clases para trabajar con ficheros en SAP

Listado de Clases y sus correspondientes Métodos para subir y bajar archivos de diferentes tipos desde o hacia la computadora.
Aporte de Yesica Castellano.

cl_gui_frontend_services=>file_save_dialog
Muestra un popup donde se puede seleccionar dónde guardar un fichero
data: filename type string,
      path     type string,
      fullpath type string.

cl_gui_frontend_services=>file_save_dialog(
  changing
    filename             = filename
    path                 = path
    fullpath             = fullpath ).

cl_gui_frontend_services=>gui_download
Graba un fichero en el PC local
cl_gui_frontend_services=>gui_download(
  exporting
    filename                  = fullpath
    filetype                  = 'BIN'
  changing
    data_tab                  = binary_tab ).










cl_gui_frontend_services=>file_open_dialog
Abre un popup donde seleccionar un fichero a cargar
data retfiletable type filetable.
data retrc type sysubrc.
data retuseraction type i.
 
at selection-screen on value-request for filename.
 
 call method cl_gui_frontend_services=>file_open_dialog
  exporting
    multiselection    = abap_false
    file_filter       = '*.xls'
    default_extension = 'xls'
  changing
    file_table        = retfiletable
    rc                = retrc
    user_action       = retuseraction.
read table retfiletable into filename index 1.

cl_gui_frontend_services=>gui_upload
Lee un fichero del PC local
data l_filename type string.
l_filename = filename.
call method cl_gui_frontend_services=>gui_upload
  exporting
    filetype   = 'BIN'
    filename   = l_filename
  importing
    filelength = input_length
  changing
    data_tab   = binary_tab.

cl_gui_frontend_services=>directory_browse
Recupera la lista de ficheros dentro de un directorio
CALL METHOD cl_gui_frontend_services=>directory_browse
  EXPORTING
    window_title         = 'Selecciona un directorio'(090).
    initial_folder       = 'C:\'
  CHANGING
    selected_folder      = l_s_fol
  EXCEPTIONS
    cntl_error           = 1
    error_no_gui         = 2
    not_supported_by_gui = 3
    OTHERS               = 4.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.


cl_gui_frontend_services=>get_computer_name
Recupera el nombre del PC en SAP
data: l_hostname type string.
CALL METHOD cl_gui_frontend_services=>get_computer_name
  CHANGING
    computer_name        = l_hostname
*  EXCEPTIONS
*    CNTL_ERROR           = 1
*    ERROR_NO_GUI         = 2
*    NOT_SUPPORTED_BY_GUI = 3
*    others               = 4. 
 
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

cl_gui_frontend_services=>clipboard_export
Exporta el contenido de una tabla interna al portapapeles.
    DATA rc TYPE i.
 
    CALL METHOD cl_gui_frontend_services=>clipboard_export
      IMPORTING
        data = source
      CHANGING
        rc   = rc.






No hay comentarios.:

Publicar un comentario