Ansicht
Dokumentation

ABENCONV_CONSTRUCTOR_INFERENCE - CONV CONSTRUCTOR INFERENCE

ABENCONV_CONSTRUCTOR_INFERENCE - CONV CONSTRUCTOR INFERENCE

BAL_S_LOG - Application Log: Log header data   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.
SAP E-Book

CONV, Type Inference for Actual Parameters

If a constructor expression

CONV #( $[let_exp$] dobj )

is passed to generically typed formal parameters as an actual parameter using the character # as a symbol for the operand type, the following type inference is performed for the character #:

  • If the data type of the argument dobj is known and matches the generic type of the formal parameter, no conversion is performed, and the type of the argument is used instead.
  • If the data type of the argument dobj is known and is elementary, types are derived from it as follows for formal parameter types with generic lengths as follows:
  • Generic type c

c with the length of the argument in arguments of the types n, d, and t; c of the predefined output length of the argument for all other argument types except strings; no type is derived for arguments of the types string and xtring
  • Generic type n

n with the length of the argument for arguments of the types n, d, and t and n with the length of a conversion of the argument to n for all other argument types except numeric types with decimal places and strings; no type is derived for arguments of the types decfloat16, decfloat34, f, and p with decimal places plus string and xtring
  • Generic type x

x with the rounded half length of the argument for arguments of the type c; x with the length 4 for all other argument types except strings; no type is derived for arguments of the types string and xtring
  • Generic type p

p without decimal places with the length 16 for arguments of the types decfloat16, decfloat34, f, string, or c and n with lengths greater than 15; p without decimal places with the length 8 for all other argument types
  • In other cases, the type is derived from the generic type of the formal parameter as follows:
  • csequence and clike produce string

  • xsequence produces xstring

  • numeric and decfloat produce decfloat34

  • p produces p with the length 8 and no decimal places

  • Standard table type with generic primary table key produces a standard table with a standard key

Other combinations of generic formal parameter types and arguments cannot be made more concrete in any meaningful way and produce a syntax error with the exception of table types that are explicitly generic with respect to their secondary table keys.

Syntax warnings that can be hidden using pragmas also indicate any redundant conversions resulting from the rules above.

Note

Example

The operator CONV generates a result of type decfloat34 in this case. The generic parameter p has this type during the execution of the method, which is shown by the value "e" returned by DESCRIBE FIELD. The method call produces a corresponding syntax warning.

CLASS demo DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS main IMPORTING p TYPE numeric.
ENDCLASS.

CLASS demo IMPLEMENTATION.
  METHOD main.
    DESCRIBE FIELD p TYPE DATA(t).
    cl_demo_output=>display( |{ p } of type { t }| ).
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  FIELD-SYMBOLS <fs> TYPE any.
  ASSIGN 100 TO <fs>.

  demo=>main( CONV #( <fs> ) ).

Conversion Operator, Type Inference






TXBHW - Original Tax Base Amount in Local Currency   Vendor Master (General Section)  
This documentation is copyright by SAP AG.

Length: 5133 Date: 20240426 Time: 110349     sap01-206 ( 119 ms )