0

The internal table size (e.g. for a DSO) is limited to 4030 bytes. I have a list of infoobjects and would like to calculate if their amount will exceed this limit. How can I convert their data type in bytes?

Example:

CHAR 4 -> xxx bytes
DATS   -> xxx bytes
FLTP   -> xxx bytes
...

Thanks a lot!

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Student
  • 1
  • 1
  • 1
  • Do you work in a Unicode system? – András Jul 13 '18 at 08:46
  • Yes, it is a unicode system – Student Jul 13 '18 at 09:17
  • What is the context, what is the exact goal? Because the "size of a structure" may have several answers, especially if you need to take into account the [alignment gaps](https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abenalignment.htm). – Sandra Rossi Jul 14 '18 at 05:44
  • Limit of 4030 bytes is for any transparent table in the ABAP Dictionary after ABAP 6.20 dixit [note 355898](https://launchpad.support.sap.com/#/notes/355898). – Sandra Rossi Dec 25 '20 at 16:21

1 Answers1

1

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. lv_length will contain the total size of the fields in bytes.

  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.
Suncatcher
  • 10,355
  • 10
  • 52
  • 90
József Szikszai
  • 4,791
  • 3
  • 14
  • 24
  • In Unicode systems characters are stored on 2 bytes, so a MANDT field has _length 3_ but _occupies 6 bytes_. NUMC, DAT, FLTP is unchanged. – András Jul 13 '18 at 11:06