Hi, the IDOC segments are character based. To put binary attachment data into the IDOC the binary data first need to be converted into BASE64 format. The BASE64 format is a character format.
To convert binary data into BASE64 function module SSCF_BASE64_ENCODE can be used.
Not sure you are sending or receiving an IDOC in SAP.
When receiving in SAP then you can use function module SSCF_BASE64_DECODE to decode the BASE64 IDOC data into binary data.
Also not sure how you want to process the attachment in SAP. When saving to a SAP office file you could use function module SO_DOCUMENT_INSERT_API1.
Regards Jack