Show TOC

Background documentationRFC Server Program Working With RfcDispatch Locate this document in the navigation structure

 

Syntax Syntax

  1. /* main program */
  2. rfc_handle = RfcAccept(...);	/*	Accept RFC connection	*/
  3. if (rfc_handle == RFC_HANDLE_NULL)	/*	Check return code	*/
  4. {
  5.   rfc_error_handling("RfcAccept");	/*	Handle error and get error	*/
  6.   return 1;	/*	specification via RfcLastError	*/
  7. }
  8. rfc_rc = RfcInstallFunction(‘ABC’, abc_function,...);
    	/*	Install RFC function ‘ABC’	*/
  9. 	/*	under the C-routine 	*/
  10. 	/*	‘abc_function’	*/
  11. if (rfc_rc != RFC_OK)	/*	Check return code	*/
  12. {
  13.   rfc_error_handling("Install function ‘ABC’);
  14. 	/*	Handle error and get error	*/
  15.   return 1;	/*	specification via RfcLastError	*/
  16. }
  17. do	/*	Wait for call or execution of	*/
  18. {
  19.   rfc_rc = RfcDispatch(...);	/*	installed RFC functions until	*/
  20. } while ( rfc_rc == RFC_OK);	/*	connection is closed or	*/	/*	terminated	*/
  21. RfcClose(...);				/*	Close RFC connection	*/
  22. /* RFC function: ‘ABC’ */
  23. static RFC_RC abc_function(RFC_HANDLE rfc_handle)
    {
      rfc_rc = RfcGetData(...);	/*	Get associated RFC data	*/
  24.   if (rfc_rc != RFC_OK)	/*	Check return code	*/
  25.   {
  26.     rfc_error_handling("RfcGetData");
    	/*	Handle error and get error	*/
  27.     return 1;	/*	specification via RfcLastError	*/
  28.   }
  29. ...	/*	Process RFC data	*/
  30. rfc_rc = RfcSendData(...);	/*Report result to ABAP program	*/
  31.   if (rfc_rc != RFC_OK)	/*	Check return code	*/
  32.   {
  33.     rfc_error_handling("RfcSendData");	
    	/*	Handle error and get error	*/
  34.     return 1;	/*	specification via RfcLastError	*/
  35.   }
  36. return 0;	/*	Back to RFC Library	*/
  37. }
End of the code.