cancel
Showing results for 
Search instead for 
Did you mean: 

Updating Base Document detals after creation

Former Member
0 Kudos

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

View Entire Topic
FOA
Advisor
Advisor
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Felipe,

Have you had any luck on this??

Jarno

Former Member
0 Kudos

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.