首页 > 解决方案 > 具有可变长度的 Char 字段的动态类型定义

问题描述

对于内部使用,我需要定义一个结构化类型,其中一个字段是具有可变长度的字符字段。

像这样的东西(我希望这个例子能澄清我的问题):

DATA: lv_type TYPE char7.
lv_type = 'char128'. "The actual length will be determined during execution of the program

TYPES: BEGIN OF ty_satzcounter,
       satza TYPE zedist,
       addit TYPE (lv_type), "<----- Something like this (obviously, it doesn't work like 
                             "       this, but I think it clarifies my question)
       menge TYPE int1,
       END OF ty_satzcounter.

DATA: lt_satzcounter TYPE TABLE OF ty_satzcounter,
      ls_satzcounter TYPE ty_satzcounter.
...
...

标签: dynamictypescharabap

解决方案


这种动态类型是不可能的,但为了您的目的,具有动态长度的字符类型,有以下类型string

TYPES: satza TYPE zedist,
       addit TYPE string,
... 

推荐阅读