Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_TRANSACTION_COMMIT doesn't commit!

Former Member
0 Likes
1,033

Hey,

I'm using BAPI_TRANSACTION_COMMIT to commit an invoice (BAPI_INCOMINGINVOICE_CREATE) out of a Java Programm. I'm using the SAP Enterprise Connector to create Proxy-Classes for Java. Problem: ret.getMessage() is always empty and nothing is commited. Some ideas? That's my Code:

jcoclient.connect();
Connector_PortType myproxy = new Connector_PortType();
Commit_PortType commitProxy = new Commit_PortType();
myproxy.messageSpecifier.setJcoClient(jcoclient);
commitProxy.messageSpecifier.setJcoClient(jcoclient);
String returnString = "Error during transmitting the data! Check required fields!";
try {
	// BAPI Invoice call
	Bapi_Incominginvoice_Create_Output output = myproxy.bapi_Incominginvoice_Create(input);
	Bapiret2Type[] returns = output.getReturn();
	if(returns.length == 1) {
		returnString = "Invoice transmitted successfully!"; //Thats OK
		// Commit call
		Bapi_Transaction_Commit_Input transInput = new Bapi_Transaction_Commit_Input();	
		transInput.setWait("X");
		Bapi_Transaction_Commit_Output transOutput = commitProxy.bapi_Transaction_Commit(transInput);
		commit.Bapiret2Type ret = transOutput.getReturn();
		returnString = returnString + " - "+ret.getMessage(); // ret.getMessage is always empty

Thanks in advance!

Regards

Michael

5 REPLIES 5
Read only

Former Member
0 Likes
734

Hi

I don't get your problem. Do you mean, the BAPI is not saving the data in this case.

Once your Invoice gets succesfully created, Why you expect a message after using BAPI_TRANSACATION_COMMIT. Is there any specific requirement, where you want to display the message.

I don't think you should be using return tables in BAPI_TRANSACTION_COMMIT, here.

Pls check again, without specifying return tables in BAPI_TRANSACTION_COMMIT.

Hope this will help.

Pls reward suitable points.

Regards

- Atul

Read only

Former Member
Read only

Former Member
0 Likes
734

Hi,

it is difficult to understand your coding, since you obviously have your own wrapper classes for the JCO classes. But one possible reason could be:

You do a connect for the bapi call and a separate connect for the transaction commit. If the second one is a new connect to the R/3 system, you are in a different LUW and the commit has no impact on the update tasks of the first bapi call.

One solution could be: Build your own ABAP wrapper for the BAPI, which does already a commit, and call this wrapper by JCO.

Best regards,

Thomas

Read only

Former Member
0 Likes
734

I think the commit may never be called because of:


if(returns.length == 1)

The RETURNS table is generally not empty after the initail BAPI call if it was successful.

Rob

Read only

Former Member
0 Likes
734

There is no problem calling BAPI_COMMIT even if the invoice create had errors. The only reason to not commit is if you are calling a series of BAPIs and want to only commit if all the BAPI calls are successful.

So to bring together some of the earlier comments, you could put the BAPI_COMMIT in the wrapper for the BAPI_INCOMINGINVOICE_CREATE and call it regardless of the result.

Michael