Skip to Content

How to copy Sales Order to A/R Invoice

Hello Experts,

Greetings for the day...!

I am facing some problem while converting sales order to Sales invoice through DIAP.while converting Sales Order into Sales invoice i am getting error like "base document card not matching with target document "

I have create one grid & i am loading all sales order for the selected periods. if i select all the Sales order and click the Post invoice .first record added successfully from second record on words im getting above error.

if i run each sales order wise its posting automatically.

kindly help me on this issue how to resolve this.

Sub PostInvoice(ByVal FormUID As String) Try objForm = objMain.objApplication.Forms.Item(FormUID) objForm.Freeze(True) oGrid = objForm.Items.Item("1000001").Specific Dim oInvoice As SAPbobsCOM.Documents = objMain.objCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices) For i As Integer = 0 To oGrid.Rows.Count - 1 If oGrid.DataTable.GetValue("Select", i) = "Y" And oGrid.DataTable.GetValue("DocEntry", i) > 0 Then Dim GetOrderData As String = "SELECT T0.DocEntry as 'Header Entry',* from ORDR T0 INNER JOIN RDR1 T1 on T0.DocEntry=T1.DocEntry WHERE T0.DocEntry='" & oGrid.DataTable.GetValue("DocEntry", i).ToString & "'" Dim oRsGetOrderData As SAPbobsCOM.Recordset = objMain.objCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset) oRsGetOrderData.DoQuery(GetOrderData) If oRsGetOrderData.RecordCount > 0 Then While oRsGetOrderData.EoF = False oInvoice.CardCode = oGrid.DataTable.GetValue("CardCode", i).ToString oInvoice.CardName = oGrid.DataTable.GetValue("CardName", i).ToString oInvoice.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items oInvoice.DocDate = oGrid.DataTable.GetValue("DocDate", i).ToString oInvoice.DocDueDate = oGrid.DataTable.GetValue("DocDate", i).ToString oInvoice.TaxDate = oGrid.DataTable.GetValue("DocDate", i).ToString oInvoice.Comments = "Sale Invoice posted from add-on" oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders oInvoice.Lines.BaseEntry = oRsGetOrderData.Fields.Item("Header Entry").Value oInvoice.Lines.BaseLine = oRsGetOrderData.Fields.Item("LineNum").Value oInvoice.Lines.Add() oRsGetOrderData.MoveNext() End While End If If oInvoice.Add() = 0 Then objMain.objApplication.StatusBar.SetText("Sale Invoice successfully posted", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success) Else objMain.objApplication.StatusBar.SetText(objMain.objCompany.GetLastErrorDescription & " for " & oGrid.DataTable.GetValue("CardCode", i) & " ", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error) End If End If Next objForm.Freeze(False) Catch ex As Exception objForm.Freeze(False) objMain.objApplication.StatusBar.SetText(ex.Message) End Try End Sub End Class

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers