on 2016 Sep 09 9:47 PM
Hello,
I am trying to create an Invoice through the DI API but I am getting the following error:
Error: -10-In "To Whse" fields, enter valid values.
I don't understand why I am getting this message because I am entering a Warehouse Code that is registered in SAP.
I would also like to know if it is possible to link it to an existing Sales Order and if I could make an A/R Invoice as well.
Thanks!!
Hi Ines,
I don't understand why I am getting this message because I am entering a Warehouse Code that is registered in SAP.
I think you are creating something different of an Invoice, I don't remember of "To Whse" field in the invoice. If you could share your code here, we can have a look.
I would also like to know if it is possible to link it to an existing Sales Order and if I could make an A/R Invoice as well.
Yes, it is possible, the SDK help says it regarding the Base fields
Use the BaseEntry, BaseLine, and BaseType properties to extract data from one document to another. For example, to extract data from a Quotation to an Order.
So, you have to set the mentioned fields within the Document_Lines(Lines) in your object and simply add the object, all the document base fields will be copied to your new object.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here's my code: could you please indicate where I have to place the fields to link it to a sales order please!
Dim oCompany As SAPbobsCOM.Company
Dim nResult As String
Dim slp_Code As Long
Dim TitularCode As Long
Dim costingCode As String
Dim whsCode As Long
oCompany = New SAPbobsCOM.Company
oCompany.CompanyDB = db
oCompany.Server = server
oCompany.language = SAPbobsCOM.BoSuppLangs.ln_English
oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008
oCompany.DbUserName = dbUserName
oCompany.DbPassword = dbPasswrod
oCompany.UserName = userName
oCompany.Password = pass
nResult = oCompany.Connect
If nResult <> 0 Then
nResult = oCompany.GetLastErrorDescription
MsgBox(nResult)
Else
Dim oPo As Object
oPo = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)
oPo.DocDate = FechaDocumento.Text
oPo.TaxDate = FechaConta.Text
oPo.DocDueDate = FechaEntrega.Text
oPo.CardCode = CardCode.Text
oPo.CardName = CardName.Text
oPo.Comments = Comentario.Text
For Each row As DataGridViewRow In TablaItems.Rows
If Not row.IsNewRow Then
oPo.Lines.ItemCode = row.Cells(0).Value.ToString
oPo.Lines.Price = row.Cells(4).Value.ToString
oPo.Lines.Quantity = row.Cells(3).Value.ToString
oPo.Lines.CostingCode = row.Cells(7).Value.ToString
oPo.Lines.WarehouseCode = row.Cells(5).Value.ToString
oPo.Lines.TaxCode = row.Cells(6).Value.ToString
End If
oPo.Lines.Add
Next
Regarding the error you have to add the invoce, try to do like this.
For Each row As DataGridViewRow In TablaItems.Rows
oPo.Lines.SetCurrentLine(oPo.Lines.Count - 1)
oPo.Lines.ItemCode = row.Cells(0).Value.ToString
oPo.Lines.Price = row.Cells(4).Value.ToString
oPo.Lines.Quantity = row.Cells(3).Value.ToString
oPo.Lines.CostingCode = row.Cells(7).Value.ToString
oPo.Lines.WarehouseCode = row.Cells(5).Value.ToString
oPo.Lines.TaxCode = row.Cells(6).Value.ToString
oPo.Lines.Add
Next
The seconde question to add a invoice based on a sales order
This is only what you need
Dim oPo As Documents
oPo = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)
oPo.Lines.BaseEntry = YourSalesOrderDocEntry
oPo.Lines.BaseLine = YourSalesOrderLineNum
oPo.Lines.BaseType = bodt_Order
oPo.Add();
Hi Ines,
Note most importantly,
You declared :
Dim oPo As Object
Where as per pointed out, you should declare as :
Dim oPo As Documents
Writing a VB code is definitely easier, most of the time you don't need to be specific of your types. VB will do the typecasting for you.
This is one of the few time you can not rely on VB's type casting.
Your error message comes from the InventoryTransfer object. Where as you are trying to create an Invoice (Documents) object.
The problem is you declared as object. The GetBusinessObject also returns an object.
VB just doesn't know which underlying type it should cast into.
Regards
Edy
Hi Ines,
That is another reason you should not declare all your variable as object
After you declare oPO as SAPbobsCOM.Documents.
I assume you are using Visual Studio or VBA with the intelisense enabled.
Type in oPO.Lines. (Exactly with the dot behind) under the list of properties shown by the intelisense.
Do you see anything familiar to you with regards to the SerialNumber ?
Plus look up for the DI API reference under C:\Program Files (x86)\SAP\SAP Business One SDK\Help\RefDI.chm
Search for 'SerialNumbers Object Members'
You will notice this line :
SystemSerialNumber :
This property is mandatory when using Serial Numbers for outgoing documents.
Field name: SysSerial.
This is a foreign key to the SerialNumbers object.
Sorry, instead of giving you the fish, i am trying to give you the fishing rod.
Please do close the thread by marking the correct answer once your question is answered.
Regards
Edy
User | Count |
---|---|
105 | |
8 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.