Techskills

August 7, 2008

Learning SAP Basic — How to Write a Remote Function Module (RFC)

Filed under: Learn SAP, SAP — Tags: , , — kumar @ 8:12 pm

Calling this function module with in this system you have to use the code as follows.

  CALL FUNCTION ‘Z_TEST_FM’
  EXPORTING
    IN_VAL2            =
    IN_VAL1            =
* IMPORTING
*   OUT_VAL1           =
* EXCEPTIONS
*   NOT_A_NUMBER       = 1
*   OTHERS             = 2
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

 

Calling this function module from a different system you have to use the code as follows.

  CALL FUNCTION ‘Z_TEST_FM’
  destination <RFCDestination>
  EXPORTING
    IN_VAL2            =
    IN_VAL1            =
* IMPORTING
*   OUT_VAL1           =
* EXCEPTIONS
*   NOT_A_NUMBER       = 1
*   OTHERS             = 2
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Make sure you give the RFC destination. Talk to BASIS team to get this information if you want to connect to another system’s Function Module.

Use the T-Code RSRFCCHK to see if your RFC destination to another system is available. (check with your basis team).

I hope this gives some Idea of  How to use the function Module.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress