cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Base64 from SAP to file (Word, Excel) gets corrupted

Mahmoud-Farag
Participant
0 Kudos

Dears,

We have a webservice that sends Base64 to third party system. However, the file gets corrupted when downloading.

After researching for a while we found out that numerous users have the same issue with no clear solution on how base64 converted to this file(doc, word)

PS: it works fine in .pdf, .txt, .png

I would really appreciate your help

Best Regards,

Mahmoud

Sandra_Rossi
Active Contributor
0 Kudos

Please show your code.

Saswata89
Participant
0 Kudos

Is it possible to send the base64 into binary after converting using btoa(<your base64>) JS function? If you can convert to binary then it will probably be easier to convert to doc or word file type at the receiver side.

Mahmoud-Farag
Participant
0 Kudos
DATA: CONTENT_BIN TYPE SDOKCNTBINS.
DATA: PROPERTIES TYPE SDOKPROPTYS.
DATA: PHIOS TYPE SKWF_IOS.
DATA: FILE_ACCESS_INFO TYPE SDOKFILACIS.
CALL METHOD CL_CRM_DOCUMENTS=>GET_DOCUMENT
EXPORTING
IO = lv_loio
IMPORTING
PROPERTIES = PROPERTIES
* PROPERTIES_ATTR =
PHIOS = PHIOS
FILE_ACCESS_INFO = FILE_ACCESS_INFO
* CONTENT_ASCII =
CONTENT_BIN = CONTENT_BIN
* BUSINESS_OBJECTS =
* LOIO =
* IO_DOES_NOT_EXIST =
.
Mahmoud-Farag
Participant
0 Kudos

sandra.rossi : I convert 'CONTENT_BIN' to BASE64 then send it with webservice
I send .png , .txt and .pdf , all this format works well but word & excel display a corrupted file ,
If you have any idea that help us,
Thanks

Sandra_Rossi
Active Contributor
0 Kudos

How do you get the exact number of bytes contained in CONTENT_BIN? (because you must not convert the extra null bytes ; I guess the length is in FILE_ACCESS_INFO)

How do you convert CONTENT_BIN into base64?

Please share the code.

Mahmoud-Farag
Participant
0 Kudos

Dear sandra.rossi, Not All Heroes Wear Capes 🙂 🙂

Accepted Solutions (1)

Accepted Solutions (1)

Mahmoud-Farag
Participant

The issue has been solved the Last Spaces in the content make the converted file corrupted

Thanks,
Mahmoud Farag

Answers (0)