gpt4 book ai didi

primary-key - 生成随机 GUID

转载 作者:行者123 更新时间:2023-12-01 07:08:02 26 4
gpt4 key购买 nike

我想生成一个随机的UUID喜欢 JavaUUID.randomUUID() .

我想出了函数GUID_GENERATE并像这样使用它

    DO 5 TIMES.
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_16 = ev_guid_16
ev_guid_22 = ev_guid_22
ev_guid_32 = ev_guid_32.

WRITE: /, ev_guid_16, ev_guid_22, ev_guid_32.
ENDDO.

这个程序的结果总是一样的 GUID .每次请求我都需要一个新的随机数。

我想将它用作数据库表中的主键。该 key 也将作为标识符通过 Web 服务传输到 Java 应用程序和用户。

你有什么想法我如何生成随机 UUID/GUIDABAP ?

最佳答案

首先,您使用的是过时的功能模块。源代码开头的注释说明了这一点。

*"----------------------------------------------------------------------
* NOW this function has been replaced, see note 935047 "BINK215094
* 28.6.2006 The function module has been switched to the new UUID methods
* which exist in the class cl_system_uuid
* - due to compatibility reasons we catch the exceptions
* - sy-subrc not touched manually
* (sy-subrc was set in case of an error when calling the former
* 'RFCControl' kernel-call, but it wasn't evaluated and finally
* overwritten when leaving this function)
*"----------------------------------------------------------------------

请使用类 CL_SYSTEM_UUID以及以下方法:
IF_SYSTEM_UUID_STATIC~CREATE_UUID_X16
IF_SYSTEM_UUID_STATIC~CREATE_UUID_C22
IF_SYSTEM_UUID_STATIC~CREATE_UUID_C26
IF_SYSTEM_UUID_STATIC~CREATE_UUID_C32

关于primary-key - 生成随机 GUID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7887639/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com