Public Sub LoopARInvoicesFromDeposit()



   Dim oDeposit As CDeposit

   Set oDeposit = New CDeposit

   oDeposit.Init FE_Application.SessionContext

   

   oDeposit.Load 36

   

   Dim oPayHeader As CPaymentHeader

   Dim oPayment As CPayment



   Dim oApp As CARApplicationsList

   Dim oAppItem As CARApplicationListItem

   

   Dim oLine As CARLineItem

   Dim oInvoice As CARInvoice

   

   For Each oPayHeader In oDeposit.Payments

   

       For Each oPayment In oPayHeader.PaymentComponents



           Set oApp = New CARApplicationsList

           oApp.Init FE_Application.SessionContext, oPayment

           

           For Each oAppItem In oApp

           

               If oAppItem.Fields(APPLICATIONLISTITEMS_fld_TRANTYPE) = "Line Item" Then



                   Set oLine = New CARLineItem

                   oLine.Init FE_Application.SessionContext

                   

                   oLine.Load oAppItem.Fields(APPLICATIONLISTITEMS_fld_CHARGEID)

                   

                   Set oInvoice = New CARInvoice

                   oInvoice.Init FE_Application.SessionContext

                   

                   oInvoice.Load oLine.Fields(ARLINEITEMS_fld_AR7INVOICESID)

                   

                   Debug.Print oInvoice.Fields(ARINVOICES_fld_DOCUMENTNUMBER)

                                   

                   oInvoice.CloseDown

                   Set oInvoice = Nothing

                   

                   oLine.CloseDown

                   Set oLine = Nothing

               

               End If



           Next oAppItem

           

           oApp.CloseDown

           Set oApp = Nothing

           

       Next oPayment

   Next oPayHeader

   

   Set oAppItem = Nothing

   

   oDeposit.CloseDown

   Set oDeposit = Nothing

   

   Set oPayment = Nothing

   Set oPayHeader = Nothing

   

End Sub

Disclaimer: We provide programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes you are familiar with Microsoft Visual Basic and the tools used to create and debug procedures. Our Customer Support can help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality. If you are interested in learning more about the VBA and API modules, contact your account manager.