Skip to Content

Inline declaration with function module.

Try as I might, I just don't seem to be able to get an inline decaration to work for what seems like a fairly simple function module. Here's the code:

 CALL FUNCTION 'MATERIAL_READ_PLANTS'
 EXPORTING
 MATNR = ls_matnr-matnr
 TABLES
 PLANTS = DATA(lt_plants).

I get the message The inline declaration "DATA(LT_PLANTS)" is not possible in this position.

Can anyone be of help as to the correct format, if at all possible.

I have also tried using "@DATA(lt_plants)" as well. But did not really expect that to work.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Jul 18, 2017 at 09:09 AM

    Since a call of a function module is always "dynamic", the compiler doesn't know the parameter type and an inline declaration is not possible.

    Add comment
    10|10000 characters needed characters exceeded

    • Exactly! I guess warnings would be more appropriate so as not to break the existing code base (although...).

      But it should still not prevent things like inline declaration for quoted literal function modules. It's just a strange gap from a developer's perspective.

  • Jul 18, 2017 at 09:08 AM

    The syntax is correct, but is not supported for some of the older constructs, including function modules.

    https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abendeclaration_positions.htm

    If you are using Eclipse, just write a variable name and do a quick fix to automatically add the declaration before the call.

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 25, 2017 at 11:56 AM

    I have not checked this again to confirm, but from memory I'm sure this worked when using the FM's export/import parmeters, just not with table. But I'll confirm this.

    Add comment
    10|10000 characters needed characters exceeded