Parameter is not type-compatible with formal parameter when method is called from FM
-
05-02-2021 - |
Question
A static public class method, zcl_abc=>dosomething, has an importing parameter
it_lines type TLINE_T optional
And there is a FM called zfm_dosame. It has a parameter
TABLES IT_LINES TYPE TLINE_T OPTIONAL
zfm_dosame calls zcl_abc=>dosomething and tries to pass it_lines to it_lines. However, syntax error:
IT_LINES is not type-compatible with formal parameter IT_LINES.
This error drives me crazy. I have no idea how come... Please help!
Solution
The TABLES part of a function interface creates internal tables with header line at runtime.
So in order to pass the entire table, instead of just one work area, you should pass IT_LINES[]
instead of IT_LINES
to the method you're calling.
OTHER TIPS
It is difficult to tell without more information like the full source code of your function module, function group, and class, but I'll take a guess: Most likely your type TLINE_T is not a global type, but is instead defined locally (and differently) in both the function group of the function module and in the class.
Try double-clicking on the type TLINE_T in both places and see where that brings you. If it brings you to a global type (which you should also be able to see in SE11) in both places, then I'm wrong and there is something else going on.