cancel
Showing results for 
Search instead for 
Did you mean: 

Adding invoice in Java

Former Member
0 Kudos

Hi,

I'm trying to add new invoice using Java Connector:

IDocuments invoice =

SBOCOMUtil.newDocument(context.getCompany(), SBOCOMConstants.BoObjectTypes_Document_oInvoices);

invoice.setCardCode("D00001");

invoice.setDocDate(new Date());

invoice.setDocDueDate(new Date());

invoice.getLines().add();

invoice.getLines().setItemCode("0101009");

invoice.getLines().setQuantity(new Double(2.0));

invoice.getLines().setPrice(new Double(2.0));

int result = invoice.add();

and I get an exception:

com.sap.smb.sbo.wrapper.com.ComFailException: A COM exception has been encountered:

At Invoke of: Add

Description: Serwer wywolal wyjatek. (Server threw an exception)

at com.sap.smb.sbo.wrapper.com.Dispatch.invokev(Native Method)

at com.sap.smb.sbo.wrapper.com.Dispatch.invokev(Unknown Source)

at com.sap.smb.sbo.wrapper.com.Dispatch.callN(Unknown Source)

at com.sap.smb.sbo.wrapper.com.Dispatch.call(Unknown Source)

at com.sap.smb.sbo.api.Documents.add(Unknown Source)

Can anyone help me?

Thanks in advance

Marek Roszatycki

Accepted Solutions (1)

Accepted Solutions (1)

AdKerremans
Active Contributor
0 Kudos

Hi Marek,

This is a Java issue, please read the sap note below to solve it. If you don't have the editbin.exe, I can send it to you.

Symptom

DI-API COM Exception occurs when adding a doc

Other terms

DI-API, COM Exception, documents, Java native interface, JNI

Reason and Prerequisites

DI-API 6.2 and later, JDK ver. 1.3 and later, MS VC 6.0

Solution

When adding a document, such as a sales order, stock transfer document through Java Connector, there always is a COM Exception, saying that

stack overflow occurs at COM side.

It turns out to be a bug in Sun's JDK 1.3 and later. In JDK 1.3 and later, the default stack size is reduced from 1M to 256K. And the command line option -Xss<size>, which works in JDK1.2, is ignored in JDK ver. 1.3 and later. According to Sun, it will not be fixed in the future.

How to find the stack size:

  • Use dumpbin.exe to check the original stack size

dumpbin.exe /headers alone.exe

One way to work around is to change the default setting in java.exe with EDITBIN.EXE provided by Microsoft VC. After changing the default stack size to 1M or above, everything works well. Here is the command line to change the default stack setting:

EDITBIN /STACK:1048576 java.exe

EDITBIN /STACK:1048576 javaw.exe

Before you run this to ol, you should copy MSPDB60.DLL from:

C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin

to the folder where EDITBIN is. It is required by EDITBIN.

After running it, you can see the following message:

Microsoft (R) COFF Binary File Editor Version 6.00.8447

and the date of java.exe and javaw.exe has been changed.

Then to replace the files

  • Replace java.exe and javaw.exe in all places where else occurs.

For example in my computer:

C:\j2sdk1.4.2\bin

C:\j2sdk1.4.2\jre\bin

C:\Program Files\Java\j2re1.4.2\bin

C:\WINNT\system32

Answers (1)

Answers (1)

jaccomoolenaar
Participant
0 Kudos

Hi Marek,

You do not have to do an add() for the first line. The first line is automatically added. Remove this line and i think the error should be solved.

Regards,

Jacco