on 06-03-2005 8:07 AM
I am trying to "join" a delivery with the corresponding order, with the order being captured after the order. Using the DI API I am able to update the Price of the delivery to the order price, but I get an error ("Item no. is missing [ODLN.ObjType]") when trying to update the base document details.
I know that updating an delivery after the order is captured is not standard, but I am hoping that someone has an idea....?
Jarno
Hi Jarno,
If you want to create a document based on an existing one, you have to indicate per line the base type.
In this example i'm creating an invoice (the order was just created before)
' Now add the invoice
Dim strObjKey As String
oInvoice = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)
strObjKey = oCompany.GetNewObjectKey()
'oCompany.GetNewObjectCode(strObjCode)
oDocument.GetByKey(strObjKey)
oInvoice.CardCode = oDocument.CardCode
Dim lint As Integer
For lint = 0 To oDocument.Lines.Count - 1
If lint > 0 Then oDocument.Lines.Add()
oInvoice.Lines.BaseEntry = strObjCode
oInvoice.Lines.BaseLine = lint
oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders
Next
lRetCode = oInvoice.Add
We deliver an example in the SDK under "C:\Program Files\SAP Manage\SAP Business One SDK\Samples\COM DI\VB.NET\05.OrderAndInvoice" you can refer to it for further info.
Best regards,
Felipe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank You for your response.
My problem however is not creating a document from a base one (this I have been able to do). It is updating the target (delivery) with the reference to the base, where the base is captured after the target. I include my code...
Function DeliveryOrderMapping(ByVal OrderDocEntry As Integer, ByVal OrderDocNum As Integer, ByVal OrderLineNum As Integer, ByVal OrderPrice As Double, ByVal DelDocEntry As Integer, ByVal DelLineNum As Integer, SQLServer, SQLUsr, SQLPasswd, SQLDB, SBOUsr, SBOPasswd) As String
DeliveryOrderMapping = ""
On Error GoTo errHandler
Dim RetVal 'As Long
Dim Errcode 'As Long
Dim ErrMsg 'As String
Dim vcmp As New SAPbobsCOM.Company
Call connectToSAP(vcmp, SQLServer, SQLDB, SBOUsr, SBOPasswd, SQLUsr, SQLPasswd)
If vcmp.Connected <> True Then
DeliveryOrderMapping = "Connetion to SAP Failed"
Exit Function
Else
Dim objSO As SAPbobsCOM.Documents
Dim objDN As SAPbobsCOM.Documents
Set objSO = vcmp.GetBusinessObject(17) '17 = oOrders
Set objDN = vcmp.GetBusinessObject(15) '15 = oDelliveryNotes
Set vObj = vcmp.GetBusinessObject(305) ' boBridge
Set oRecordset = vcmp.GetBusinessObject(300)
GetByKeyResult = objSO.GetByKey(OrderDocEntry)
If GetByKeyResult <> "True" Then
Errcode = vcmp.GetLastErrorCode
ErrMsg = vcmp.GetLastErrorDescription
Call DBLog("DeliveryOrderMapping", Errcode, ErrMsg, SQLServer, SQLUsr, SQLPasswd)
DeliveryOrderMapping = Errcode & ErrMsg
Exit Function
End If
objSO.Lines.SetCurrentLine (OrderLineNum)
GetByKeyResult = objDN.GetByKey(DelDocEntry)
If GetByKeyResult <> "True" Then
Errcode = vcmp.GetLastErrorCode
ErrMsg = vcmp.GetLastErrorDescription
Call DBLog("DeliveryOrderMapping", Errcode, ErrMsg, SQLServer, SQLUsr, SQLPasswd)
DeliveryOrderMapping = Errcode & ErrMsg
Exit Function
End If
objDN.Lines.SetCurrentLine (DelLineNum)
objDN.Lines.Price = objSO.Lines.Price
objDN.Lines.BaseType = (17) 'order
objDN.Lines.BaseEntry = OrderDocNum
objDN.Lines.BaseLine = OrderLineNum
RetVal = objDN.Update
'Check the result
If RetVal <> 0 Then
Errcode = vcmp.GetLastErrorCode
ErrMsg = vcmp.GetLastErrorDescription
Call DBLog("DeliveryOrderMapping", Errcode, ErrMsg, SQLServer, SQLUsr, SQLPasswd)
DeliveryOrderMapping = Errcode & ErrMsg
GoTo errHandler
End If
End If
Exit Function
errHandler:
DeliveryOrderMapping = Err.Description
End Function
SDK does not do what SAP B1 does not. I don't see a feature in B1 that lets you create a Base document from a target!!!
does not make sense to me (or may be I don't understand your question.)
can you explain the circumstances that compels you to do a base doc after the target has been created?
Indika.
Hello all,
I had a similar problem. I look at this posting and was able to find out more information on my problem. My outcome seem to be that we can't add a line until we have multiple line.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
6 | |
5 | |
5 | |
5 | |
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.