Ver Mensaje Individual
  #4  
Viejo 06/04/16, 15:44:11
Avatar de Jesicka_21
Jesicka_21 Jesicka_21 is offline
Junior Member
 
Fecha de Ingreso: sep 2013
Mensajes: 15
Formato txt con un nombre predeterminado

Con respecto a este tema, lo que se me ocurriría es que al momento de seleccionar el botón, realices lo siguiente.

Llamar al siguiente método:

CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
window_title = 'Seleccionar carpeta'
initial_folder = 'C:\Users\'
CHANGING
selected_folder = gv_directorio
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3.

Te va a mostrar el directorio desde la ubicación que le pasaste en INITIAL_FOLDER.
Cuando selecciones la carpeta, vas a tener que realizar un concatenate con el nombre predeterminado que vas a usar de la siguiente forma:

IF gv_directorio IS NOT INITIAL.

CONCATENATE gv_directorio
'\'
gv_nombre_predeterminado
'.txt'
INTO gv_directorio.

ENDIF.

Luego llamar a la función GUI_DOWNLOAD de la siguiente manera:

IF gv_directorio IS NOT INITIAL.

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = gv_directorio
TABLES
data_tab = gt_tabla
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.

ENDIF.


El código entonces te quedaría de la siguiente manera:

DATA: gv_directorio TYPE string.

CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
window_title = 'Seleccionar carpeta'
initial_folder = 'C:\Users\'
CHANGING
selected_folder = gv_directorio
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3.

IF gv_directorio IS NOT INITIAL.

CONCATENATE gv_directorio
'\'
gv_nombre_predeterminado
'.txt'
INTO gv_directorio.

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = gv_directorio
TABLES
data_tab = gt_tabla
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.

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.

ENDIF.

Espero que te sirva, sino cualquier cosa avisame y lo vemos.
__________________
Saludos!,

Jess.

"...Puedes llegar a cualquier parte, siempre y cuando andes lo suficiente..."
Responder Con Cita