• 如何创建,转换UUID[CL_SYSTEM_UUID]


    UUID含义是通用唯一识别码 (Universally Unique Identifier),通俗一点就是一个不重复的字符串,有时会把UUID作为数据库的一个主键,这样就不用担心主键重复的问题。

    SAP中有个专门生成CL_SYSTEM_UUID,提供了4个静态方法创建生成不同类型的UUID:2进制,16进制,64位以及32位uuid。

    也可以进行不同类型UUID之间的相互转换。

    代码:

    REPORT ztest_uuid.
    
    DATA:l_uuid22 TYPE sysuuid_c22,
         l_uuid32 TYPE sysuuid_c32,
         l_uuid26 TYPE sysuuid_c26,
         l_uuid16 TYPE sysuuid_x16.
    
    TRY.
        CALL METHOD cl_system_uuid=>if_system_uuid_static~create_uuid_x16
          RECEIVING
            uuid = l_uuid16.
      CATCH cx_uuid_error .
    ENDTRY.
    TRY.
        CALL METHOD cl_system_uuid=>if_system_uuid_static~create_uuid_c22
          RECEIVING
            uuid = l_uuid22.
      CATCH cx_uuid_error .
    ENDTRY.
    TRY.
        CALL METHOD cl_system_uuid=>if_system_uuid_static~create_uuid_c32
          RECEIVING
            uuid = l_uuid32.
      CATCH cx_uuid_error .
    ENDTRY.
    TRY.
        CALL METHOD cl_system_uuid=>if_system_uuid_static~create_uuid_c26
          RECEIVING
            uuid = l_uuid26.
      CATCH cx_uuid_error .
    ENDTRY.
    
    WRITE:  `Binary Format UUID:`,l_uuid16.
    WRITE:/ `Base64 UUID:       `,l_uuid22.
    WRITE:/ `Base32 UUID:       `,l_uuid26.
    WRITE:/ `Hex Format UUID:   `,l_uuid32.

    运行结果:

    也可以通过函数SYSTEM_UUID_CREATE来生成UUID,SE37

    看一下代码,其中也是调用类CL_SYSTEM_UUID创建的二进制类型UUID

    以上。

  • 相关阅读:
    LeetCode No944. 删列造序
    LeetCode No38. 外观数列
    LeetCode No39. 组合总和
    leetcode 643. Maximum Average Subarray I 子数组最大平均数 I
    leetcode 3. Longest Substring Without Repeating Characters 无重复字符的最长子串
    go 的day 10
    mysqlinsert
    oracle sql经验
    数据同步思路
    Redis 扫描scan Anthony
  • 原文地址:https://www.cnblogs.com/datie/p/11435451.html
Copyright © 2020-2023  润新知