Application Development and Automation 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: 
Read only

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

fabianlupa
Contributor
2,298

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

Is this a bug or am I missing something?

1 ACCEPTED SOLUTION
Read only

retired_member
Product and Topic Expert
Product and Topic Expert
2,178

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.

6 REPLIES 6
Read only

retired_member
Product and Topic Expert
Product and Topic Expert
2,179

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.

Read only

2,178

Ok thanks!

I'll use the CONV approach for now and hide the warning with ##OPERATOR[I] until there is a fix in one way or another.

Read only

2,178

You can also use methods WRITE and DISPLAY. They are typed with ANY already.

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,178

Could you provide the code as text so that we can test on different releases? Thanks!

Read only

fabianlupa
Contributor
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,178
Thanks. Exactly the same issue with 7.31 and 7.52.