05-13-2016 12:34 PM
Hi all,
We are developing on a SAP basis 7.40 SP 8 and experience some trouble with inline data declarations:
* we defined a data element with tpye P(9) DEC 2
* when using two variables with that data element as type the derived type is not a P(9) DEC 2, but only a P(8)
* in the debugger the tooltips show the types:
Here both iv_base_amount and iv_offset_amount are of type P(9) DEC 2, but the derived type is P(8)
I would consider this as a bug, right?
Does anyone know whether a note is already available?
Thanks in advance and kind regards,
Valentin
05-14-2016 9:23 AM
I think it's not a bug but a consequence of historical way of calculating: there is the concept of "calculation type", that you may find in the abap documentation. Quote:
If operands are specified as generically typed field symbols or formal parameters and an inline declaration DATA(var) is used as the target field of an assignment, the generic types contribute to the statically detectable calculation type (used to determine the data type of the declaration) as follows
- any, data, simple, numeric, and decfloat like decfloat34
- csequence, clike, c, n, and p like p. If no type with a higher priority is involved, the type p with length 8 (no decimal places) is used for the declaration.
- xsequence and x like i
I guess "no type with a higher priority is involved" means no type that would be interpreted in the previous line "like decfloat34", but it's subject to interpretation.
05-14-2016 9:23 AM
I think it's not a bug but a consequence of historical way of calculating: there is the concept of "calculation type", that you may find in the abap documentation. Quote:
If operands are specified as generically typed field symbols or formal parameters and an inline declaration DATA(var) is used as the target field of an assignment, the generic types contribute to the statically detectable calculation type (used to determine the data type of the declaration) as follows
- any, data, simple, numeric, and decfloat like decfloat34
- csequence, clike, c, n, and p like p. If no type with a higher priority is involved, the type p with length 8 (no decimal places) is used for the declaration.
- xsequence and x like i
I guess "no type with a higher priority is involved" means no type that would be interpreted in the previous line "like decfloat34", but it's subject to interpretation.
05-16-2016 6:55 PM
Hello Sandra Rossi,
your answer is correct. Unfortunately this behaviour cannot be changed anymore :-). In Open SQL we where more clever. If you write:
SELECT @iv_base_amount - @iv_offset_amount FROM t000 WHERE mandt = @sy-mandt INTO @DATA(foo)
you will hopefully don't get a P(8) but a P(12,2) or so.
Best regards,
Kilian.
05-16-2016 7:36 PM
Good. But what a mess globally speaking, too many particular cases in ABAP
05-17-2016 9:58 AM
Hi Sandra, thanks for the info!
Anyhow, I think the description text should be adapted slightly:
If operands are specified as generically typed field symbols or formal parameters and an inline declaration DATA(var) is used as the target field of an assignment, the generic types those operands contribute to the statically detectable calculation type (used to determine the data type of the declaration) as follows [...]
And yeah, what a mess... 😉