on 10-07-2015 1:31 PM
Hello!
DI API version is 8.81
The problem, that I cannot create A/P Correction Invoice from Draft, I always get an error message, that CPI1.LineStatus Invalid value, what can be the problem?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've tried and this code is working.
If oDraft.GetByKey(CInt(oRS.Fields.Item(0).Value)) Then
'Build the GRPO (new GRPO Obj for each GRPO Doc)
oGRPO = oComp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes)
oGRPO.DocDate = oDraft.DocDate
oGRPO.DocDueDate = oDraft.DocDueDate
oGRPO.DiscountPercent = oDraft.DiscountPercent
oGRPO.CardCode = oDraft.CardCode
For i = 0 To oDraft.Lines.Count - 1
oDraft.Lines.SetCurrentLine(i)
oGRPO.Lines.BaseType = oDraft.Lines.BaseType
oGRPO.Lines.BaseEntry = oDraft.Lines.BaseEntry
oGRPO.Lines.BaseLine = oDraft.Lines.BaseLine
If i < oDraft.Lines.Count - 1 Then
oGRPO.Lines.Add()
End If
Next i
'Add the GRPO
iRetCode = oGRPO.Add
If iRetCode <> 0 Then
oComp.GetLastError(iRetCode, sErrMsg)
Log.WriteLog("Error Adding GRPO : " & sErrMsg, EventLogEntryType.Warning)
Return False
End If
'Kill the GRPO
oGRPO = Nothing
'Remove the Draft
oDraft.Remove()
End If
Regards,
Bry
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Bryan!
The source code is the following
oDoc = _ocmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts)
oDoc.DocObjectCode = SAPbobsCOM.BoObjectTypes.oCorrectionPurchaseInvoice
oRs.DoQuery("select docentry,cardcode from odrf where docentry='" & xEle.Element("ORDNUM").Value & "'")
sbaseentry = oRs.Fields.Item("docentry").Value
oDoc.GetByKey(sbaseentry)
.
.
.
.
working with the document lines. This document has 6 lines, 3 lines status are open and 3 lines status are closed
.
.
.
oDoc.Add()
BR
Ricsi
Hi, you should only get the open line status. Kindly check why the other 3 lines are already closed.
Regards,
Bry
Richard,
In my experiences, -5002 errors when converting drafts into documents come often from the data that I am trying to push into the document being the incorrect type for the field. Another cause of this is that the data is actually NULL, which obviously has no type.
Without having access to your data and your full code, my suggestion to you would be to go through every field that you're trying to push into the document, and make sure that you use IsNull to convert a null value into a blank string, integer, or other applicable "NULL" type value for the field type, and also make sure that you throw all of your input values into a Convert method to force it to be the same type as we want in that field.
Here is a rough example using some of the code that you provided above:
oDoc = _ocmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts)
oDoc.DocObjectCode = SAPbobsCOM.BoObjectTypes.oCorrectionPurchaseInvoice
oRs.DoQuery("select docentry,cardcode from odrf where docentry='" & xEle.Element("ORDNUM").Value & "'")
'DocEntry fields are Integers, so we force this value to be an integer
Dim iDocEntry AS Integer = Convert.ToInt32(oRs.Fields.Item("docentry").Value)
If iDocEntry <> 0 Then
sbaseentry = iDocEntry
oDoc.GetByKey(sbaseentry)
ELSE
MsgBox("Error: DocEntry is null or zero")
END IF
Hopefully this helps.
Why don't you post your whole source code on how you post the transaction?
Regards,
Bry
Hi Richard,
What is the status of the line?
Regards,
Diego
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
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.