project QadFinancials > class BPaymentSelection > method FillProDataSetCreditor


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPaymentSelection.FillProDataSet


program code (program7/bpaymentselection.p)

/* ========================================================= */
/* Fill the ttCreditor temp table and it's child temp tables
   step1. Start All the Queries which will be used in the procedure.
   step2. Run the Query to get the records of the target table by supplying the ID parameter.
   step3. Validate whether the query return the expect records,if yes then continue else return.
   step4. Buffercopy the query result to the target temp table.
   step5. (optional) Do some calculation work. 
   step6. Go to step2 until fill all the child temp tables. 
   step7. Stop all the queries used in the procedure. */
/* ========================================================= */
if oiReturnStatus = 0
then assign oiReturnStatus = -98.
<Q-16 run CreditorAllInfo
   (Start) in BCreditor >
<Q-17 run BusinessRelationByIDAllInfo
   (Start) in BBusinessRelation >
<Q-18 run AddressByIDsAllInfo
   (Start) in BBusinessRelation >
<Q-48 run CountryByIDAllInfo
   (Start) in BCountry >
<Q-47 run StateByIDAllInfo
   (Start) in BState >
for each tCDocumentPaySel:
    <Q-1 run CreditorAllInfo (all) (Read) (NoCache)
       (input ?, (CompanyId)
        input tCDocumentPaySel.Creditor_ID, (Creditor_ID)
        output dataset tqCreditorAllInfo) in BCreditor >
    find first tqCreditorAllInfo no-error.
    if not available tqCreditorAllInfo
    then do:
        <M-37 run SetMessage
           (input  #T-38'No supplier record is available.':50(999890597)T-38# (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'D':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QadFin-5340':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                     
        assign
            oiReturnStatus = -1.
            return.
    end. /* end of if not available tqCreditorAllInfo */
    else do:
        assign
            vhBufferForProDataSet = dataset tqCreditorAllInfo:get-buffer-handle(1).
        for each tqCreditorAllInfo:
            find first tPaymentCreditor where tPaymentCreditor.Creditor_ID = tCDocumentPaySel.Creditor_ID no-error.
            if not available tPaymentCreditor and tCDocumentPaySel.Creditor_ID <> 0
            then do:
            create tPaymentCreditor.
            <M-3 run BufferCopy
               (input  vhBufferForProDataSet (ihFrom), 
                input  buffer tPaymentCreditor:handle (ihTo), 
                output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
            if viFcReturnSuper <> 0 
            then assign oiReturnStatus = viFcReturnSuper.
            if viFcReturnSuper < 0
            then return.
            <Q-4 run BusinessRelationByIDAllInfo (all) (Read) (NoCache)
               (input tPaymentCreditor.BusinessRelation_ID, (BusinessRelation_ID)
                output dataset tqBusinessRelationByIDAllInfo) in BBusinessRelation >
            find first tqBusinessRelationByIDAllInfo no-error.
            if not available tqBusinessRelationByIDAllInfo
            then do:
                <M-39 run SetMessage
                   (input  #T-40'No business relation record is available.':50(999890598)T-40# (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'D':U (icType), 
                    input  3 (iiSeverity), 
                    input  '':U (icRowid), 
                    input  'QadFin-5341':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                     
                assign
                    oiReturnStatus = -1.
                    return.
                     
            end. /* end of if not available tqBusinessRelationByIDAllInfo */
            else do:
                assign
                    vhBufferForBusinessRelation = dataset tqBusinessRelationByIDAllInfo:get-buffer-handle(1).
                for first tqBusinessRelationByIDAllInfo:
                    find first tCreditorBusRel where tCreditorBusRel.BusinessRelation_ID = tqBusinessRelationByIDAllInfo.tiBusinessRelation_ID no-error.
                    if not available tCreditorBusRel then do: /* to avoid duplicate key issue */
                       create tCreditorBusRel.
                       <M-6 run BufferCopy
                          (input  vhBufferForBusinessRelation (ihFrom), 
                           input  buffer tCreditorBusRel:handle (ihTo), 
                           output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                       if viFcReturnSuper <> 0 
                       then assign oiReturnStatus = viFcReturnSuper.
                       if viFcReturnSuper < 0
                       then return.
                       
                       assign vlAddressID = false.                                      
                        <Q-91 run AddressByIDsAllInfo (all) (Read) (NoCache)
                           (input tPaymentCreditor.BusinessRelation_ID, (BusinessRelation_ID)
                            input viAddressTypeRemittance_ID, (AddressType_ID)
                            output dataset tqAddressByIDsAllInfo) in BBusinessRelation>
                        find first tqAddressByIDsAllInfo no-error.
                        if available tqAddressByIDsAllInfo    
                        then do:
                            assign vlAddressID = true.
                            assign tCreditorBusRel.BusinessRelationName1      = tqAddressByIDsAllInfo.tcAddressName
                                   tCreditorBusRel.BusinessRelationSearchName = tqAddressByIDsAllInfo.tcAddressSearchName.
                        end. /* if available tqAddressByIDsAllInfo */               
                   end.            
                    
                    <Q-7 run AddressByIDsAllInfo (all) (Read) (NoCache)
                       (input tCreditorBusRel.BusinessRelation_ID, (BusinessRelation_ID)
                        input viAddressTypeRemittance_ID, (AddressType_ID)
                        output dataset tqAddressByIDsAllInfo) in BBusinessRelation>
                    find first tqAddressByIDsAllInfo no-error.
                    if not available tqAddressByIDsAllInfo 
                    then do:

                        <Q-75 run AddressByIDsAllInfo (all) (Read) (NoCache)
                           (input tCreditorBusRel.BusinessRelation_ID, (BusinessRelation_ID)
                            input viAddressType_ID, (AddressType_ID)
                            output dataset tqAddressByIDsAllInfo) in BBusinessRelation>

                        find first tqAddressByIDsAllInfo no-error.
                        if not available tqAddressByIDsAllInfo
                        then do:

                            <M-41 run SetMessage
                               (input  #T-42'No address record is available.':50(999890599)T-42# (icMessage), 
                                input  '':U (icArguments), 
                                input  '':U (icFieldName), 
                                input  '':U (icFieldValue), 
                                input  'D':U (icType), 
                                input  3 (iiSeverity), 
                                input  '':U (icRowid), 
                                input  'QadFin-5342':U (icFcMsgNumber), 
                                input  '':U (icFcExplanation), 
                                input  '':U (icFcIdentification), 
                                input  '':U (icFcContext), 
                                output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
    
                            assign
                                oiReturnStatus = -1.
                                return.
                        end. /* if not available tqAddressByIDsAllInfo */
                    end. /* if not available tqAddressByIDsAllInfo then do: */

                    find first tqAddressByIDsAllInfo no-error.
                    if available tqAddressByIDsAllInfo 
                    then do:
                        assign
                            vhBufferForAddress = dataset tqAddressByIDsAllInfo:get-buffer-handle(1).
                        for each tqAddressByIDsAllInfo:
                            find first tAddressOfCreditor where tAddressOfCreditor.Address_ID = tqAddressByIDsAllInfo.tiAddress_ID no-error.
                            if not available tAddressOfCreditor then do: /* to avoid duplicate key issue */
                                create tAddressOfCreditor.
                                <M-9 run BufferCopy
                                   (input  vhBufferForAddress (ihFrom), 
                                    input  buffer tAddressOfCreditor:handle (ihTo), 
                                    output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                                if viFcReturnSuper <> 0 
                                then assign oiReturnStatus = viFcReturnSuper.
                                if viFcReturnSuper < 0
                                then return.
                            end.
                            
                            find first tCountryOfCreditor where tCountryOfCreditor.Country_ID = tAddressOfCreditor.Country_ID no-error.                            
                            if not available tCountryOfCreditor and tAddressOfCreditor.Country_ID <>0
                            then do:
                                <Q-49 run CountryByIDAllInfo (all) (Read) (NoCache)
                                   (input tAddressOfCreditor.Country_ID, (Country_ID)
                                    output dataset tqCountryByIDAllInfo) in BCountry >
                                find first tqCountryByIDAllInfo no-error.
                                if not available tqCountryByIDAllInfo
                                then do:
                                    <M-43 run SetMessage
                                       (input  #T-44'No country record is available.':50(999890600)T-44# (icMessage), 
                                        input  '':U (icArguments), 
                                        input  '':U (icFieldName), 
                                        input  '':U (icFieldValue), 
                                        input  'D':U (icType), 
                                        input  3 (iiSeverity), 
                                        input  '':U (icRowid), 
                                        input  'QadFin-5343':U (icFcMsgNumber), 
                                        input  '':U (icFcExplanation), 
                                        input  '':U (icFcIdentification), 
                                        input  '':U (icFcContext), 
                                        output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                                    assign
                                        oiReturnStatus = -1.
                                        return.
                                end. /* end of if not available tqCountryByIDAllInfo */
                                else do:
                                    assign
                                        vhBufferForCountry = dataset tqCountryByIDAllInfo:get-buffer-handle(1).
                                    for each tqCountryByIDAllInfo:
                                        create tCountryOfCreditor.
                                    <M-12 run BufferCopy
                                       (input  vhBufferForCountry (ihFrom), 
                                        input  buffer tCountryOfCreditor:handle (ihTo), 
                                        output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                                    if viFcReturnSuper <> 0 
                                    then assign oiReturnStatus = viFcReturnSuper.
                                    if viFcReturnSuper < 0
                                    then return.
                                    end. /* for each tqCountryAllInfo*/
                                end. /* tqCountryAllInfo else do */
                            end. /*if not available tCountryOfCreditor and tAddressOfCreditor.Country_ID <>0 */
                            find first tStateOfCreditor where tStateOfCreditor.State_ID = tAddressOfCreditor.State_ID no-error.
                            if not available tStateOfCreditor and tAddressOfCreditor.State_ID<>0
                            then do:

                                <Q-50 run StateByIDAllInfo (all) (Read) (NoCache)
                                   (input tAddressOfCreditor.State_ID, (State_ID)
                                    output dataset tqStateByIDAllInfo) in BState >
                          
                                assign
                                    vhBufferForState = dataset tqStateByIDAllInfo:get-buffer-handle(1).
                                for each tqStateByIDAllInfo:
                                    create tStateOfCreditor.
                                    <M-36 run BufferCopy
                                       (input  vhBufferForState (ihFrom), 
                                        input  buffer tStateOfCreditor:handle (ihTo), 
                                        output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                                    if viFcReturnSuper <> 0 
                                    then assign oiReturnStatus = viFcReturnSuper.
                                    if viFcReturnSuper < 0
                                    then return.
                                end. /*for each tqStataAllInfo */
                            end. /*if not available tStateOfCreditor and tAddressOfCreditor.State_ID<>0 */
                        end. /* for each tqAddressAllInfo */
                    end. /* if available tqAddressByIDsAllInfo */
                end. /* for each tqBusinessRelationAllInfo */
            end. /* tqBusinessRelationAllInfo else do */
            end.
        end. /* for each tqCreditorAllInfo */
    end. /* tqCreditorAllInfo else do */
end. /* for each tPayment*/
<Q-51 run StateByIDAllInfo
  (Stop) in BState >
<Q-52 run CountryByIDAllInfo
  (Stop) in BCountry >
<Q-21 run AddressByIDsAllInfo
  (Stop) in BBusinessRelation >
<Q-22 run BusinessRelationByIDAllInfo
  (Stop) in BBusinessRelation >
<Q-23 run CreditorAllInfo
  (Stop) in BCreditor >

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