CHAR_HEX_CONVERSION 导致 ABAP 转储

CHAR_HEX_CONVERSION results in ABAP dump

我需要将一个字符(具体来说是char20)转换成十六进制值。我想到了以下内容:

CALL FUNCTION 'CHAR_HEX_CONVERSION'
  EXPORTING
    input     = character
  IMPORTING
    hexstring = character_hex.

但是我在执行此操作时总是遇到运行时错误。

我做错了什么?

我刚刚测试了 CHAR_HEX_CONVERSION,我得到了我认为相同的转储:

For the statement "WRITE src TO dest" only flat, character-type data objects are supported at the argument position "dest".

In this case, the operand "dest" has the non-character-type or non-flat type "X". The current program is a Unicode program. In the Unicode context, the type 'X' or structures containing not only character-type components are regarded as non-character-type.

我认为是 X 类型的使用导致了转储。我还没有找到另一个可以进行转换的已发布功能模块(手动编码很容易,但我很懒!),但我可以建议使用以下功能模块:CRM_EI_KB_CONV_DEC_TO_HEX。尽管名称如此,它在 ECC 6.0 系统中可用,并且应该满足您的需要。

转储发生在将传入值传递给字段符号时,该字段符号引用导出参数。代码中是后加了'X'类型的assign语句,我一般不推荐这种方式

我还对该模块及其功能组进行了使用位置检查,似乎它没有被调用,至少没有被直接调用。很可能整个功能组从未发布过。

您可以尝试改用 SCMS 功能模块 - 它们还负责代码页转换。尝试 SCMS_TEXT_TO_BINSCMS_STRING_TO_XSTRING.