project QadFinancials > class BBankNumber > method ApiLoadCustomerBankNumber

Description

This method is used on the UI for Excel Integration. It returns Customer BankNumbers so they can be shown in the Excel Integration grid.


Parameters


tApiBankNumberoutputtemp-tableTemp-table to pass the BankNumber records that match the input parameters
tApiBankNumberPayCodeoutputtemp-tableTemp-table to pass the BankNumberPayCode records that match the input parameters
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program9/bbanknumber.p)

empty temp-table tApiBankNumber.
empty temp-table tApiBankNumberPayCode.

/* Get the data and populate the table tApiBankNumber */
<Q-12 run BankNumberForExcelIntegration (all) (Read) (NoCache)
   (input {&BANKNUMBERPARENTTYPE-DEBTOR}, (BankNumberParentType)
    input viCompanyId, (CompanyId)
    output dataset tqBankNumberForExcelIntegration) in BBankNumber >

<Q-17 run DebtorPrim (Start) in BDebtor >
<Q-26 run DInvoiceBankByBankNumberID  (Start) in BDInvoice >
<Q-27 run BankNumberForDDocument  (Start) in BBankNumber >
                 
for each tqBankNumberForExcelIntegration:
    create tApiBankNumber.
    <M-19 run BufferCopy
       (input  buffer tqBankNumberForExcelIntegration:handle (ihFrom), 
        input  buffer tApiBankNumber:handle (ihTo), 
        output viFcReturnSuper (oiReturnStatus)) in BBankNumber>
    assign tApiBankNumber.tcOwnGLCode = tqBankNumberForExcelIntegration.tcGLCode
           tApiBankNumber.tcPayFormatTypePaymentInstrument = tqBankNumberForExcelIntegration.tcPayFormatTypePayInstrument.

    /* Check whether the bank number is linked with an invoice */
    <Q-24 run DInvoiceBankByBankNumberID (all) (Read) (NoCache)
       (input tApiBankNumber.BankNumber_ID, (BankNumberID)
        output dataset tqDInvoiceBankByBankNumberID) in BDInvoice >
    find first tqDInvoiceBankByBankNumberID where
               tqDInvoiceBankByBankNumberID.tiBankNumber_ID = tApiBankNumber.BankNumber_ID
               no-error.
    if available tqDInvoiceBankByBankNumberID
    then assign tApiBankNumber.tlBankNumberIsReferenced = true.
    else assign tApiBankNumber.tlBankNumberIsReferenced = false.

    /* Check whether the bank number is linked with a payment */
    <Q-25 run BankNumberForDDocument (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input tApiBankNumber.BankNumber_ID, (BankNumberId)
        output dataset tqBankNumberForDDocument) in BBankNumber >
    find first tqBankNumberForDDocument where
               tqBankNumberForDDocument.tiBankNumber_ID = tApiBankNumber.BankNumber_ID
               no-error.
    if available tqBankNumberForDDocument
    then assign tApiBankNumber.tlExistRecord = false.
    else assign tApiBankNumber.tlExistRecord = true.

    /* Fill in the ParentObjectCode based on the ID */
    if tApiBankNumber.ParentObject_ID > 0
    then do:
        <Q-16 run DebtorPrim (all) (Read) (Cache)
           (input viCompanyId, (CompanyId)
            input ?, (DebtorCode)
            input tApiBankNumber.ParentObject_ID, (Debtor_ID)
            output dataset tqDebtorPrim) in BDebtor >
        find first tqDebtorPrim no-error.
        if available tqDebtorPrim
        then assign tApiBankNumber.tcParentObjectCode = tqDebtorPrim.tcDebtorCode. 
        else do:
            delete tApiBankNumber.
            next.
        end.
    end.
    else do:
        delete tApiBankNumber.
        next.
    end.
end. /* for each tqBankNumberForExcelIntegration */

<Q-18 run DebtorPrim (Stop) in BDebtor >
<Q-28 run DInvoiceBankByBankNumberID  (Stop) in BDInvoice >
<Q-29 run BankNumberForDDocument  (Stop) in BBankNumber >


/* Get the data and populate the table tApiBankNumberPayCode */
<Q-20 run BankNumberPayCodeForExcelInteg (all) (Read) (NoCache)  (output dataset tqBankNumberPayCodeForExcelInteg) in BBankNumber >
for each tqBankNumberPayCodeForExcelInteg,
    first tApiBankNumber where
          tApiBankNumber.BankNumber_ID = tqBankNumberPayCodeForExcelInteg.tiBankNumber_ID:
    create tApiBankNumberPayCode.
    <M-21 run BufferCopy
       (input  buffer tqBankNumberPayCodeForExcelInteg:handle (ihFrom), 
        input  buffer tApiBankNumberPayCode:handle (ihTo), 
        output viFcReturnSuper (oiReturnStatus)) in BBankNumber>
    assign tApiBankNumberPayCode.BankNumberPayCodeValue = tqBankNumberPayCodeForExcelInteg.tcPayFormatCode
           tApiBankNumberPayCode.tc_ParentRowid = tApiBankNumber.tc_Rowid
           tApiBankNumberPayCode.tc_Rowid = tqBankNumberPayCodeForExcelInteg.tc_rowid.
end. /* for each tqBankNumberPayCodeForExcelInteg */


Sample code: how to call this method through RPCRequestService (QXtend Inbound)

define temp-table ttContext no-undo
    field propertyQualifier as character
    field propertyName as character
    field propertyValue as character
    index entityContext is primary unique
        propertyQualifier
        propertyName
    index propertyQualifier
        propertyQualifier.

define dataset dsContext for ttContext.

define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.

/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
       ttContext.propertyValue = "BBankNumber".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "ApiLoadCustomerBankNumber".
create ttContext.
assign ttContext.propertyName = "applicationId"
       ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
       ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
       ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
       ttContext.propertyValue = "".

/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").

if not vhServer:connected()
then do:
    message "Could not connect AppServer" view-as alert-box error title "Error".
    return.
end.

/* Run */
assign vhContextDS = dataset dsContext:handle.

run program/rpcrequestservice.p on vhServer
    (input-output dataset-handle vhContextDS by-reference,
           output dataset-handle vhExceptionDS,
     input        dataset-handle vhInputDS by-reference,
     input-output dataset-handle vhInputOutputDS by-reference,
           output dataset-handle vhOutputDS).

/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).

if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).

/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.

if valid-handle(vhInputDS)
then delete object vhInputDS.

if valid-handle(vhOutputDS)
then delete object vhOutputDS.

if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.