09-15-2009 2:20 PM
Hello,
We are using GUI_UPLOAD function to upload the data from presentation server by using excel file in binary mode but for some reason the data is not uploaded correctley could any one check the below code and let me know the issue,
once the data is uploaded i am concatenating in byte mode to create an XML message and in XML message i am not getting the data in binary mode could someone help,
DATA: BEGIN OF hex_record,
myhex(1024) TYPE x,
END OF hex_record.
DATA: lw_fname TYPE string,
tab LIKE hex_record OCCURS 1 WITH HEADER LINE,
lw_fname = rlgrap-filename.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lw_fname
filetype = 'BIN'
TABLES
data_tab = tab
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.
*--Append the attachment data to the attachment itab
CLEAR gw_attachment_data.
lw_lines = LINES( gt_attachment_data ).
gw_attachment_data-att_index = lw_lines + 1.
gw_attachment_data-name = l_file.
gw_attachment_data-filetype = l_mime_type.
gw_attachment_data-fileextn = l_extension.
LOOP AT tab.
CONCATENATE gw_attachment_data-datastream tab-myhex
INTO gw_attachment_data-datastream IN BYTE MODE.
ENDLOOP.
APPEND gw_attachment_data TO gt_attachment_data.
Thanks
09-16-2009 1:19 PM
Hi,
Try something like this:
DATA:
size type i.
DATA:
l_xstring type xstring
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = lw_fname "<-- full path!
FILETYPE = 'BIN'
IMPORTING
FILELENGTH = size
CHANGING
DATA_TAB = tab.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
INPUT_LENGTH = size
IMPORTING
BUFFER = l_xstring
TABLES
BINARY_TAB = tab.
* use l_xstring in xml message
09-16-2009 2:09 PM
Hi,
Below is the FM to upload the data from EXCEL:
FAA_FILE_UPLOAD_EXCEL
You need to pass the full filename/path and the delimiter(if any)
Regards
Shiva
09-17-2009 6:45 AM
Hi Kkc_Kkc,
If you want to upload file from excel then use below mentioned FM:
TEXT_CONVERT_XLS_TO_SAP
or
ALSM_EXCEL_TO_INTERNAL_TABLE
Regards,
Tutun
09-17-2009 6:56 AM
Hi,
U can upload excel file from presentaion server to internal table using 'TEXT_CONVERT_XLS_TO_SAP'
i think u can do tat with gui_upload.
check below code
DATA : l_file TYPE string,
it_raw TYPE truxs_t_text_data.
l_file = pfname.
--
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_line_header = 'X'
i_tab_raw_data = it_raw
i_filename = pfname
TABLES
i_tab_converted_data = it_upload[]
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE 'Error in uploading file' TYPE 'E'.
ENDIF.
Rgds
Siva
09-17-2009 7:40 AM
Hi, <li>Put break-point on GUI_UPLOAD function module, check what is the file path ? after executing function module what is value in the internal table TAB? Thanks Venkat.O