SAP Knowledge Base Article - Public

2568375 - Convert Binary to String


You are using a method which returns a Binary value as result and you want to convert this value to String.


SAP Hybris Cloud for Customer / SAP Business ByDesign - all versions

Reproducing the Issue

You are using a method of a library to return some values.
E.g: You are using the method EncryptWithHashBasedMessageAuthenticationCode of the library WebServiceUtilities to return values. You need a String as result but this method returns only Binary values.

Binary value contains 164E920F43E495FC62BA3545AE83FBC2D8721FA38170B94CBC694AD9D0999F60

var str = Binary.ToString();
Result: str = "<data><simple><type>String</type><value>"�N��C���b�5E�����r���p�L�iJ��`"</value></simple></data>"

The value in str should be 164E920F43E495FC62BA3545AE83FBC2D8721FA38170B94CBC694AD9D0999F60 of type String.


You can use a variable with data type LANGUAGE_INDEPENDENT_EXTENDEDTEXT. In this case you can directly assign the value of your token to the variable, without having to use ToString() function. The variable with data type LANGUAGE_INDEPENDENT_EXTENDEDTEXT will storage the String representation of Hexadecimal value of Binary.

You can use this String representation as parameters for the method EncryptWithHashBasedMessageAuthenticationCode.


Binary; ToString; String; Token; method; , KBA , tostring , c4c , sapcloudapplicationsstudio , sapbysinessbydesign , saphybriscloudforcustomer , byd , AP-RC-BDS-SCR , ByDesign Studio Scripting (ABSL) , How To


SAP Business ByDesign all versions ; SAP Cloud Applications Studio all versions ; SAP Cloud for Customer add-ins all versions ; SAP Cloud for Customer core applications all versions