Have you ever had to execute an RFC-enabled function module from outside the SAP system, for instance from a custom-developed Java application?
If so, then for sure you already know the SAP JCo (SAP Java Connector) Java library, and most probably you have also experienced some difficulties with it. For quite a long time I thought that using JCo is the only way of doing this, just because of the obligatory use of the RFC communication protocol. And finally, I have discovered a nice and smooth way to communicate with SAP "from outside" over HTTP, which means that you can establish the communication easier and more flexibly then ever before.
This blog refers strictly to calling RFC-enabled function modules. If you are interested in sending IDocs to SAP over HTTP, please refer to this blog:
Post IDoc to SAP ERP over HTTP from any application
It also assumes that your Internet Communication Framework (SICF) is configured properly, as the configuration of this framework is not the topic of this blog.
As a prerequisite, go to transaction SICF and locate the following service: sap -> bc -> soap -> rfc. Its description gives you some more details about the functionality: SOAP HTTP HANDLER FOR RFC-CAPABLE FUNCTION MODULES.
Now, right-click on that service and choose Test Service, and make sure that you allow SAP to open your web browser (in a popup that appears). Make note of the URL that is opened in the browser. Generally, this URL would look as follows: http://[hostname]:[SICF port]/sap/bc/soap/rfc?sap-client=[client]
Of course, in your particular case it will already contain a concrete host name, port number and client number.
Now that you know the communication URL, use an HTTP client to communicate with SAP. In this example, I will use the SOAP UI tool for this purpose, but it can be any application, including your custom-developed ones, of course. My goal is to execute BAPI_SALESORDER_GETLIST:
The screenshot below ilustrates the most important elements of the configuration:
As a final outcome, you will receive the response from your RFC-enabled function module as the SOAP/HTTP Response.
What is really interesting, you can call several independent function modules without additional effort. You even get separate responses by default. Most importantly, you can use it to execute one particular BAPI and then perform a commit. For instance, if you had to create a sales order and commit it afterwards, you could use the following HTTP request:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:RFCDEMO="urn:sap-com:document:sap:rfc:functions">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<RFCDEMO:BAPI_SALESORDER_CREATEFROMDAT2>
<SALESDOCUMENTIN/>
<ORDER_HEADER_IN>
<DOC_TYPE>OR</DOC_TYPE>
<SALES_ORG>1000</SALES_ORG>
<DISTR_CHAN>10</DISTR_CHAN>
<DIVISION>00</DIVISION>
</ORDER_HEADER_IN>
<CONVERT>X</CONVERT>
<RETURN/>
<ORDER_PARTNERS>
<item>
<PARTN_ROLE>WE</PARTN_ROLE>
<PARTN_NUMB>0000001360</PARTN_NUMB>
</item>
</ORDER_PARTNERS>
</RFCDEMO:BAPI_SALESORDER_CREATEFROMDAT2>
<RFCDEMO:BAPI_TRANSACTION_COMMIT/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
One more important thing to notice here is that whenever you have to pass an entry to a TABLES parameter, use the <item> tag to define an array line.
There are few more things to consider when using the approach described:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
9 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |