[英]Calculate the length of itab structure in bytes
The internal table size (eg for a DSO) is limited to 4030 bytes.内部表大小(例如对于 DSO)限制为 4030 字节。 I have a list of infoobjects and would like to calculate if their amount will exceed this limit.我有一个 infoobject 列表,想计算它们的数量是否会超过这个限制。 How can I convert their data type in bytes?如何以字节为单位转换它们的数据类型?
Example:例子:
CHAR 4 -> xxx bytes
DATS -> xxx bytes
FLTP -> xxx bytes
...
Thanks a lot!非常感谢!
You have to replace the ls_bkpf
with the actual structure (line of internal table) you use in your program, oherwise I hope it helps.您必须将ls_bkpf
替换为您在ls_bkpf
使用的实际结构(内部表行),否则我希望它会有所帮助。 lv_length will contain the total size of the fields in bytes. lv_length 将包含字段的总大小(以字节为单位)。
DATA: ls_bkpf TYPE bkpf.
FIELD-SYMBOLS: <lv_field> TYPE any.
DATA: lo_typedesc TYPE REF TO cl_abap_typedescr.
DATA: lv_length TYPE i.
DO.
ASSIGN COMPONENT sy-index
OF STRUCTURE ls_bkpf
TO <lv_field>.
IF sy-subrc EQ 0.
lo_typedesc = cl_abap_elemdescr=>describe_by_data( <lv_field> ).
ADD lo_typedesc->length TO lv_length.
ELSE.
EXIT.
ENDIF.
ENDDO.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.