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

FUnction to calculate unique key

Former Member
0 Likes
1,805

Hi All,

I have a situation where my source is 32 char length and destination InfoObject is only 20 char length. I want to derive a 20 char or less key from 32 char and store it in my InfoObject. The key should be unique to a char sequence.

I should also be able to derive the 32 char from 20 char key generated. Does ABAP have any standard functions which would derive a hash value which is unique and from which you can again derive the original value.

Please help.

Devang.

1 ACCEPTED SOLUTION
Read only

Clemenss
Active Contributor
0 Likes
1,318

Hi Deva,

if you can create the uinique key yourself, you can use FM GUID_CREATE: You will get a unique identifier in 16 bytes raw hex format, 22 character upper/lower case ASCII char format and in 32 character uppercase ASCII format..

They are mutually convertible by FM GUID_CONVERT.

So you can use GUID_CREATE to get the 32 char source key - you can convert it to a 16 byte hex value for your object.

I don't know if this works as you did not say what it is all about.

Regards

Clemens

4 REPLIES 4
Read only

matt
Active Contributor
0 Likes
1,318

Unless there's a lot of redundancy in the source, I can't think that it's even mathematically possible. There are more combinations possible with 32 characters than with 20.

matt

Read only

Former Member
0 Likes
1,318

HI Matt,

I am sure that we dont have so much data that it will pass combination of 20char. So I think we should be good mathematically.

Thanks,

Devang.

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,318

Hi,

I don't think what you're looking for is feasible, so you should better use the usual workaround : define a database table to store the values, with a primary key field made of 20 numeric digits, and data is 32 characters, and a unique index on the 32C field. Each new 32C value is assigned the next 20N number (like with a number range), and if it is an existing 32C value, then it returns the corresponding 20N key.

Sandra

Read only

Clemenss
Active Contributor
0 Likes
1,319

Hi Deva,

if you can create the uinique key yourself, you can use FM GUID_CREATE: You will get a unique identifier in 16 bytes raw hex format, 22 character upper/lower case ASCII char format and in 32 character uppercase ASCII format..

They are mutually convertible by FM GUID_CONVERT.

So you can use GUID_CREATE to get the 32 char source key - you can convert it to a 16 byte hex value for your object.

I don't know if this works as you did not say what it is all about.

Regards

Clemens