ā2010 Sep 10 10:01 AM
Hallo,
i have a problem to transfer docx, xlsx and so on with gui_upload.
With open dataset it worked, but i will transfer files(docx, xlsx ..) from frontend with gui_upload. It dosn“t work.
Have anyone a idea?
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = iv_path
filetype = 'BIN'
HAS_FIELD_SEPARATOR = SPACE
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = SPACE
codepage = lv_cp2
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
VIRUS_SCAN_PROFILE =
IMPORTING
filelength = lv_filelength
HEADER =
CHANGING
data_tab = lt_line
Thanks.
ā2010 Sep 10 1:50 PM
Dear Harryatworld,
Try with different variations for 'FILETYPE' i.e (BIN,ASC,DAT) and 'HAS_FIELD_SEPARATOR' parameter.
The differences will be available in the method documentation.
I had a similar requirement to read from a xlsx file in my project. The below code helped in my case.It reads both xls and xlsx filetypes.
types: begin of ty_output,
sno(5) type c,
obj_type(20) type c,
out_level(2) type c,
out_num(20) type c,
id(24) type c,
desc(40) type c,
network(12) type c,
netprof(7) type c,
nettype(4) type c,
wbs_net(24) type c,
ctrl_key(4) type c,
wbs_elem(24) type c,
dur(15) type c,
pred type string,
end of ty_output.
data: it_output type standard table of ty_output.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = l_v_filename
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = it_output
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
.
Regards,
Rijuraj
ā2010 Sep 10 1:50 PM
Dear Harryatworld,
Try with different variations for 'FILETYPE' i.e (BIN,ASC,DAT) and 'HAS_FIELD_SEPARATOR' parameter.
The differences will be available in the method documentation.
I had a similar requirement to read from a xlsx file in my project. The below code helped in my case.It reads both xls and xlsx filetypes.
types: begin of ty_output,
sno(5) type c,
obj_type(20) type c,
out_level(2) type c,
out_num(20) type c,
id(24) type c,
desc(40) type c,
network(12) type c,
netprof(7) type c,
nettype(4) type c,
wbs_net(24) type c,
ctrl_key(4) type c,
wbs_elem(24) type c,
dur(15) type c,
pred type string,
end of ty_output.
data: it_output type standard table of ty_output.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = l_v_filename
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = it_output
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
.
Regards,
Rijuraj
ā2010 Sep 14 6:24 AM