SAP ST LENGTH



Get Example source ABAP code based on a different SAP table
  


• length ABAP_ST_ELEMENT
• minLength ABAP_ST_ELEMENT
• maxLength ABAP_ST_ELEMENT

ABAP_ST - length, minLength, maxLength, Specified Length

ABAP_SYNTAX
... length='len' ...
... minLength='len' ...
... maxLength='len' ...

What does it do?
The attributes length, minLength, and maxLength can be used to specify a length len for tt:value, tt:write, and tt:read. This restricts the length of the data to be passed in serializations and deserializations.
Positive integers can be specified for len. Lengths can be specified for data nodes or variables with the ABAP types c, x, string, and xstring. Any other data types ignore any length specifications.
Specifying the length attribute always affects tt:value and tt:write as if minLength and maxLength were listed at the same time with the value specified for len.

Serialization
The minLength or length attribute defines the resulting XML value as representing at least the number of characters or bytes defined in len. If a passed value contains fewer characters, or bytes, it is filled on the right with blanks or 0x00 until it is of the specified length and an XML value is created. The maxLength or length attribute defines the maximum number of characters or bytes that can be passed. If the XML value to be serialized contains more characters or bytes than specified by len , the exception CX_ST_CONSTRAINT_ERROR is raised, unless only trailing blanks or zero bytes in a serialization of a data object with type c or x are affected.

Deserialization
The minLength attribute is ignored by deserialization. The maxLength or length attribute defines the maximum number of characters or bytes expected in the XML value. If the XML value to be deserialized contains more characters or bytes than specified by len , the exception CX_ST_CONSTRAINT_ERROR is raised, unless only trailing blanks or zero bytes in a deserialization to a data object with type c or x are affected.



Latest notes:

Exception CX_ST_CONSTRAINT_ERROR cannot be caught directly during the call of CALL TRANSFORMATION, instead it is wrapped in CX_ST_SERIALIZATION_ERROR or CX_ST_DESERIALIZATION_ERROR.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The following transformation DEMO_ST_SPECIFIED_LENGTH performs serializations and deserializations with differing lengths:
TRNS DEMO_ST_SPECIFIED_LENGTH
The following ABAP program can call the transformation:
ABEXA 01711
The result of the transformation is: < Text>1234 < /Text>
Since more characters are passed by the deserialization than expected, the exception CX_ST_CONSTRAINT_ERROR is raised, which is wrapped in the exception CX_ST_DESERIALIZATION_ERROR.
ABAP_EXAMPLE_END