project QadFinancials > class BDInvoice > method LoadCInvoiceForNewBankAPI


Parameters


tApiUpdateDInvoiceWithNewBankinputtemp-table
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDInvoice.ApiUpdateCInvoiceWithNewBank


program code (program1/bdinvoice.p)

/* 
This methid will load all the invoices from the database into memory.
The invoice that are loaded is created from the list of invoices id's or company_id, voucher, journal code and posting year 
*/

assign 
    vcListCInvoiceIds = "":U
    oiReturnStatus = 0.
       
/* Need to loop the dataset and setup Invoice Id's from Posting Year, Journal Code, Invoice Voucher and Compnay Id*/
for each tApiUpdateDInvoiceWithNewBank:        
    if tApiUpdateDInvoiceWithNewBank.tiDInvoice_ID = 0 OR  tApiUpdateDInvoiceWithNewBank.tiDInvoice_ID = ? 
    then do:              
        <M-13 run GetDInvoiceIDFromInvoiceInfo
           (input  ? (iiDInvoiceId), 
            input  tApiUpdateDInvoiceWithNewBank.tiCompany_ID (iiCompanyId), 
            input  tApiUpdateDInvoiceWithNewBank.tiDInvoiceVoucher (iiDInvoiceVoucher), 
            input  tApiUpdateDInvoiceWithNewBank.tcDAJournalCode (icJournalCode), 
            input  ? (iiJournalId), 
            input  tApiUpdateDInvoiceWithNewBank.tiDInvoicePostingYear (iiPostingYear), 
            output tApiUpdateDInvoiceWithNewBank.tiDInvoice_ID (oiReturnStatus)) in BDInvoice>          
    end. 
end.    

/* Load the data tables from the invoices id */    
for each tApiUpdateDInvoiceWithNewBank:

    if tApiUpdateDInvoiceWithNewBank.tiDInvoice_ID <> -1 
    then do:     
        if vcListCInvoiceIds = '':U
            then assign vcListCInvoiceIds = string(tApiUpdateDInvoiceWithNewBank.tiDInvoice_ID).
        else 
            assign vcListCInvoiceIds = vcListCInvoiceIds + chr(4) + string(tApiUpdateDInvoiceWithNewBank.tiDInvoice_ID).
    
        /* if vcListCInvoiceIds > 10000, load the data to prevent vcListPostingIDsToLoad to get out of 32K limit */
        if length(vcListCInvoiceIds , "CHARACTER") > 10000 
        then do:               
          <M-60 run DataLoad
             (input  '':U (icRowids), 
              input  vcListCInvoiceIds (icPkeys), 
              input  '':U (icObjectIds), 
              input  '':U (icFreeform), 
              input  yes (ilKeepPrevious), 
              output viFcReturnSuper (oiReturnStatus)) in BDInvoice> 
                             
            assign vcListCInvoiceIds = '':U.             
        end.                             
                    
        if viFcReturnSuper <> 0 
        then do:
            assign oiReturnStatus = viFcReturnSuper.
            if viFcReturnSuper < 0
            then do:
                
                assign 
                        vcMessage      = trim(substitute(#T-65'Data could not be loaded: unable to load the list of customer invoices (&1).':100(1795)T-65#, replace(vcListCInvoiceIds, chr(4), ",":U)))
                        oiReturnStatus = -1.
                        
                <M-80 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '':U (icRowid), 
                    input  'qadfin-301209':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDInvoice>                    
                return.
            end. /* if viFcReturnSuper < 0 */
        end. /* if viFcReturnSuper <> 0 */        
    end. /* tApiUpdateDInvoiceWithNewBank.tiDInvoice_ID <> -1*/
end.    

if vcListCInvoiceIds <> ''
then do:     
    <M-63 run DataLoad
       (input  '':U (icRowids), 
        input  vcListCInvoiceIds (icPkeys), 
        input  '':U (icObjectIds), 
        input  '':U (icFreeform), 
        input  yes (ilKeepPrevious), 
        output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
        
      assign vcListCInvoiceIds = '':U.
end.
 
if viFcReturnSuper <> 0
    then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
    then return.