on 07-29-2008 2:39 PM
Hi,
I am trying to write code to update an existing AP Invoice and cannot get it working. Basically the code I am using is:
Dim itemCode As String
REM set the item code
itemCode = "P-0004-SAP001-2" 'Not sure where to get this
Dim Inv As SAPbobsCOM.Documents
Dim InvLine As SAPbobsCOM.Document_Lines
'Get Invoice Object
Inv = vCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseInvoices)
REM get the relevant invoice
System.Console.WriteLine("Getting AP Invoice")
Inv.GetByKey(168)
'Add a line to the Invoice
InvLine = Inv.Lines
System.Console.WriteLine("Count(1): " & CStr(InvLine.Count))
InvLine.Add()
System.Console.WriteLine("Count(2): " & CStr(InvLine.Count))
System.Console.WriteLine("Setting current line")
InvLine.SetCurrentLine(InvLine.Count - 1)
InvLine.ItemCode = itemCode
InvLine.Quantity = 3
InvLine.PriceAfterVAT = 666.0
InvLine.TaxCode = "S"
InvLine.VatGroup = "S"
InvLine.Currency = "GBP"
InvLine.ItemDescription = "This is an add item to existing test"
'Add the Reserced Invoice
retVal = Inv.Update()
InvLine = Inv.Lines
System.Console.WriteLine("Count(3): " & CStr(InvLine.Count))
'Check the result
If retVal <> 0 Then
vCmp.GetLastError(ErrCode, ErrMsg)
System.Console.WriteLine(ErrCode & " " & ErrMsg)
End If
(Note: The System.Console.WriteLine... statements are just for debugging purposes)
The error I'm getting from this is:
ErrCode -5002
ErrMsg "Cannot add or update this document; rows are missing [OPCH.DocNum][line: 0]"
Can someone explain what I am doing wrong or point me in the right direction.
Many thanks
Adrian
Guys,
Thanks - Although not a solution to my problem (It would appear that this is a problem without solution) your answers have been very very useful. Will have to do the modification upstream before passing data into SAP B1 by the looks of things
Adrian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Adrian,
you are true, there is no easy solution for this - after adding invoice you can change only few fields with no link to GL and accounts.
If you need change some other field, which is not allowed to change after invoice is created, you should use oCorrectionInvoice object and change it with correction invoice.
Hi Adrian,
U cannot update an invoice completly, just check from the standard SAP B1 screen.
We can update only the duedate, doc date, and remarks.. etc..
We cannot update the rowlevel information.
Dont forget to reward points.
Regards,
Vasu Natari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
AP Invoice cannot be updated when it is added into the database.
(see B1 standard gui, when you add the AP Invoice you will get the same disclaimer!)
Regards
J.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
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.