on 05-01-2006 6:20 PM
When trying to create/update records, If the create/update bapi is called thru a web service.
What is the best practice to call a commit when using webservices. Can we call commit/rollback after calling a webservice and checking the error table for errors. I would like to call committ/rollback from .net after i call the webservice and check for errors.
Message was edited by: Tarun Gogia
You need to do two things:
- You must have BAPI_TRANSACTION_COMMIT in your proxy. When getting the WSDL (see other thread) just add it separated by a comma.
- You need to turn the use of a common session on. This is done with the query string parameter "session_mode". For details please see the samples / docu and my answer on the thread .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Reiner,
<b>1. Could you provide an example for how to use bapi_transaction_commit in any other update/add webservice.I couldn't find it in the thread you gave the link to. DO I have to add BAPI_TRANSACTION_COMMIT as a web reference. I am not sure where to add BAPI_TRANSACTION_COMMIT separated by a comma</b>
<b>2. About the querystring parameter session_mode = 1 in the first call and session_mode =2 in the last call, does it mean we can have multiple adds/updates and in the end we might just commit or rollback depending on if there were no errors. Also, this querystring should it be in url for wsdl which is used to add a web reference.</b>
Thanks..
Tarun
1. To get WSDL you use the url
http://<host_name>:<port_number>/sap/bc/soap/wsdl/?services=<functionmodule_names>&sap-client=<relev...; , where <functionmodule_names> is a comma-separated list of BAPIs, including BAPI_TRANSACTION_COMMIT.
This will create you a C#/VB proxy with all specified methods in one class.
2. Yes, each official BAPI will only store any changes in the Udate process. You need to call BAPI_TRANSACTION_COMMIT to commit the changes. Else they are lost.
The session_mode parameter must be appendend to the standard-URL from WSDL. You specify it only at runtime - not at design time.
>The url property on the service which i instantiated is
> different and ends with sap/bc/soap/rfc.
Yes, this is correct. This is the correct thing to change:
WebServiceProxy proxy = new WebServiceProxy();
...
string orgUrl = proxy.Url;
proxy.Url = orgUrl + "&session_mode=1";
proxy.FirstCall();
proxy.Url = orgUrl;
proxy.SecondCall();
proxy.Url = orgUrl + "&session_mode=2";
proxy.LastCall();
I am not sure , i understood what you meant by webserviceproxy. Please have a look the following code snippet. Is it totally to avoid using web-reference and consuming it dynamically. Is it a kind of add-on (webserviceProxy) or am i just missing a namespace.
<b>S.url at runtme is
http://<server-name>:8000/sap/bc/soap/rfc</b>;
<b> 'bpadd is the web-reference name
Dim s As bpadd.RfcService = New bpadd.RfcService()
s.Credentials = cred
Dim BuisnessPartner As String = "0000000232"
Dim BAPIRET2() As bpadd.BAPIRET2 = _
{New bpadd.BAPIRET2()}
Dim tmpUrl As String
tmpUrl = s.Url + "&session_mode=1"
s.Url = tmpUrl
s.YEXTERNALBPADD(BuisnessPartner, BAPIRET2)
tmpUrl = s.Url + +"&session_mode=2"
s.Url = tmpUrl
Dim ErrTable As bpadd.BAPIRET2
ErrTable = s.BAPI_TRANSACTION_COMMIT("")</b>
Your code is allmost correct except
- You must save the original url in a string and restore it. In your current code you concatenate "&session_mode=1" with "&session_mode=2".
- If your org URL doesn't already contain query string parameters, you nee to use "?" as delemiter:
'bpadd is the web-reference name
Dim s As bpadd.RfcService = New bpadd.RfcService()
s.Credentials = cred
s.CookieContainer = new CookieContainer();
Dim BuisnessPartner As String = "0000000232"
Dim BAPIRET2() As bpadd.BAPIRET2 = _
{New bpadd.BAPIRET2()}
Dim tmpUrl As String
tmpUrl = s.Url
s.Url = tmpUrl + "?session_mode=1"
s.YEXTERNALBPADD(BuisnessPartner, BAPIRET2)
s.Url = tmpUrl
' do any additional calls here
Dim ErrTable As bpadd.BAPIRET2
s.Url = tmpUrl + "?session_mode=2"
ErrTable = s.BAPI_TRANSACTION_COMMIT("")
Thanks,it worked fine...
Though i have a question, how would this scenario work when multiple users over the web are calling the webservices. I mean though we have a session , but not a sessionID, to uniquely identify a user. So though mutiple calls to bapis would go in a session, but it may not be unique to the user. Is that correct...
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.