cancel
Showing results for 
Search instead for 
Did you mean: 

Creating StockTransferDraft throug DIAPI giving error -5001

Former Member
0 Kudos

Stock Transfer Draft through DIAPI giving error -5001

Posted: Mar 9, 2011 10:44 AM Reply

Dear all,

I tried to add a stock tranfer draft through DI API using the follwing code

Dim oInvenDraft As SAPbobsCOM.StockTransfer

oInvenDraft = p_oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransferDraft)

oInvenDraft.DocDate = CDate(System.DateTime.Now)

oInvenDraft.FromWarehouse = "CSP001"

oInvenDraft.Lines.ItemCode = "LAVO Tiger"

oInvenDraft.Lines.Quantity = 1

oInvenDraft.Lines.WarehouseCode = "CSP002"

oInvenDraft.Lines.ProjectCode = "P01"

oItems.GetByKey("LAVO Tiger")

If oItems.ManageSerialNumbers = SAPbobsCOM.BoYesNoEnum.tYES Then

oInvenDraft.Lines.SerialNumbers.InternalSerialNumber = "CSP002"

oInvenDraft.Lines.SerialNumbers.Add()

End If

oInvenDraft.Lines.Add()

lGR = oInvenDraft.Add

If lGR 0 Then

oCompany.GetLastError(lErrCode, sErrDesc)

end if

Its throwing IGR value as -5001

but company.getlasterror method giving error description as null...

please help me in resolving this

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hello!

If you have only one line, don't use Lines.Add. It initiates the second line, and since you don't set any property in this line, the document creation will be failed.

But the error code 5001 doesn't refers to this. You should have set DocObjectCode property. So insert this line:

oInvenDraft.DocObjectCode = SAPbobsCOM.BoObjectTypes.oStockTransfer

Regards, Gergő

Edited by: Gergely Humicsko on Dec 17, 2011 5:49 AM