cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Application Programming Model - mapping existing GUID to edm.guid

former_member182048
Active Contributor

how do we take an existing HANA Guid and convert it to what CDS will accept and map to an OData edm.guid?

Context

I am using data across a number of different sources. the key that links the data is a guid

I am having troubles getting the existing guid to parse as an OData edm.guid, NodeJS OData V4

Background

I read this in the help - Using UUIDs

By default, CDS maps UUIDs to nvarchar(36) in SQL databases. The length is to accommodate representations with hyphens as well as any other.

https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/5a7fc091b4664c269f484411195...

It is expecting nvarchar(36) with the hashes, an existing guid is saved in HANA as nvarchar(32) sans hash

Work Around

in SQLScript I can use a REGEX to do the dashes

SELECT
REPLACE_REGEXPR('(.{8})(.{4})(.{4})(.{4})(.*)' IN "DB_KEY" with '\1-\2-\3-\4-\5') as "DBKey"
FROM "My.ExternalView"

makes

"DB_KEY": 0060768214261ED886C1D048C5E5B699  
"DBKey" : 00607682-1426-1ED8-86C1-D048C5E5B699

How to do that in CDS, can i use a formatter or a custom type?

johannesvogel
Advisor
Advisor
0 Kudos

Hi Paul,

is there a specific reason why you want to convert it to a UUID according to CDS and not treat it as String(32)?

Best regards,

Johannes

Accepted Solutions (0)

Answers (0)