Copyright 2024 - BV TallVision IT

Strings are character fields, which don't really have a size. As field type in a (DDIC) table that's not possible - but in Abap memory it is ! If you are not used to strings yet, you will be soon. They reflect a certain freedom to the developer. Instead of an internal table of 100-character fields holding 1000 lines, the same table defined as strings consumes a lot less memory space. How ? Smart SAP memory management. 

The length of a text field or string can be determined with STRLEN or with the DESCRIBE FIELD statement.

The STRLEN statement will return the length of a string, where DESCRIBE FIELD ... LENGTH ... IN CHARACTER MODE can only be performed on variables of data type C,N, D or T (excluding strings). An example to get the string length:

data: lv_string type string,
      lv_length type p. "Packed number

lv_string = '0123456789'.
do 20 times.
  concatenate lv_string lv_string into lv_string.
* WON'T WORK: the statement can not be used directly
*  write: / strlen( lv_string ).
  lv_length = strlen( lv_string ).
  write: / lv_length.
* WON'T WORK: lv_string must be a character type
*  describe field lv_string length lv_length in character mode.
enddo.

The outcome of this bit of coding demonstrates how long a string can become, which was for the above example:

 {14 lines omitted}
        327.680
        655.360
      1.310.720
      2.621.440
      5.242.880
     10.485.760

Thus the string is actually holding over 10MB of data. There is a limit to this size, specified in system parameter ztta/max_memreq_MB (check out RSPARAM).