Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Type inferrence with 7.40 inline data declaration buggy?

former_member186905
Participant
0 Kudos

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

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos

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.

4 REPLIES 4

Sandra_Rossi
Active Contributor
0 Kudos

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.

0 Kudos

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.

0 Kudos

Good. But what a mess globally speaking, too many particular cases in ABAP

0 Kudos

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... 😉