Skip to Content
author's profile photo Former Member
Former Member

Posting A/R Invoice using SDK -the process stopping automatically after 30M

Dear Friends,

I am trying to post Service A/R invoice Using SDK for 254 documents(Number of detail row in A/R Invoice is 15-20) approximately by fetching data from .CSV file for UK Localization. As the number of lines is more, the system is taking more than half an hour to post the documents.While processing, when it is reaching Nth record (96th record in my case) the process getting stopped posting without throwing any errors and the system is not hanging also.The time taken to reach the Nth record is 30 minutes.The issue is repeating even when i try multiple times during off-peak hours also.

I paralley checked my hardware resources also. The system was too good in configuration.Please find my hardware configuration as below,

Intel Xeon CPU X5650 2.67 GHz 2.67 GHz (2 Processors)

64 Bit Operating System

64GB Memory (RAM)

320GB HDD

I couldn't conclude the cause of the issue is due to any memory bottleneck or object releasing problem?

Kindly help me to move forward.

regards,

Sakthivel

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 06, 2014 at 01:21 PM

    Hi Sakthi,

    Are you using DI API? Can you share the codes?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi ,

      Ya I am using DI API.

      My Code is :

      Function InvoicePosting() As Boolean

      Try

      Dim Dt As New DataSet

      Dim value As String() = Split(frmInvoicePreview.Items.Item("t_xlsfile").Specific.value.ToString.Trim, "\")

      Dim Path = frmInvoicePreview.Items.Item("t_xlsfile").Specific.value.ToString.Trim.Substring(0, Len(frmInvoicePreview.Items.Item("t_xlsfile").Specific.value.ToString.Trim) - Len(value(UBound(value))))

      If (LoadIntoDataTables(Path, value(UBound(value)), Dt) = False) Then

      Exit Function

      End If

      ' Geting Invoice type code .....................Details...........

      oApplication.StatusBar.SetText("All Query values data geting Started...", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)

      'Invoice Type

      Dim inttypecode As String = getSingleValue("select Code from [@SHJ_INV_OINTY] where Code=(select U_InvType from [@SHJ_INV_OINCT] where Code='" & frmInvoicePreview.Items.Item("t_invcat").Specific.value.ToString.Trim & "')")

      Dim intType As String = "select Code from [@SHJ_INV_OINTY] where Code=(select U_InvType from [@SHJ_INV_OINCT] where Code='" & frmInvoicePreview.Items.Item("t_invcat").Specific.value.ToString.Trim & "')"

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Invocie Type query : " & intType, "E")

      ' Geting Business Partner Code of GRMD ..................... Details............

      'Dim GANBPCode As String = getSingleValue("select U_GANBPCode from [@SHJ_INV_OINCT] where Code='" & frmInvoicePreview.Items.Item("t_invcat").Specific.value.ToString.Trim & "' and isnull(U_RBPFF,'N')='N' ")

      'Getting GAN Customer Coder

      Dim GANBPCode As String = getSingleValue("select U_GCCode from [@SHJ_INV_OINCT] where Code='" & frmInvoicePreview.Items.Item("t_invcat").Specific.value.ToString.Trim & "' and isnull(U_RBPFF,'N')='N' ")

      ' Geting Business Partner Code of PTML..................... Details............

      Dim PTMLBPCode As String = getSingleValue("select U_PTMLBPCode from [@SHJ_INV_OINCT] where Code='" & frmInvoicePreview.Items.Item("t_invcat").Specific.value.ToString.Trim & "' and isnull(U_RBPFF,'N')='N' ")

      ' Geting Business Partner Code of GAN PTML..................... Details............

      Dim GANPTMLBPCode As String = getSingleValue("select U_GPBPCode from [@SHJ_INV_OINCT] where Code='" & frmInvoicePreview.Items.Item("t_invcat").Specific.value.ToString.Trim & "' and isnull(U_RBPFF,'N')='N' ")

      ' Geting Business Partner Code of GAN GGI..................... Details............

      Dim GANGGIBPCode As String = getSingleValue("select U_GGBPCode from [@SHJ_INV_OINCT] where Code='" & frmInvoicePreview.Items.Item("t_invcat").Specific.value.ToString.Trim & "' and isnull(U_RBPFF,'N')='N' ")

      'FOR TEST--Display query

      Dim GANCodequery As String = "select U_GCCode from [@SHJ_INV_OINCT] where Code='" & frmInvoicePreview.Items.Item("t_invcat").Specific.value.ToString.Trim & "' and isnull(U_RBPFF,'N')='N' "

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": GRMD BP Code : " & GANCodequery, "E")

      Dim PTMLCodequery As String = "select U_PTMLBPCode from [@SHJ_INV_OINCT] where Code='" & frmInvoicePreview.Items.Item("t_invcat").Specific.value.ToString.Trim & "' and isnull(U_RBPFF,'N')='N' "

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": PTML BP Code : " & PTMLCodequery, "E")

      '*****************************************

      ' Get column mapping data details..................

      'Dim Sqlstr As String = " select T0.U_InvType,T0.U_InvCat,T0.U_InvNo,T0.U_InvDt,U_VoyNo,U_Vessal,U_PortOL,U_Bill,U_CustCode,U_CustName,U_AmtPaid,U_IFCode, " & _

      ' "U_IFName,U_GANCode,T1.U_GANTCode,T1.U_ExCName,T1.U_GANPer,T1.U_PTMLCode, T1.U_PTMLTCode,T1.U_PTMLPer from [@SHJ_INV_OINCM] T0 Join [@SHJ_INV_INCM1] T1 on T0.Code=T1.Code " & _

      ' "where T0.U_InvType='" & frmInvoicePreview.Items.Item("t_invtype").Specific.value.ToString.Trim & "' and T0.U_InvCat='" & frmInvoicePreview.Items.Item("t_invcat").Specific.value.ToString.Trim & "' " & _

      ' "and T0.U_EffSdate = (select Top 1 U_EffSdate from [@SHJ_INV_OINCM] " & _

      ' "where T0.U_InvType=U_InvType and T0.U_InvCat=U_InvCat order by U_EffSdate desc) and U_Active ='Y' "

      ' Get column mapping data details..................

      Dim Sqlstr As String = " select T0.U_InvType,T0.U_InvCat,T0.U_InvNo,T0.U_InvDt,U_VoyNo,U_Vessal,U_PortOL,U_Bill,U_CustCode,U_CustName,U_IFCode, " & _

      "U_IFName,U_GANCode,T1.U_GANTCode,T1.U_ExCName,T1.U_GANPer,T1.U_GPTMLCode, T1.U_GPTMLTCode,T1.U_PTMLPer,T1.U_PTMLCode, T1.U_PTMLTCode,T1.U_MGGICode, T1.U_MGGITCode,T1.U_GGIPer,T1.U_GGICode, T1.U_GGITCode,U_BnkCuAcc ,U_totamt,U_MTJnl,U_CuRecAcc from [@SHJ_INV_OINCM] T0 Join [@SHJ_INV_INCM1] T1 on T0.Code=T1.Code " & _

      "where T0.U_InvType='" & frmInvoicePreview.Items.Item("t_invtype").Specific.value.ToString.Trim & "' and T0.U_InvCat='" & frmInvoicePreview.Items.Item("t_invcat").Specific.value.ToString.Trim & "' " & _

      "and T0.U_EffSdate = (select Top 1 U_EffSdate from [@SHJ_INV_OINCM] " & _

      "where T0.U_InvType=U_InvType and T0.U_InvCat=U_InvCat order by U_EffSdate desc) and U_Active ='Y' "

      Dim INV As SAPbobsCOM.Recordset

      INV = DoQuery(Sqlstr)

      'For Dsipay

      Dim MappingDetails1 As String = " select T0.U_InvType,T0.U_InvCat,T0.U_InvNo,T0.U_InvDt,U_VoyNo,U_Vessal,U_PortOL,U_Bill,U_CustCode,U_CustName,U_IFCode, " & _

      "U_IFName,U_GANCode,T1.U_GANTCode,T1.U_ExCName,T1.U_GANPer,T1.U_PTMLCode,T1.U_PTMLTCode,T1.U_PTMLPer,U_MTJnl from [@SHJ_INV_OINCM] T0 Join [@SHJ_INV_INCM1] T1 on T0.Code=T1.Code "

      Dim MappingDetails2 As String = "where T0.U_InvType='" & frmInvoicePreview.Items.Item("t_invtype").Specific.value.ToString.Trim & "' and T0.U_InvCat='" & frmInvoicePreview.Items.Item("t_invcat").Specific.value.ToString.Trim & "' " & _

      "and T0.U_EffSdate = (select Top 1 U_EffSdate from [@SHJ_INV_OINCM] " & _

      "where T0.U_InvType=U_InvType and T0.U_InvCat=U_InvCat order by U_EffSdate desc) and U_Active ='Y'"

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": GAN Mapping Details1 : " & MappingDetails1, "E")

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": GAN Mapping Details2 : " & MappingDetails2, "E")

      'For Dispaly

      oApplication.StatusBar.SetText("All Query values data geting Successfully...", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)

      ' csv file data loop for read all rows................

      Dim InvNo As Integer

      Dim Invdate As Integer

      'Check the PTML Company Connected or not

      If (oPTMLCompany.Connected = False) Then

      If (ConnectToPTMLCompany() = False) Then

      LogInfo("PTML Company Connection Failed ", "E")

      Exit Function

      End If

      End If

      'Start PTML

      If (oPTMLCompany.InTransaction = False) Then

      oPTMLCompany.StartTransaction()

      End If

      'Start GAN

      If (oCompany.InTransaction = False) Then

      oCompany.StartTransaction()

      End If

      'Account Code for Difference Amount Paid -->Control Account

      Dim CustomerAccCode As String = INV.Fields.Item("U_BnkCuAcc").Value

      Dim PTMLCustomerAccCode As String = ""

      '*******************************

      Dim PTMLLineCount As Integer = 0

      Dim GRMDLineCount As Integer = 0

      Dim GGILineCount As Integer = 0

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": No of Row in CSV File : " & Dt.Tables(0).Rows(0)(0).ToString().Trim(), "E")

      If Dt.Tables(0).Rows(0)(0).ToString().Trim() <> String.Empty Then

      INV.MoveFirst()

      ' Invoice Posting data for Line details.......................

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": A/R Invoice line Posting Started : ", "E")

      '**********************************************************************************

      'GAN-PTML-JE

      Dim oPTMLJE As SAPbobsCOM.JournalEntries

      oPTMLJE = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries)

      'GAN-GGI-JE

      Dim oGGIJE As SAPbobsCOM.JournalEntries

      oGGIJE = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries)

      Dim GANPTMLJETotalValue As Double = 0

      Dim GANGGIJETotalValue As Double = 0

      Dim InvoiceNoGGI As String = ""

      Dim InvoiceNoPTML As String = ""

      '*************************************************************************************

      frmInvoicePreview.Items.Item("t_NoOfRec").Specific.value = Dt.Tables(0).Rows.Count & "/"

      For L As Integer = 0 To Dt.Tables(0).Rows.Count - 1

      If Dt.Tables(0).Rows(L)(0).ToString().Trim() <> String.Empty Then

      frmInvoicePreview.Items.Item("t_CompRec").Specific.value = L + 1

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": No of Record Completed " & frmInvoicePreview.Items.Item("t_NoOfRec").Specific.value & "/" & frmInvoicePreview.Items.Item("t_CompRec").Specific.value, "E")

      Dim GRMTotalAmount As Double = 0

      If (IIf(Dt.Tables(0).Rows(L)(0).ToString().Trim() = "", 0, Dt.Tables(0).Rows(L)(0).ToString().Trim()) <= 0) Then

      Continue For

      End If

      INV.MoveFirst()

      'GRMD

      Dim oInvoice As SAPbobsCOM.Documents

      oInvoice = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)

      'PTML

      Dim oPTMLInvoice As SAPbobsCOM.Documents

      oPTMLInvoice = oPTMLCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)

      Try

      InvNo = INV.Fields.Item("U_InvNo").Value

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Invocie Number error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Dim VoyNo As Integer

      Try

      VoyNo = INV.Fields.Item("U_VoyNo").Value

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Voyage Number error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Dim Vessal As Integer

      Try

      Vessal = INV.Fields.Item("U_Vessal").Value

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Vessal Number error : " & ex.Message.ToString().Trim(), "E")

      End Try

      'Total Amount **************************

      Dim TotalAmount As Integer

      Try

      TotalAmount = INV.Fields.Item("U_totamt").Value

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": total Amount : " & ex.Message.ToString().Trim(), "E")

      End Try

      '****************************************

      Dim PortOL As Integer

      Try

      PortOL = INV.Fields.Item("U_PortOL").Value

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Port of Loading error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Dim Bill As Integer

      Try

      Bill = INV.Fields.Item("U_Bill").Value

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Bill Number error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Dim InvType As String = ""

      Try

      InvType = INV.Fields.Item("U_InvType").Value

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Invoice Type error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Dim InvCat As String

      Try

      InvCat = INV.Fields.Item("U_InvCat").Value

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Invoice Category error : " & ex.Message.ToString().Trim(), "E")

      End Try

      'GAN Customer Code

      Dim CustCode As String

      Try

      CustCode = INV.Fields.Item("U_CustCode").Value

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Customer Code error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      Invdate = INV.Fields.Item("U_InvDt").Value

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Invocie Date error : " & ex.Message.ToString().Trim(), "E")

      End Try

      'GAN Header --Start

      Dim CustomerCode As String = ""

      'Customer Code

      Try

      If CustCode.ToString.Trim = "" Then

      oInvoice.CardCode = GANBPCode

      CustomerCode = GANBPCode

      Else

      oInvoice.CardCode = Dt.Tables(0).Rows(L)(CustCode).ToString.Trim()

      CustomerCode = Dt.Tables(0).Rows(L)(CustCode).ToString.Trim()

      End If

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Card Code: " & oInvoice.CardCode, "E")

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": BP Code error : " & ex.Message.ToString().Trim(), "E")

      End Try

      'DOcument Date ,Due Date, Posting Date

      Try

      oInvoice.DocDate = CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim())

      oInvoice.DocDueDate = CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim())

      oInvoice.TaxDate = CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim())

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Doc Date error : " & ex.Message.ToString().Trim(), "E")

      End Try

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Invoice Date: " & oInvoice.DocDate, "E")

      'INvoice type -->Service

      Try

      oInvoice.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Service

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Item Type : " & ex.Message.ToString().Trim(), "E")

      End Try

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Doc. Type: " & oInvoice.DocType, "E")

      'Invoice No assing in User Defined Field

      Try

      oInvoice.UserFields.Fields.Item("U_InvNo").Value = Dt.Tables(0).Rows(L)(InvNo).ToString.Trim()

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Invoice Number error : " & ex.Message.ToString().Trim(), "E")

      End Try

      oInvoice.Comments = "Invoice Type is : " & InvType & "- Invoice No " & Dt.Tables(0).Rows(L)(InvNo).ToString.Trim()

      oPTMLInvoice.Comments = "Invoice Type is : " & InvType & "- Invoice No " & Dt.Tables(0).Rows(L)(InvNo).ToString.Trim()

      Try

      oInvoice.UserFields.Fields.Item("U_InvDt").Value = CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim())

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Invoice Date error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      oInvoice.UserFields.Fields.Item("U_VoyNo").Value = Dt.Tables(0).Rows(L)(VoyNo).ToString.Trim()

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Voyage Number error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      oInvoice.UserFields.Fields.Item("U_Vessal").Value = Dt.Tables(0).Rows(L)(Vessal).ToString.Trim()

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Vessal error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      oInvoice.UserFields.Fields.Item("U_PortOL").Value = Dt.Tables(0).Rows(L)(PortOL).ToString.Trim()

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Port of Loading error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      oInvoice.UserFields.Fields.Item("U_Bill").Value = Dt.Tables(0).Rows(L)(Bill).ToString.Trim()

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Bill error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      oInvoice.UserFields.Fields.Item("U_InvType").Value = InvType.ToString()

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Invoice Type error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      oInvoice.UserFields.Fields.Item("U_InvCat").Value = InvCat.ToString()

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Invoice Category error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      GRMTotalAmount = Dt.Tables(0).Rows(L)(TotalAmount).ToString.Trim()

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Vessal error : " & ex.Message.ToString().Trim(), "E")

      End Try

      'PTML Header Setting

      Try

      oPTMLInvoice.UserFields.Fields.Item("U_InvNo").Value = Dt.Tables(0).Rows(L)(InvNo).ToString.Trim()

      Catch ex As Exception

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Invoice Number error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      oPTMLInvoice.UserFields.Fields.Item("U_InvDt").Value = CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim())

      Catch ex As Exception

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Invoice Date error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      oPTMLInvoice.UserFields.Fields.Item("U_VoyNo").Value = Dt.Tables(0).Rows(L)(VoyNo).ToString.Trim()

      Catch ex As Exception

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Voyage Number error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      oPTMLInvoice.UserFields.Fields.Item("U_Vessal").Value = Dt.Tables(0).Rows(L)(Vessal).ToString.Trim()

      Catch ex As Exception

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Vessal error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      oPTMLInvoice.UserFields.Fields.Item("U_PortOL").Value = Dt.Tables(0).Rows(L)(PortOL).ToString.Trim()

      Catch ex As Exception

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Port of Loading error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      oPTMLInvoice.UserFields.Fields.Item("U_Bill").Value = Dt.Tables(0).Rows(L)(Bill).ToString.Trim()

      Catch ex As Exception

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Bill error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      oPTMLInvoice.UserFields.Fields.Item("U_InvType").Value = InvType.ToString()

      Catch ex As Exception

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Invoice Type error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      oPTMLInvoice.UserFields.Fields.Item("U_InvCat").Value = InvCat.ToString()

      Catch ex As Exception

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Invoice Category error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      If PTMLBPCode <> String.Empty Then

      oPTMLInvoice.CardCode = PTMLBPCode

      End If

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Card Code: " & oInvoice.CardCode, "E")

      Catch ex As Exception

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": BP Code error : " & ex.Message.ToString().Trim(), "E")

      End Try

      Try

      oPTMLInvoice.DocDate = CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim())

      oPTMLInvoice.DocDueDate = CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim())

      oPTMLInvoice.TaxDate = CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim())

      Catch ex As Exception

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Doc Date error : " & ex.Message.ToString().Trim(), "E")

      End Try

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Invoice Date: " & oPTMLInvoice.DocDate, "E")

      Try

      oPTMLInvoice.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Service

      Catch ex As Exception

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Item Type : " & ex.Message.ToString().Trim(), "E")

      End Try

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Doc. Type: " & oPTMLInvoice.DocType, "E")

      '*************************

      Dim ControlAccount As String = INV.Fields.Item("U_CuRecAcc").Value

      For M As Integer = 0 To INV.RecordCount - 1

      Try

      'Common

      Dim AmtPaid As Integer = INV.Fields.Item("U_ExCName").Value

      Dim IFcode As String = INV.Fields.Item("U_IFCode").Value

      Dim IFName As String = INV.Fields.Item("U_IFName").Value

      'Girimaldi

      Dim GANCode As String = INV.Fields.Item("U_GANCode").Value

      Dim GANTCode As String = INV.Fields.Item("U_GANTCode").Value

      Dim GANPer As Integer = INV.Fields.Item("U_GANPer").Value

      Dim GPTMLCode As String = INV.Fields.Item("U_GPTMLCode").Value

      Dim GPTMLTCode As String = INV.Fields.Item("U_GPTMLTCode").Value

      Dim MGGICode As String = INV.Fields.Item("U_MGGICode").Value

      Dim MGGITCode As String = INV.Fields.Item("U_MGGITCode").Value

      Dim GGIPer As Integer = INV.Fields.Item("U_GGIPer").Value

      'PTML

      Dim PTMLCode As String = INV.Fields.Item("U_PTMLCode").Value

      Dim PTMLTCode As String = INV.Fields.Item("U_PTMLTCode").Value

      Dim PTMLPer As Integer = INV.Fields.Item("U_PTMLPer").Value

      Dim amt As Decimal = Convert.ToDecimal(Dt.Tables(0).Rows(L)(AmtPaid).ToString.Trim())

      'Grimalid Percentage

      Dim Percentage As Double = Convert.ToDouble(GANPer)

      'PTML Percentage

      Dim PTMLPercentage As Double = Convert.ToDouble(PTMLPer)

      'GGI Percentage

      Dim GGIPercentage As Double = Convert.ToDouble(GGIPer)

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Line Details, Amount : " & amt & "Percentage :" & Percentage, "E")

      Dim AccCode As String

      Dim TaxTCode As String

      'PTML Line Added

      If amt > 0 And PTMLPercentage > 0 Then

      Try

      AccCode = PTMLCode

      TaxTCode = PTMLTCode

      Dim LTotal As Double = amt * (PTMLPercentage / 100)

      ' Try

      ' Dim Rate As Double = 0

      'Try

      'Try

      ' Dim rset As SAPbobsCOM.Recordset = oPTMLCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

      ' Dim strReturnVal As String = ""

      ' rset.DoQuery("select Rate from OVTG where Code ='" & PTMLTCode.ToString.Trim() & "'")

      ' Rate = IIf(rset.RecordCount > 0, rset.Fields.Item(0).Value.ToString().Trim(), "")

      'Catch ex As Exception

      'oApplication.StatusBar.SetText(" Get Single Value Function Failed : ", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)

      ' End Try

      'Catch ex As Exception

      ' LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": OVTG Rating Error : " & ex.Message.ToString().Trim(), "E")

      'End Try

      'If Rate <> 0 Then

      ' LTotal = (LTotal * 100) / (100 + Rate)

      ' End If

      'Catch ex As Exception

      ' LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Rating Error : " & ex.Message.ToString().Trim(), "E")

      'End Try

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ":PTML Line Details, FName : " & IFName, "E")

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ":PTML Line Details, LTotal : " & LTotal, "E")

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ":PTML Line Details, PTML Acc Code : " & PTMLCode, "E")

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ":PTML Line Details, PTML Tax Code : " & PTMLTCode, "E")

      oPTMLInvoice.Lines.ItemDescription = PTMLPercentage & IFName

      oPTMLInvoice.NumAtCard = Dt.Tables(0).Rows(L)(0).ToString().Trim()

      oPTMLInvoice.Lines.LineTotal = LTotal

      oPTMLInvoice.Lines.AccountCode = AccCode

      oPTMLInvoice.Lines.VatGroup = TaxTCode

      oPTMLInvoice.Lines.Add()

      PTMLLineCount = PTMLLineCount + 1

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & "PTML Line Det-Successfully Added Line Item : " & M + 1, "E")

      Catch ex As Exception

      LogInfo("Error Message" & ex.Message.ToString().Trim(), "E")

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & " Database :PTML -A/R Invoice line Posting Error : " & oPTMLCompany.GetLastErrorDescription.ToString().Trim(), "E")

      oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      oPTMLCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      Return False

      End Try

      ' End If

      End If

      'Girimaldi Line Details Added

      If (amt > 0 And Percentage > 0) Or (amt > 0 And PTMLPercentage > 0) Or (amt > 0 And GGIPercentage > 0) Then

      Try

      Dim LTotal As Double = 0

      If (Percentage > 0) Then

      AccCode = GANCode

      TaxTCode = GANTCode

      LTotal = amt * (Percentage / 100)

      'Try

      ' Dim Rate As Double = 0

      ' Try

      ' Rate = getSingleValue("select Rate from OVTG where Code ='" & GANTCode.ToString.Trim() & "'")

      ' Catch ex As Exception

      ' LogInfo(oCompany.CompanyName.ToString().Trim() & ": OVTG Rating Error : " & ex.Message.ToString().Trim(), "E")

      ' End Try

      ' If Rate <> 0 Then

      ' ' LTotal = (LTotal * 100) / (100 + Rate)

      ' End If

      'Catch ex As Exception

      ' LogInfo(oCompany.CompanyName.ToString().Trim() & ": Rating Error : " & ex.Message.ToString().Trim(), "E")

      'End Try

      oInvoice.Lines.ItemDescription = Percentage & " % " & IFName

      oInvoice.NumAtCard = Dt.Tables(0).Rows(L)(0).ToString().Trim()

      oInvoice.Lines.LineTotal = LTotal

      oInvoice.Lines.AccountCode = AccCode

      oInvoice.Lines.VatGroup = TaxTCode

      oInvoice.Lines.Add()

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GRN Line Details, FName : " & IFName, "E")

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GRN Line Details, LTotal : " & LTotal, "E")

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GRN Line Details, GAN Acc Code : " & AccCode, "E")

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GRN Line Details, GAN Tax Code : " & TaxTCode, "E")

      GRMDLineCount = GRMDLineCount + 1

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":Successfully Added Line Item : " & M + 1, "E")

      End If

      If (PTMLPercentage > 0) Then

      AccCode = GPTMLCode

      TaxTCode = GPTMLTCode

      LTotal = amt * (PTMLPercentage / 100)

      '*****************GAN PTML JE Posting ******************

      If (INV.Fields.Item("U_MTJnl").Value = "Y") Then

      oPTMLJE.Memo = "JE-GAN-PTML and Inv.Typ is : " & InvType '& "- Inv No " & Dt.Tables(0).Rows(L)(InvNo).ToString.Trim

      oPTMLJE.Reference2 = Dt.Tables(0).Rows(L)(InvNo).ToString.Trim()

      oPTMLJE.DueDate = CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim())

      oPTMLJE.TaxDate = CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim())

      oPTMLJE.ReferenceDate = CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim())

      'oPTMLJE.Reference = "JE Based on :" & frmConsignment.Items.Item("t_InvNo").Specific.value.ToString

      'Add Lines to Journal Entry

      GANPTMLJETotalValue = GANPTMLJETotalValue + LTotal

      oPTMLJE.Lines.AccountCode = AccCode

      oPTMLJE.Lines.Debit = CDbl(LTotal)

      oPTMLJE.Lines.Add()

      End If

      '************************************************************

      'Try

      ' Dim Rate As Double = 0

      ' Try

      ' Rate = getSingleValue("select Rate from OVTG where Code ='" & PTMLTCode.ToString.Trim() & "'")

      ' Catch ex As Exception

      ' LogInfo(oCompany.CompanyName.ToString().Trim() & ": OVTG Rating Error : " & ex.Message.ToString().Trim(), "E")

      ' End Try

      ' If Rate <> 0 Then

      ' 'LTotal = (LTotal * 100) / (100 + Rate)

      ' End If

      'Catch ex As Exception

      ' LogInfo(oCompany.CompanyName.ToString().Trim() & ": Rating Error : " & ex.Message.ToString().Trim(), "E")

      'End Try

      ' MsgBox(AccCode)

      ' MsgBox(TaxTCode)

      'MsgBox(LTotal)

      oInvoice.Lines.ItemDescription = PTMLPercentage & " % " & IFName

      oInvoice.NumAtCard = Dt.Tables(0).Rows(L)(0).ToString().Trim()

      oInvoice.Lines.LineTotal = LTotal

      oInvoice.Lines.AccountCode = AccCode

      oInvoice.Lines.VatGroup = TaxTCode

      oInvoice.Lines.Add()

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GPTML Line Details, FName : " & IFName, "E")

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GPTML Line Details, LTotal : " & LTotal, "E")

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GPTML Line Details, GAN Acc Code : " & AccCode, "E")

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GPTML Line Details, GAN Tax Code : " & TaxTCode, "E")

      GRMDLineCount = GRMDLineCount + 1

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":Successfully Added Line Item : " & M + 1, "E")

      End If

      If (GGIPercentage > 0) Then

      AccCode = MGGICode

      TaxTCode = MGGITCode

      LTotal = 0

      LTotal = amt * (GGIPercentage / 100)

      '*****************GAN GGI JE Posting ******************

      If (INV.Fields.Item("U_MTJnl").Value = "Y") Then

      oGGIJE.Memo = "JE-GAN-GGI and Inv.Typ is : " & InvType '& "- Inv No " & Dt.Tables(0).Rows(L)(InvNo).ToString.Trim

      oGGIJE.Reference2 = Dt.Tables(0).Rows(L)(InvNo).ToString.Trim()

      oGGIJE.DueDate = CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim())

      oGGIJE.TaxDate = CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim())

      oGGIJE.ReferenceDate = CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim())

      'Add Lines to Journal Entry

      GANGGIJETotalValue = GANGGIJETotalValue + LTotal

      oGGIJE.Lines.AccountCode = AccCode

      oGGIJE.Lines.Debit = CDbl(LTotal)

      oGGIJE.Lines.Add()

      End If

      '************************************************************

      'Try

      ' Dim Rate As Double = 0

      ' Try

      ' Rate = getSingleValue("select Rate from OVTG where Code ='" & MGGITCode.ToString.Trim() & "'")

      ' Catch ex As Exception

      ' LogInfo(oCompany.CompanyName.ToString().Trim() & ": OVTG Rating Error : " & ex.Message.ToString().Trim(), "E")

      ' End Try

      ' If Rate <> 0 Then

      ' ' LTotal = (LTotal * 100) / (100 + Rate)

      ' End If

      'Catch ex As Exception

      ' LogInfo(oCompany.CompanyName.ToString().Trim() & ": Rating Error : " & ex.Message.ToString().Trim(), "E")

      'End Try

      oInvoice.Lines.ItemDescription = GGIPercentage & " % " & IFName

      oInvoice.NumAtCard = Dt.Tables(0).Rows(L)(0).ToString().Trim()

      oInvoice.Lines.LineTotal = LTotal

      oInvoice.Lines.AccountCode = AccCode

      oInvoice.Lines.VatGroup = TaxTCode

      oInvoice.Lines.Add()

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GGI Line Details, FName : " & IFName, "E")

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GGI Line Details, LTotal : " & LTotal, "E")

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GGI Line Details, GAN Acc Code : " & AccCode, "E")

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GGI Line Details, GAN Tax Code : " & TaxTCode, "E")

      GGILineCount = GGILineCount + 1

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":Successfully Added Line Item : " & M + 1, "E")

      End If

      Catch ex As Exception

      LogInfo("Error Message" & ex.Message.ToString().Trim(), "E")

      LogInfo(oCompany.CompanyName.ToString().Trim() & " Database : A/R Invoice line Posting Error : " & oCompany.GetLastErrorDescription.ToString().Trim(), "E")

      oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      oPTMLCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      Return False

      End Try

      End If

      INV.MoveNext()

      Catch ex As Exception

      LogInfo("Error Message" & ex.Message, "E")

      LogInfo(oCompany.CompanyName.ToString().Trim() & " Database :GAN - A/R Invoice line Posting Error : " & oCompany.GetLastErrorDescription & ex.Message.ToString().Trim(), "E")

      oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      oPTMLCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      Return False

      End Try

      Next

      'Girimaldi

      If (GRMDLineCount > 0) Then

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GAN- A/R Invoice Header Posting...", "E")

      If oInvoice.Add() <> 0 Then

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GAN- A/R Invoice Posting Failed : " & oCompany.GetLastErrorDescription.ToString().Trim(), "E")

      oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      oPTMLCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      Return False

      Else

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GAN- A/R Invoice Posting Completed...", "E")

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GAN - Incomming Posting Started...", "E")

      Dim InvoiceTotal As String = getSingleValue("select DocTotal from OINV where DocEntry=(select Max(DocEntry) from OINV)")

      Dim CardCodevalue As String = getSingleValue("select CardCode from OINV where DocEntry=(select Max(DocEntry) from OINV)")

      Dim DocEntry As String = getSingleValue("select Max(DocEntry) from OINV")

      If (IncommingPaymentPosting(InvoiceTotal, CustomerAccCode, CardCodevalue, DocEntry, GRMTotalAmount - InvoiceTotal, CustomerCode, ControlAccount, CDate(Dt.Tables(0).Rows(L)(Invdate).ToString.Trim()), Dt.Tables(0).Rows(L)(InvNo).ToString.Trim()) = False) Then

      LogInfo(oCompany.CompanyName.ToString().Trim() & ":GAN -Incomming Posting Failed : " & oCompany.GetLastErrorDescription.ToString().Trim(), "E")

      oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      oPTMLCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      Return False

      End If

      End If

      Else

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": Line Details Count is " & GRMDLineCount, "E")

      End If

      'PTML

      If (PTMLLineCount > 0) Then

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ":PTML-A/R Invoice Header Posting...", "E")

      If oPTMLInvoice.Add() <> 0 Then

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ":PTML-A/R Invoice Posting Failed : " & oPTMLCompany.GetLastErrorDescription.ToString().Trim(), "E")

      oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      oPTMLCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      Return False

      Else

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ":PTML- A/R Invoice Posting Completed...", "E")

      ' LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ":PTML-Incomming Payment Posting Completed...", "E")

      ' Dim InvoiceTotal As SAPbobsCOM.Recordset = oPTMLCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

      ' PTMLRS.DoQuery(" select Credit ,Debit,Account from OJDT m left outer join JDT1 d on m.TransId =d.TransId where m.Number ='" & PTMLJENumber.ToString.Trim & "' ")

      ' InvoiceTotal.DoQuery("select DocTotal from OINV where DocEntry=(select Max(DocEntry) from OINV)")

      ' Dim PTMLTotal = IIf(InvoiceTotal.RecordCount > 0, InvoiceTotal.Fields.Item(0).Value.ToString().Trim(), "")

      ' InvoiceTotal.DoQuery("select CardCode from OINV where DocEntry=(select Max(DocEntry) from OINV)")

      ' Dim PTMLCardCodevalue = IIf(InvoiceTotal.RecordCount > 0, InvoiceTotal.Fields.Item(0).Value.ToString().Trim(), "")

      ' InvoiceTotal.DoQuery("select Max(DocEntry) from OINV")

      ' Dim PTMLDocEntry = IIf(InvoiceTotal.RecordCount > 0, InvoiceTotal.Fields.Item(0).Value.ToString().Trim(), "")

      ' LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Invoice Document Entry : " & PTMLTotal, "E")

      'If (PTMLIncommingPaymentPosting(PTMLTotal, PTMLCustomerAccCode, PTMLCardCodevalue, PTMLDocEntry) = False) Then

      ' LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ":Incomming Posting Failed : " & oPTMLCompany.GetLastErrorDescription.ToString().Trim(), "E")

      ' oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      ' oPTMLCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      ' Return False

      'End If

      End If

      Else

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": Line Details Count is " & PTMLLineCount, "E")

      End If

      End If

      Next

      ' ****************GAN PTML JE Posting *****************

      If (GANPTMLJETotalValue > 0) Then

      oPTMLJE.Lines.ShortName = GANPTMLBPCode

      oPTMLJE.Lines.Credit = CDbl(GANPTMLJETotalValue)

      oPTMLJE.Lines.Add()

      Dim lRetCode = oPTMLJE.Add

      If lRetCode = 0 Then

      StatusBarWarningMsg("GAN-PTML Journal Move - completed successfully.")

      Else

      StatusBarErrorMsg("GAN-PTML Journal Move is failed.")

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": GAN-PTML JE failed : " & oCompany.GetLastErrorDescription.ToString().Trim(), "E")

      If oCompany.InTransaction = True Then

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": RollBack: ", "E")

      oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      Return False

      End If

      If oPTMLCompany.InTransaction = True Then

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": RollBack: ", "E")

      oPTMLCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      Return False

      End If

      End If

      End If

      '**************************************************************************

      '****************GAN GGI JE Posting *****************

      If (GANGGIJETotalValue > 0) Then

      oGGIJE.Lines.ShortName = GANGGIBPCode

      oGGIJE.Lines.Credit = CDbl(GANGGIJETotalValue)

      oGGIJE.Lines.Add()

      Dim lRetCode = oGGIJE.Add

      If lRetCode = 0 Then

      StatusBarWarningMsg("GAN-GGI Journal Move - completed successfully.")

      Else

      StatusBarErrorMsg("GAN-GGI Journal Move is failed.")

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": GAN-GGI JE failed : " & oCompany.GetLastErrorDescription.ToString().Trim(), "E")

      If oCompany.InTransaction = True Then

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": RollBack: ", "E")

      oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      Return False

      End If

      If oPTMLCompany.InTransaction = True Then

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": RollBack: ", "E")

      oPTMLCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      Return False

      End If

      End If

      End If

      '**************************************************************************

      End If

      Return True

      Catch ex As Exception

      LogInfo("Error - ", ex.Message)

      If oCompany.InTransaction = True Then

      LogInfo(oCompany.CompanyName.ToString().Trim() & ": RollBack: ", "E")

      oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      Return False

      End If

      If oPTMLCompany.InTransaction = True Then

      LogInfo(oPTMLCompany.CompanyName.ToString().Trim() & ": RollBack: ", "E")

      oPTMLCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)

      Return False

      End If

      LogInfo(" A/R Invoice Posting Failed : " & ex.Message, "E")

      Return False

      End Try

      Return True

      End Function

      Regards

      Sakthi

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.