RFC Calls: Function Module Parameter Passing

By | April 17, 2009 | Function Module | 20,782 | 2

Parameter Passing in the RFC Function Module Calls

Today we will discuss how system take care of the obligatory parameter passing in the RFC function module.

Generally, when we call the FM without passing the obligatory parameter, system would raise the exception CALL_FUNCTION_PARM_MISSING and would lead to run time error. Now, when we call the same RFC FM with perticular Destination without passing the obligatory parameter, system is not giving any runtime error. How does this happen? Why this different behaviour?

Actually, when we generate our RFC FM, System generates one more Include program with Subroutine which calls the FM. So, when we call the RFC FM using CALL FUNCTION … DESTINATION .. RFC Framework calls this generated Subroutine. This Subroutine passes all the parameters to the FM Call, including the obligatory ones and it is not giving us any runtime error of missing parameters.

To demonstrate this, I would use the RFC FM ZTEST_NP_RFC which was created in the FG ZTEST_NP. This is the code snippet for the RFC FM:

FUNCTION ztest_np_rfc.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(KUNNR) TYPE  KUNNR
*"     VALUE(NAME1) TYPE  NAME1
*"  EXPORTING
*"     VALUE(SUBRC) TYPE  SUBRC
*"  EXCEPTIONS
*"      NO_DATA_FOUND
*"----------------------------------------------------------------------
*
* Both initial.. Return 3
* Else.. Return 4
  IF  kunnr IS INITIAL
  AND name1 IS INITIAL.
    subrc '3'.
  ELSE.
    subrc '4'.
  ENDIF.
*
ENDFUNCTION.

System has generated the Include LZTEST_NP_RFCV01 (L+fgname+V+fmnumber) with subroutine ZTEST_NP_RFC (same name as the FM) which call the FM. This include is part of the RFC framework. Here is the code snippet for this include LZTEST_NP_RFCV01:

*******************************************************************
*   THIS FILE IS GENERATED BY THE FUNCTION LIBRARY               **
*   NEVER CHANGE IT MANUALLY, PLEASE!                            **
*******************************************************************
FORM ztest_np_rfc %_RFC.
* Parameter declaration
  DATA kunnr TYPE
  kunnr
  .
  DATA name1 TYPE
  name1
  .
  DATA subrc TYPE
  subrc
  .
* Assign default values
* Call remote function
  CALL FUNCTION 'ZTEST_NP_RFC' %_RFC
    EXPORTING
      kunnr kunnr
      name1 name1
    IMPORTING
      subrc subrc.
ENDFORM.                    "ZTEST_NP_RFC

Lets see the call to this FM using this test program.

REPORT  ztest_np_1 LINE-COUNT 10 NO STANDARD PAGE HEADING.
*
DATAlf_subrc TYPE subrc.
*
START-OF-SELECTION.
*
* CALL RFC FM without passing the mandatory Parameters
*  and it would give us error
  CALL FUNCTION 'ZTEST_NP_RFC' DESTINATION 'NONE'
    IMPORTING
      subrc lf_subrc.
*
  WRITElf_subrc.

Now, how do we find out how does this work? Since this is a part of the system, we need to activate the system debugging.
1. Put a breakpoint on the FM
2. Run the Program
3. From the debugger, start the System debugging. Settings > System Debugging
4. Step in (F5)
5. Check the Call the Stack

Have a look at the call stack

.. and the RFC Framework subroutine:

This would raise an question: As a developer, how do we design our RFC FMs which would not fail in terms of the functionality (works even we don’t pass the mandatory parameters)? In next blog, we would explore why it behaves like this and how we can overcome the problem. You can find it here: RFC Calls II – Solution to mandatory Parameters to FM

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{274 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 274 articles.

Load comments

2 Comments

  • Madhu

    It is good one.

    Regards,
    Madhu.

  • […] time ago, I wrote about RFC Calls: Function Module Parameter Passing. In this post, I figured out the hidden include by using the naming standard. System has […]

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.