Search code examples
abapsubroutine

How do I pass multiple parameters to a subroutine?


I am trying to pass multiple parameters to a subroutine, but I get the following error:

Incorrect nesting: before the statement "FORM", the structure introduced by "FORM" must be concluded with "ENDFORM"

Here is my code:

CASE p_choose.
  WHEN 'UMK'.
    PERFORM umk USING: p_modul,
                       p_e_pal,
                       p_vbeln,
                       p_e_umk.
"some other cases
ENDCASE.

FORM umk USING: p_modul,
                p_e_pal,
                p_vbeln,
                p_e_umk.
ENDFORM.

Where is my mistake? How can I pass multiple parameters? Or isn't it possible at all? Thanks!


Solution

  • To complete your own answer which is the correct solution, let me explain the reason of the error which is due to a misunderstanding of how the chained statements work, by showing the equivalent code without the chained statements.

    Your old code with chained statements (symbols : and ,):

    FORM umk USING: p_modul,
                    p_e_pal,
                    p_vbeln,
                    p_e_umk.
    ENDFORM.
    

    is exactly equivalent to this code without chained statements:

    FORM umk USING p_modul.
    FORM umk USING p_e_pal.
    FORM umk USING p_vbeln.
    FORM umk USING p_e_umk.
    ENDFORM.
    

    Hence the obvious syntax error.