SAP Knowledge Base Article - Public

2568375 - Convert Binary to String

Symptom

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

Environment

  • SAP Cloud for Customer
  • SAP Business ByDesign
  • SAP Cloud Applications Studio

Reproducing the Issue

You are using a library method 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.

Example:
The 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.

Cause

Resolution

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

You can use this string representation as parameter for the method EncryptWithHashBasedMessageAuthenticationCode.

See Also

Keywords

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

Product

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