project QadFinancials > class BPaymentSelection > method FillProDataSet


Parameters


iiPaySel_IDinputinteger
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPaymentSelection.BuildProDataSet


program code (program7/bpaymentselection.p)

/* ========================= */
/*Invoke the FillProDataSet methods to Fill the temp-tables of the ProDataSet */
/* ========================= */
if oiReturnStatus = 0 
then assign oiReturnStatus = -98.
          /* To get the AddressType_ID of AddressTypeCode = HeaderOffice */
<Q-15 run AddressTypeByCode (all) (Read) (NoCache)
   (input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
    output dataset tqAddressTypeByCode) in BAddressType >
find first tqAddressTypeByCode no-error.
if not available tqAddressTypeByCode 
then do:
    <M-13 run SetMessage
       (input  #T-1'No address type record is available.':50(999890589)T-1# (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'D':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-5332':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
         assign
             oiReturnStatus = -1.
end. /* end of if */
else do:
    assign vhBufferForProDataSet = dataset tqAddressTypeByCode:get-buffer-handle(1).
    for each tqAddressTypeByCode no-lock:                
        create tAddressType.
        <M-11 run BufferCopy
           (input  vhBufferForProDataSet (ihFrom), 
            input  buffer tAddressType:handle (ihTo), 
            output oiReturnStatus (oiReturnStatus)) in BPaymentSelection>
        assign viAddressType_ID = tAddressType.AddressType_ID.
    end. /*for each tqAddressTypeCode */
end. /* end of else do */

<Q-34 run AddressTypeByCode (all) (Read) (NoCache)
   (input {&ADDRESSTYPECODESYSTEM-REMITTANCE}, (AddressTypeCode)
    output dataset tqAddressTypeByCode) in BAddressType>
find first tqAddressTypeByCode no-error.
if available tqAddressTypeByCode 
then do:
    assign viAddressTypeRemittance_ID = tqAddressTypeByCode.tiAddressType_ID.
end. /* if available tqAddressTypeByCode */     

/* Fill The tAPHeaderAttribute temp table */
<Q-18 run PaySelPayCodeByPaySelID (all) (Read) (NoCache)
   (input iiPaySel_ID, (PaySelID)
    input ?, (PayFormatGroupCode)
    output dataset tqPaySelPayCodeByPaySelID) in BPaymentSelection>
assign
    vhBufferForProDataSet = dataset tqPaySelPayCodeByPaySelID:get-buffer-handle(1).
for each tqPaySelPayCodeByPaySelID:
    create tAPHeaderAttribute.
    /*assign 
        tAPHeaderAttribute.tcAttributeName = tqPaySelPayCodeByPaySelID.tcPayFormatGroupCode
        tAPHeaderAttribute.tiPaySel_ID = iiPaySel_ID.
    if tqPaySelPayCodeByPaySelID.tiPayFormatCode_ID <> 0 and tqPaySelPayCodeByPaySelID.tiPayFormatCode_ID <> ?
    then do:
        <Q-23 run PayFormatCodePrim (all) (Read) (Cache)
           (input tqPaySelPayCodeByPaySelID.tiPayFormatCode_ID, (PayFormatCodeID)
            input ?, (PayFormatCode)
            output dataset tqPayFormatCodePrim) in BPaymentFormat >
        find first tqPayFormatCodePrim no-error.
        if available tqPayFormatCodePrim
        then do:
            assign tAPHeaderAttribute.tcAttributeValue = tqPayFormatCodePrim.tcPayFormatCode.
        end.
    end.
    else do:
        assign tAPHeaderAttribute.tcAttributeValue = tqPaySelPayCodeByPaySelID.tcPaySelPayCodeValue.
    end. */
    /*FIN-3198*/
    assign 
        tAPHeaderAttribute.tcAttributeName = tqPaySelPayCodeByPaySelID.tcPayFormatGroupCode
        tAPHeaderAttribute.tcAttributeValue = tqPaySelPayCodeByPaySelID.tcPaySelPayCodeValue
        tAPHeaderAttribute.tiPaySel_ID = iiPaySel_ID.
    if tAPHeaderAttribute.tcAttributeValue = ? or tAPHeaderAttribute.tcAttributeValue = ""
    then do:
        if tqPaySelPayCodeByPaySelID.tiPayFormatCode_ID <> 0 and tqPaySelPayCodeByPaySelID.tiPayFormatCode_ID <> ?
        then do:
            <Q-5 run PayFormatCodePrim (all) (Read) (Cache)
               (input tqPaySelPayCodeByPaySelID.tiPayFormatCode_ID, (PayFormatCodeID)
                input ?, (PayFormatCode)
                output dataset tqPayFormatCodePrim) in BPaymentFormat >
            find first tqPayFormatCodePrim no-error.
            if available tqPayFormatCodePrim
            then do:
                assign tAPHeaderAttribute.tcAttributeValue = tqPayFormatCodePrim.tcPayFormatCode.
            end.
        end.
    end.
end. /* for each tqPaySelPayCodeByPaySelID */


<M-1 run FillProDataSetPayment (input  iiPaySel_ID (iiPaySel_ID), 
                                output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0 
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

/* Fill the tAPPaymentAttribtue temp table*/
for each tPayment:
    for each tPaymentCInvoice where tPaymentCInvoice.tiCDocument_ID = tPayment.CDocument_ID:
          
        <Q-25 run CInvoiceByIDsForAttr (all) (Read) (NoCache)
           (input ?, (CompanyId)
            input tPaymentCInvoice.CInvoice_ID, (CInvoiceID)
            input tPayment.Creditor_ID, (CreditorID)
            input tPayment.BankNumber_ID, (BankNumberID)
            input tPayment.Currency_ID, (CurrencyID)
            output dataset tqCInvoiceByIDsForAttr) in BCInvoice >
        
                
        for each tqCInvoiceByIDsForAttr:
            
            find first tAPPaymentAttribute where tAPPaymentAttribute.tiCDocument_ID = tPayment.CDocument_ID and
                tAPPaymentAttribute.tcAttributeName =  tqCInvoiceByIDsForAttr.tcPayformatGroupCode no-error.
            if not available tAPPaymentAttribute and tqCInvoiceByIDsForAttr.tcPayFormatGroupLevel = {&PAYFORMATGROUPLEVEL-PAYMENT}
            then do:
               
                create tAPPaymentAttribute.
                assign
                    tAPPaymentAttribute.tcAttributeName         = tqCInvoiceByIDsForAttr.tcPayformatGroupCode
                    tAPPaymentAttribute.tiCDocument_ID        = tPayment.CDocument_ID.
                if tqCInvoiceByIDsForAttr.tiPayFormatCode_ID <> 0 and tqCInvoiceByIDsForAttr.tiPayFormatCode_ID <> ?
                then do:
                    <Q-27 run PayFormatCodePrim (all) (Read) (Cache)
                       (input tqCInvoiceByIDsForAttr.tiPayFormatCode_ID, (PayFormatCodeID)
                        input ?, (PayFormatCode)
                        output dataset tqPayFormatCodePrim) in BPaymentFormat >
                    find first tqPayFormatCodePrim no-error.
                    if available tqPayFormatCodePrim
                    then do:
                        assign tAPPaymentAttribute.tcAttributeValue = tqPayFormatCodePrim.tcPayFormatCode.
                    end.
        
                end. /* if tqCInvoiceBankPayCodeByIDs.tiPayFormatCode_ID <> 0 */
                else do:
                    tAPPaymentAttribute.tcAttributeValue = tqCInvoiceByIDsForAttr.tcCInvoiceBankPayCodeValue.
                end.
            end. /* if not available tAPPaymentAttribute */
        end. /*for each tqCInvoiceBankPayCodeByIDs: */
    end. /* for each tPaymentCInvoice */
end. /* for each tPayment */

/* Fill the tAPCInvoiceAttribtue temp-table */
for each tPayment:
    for each tPaymentCInvoice where tPaymentCInvoice.tiCDocument_ID = tPayment.CDocument_ID:
         <Q-30 run CInvoiceByIDsForAttr (all) (Read) (NoCache)
            (input ?, (CompanyId)
             input tPaymentCInvoice.CInvoice_ID, (CInvoiceID)
             input ?, (CreditorID)
             input tPayment.BankNumber_ID, (BankNumberID)
             input ?, (CurrencyID)
             output dataset tqCInvoiceByIDsForAttr) in BCInvoice >
        for each tqcinvoicebyidsforAttr:
            find first tAPCInvoiceAttribute where tAPCInvoiceAttribute.tcAttributeName = tqCInvoiceByIDsForAttr.tcPayFormatGroupCode and
                                                  tAPCInvoiceAttribute.tiCInvoiceID = tPaymentCInvoice.CInvoice_ID and
                                                  tAPCInvoiceAttribute.tiCDocument_ID = tPaymentCInvoice.tiCDocument_ID no-error.
            if not available tAPCInvoiceAttribute and tqCInvoiceByIDsForAttr.tcPayFormatGroupLevel = {&PAYFORMATGROUPLEVEL-INVOICE}
            then do:
                create tAPCInvoiceAttribute.
                assign
                    tAPCInvoiceAttribute.tcAttributeName  = tqCInvoiceByIDsForAttr.tcPayformatGroupCode
                    tAPCInvoiceAttribute.tiCInvoiceid     = tPaymentCInvoice.CInvoice_ID
                    tAPCInvoiceAttribute.tiCDocument_ID   = tPaymentCInvoice.tiCDocument_ID.
                if tqCInvoiceByIDsForAttr.tiPayFormatCode_ID <> 0 and tqCInvoiceByIDsForAttr.tiPayFormatCode_ID <> ?
                then do:
                    <Q-31 run PayFormatCodePrim (all) (Read) (Cache)
                       (input tqCInvoiceByIDsForAttr.tiPayFormatCode_ID, (PayFormatCodeID)
                        input ?, (PayFormatCode)
                        output dataset tqPayFormatCodePrim) in BPaymentFormat >
                    find first tqPayFormatCodePrim no-error.
                    if available tqPayFormatCodePrim
                    then do:
                        assign tAPCInvoiceAttribute.tcAttributeValue = tqPayFormatCodePrim.tcPayFormatCode.
                    end.
        
                end. /* if tqCInvoiceByIDsForAttr.tiPayFormatCode_ID <> 0 */
                else do:
                    tAPCInvoiceAttribute.tcAttributeValue = tqCInvoiceByIDsForAttr.tcCInvoiceBankPayCodeValue.
                end.
            end.
        end. /* for each tqCInvoiceByidsForAttr */
    end. /* for each tPaymentCInvoice */
end. /* for each tPayment*/

/* Initiate TpAddress,TpSite which will used in EDI mapping */
find first tPaySel where tPaySel.PaySel_ID = iiPaySel_ID no-error.
if available tPaySel
then do:
    if tPaySel.tcPayFormatTypeCode <> "":U
    then do:
        for each tPaymentPaySel:
            assign
                tPaymentPaySel.tcTpAddress = tPaySel.tcPayFormatTypeCode
                tPaymentPaySel.tcTpSite    = tPaySel.tcPayFormatTypeCode.
        end.
    end.
    else do:
        <Q-35 run BankPayFormatByID (all) (Read) (NoCache)
       (input tPaySel.BankPayFormat_ID, (BankPayFormatId)
        input ?, (CompanyId)
        output dataset tqBankPayFormatByID) in BBankPayFormat >

        find first tqBankPayFormatByID no-error.
        if not available tqBankPayFormatByID
        then do:
            <M-36 run SetMessage
               (input  #T-37'BankFile Format Not Found':100(999890590)T-37# (icMessage), 
                input  '':U (icArguments), 
                input  'tPaySel.BankPayFormat_ID':U (icFieldName), 
                input  string(tPaySel.BankPayFormat_ID) (icFieldValue), 
                input  'S':U (icType), 
                input  2 (iiSeverity), 
                input  '':U (icRowid), 
                input  'QadFin-9138':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                assign oiReturnStatus = -1.
                return.
    
        end.
        for each tPaymentPaySel:
            assign
                tPaymentPaySel.tcTpAddress = tqBankPayFormatByID.tcPayFormatTypeCode
                tPaymentPaySel.tcTpSite    = tqBankPayFormatByID.tcPayFormatTypeCode.
        end.
    end.
    
end.






for each tPayment:
    for each tPaymentCinvoice where tPaymentCInvoice.tiCDocument_ID = tPayment.CDocument_ID:
        tPayment.tcReferenceSum = tPayment.tcReferenceSum + tPaymentCInvoice.CInvoiceReference.
    end.
end.

<M-4 run FillProDataSetCreditor (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0 
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-6 run FillProDataSetCCollection
   (input  iiPaySel_ID (iiPaySel_ID), 
    output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0 
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-7 run FillProDataSetCompany
   (input  iiPaySel_ID (iiPaySel_ID), 
    output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0 
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-3 run FillProDataSetGL
   (input  iiPaySel_ID (iiPaySel_ID), 
    output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper <> 0 
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

/* ========================= */
/* Set default return status */
/* ========================= */
if oiReturnStatus = -98 
then assign oiReturnstatus = 0.