Ansicht
Dokumentation
ABENST_LENGTH - ST LENGTH
PERFORM Short Reference ROGBILLS - Synchronize billing plansThis documentation is copyright by SAP AG.
- length, minLength, maxLength, Specified Length
... length="len" ...
... minLength="len" ...
... maxLength="len" ...
Effect
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.
Note
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.
Example
The following transformation performs serializations and deserializations with differing lengths:
?sap.transform simple?>
tt:transform
xmlns:tt="http://www.sap.com/transformation-templates">
tt:root name="ROOT"/>
tt:template>
tt:serialize>
Text>
tt:value length="8" ref="ROOT"/>
/Text>
/tt:serialize>
tt:deserialize>
Text>
tt:value length="4" ref="ROOT"/>
/Text>
/tt:deserialize>
/tt:template>
/tt:transform>
The following ABAP program can call the transformation:
DATA: text TYPE string VALUE `1234`,
xml_xstring TYPE string,
exc_trafo TYPE REF TO cx_transformation_error,
exc_prev TYPE REF TO cx_root.
CALL TRANSFORMATION ... SOURCE root = text
RESULT XML xml_xstring.
cl_abap_browser=>show_xml( xml_string = xml_xstring ).
TRY.
CALL TRANSFORMATION ... SOURCE XML xml_xstring
RESULT root = text.
CATCH cx_st_deserialization_error INTO exc_trafo.
MESSAGE exc_trafo TYPE 'I' DISPLAY LIKE 'E'.
IF exc_trafo->previous IS NOT INITIAL.
exc_prev = exc_trafo->previous.
MESSAGE exc_prev TYPE 'I' DISPLAY LIKE 'E'.
ENDIF.
ENDTRY.
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.
SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up CL_GUI_FRONTEND_SERVICES - Frontend Services
This documentation is copyright by SAP AG.
Length: 7198 Date: 20240427 Time: 071207 sap01-206 ( 91 ms )