Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Preferred data type for attachments

kjyothiraditya
Participant
0 Likes
1,767

hi experts,

Can you please let me know the preferred data type to be used for reading binary data of files from bds attachments. By default it is mostly hexadecimal. If I am using scms*xstringto*binary,the conversion isn't happening in my program. The data is still in hexadecimal. When I send this data after conversion to other system, the document is corrupted. If the other system converts from hex to binary, it is working fine. Can you let me know best practice method ? I have used scms* FM in the past like for email attachment and it worked fine.

4 REPLIES 4
Read only

Sandra_Rossi
Active Contributor
1,432

Hexadecimal is just a way of showing the values of bytes in a human-readable format (2 hexa characters = the value of 1 byte).

If you're talking about the contents of a XSTRING variable, prefer the term "byte string".

SCMS_XSTRING_TO_BINARY only transfers bytes from a XSTRING variable to an internal table with lines of type X (or more precisely whose 1st component has a type which can be casted to X, and if the table has unstructured lines the whole line has a type which can be casted to X).

Concerning how the files are to be transmitted via BDS API or BCS API (email), the API is to be used differently of course, but there's nothing really special about the handling of bytes/binary/hexadecimal.

I would say that your code is buggy somewhere, and that you don't understand a few important things (no offense!). Let's discuss.

Read only

kjyothiraditya
Participant
0 Likes
1,432

Hi Sandra,

Thanks for replying. I am trying to understand if we can get the file in binary format. Also I am sending this data to other system in an idoc.so is it ok if I sending hexadecimal format or do I have to send in binary. Also I am using idoc as the container and pi is the middle communication agent. My idea is to skip the conversion from hex to bin at the other system.

Can you also suggest if any better way to send files to other system?

Read only

Sandra_Rossi
Active Contributor
1,432

You can't avoid the conversion.

IDocs can transfer only characters (but any data type can be represented via characters so this "limit" is not really a problem). These other data types must be "encoded" into characters and "decoded" at the other side. The encoding is as simple as doing a WRITE of the variable. For bytes, I would prefer base64 over hexadecimal because it takes less characters (# of bytes * 4 / 3, rounded up to a multiple of 4, versus # of bytes * 2 for hexadecimal).

Read only

kjyothiraditya
Participant
0 Likes
1,432

So to reduce payload I have to convert hex to base64 and the other system has to decode and convert to binary ? Please confirm