Skip to Content
Technical Articles

Converting UUID between hyphened representation and RAW16

If you’ve been testing OData services for example with Postman lately, you’ve most likely come across the scenario where you need to convert a UUID (Universal Unique Identifier) between hyphened representation and RAW16. I’ve previously done this manually, but today I decided to find a class that could help me with this.


Let’s assume that we want to test an OData service where one of the properties is the business partner GUID (Edm Core Type = Edm.Guid). The OData service expects this property to be supplied in hyphened representation (e.g. 0050569a-1453-1ed5-b9cb-7e54178c13f0). In the SAP business partner table, the business partner GUID is however stored in RAW16 format (e.g. 0050569A14531ED5B9CB7E54178C13F0).

It is trivial to manually convert between hyphened representation and RAW16, but I find this to be a bit tedious.


After some searching, I eventually came across the class CL_SOAP_WSRMB_HELPER which can assist us when doing the conversion.

From hyphened representation into RAW16

The following unit test illustrates how the conversion from hyphened representation into RAW16 can be done:

" Convert UUID from hyphened representation into RAW16
" given
CONSTANTS uuid_raw_exp TYPE sysuuid_x VALUE '0050569A14531ED5B9CB7E54178C13F0'.
CONSTANTS uuid_hyphened TYPE string VALUE '0050569a-1453-1ed5-b9cb-7e54178c13f0'.

" when
DATA(uuid_raw_act) = cl_soap_wsrmb_helper=>convert_uuid_hyphened_to_raw( uuid_hyphened ).

" then
cl_abap_unit_assert=>assert_equals( act = uuid_raw_act
                                    exp = uuid_raw_exp ).

From RAW16 into hyphened representation

The following unit test illustrates how the conversion from RAW16 into hyphened representation can be done:

" Convert UUID from RAW16 into hyphened representation
" given
CONSTANTS uuid_hyphened_exp TYPE string VALUE '0050569a-1453-1ed5-b9cb-7e54178c13f0'.
CONSTANTS uuid_raw TYPE sysuuid_x VALUE '0050569A14531ED5B9CB7E54178C13F0'.

" when
DATA(uuid_hyphened_act) = cl_soap_wsrmb_helper=>convert_uuid_raw_to_hyphened( uuid_raw ).

" then
cl_abap_unit_assert=>assert_equals( act = uuid_hyphened_act
                                    exp = uuid_hyphened_exp ).

Happy converting!

This blog post first appeared on the Developer Voyage blog at

You must be Logged on to comment or reply to a post.
  • Hi Johan,

    I too had that issue some time ago and found the class CL_GDT_CONVERSION with its (class-)methods GUID_INBOUND and GUID_OUTBOUND which to the same job.

    I'm not sure which class is "older" (in terms of available for a lower release), but maybe this will help somebody who needs this info.



  • Johan Wigert Thanks for this guide! Is there a standard ABAP data element to store the hyphened UUID in an SAP table, or do you suggest to always convert to Raw16? I'm creating an iOS app in Swift and will need to store a Swift-generated UUID as key in a table. Would be nice to not convert back and forth 🙂

    • Thanks! In our use cases we never store the hyphened UUID in any SAP tables. We only use it in DTO classes and there we use STRING. I'm not aware of any standard ABAP data element which would be suitable.