PDA

Ver la Versión Completa : Ayuda con GUI_DOWNLOAD


Karla V.
04/03/17, 13:29:18
Hola, estoy usando la funcion GUI_DOWNLOAD pero necesito que el usuario me indique la ruta y nombre del archivo, puedo hacerlo con esa miama funcion? porque intente pedirlo con la funcion F4_DXFILENAME_TOPRECURSION pero a pesar de que e pongo el parametro filemask = '*.txt' igual me muestra todos los archivos en el explorer de todas las extensiones y queria que solo me filtrara los archivos .txt, alguna idea por favor? :confused:

calanis
05/03/17, 12:37:31
Buenas Karla!

El tema es que si deseas filtrar por una extensión de Archivo te conviene usar otro método de la clase cl_gui_frontend_services

Los metodos que te conviene utilizar son los siguientes:

file_open_dialog -->Popup de Abrir Archivo
gui_upload -->Subir Archivo


*Parámetro
parameters: p_path type admi_file.


form z_get_path_local_file changing ch_file type admi_file.
constants:
lc_default_extension type string value 'TXT',
lc_file_filter type string value 'Archivo TXT (*.txt)|*.TXT|',
lc_initial_directory type string value 'C:\'.
data: lv_file_filter type string.
data: lt_file_tab type filetable.
data: ls_file_line type file_table.
data: lv_rc type i.

concatenate lc_file_filter
cl_gui_frontend_services=>filetype_text cl_gui_frontend_services=>filetype_all
into lv_file_filter.
*Si no te aparece bien el texto del filtro para TXT
* reemplaza la variable cl_gui_frontend_services=>filetype_text
* por esta constante lc_file_filter
call method cl_gui_frontend_services=>file_open_dialog
exporting
default_extension = lc_default_extension
file_filter = lv_file_filter
initial_directory = lc_initial_directory
multiselection = abap_false
changing
file_table = lt_file_tab
rc = lv_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.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
read table lt_file_tab into ls_file_line index 1.
check sy-subrc = 0.
move ls_file_line-filename to ch_file.
endif.
endform. "z_get_path_local_file


form z_upload_local importing im_file type admi_file.
data: lv_path type string,
lv_name type string,
ls_data type dxrawdata.
lv_path = im_file.

call method cl_gui_frontend_services=>gui_upload
exporting
filename = lv_path
filetype = 'ASC'
* has_field_separator = abap_true "<--Si deseas CSV por TAB
changing
data_tab = gt_data
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 is not initial.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform.

Karla V.
06/03/17, 14:43:05
Hola, muchas gracias, si me funcionò! y para colocarle el nombre del archivo por defecto como lo hago? en que paràmetro lo coloco?

Karla V.
06/03/17, 16:03:25
Listo! ya vi donde era, es el paràmetro:
default_filename = '*'
en el exporting