‎2019 Nov 21 1:06 PM
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.
‎2019 Nov 21 2:51 PM
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.
‎2019 Nov 21 2:45 PM
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).
‎2019 Nov 21 2:51 PM
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.
‎2019 Nov 21 3:08 PM
‎2019 Nov 21 3:18 PM
@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.
‎2019 Nov 22 8:46 AM
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... )