What does it do? A constructor expression> with the conversion operator CONV> converts > the argument dobj> to the data type specified using type > and creates an appropriate result. The following can be specified for type>:
A non-generic data type dtype> (with the exception of reference types>).
The #> character as a symbol for the operand type>.
If the data type required in an operand position is unique and known completely, this type is used.
If the constructor expression is passed to an actual parameter with a generically typed formal parameter, the operand type is derived in accordance with special rules>.
In other cases, the character #> cannot be specified. The parentheses must contain exactly one unnamed argument dobj> that can be converted to the data type type>, with the following restriction<(>:<)> If dobj> is specified as a bit expression>, type> must be byte-like or character-like with the type c> or string>. dobj> is a general expression position>. The content of the result is determined by an assignment of the argument in accordance with the associated conversion rule>. For enumerated types>, special rules> apply. If dobj> is compatible with the data type type>, CONV> does not need to be used and a syntax check warning is usually produced. An optional LET> expression let_exp>> can be specified in front of the data object to define local helper fields. If a LET> expression is specified, no warning is produced in conversions to compatible types, since LET> can be used to construct new values using helper variables.
Latest notes:
The conversion operator CONV> is suitable for avoiding the declaration of helper variables that are only necessary to do the following, for example
specify type-compliant actual parameters.
affect the calculation type> of an arithmetic expression> or the comparison type> of a relational expression>.
The argument of CONV> can itself be a calculation expression>, which means that CONV> can be used within a calculation expression to transform results of partial calculations into a specific type.
No empty parentheses can be specified after CONV> to construct an initial value of the specified type. The expression VALUE #( )>> can be used to do this.
The conversion operator CONV> closes the gap where the value operator VALUE>> cannot be used to construct values for elementary data objects except for the initial value.
If a constructor expression with the conversion operator is used as a source field of an assignment in which the same conversion takes place, it is not necessary and is removed when the program is compiled.
For reference types, the conversion operator CONV> is not necessary, since these involve only castings and no conversions. The operator CAST>> is used for castings. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 The method CONVERT> of the interface IF_ABAP_CONV_OUT>> of the object created using the class CL_ABAP_CONV_CODEPAGE>> expects the data type string> for the input parameter SOURCE>. CONV > is used to convert a text field to this data type, directly in the operand position. ABEXA 00893 ABAP_EXAMPLE_END
ABAP_EXAMPLE_VX5 Even though the internal table itab> in the method meth1> has the same line type as the table type of the parameter para> of the method meth2>, it cannot be passed directly due to the different table type and key. CONV> is used to convert itab> to the required table type. ABEXA 00894 ABAP_EXAMPLE_END
ABAP_EXAMPLE_VX5 The two calculations produce different results. In the first case, the calculation type> is f> and the end result is converted to i>. In the second case, CONV> converts each interim result to the calculation type i>. ABEXA 00895 ABAP_EXAMPLE_END
ABAP_EXAMPLE_VX5 The first logical expression is false, as specified in the comparison rules for character-like data types >. CONV> is used to modify the comparison type of the second comparison so that the comparison is true. ABEXA 00896 ABAP_EXAMPLE_END