Skip to Content
4
May 14, 2018 at 03:28 PM

Pass calculated value with build in function to TYPE data importing parameter syntax error

94 Views Last edit May 14, 2018 at 03:30 PM 2 rev

I wanted to display some debug values using CL_DEMO_OUTPUT. One was the number of lines an internal table has. I wrote something like this:

DATA: gt_tab TYPE stringtab.

cl_demo_output=>new(
  )->write_data( lines( gt_tab )
  )->display( ).

I was very surprised to find out that is syntactically not correct and does not compile (751SP02).

As my go-to alternative for when type determination fails or just does not have enough information I adjusted the line to give it some assistance:

cl_demo_output=>new(
  )->write_data( CONV i( lines( gt_tab ) )
  )->display( ).

That now results in a syntax warning though:

Which seems weird to me because if it would be redundant then I should be able to just leave it out.

I looked at the parameter interface of write_data and tried to find out if it makes a difference whether a generic importing parameter is passed by value or by reference but that doesn't seem to make any difference. What does make a difference though is using TYPE ANY instead of TYPE data (?!). I was under the impression that they act the same and nowadays data would be the one to use (if you have to use generic parameters). In the documentation I also couldn't find any hint as to them acting differently:

"The generic type any can, like all generic types listed here except data and object, only be specified directly after TYPE and has exactly the same effect there as the generic type data." ( https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abenbuilt_in_types_generic.htm )

Is this a bug or am I missing something?

Attachments

1.png (1.9 kB)
2.png (1.7 kB)
3.png (56.5 kB)