Call-Back from an ABAP Function Module

The following programming example shows you how to use this feature:

RFC client program

 

Function module in an R/3 System

rfc_rc = RfcOpen(...);

 

FUNCTION ABC.

rfc_rc = RfcInstallFunction(‘XYZ’, xyz_function,...);

   

rfc_rc = RfcCallReceive(‘ABC’,...);

----->

...

   

CALL FUNCTION ‘XYZ’ DESTINATION ‘BACK’

If(rfc_rc==RFC_CALL)

<-----

...

{

   

rfc_rc = RfcDispatch(...);

   

if(rfc_rc!=RFC_OK)

   

exit(1);

----->

...

}

   

rfc_rc=RfcReceive(...);

<-----

ENDFUNCTION

...

   

 

/* RFC function: ‘ABC’ */

static RFC_RC xyz_function(RFC_HANDLE rfc_handle)

{

rfc_rc = RfcGetData(...); /* Get RFC data */

... /* Process RFC data */

rfc_rc = RfcSendData(...); /* Report result to ABAP */

return 0;

}