!--a11y-->
SAPServer and TRFC 
An RFC server application allows you to use .NET functionality within your SAP system. RFC servers can be (normal) RFC, TRFC or QRFC servers.
To write a QRFC server, you have to implement the SAP queuing mechanism. For purposes where you want queuing, we recommend to use Microsoft Message Queue in a TRFC server.
A TRFC server makes sense when have to send information only once from the SAP system to another application (for example, sending a purchase order) . TRFC is required if you want to write an application to receive SAP IDOCS. On your TRFC server, you must manage a connection to a transactional store such as Microsoft SQL Server. You require a transaction store to ensure you can keep track of and manage all RfcTID sent to you from the SAP system so that you can create the TID and the function execution within a transaction. You should therefore override the base class CheckTransactionand CommitTransactionmethods. The base method returns 0 indicating success.
For TRFC, you must implement the following methods:
|
|
Method |
Explanation |
|
When this method is called you should search your TID database to determine if this transaction ID exists or not. If it exists it means that we have already received the request to execute the function. If not, this is the first time and we should log the TID with a status that indicates the method is not yet executed. It should return the following: 0 – It is a new TID. Begin transaction and insert TID into our database 1 – TID already exists in our database, but is not yet confirmed in SAP system (client). SAP will confirm on its end. No further action is required Other – there is an error (for example database connection is down. This tells the SAP system to try again later) |
||
|
2. |
In the transaction, execute the function. If there is a problem, throw an exception |
|
|
3. |
This method is called if you do not throw an exception during the actual method execution (step 2). When the method is called, you should commit the transaction and return the following: 0 – committed successfully Other – Failure |
|
|
4. |
This function is called after the method execution failed because you raised an exception. You can rollback the transaction at this point or in the method. |
|
|
5. |
|
This method is simply an opportunity for you to clean up your TID database by removing TID values that have been fully executed 0 – means it is ok Other values – means it is not ok. |
If the transaction fails at any point, the SAP system tries to resubmit it. By default, the system attempts to resubmit the transaction every 15 minutes up to a maximum of 30 attempts. However, you can configure the resubmission parameters individually for each RFC destination using transaction SM59. From the destination maintenance screen, choose Destination ® TRFC options.