2017 Nov 15 1:16 PM
Hi all,
I want to get files via FTP with an ABAP program. Each file can have different extensions, (.txt, .csv, .xlsx etc.)
When I want to export the excel file to SAP, I get meaningless data.
PK########|G&K{xéÎ####¾#######xl/workbook.xml##KN#A##÷&Ş¡S{éÁ#1###A#6Æ#²/fj##ıJuóĞËx#î€÷²g#¨;7İùëñåÿk4Ş#-¶ÄA9#C¿## [ºJÙU#oóç###!¢P;K9¼S€qq}5Ú9^/#[##°!#&F?#2####=çɦNíØ`L#W2x&¬BC###Yv/#*#'Â#ÿÃpuJ#ºrcÈÆ##IcLöC£|€bT+M#S"#Ş¿ I¾÷##Æ##*#©Êá.I£?#ŞøÇ#Òmw##@##
I'm using the following code;
REFRESH: lt_blob.
CALL FUNCTION 'FTP_SERVER_TO_R3'
EXPORTING
handle = lv_hdl
fname = <ls_files>-filename
IMPORTING
blob_length = lv_blob_length
TABLES
blob = lt_blob
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
OPEN DATASET lv_filename FOR OUTPUT IN
TEXT MODE ENCODING UTF-8.
LOOP AT lt_blob ASSIGNING FIELD-SYMBOL(<ls_blob>).
CONCATENATE lv_string <ls_blob> INTO lv_string.
ENDLOOP.
IF sy-subrc = 0.
TRANSFER lv_string TO lv_filename.
ENDIF.
How can i make this data meaningful?
2017 Nov 15 4:15 PM
the "meaningless data" seems to be in fact a quite valid XLSX file, as far as I can see (PK being for a zip file, workbook.xml being one of the files of the zip, conforming to the XLSX standard).
2017 Nov 15 1:30 PM
Have you seen the various links to abap2xlsx ? This is the ultimate place to get anything Excel. I've used it before and it's worked great. I don't currently have a system to help you out with what you would need to do, but this is really developer friendly. If that's a bit too much work for you project - have you tried CL_BCS_CONVERT=>STRING_TO_SOLIX? This converts binary to a hex format. (One long string) There is a lot of documentation out there - use this search and google:
sap CL_BCS_CONVERT=>STRING_TO_SOLIX
Best of luck,
Michelle
2017 Nov 15 4:15 PM
the "meaningless data" seems to be in fact a quite valid XLSX file, as far as I can see (PK being for a zip file, workbook.xml being one of the files of the zip, conforming to the XLSX standard).