methodsabapsaprfcfunction-module

Parameter is not type-compatible with formal parameter when method is called from FM


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.