Skip to Content

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

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?

1.png (1.9 kB)
2.png (1.7 kB)
3.png (56.5 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    May 14 at 04:01 PM

    I'd say bug. TYPE data and TYPE any should behave the same way. As the author of CL_DEMO_OUTPUT I would never have expected that syntax error. I will report it to kernel development and hope for a correction. If there is none, the difference between data and any must be documented and I will change the parameter typing in CL_DEMO_OUTPUT to any.

    Add comment
    10|10000 characters needed characters exceeded