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

Generate GUID, range?

RicardoRomero_1
Active Contributor
0 Likes
17,643

Hello,

We are migrating a custom solution to one system to a new s4 system. (lot of programs and tables...)

They want to keep the old data of our custom tables in the new system, theese tables have a GUID as key field.
We generate this GUID in our programs with FM CMS_API_GENERAL_GUID_CREATE (inside this FM the class cl_system_uuid is used)

My question is; what happens when we copy all the data from the old system to the new one, with thousands of GUID generated and we try to create a new one? Could be a conflict? Could a GUID be generated with the same value as an old one?

Is there any range we can initialize to start the generation of the GUID from the last one created in the old system?

Class cl_system_uuid use some KERNEL MODULEs, don't know exactly how it works.

Any advice?

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

r_herrmann
Active Contributor
12,823

Hi Ricardo,

if you would face duplicate ids, then the developer of the CL_SYSTEM_UUID had done a bad job. Per definition a UUID (Universally unique identifier) has to be real unique. Since UUID generators usually not only use the time as a component, but also the MAC address (besides some other calculations) and I guess you switched the hardware for your new system, you should never, ever see a conflict with your old ids.

5 REPLIES 5
Read only

srikanthnalluri
Active Participant
12,823

May be you can directly use the class - CL_SYSTEM_UUID and methods - CONVERT_UUID* to generate your unique ID using the input key (You can pass time time stamp).

Read only

r_herrmann
Active Contributor
12,824

Hi Ricardo,

if you would face duplicate ids, then the developer of the CL_SYSTEM_UUID had done a bad job. Per definition a UUID (Universally unique identifier) has to be real unique. Since UUID generators usually not only use the time as a component, but also the MAC address (besides some other calculations) and I guess you switched the hardware for your new system, you should never, ever see a conflict with your old ids.

Read only

0 Likes
12,823

Thank you, thats all I need to know !

Read only

ThangaPrakash
Active Contributor
12,822

@Ricardo Romero Mata As the name suggests, Universal Unique Identifier, it has to be obviously unique when generated by the KERNEL methods.

One interesting which I noticed is, function module 'GUID_CREATE' is marked as Obsolete by SAP, I would advise better use CL_SYSTEM_UUID and it methods and catch exceptions like an example below ( as per Class documentation ).

DATA: l_uuid_x16 TYPE sysuuid_x16.
DATA: system_uuid TYPE REF TO if_system_uuid.
DATA: oref        TYPE REF TO cx_uuid_error.


system_uuid = cl_uuid_factory=>create_system_uuid( ).


TRY.
    l_uuid_x16 = system_uuid->create_uuid_x16( ). " create uuid_x16


  CATCH cx_uuid_error INTO oref.                  " catch error
    DATA: s1 TYPE string.
    s1 = oref->get_text( ).
ENDTRY.

Read only

0 Likes
12,822

Thanks, we'll consider to change the FM. There are a lot of programs in our old solution that use this FM.... Anyway, inside this obsolete FM the class cl_system_uuid is being used in our system. (not in others systems as i can see... )