tags:

views:

30

answers:

1

What are the drawbacks of the String type in abap? When to use it, when not?

An example : I have a text field that should save values ranging from 0 to 12 chars, better to use a string or a Char(12)?

Thanks!

+4  A: 

A string is stored as a dynamic array of characters while a char is statically allocated.

Some of the downsides of strings include:

  • Overhead - because they are dynamic the length must be stored in addition to the actual string.
  • The substring and offset operators don't work with strings.
  • Strings cannot be turned into translatable text elements.

So to answer your question, strings should only be used for fairly long values with a wide range of lengths where the additional overhead is negligible relative to the potential wasted space of a static char(x) variable.

BenV