project QadFinancials > class BDomain > method AdditionalUpdatesReplication

Description

Additional AdditionalUpdates method to replicate the Shared Set related data (Journal, Division, GL, Creditor, Debtor, Project, CostCentre, ExchangeRate)


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDomain.AdditionalUpdates


program code (program5/bdomain.p)

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

/* ================================================ */
/* Reset the input for the call to the daemon       */
/* ================================================ */
empty temp-table tReplicaDaemonQueueDomain.

/* ================================================================================ */
/* Go through all domains wherefor DomainSetUpIsComplete has been just set to true  */
/* ================================================================================ */
DOMAINBLOCK:
for each tDomainPropertyRefer where
        (tDomainPropertyRefer.tc_Status = "C":U or
         tDomainPropertyRefer.tc_Status = "N":U)      and
         tDomainPropertyRefer.DomainPropertyIsSetupCompl = true:
    /* Check if the domain was just set to DomainSetUpIsComplete */
    if tDomainPropertyRefer.tc_Status = "C":U and
        can-find(tInitialDomainPropertyRefer where
                 tInitialDomainPropertyRefer.Domain_ID                  = tDomainPropertyRefer.Domain_ID and 
                 tInitialDomainPropertyRefer.DomainPropertyIsSetupCompl = true)
    then next DOMAINBLOCK.              
         
    /* Get the domain for the domainproperty */         
    find tDomains where 
         tDomains.Domain_ID              = tDomainPropertyRefer.Domain_ID and
         tDomains.PrimaryCompany_ID     <> 0                              and 
         tDomains.PrimaryCompany_ID     <> ?                              and
         tDomains.tc_Status             <> "D":U  
         no-lock no-error.
    if not available tDomains
    then next DOMAINBLOCK.
    
    /* ===================== */
    /* Companies & Employees */
    /* ===================== */
    <Q-30 run CompanyByDomain (all) (Read) (NoCache)
       (input 0, (CompanyId)
        input tDomains.Domain_ID, (DomainId)
        input ?, (Active)
        output dataset tqCompanyByDomain) in BCompany >
    assign viCounter         = 0
           viCntEmployee     = 0
           vcListIDs         = "":U
           vcListEmployeeIDs = "":U.
    for each tqCompanyByDomain break by tqCompanyByDomain.tiCompany_ID:
        assign vcListIds = vcListIDs + chr(4) + trim(string(tqCompanyByDomain.tiCompany_ID))
               viCounter = viCounter + 1.
        if viCounter >= 90 or last(tqCompanyByDomain.tiCompany_ID)
        then do :
            create tReplicaDaemonQueueDomain.
            assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = {&REPLICATIONDAEMON-COMPANY} + chr(4) + trim(string(tDomains.PrimaryCompany_ID))
                   tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListIDs, 2, (length(vcListIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                   tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 9
                   vcListIDs                                             = "":U
                   viCounter                                             = 0.
        end. /* if viCounter >= 90 */
        if vlStartEmployee = false
        then do:
            <Q-32 run EmployeePrim  (Start) in BEmployee >
            assign vlStartEmployee = true.
        end.
        <Q-31 run EmployeePrim (all) (Read) (NoCache)
           (input 0, (EmployeeId)
            input '':U, (EmployeeCode)
            input tqCompanyByDomain.tiCompany_ID, (CompanyId)
            output dataset tqEmployeePrim) in BEmployee >
        for each tqEmployeePrim:
            assign vcListEmployeeIDs = vcListEmployeeIDs + chr(4) + trim(string(tqEmployeePrim.tiEmployee_ID))
                   viCntEmployee = viCntEmployee + 1.
            if viCntEmployee >= 90
            then do :
                create tReplicaDaemonQueueDomain.
                assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = {&REPLICATIONDAEMON-EMPLOYEE} + chr(4) + trim(string(tqCompanyByDomain.tiCompany_ID))
                       tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListEmployeeIDs, 2, (length(vcListEmployeeIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                       tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 12
                       vcListEmployeeIDs                                     = "":U
                       viCntEmployee                                         = 0.
            end. /* if viCounter >= 90 */
        end. /* for each tq */        
        if last(tqCompanyByDomain.tiCompany_ID) and vcListEmployeeIDs <> "":U
        then do:
            create tReplicaDaemonQueueDomain.
            assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = {&REPLICATIONDAEMON-EMPLOYEE} + chr(4) + trim(string(tqCompanyByDomain.tiCompany_ID))
                   tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListEmployeeIDs, 2, (length(vcListEmployeeIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                   tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 12
                   vcListEmployeeIDs                                     = "":U
                   viCntEmployee                                         = 0.        
        end.
    end. /* f.e. Company */
    
    /* ================== */
    /* Payment Conditions */
    /* ================== */
    <Q-34 run PaymentConditionPrim (all) (Read) (NoCache)
       (input 0, (PaymentConditionId)
        input '':U, (PaymentConditionCode)
        output dataset tqPaymentConditionPrim) in BPaymentCondition>
    assign viCounter         = 0
           vcListIDs         = "":U.
    for each tqPaymentConditionPrim break by tqPaymentConditionPrim.tiPaymentCondition_ID:
        assign vcListIDs = vcListIDs + chr(4) + trim(string(tqPaymentConditionPrim.tiPaymentCondition_ID))
               viCounter = viCounter + 1.
        if viCounter >= 90 or last(tqPaymentConditionPrim.tiPaymentCondition_ID)
        then do:
            create tReplicaDaemonQueueDomain.
            assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = {&REPLICATIONDAEMON-PAYMENTCONDITION} + chr(4) + trim(string(tDomains.PrimaryCompany_ID))
                   tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListIDs, 2, (length(vcListIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                   tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 13
                   vcListIDs                                             = "":U
                   viCounter                                             = 0.        
        end. /* if viCounter >= 90 or last(tqPaymentConditionPrim) */
    end. /* for each tqPaymentConditionPrim */
            
    for each tDomainSharedSet where 
             tDomainSharedSet.tc_ParentRowid   = tDomains.tc_Rowid and 
             tDomainSharedSet.tcSharedSetCode <> "":U              and 
             tDomainSharedSet.tcSharedSetCode <> ?                 and
             tDomainSharedSet.tc_status       <> "D":U 
             no-lock :            

      /* Check on the SS-type */
      Case tDomainSharedSet.tcSharedSetTypeCode :

        /* ============================== */
        /* Actions for the Journal-SS     */
        /* ============================== */
        when {&SHAREDSETTYPECODE-JOURNAL}
        then do :
            <Q-3 run JournalPrim (all) (Read) (NoCache)
               (input tDomains.PrimaryCompany_ID, (CompanyId)
                input '':U, (JournalCode)
                input 0, (JournalID)
                output dataset tqJournalPrim) in BJournal >
            assign viCounter = 0
                   vcListIDs = "":U.
            for each tqJournalPrim where
                     tcJournalControl = {&JOURNALCONTROL-LOGISTIC}
            break by tqJournalPrim.tiJournal_ID:
                assign vcListIds = vcListIDs + chr(4) + trim(string(tqJournalPrim.tiJournal_ID))
                       viCounter = viCounter + 1.
                if viCounter >= 90 or last(tqJournalPrim.tiJournal_ID)
                then do :
                    create tReplicaDaemonQueueDomain.
                    assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = trim(tDomainSharedSet.tcSharedSetTypeCode) + chr(4) + trim(string(tDomains.PrimaryCompany_ID))
                           tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListIDs, 2, (length(vcListIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                           tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 1
                           vcListIDs                                             = "":U
                           viCounter                                             = 0.
                end. /* if viCounter >= 90 */
            end. /* for each tq */
        end. /* Journal */       
        
        /* ============================== */
        /* Actions for the Division-SS    */
        /* ============================== */
        when {&SHAREDSETTYPECODE-DIVISION}
        then do :
            <Q-5 run DivisionPrim (all) (Read) (NoCache)
               (input tDomains.PrimaryCompany_ID, (CompanyId)
                input 0, (DivisionID)
                input '':U, (DivisionCode)
                output dataset tqDivisionPrim) in BDivision >
            assign viCounter = 0
                   vcListIDs = "":U.
            for each tqDivisionPrim break by tqDivisionPrim.tiDivision_ID:
                assign vcListIds = vcListIDs + chr(4) + trim(string(tqDivisionPrim.tiDivision_ID))
                       viCounter = viCounter + 1.
                if viCounter >= 90 or last(tqDivisionPrim.tiDivision_ID)
                then do :
                    create tReplicaDaemonQueueDomain.
                    assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = trim(tDomainSharedSet.tcSharedSetTypeCode) + chr(4) + trim(string(tDomains.PrimaryCompany_ID))
                           tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListIDs, 2, (length(vcListIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                           tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 2
                           vcListIDs                                             = "":U
                           viCounter                                             = 0.
                end. /* if viCounter >= 90 */
            end. /* for each tq */
        end. /* Division */       
        
        /* ============================== */
        /* Actions for the GL-SS          */
        /* ============================== */
        when {&SHAREDSETTYPECODE-GL}
        then do :
            <Q-1 run GLPrim (all) (Read) (NoCache)
               (input tDomains.PrimaryCompany_ID, (CompanyId)
                input '':U, (GLCode)
                input 0, (GLId)
                output dataset tqGLPrim) in BGL >
            assign viCounter = 0
                   vcListIDs = "":U.
            for each tqGLPrim break by tqGLPrim.tiGL_ID:
                assign vcListIds = vcListIDs + chr(4) + trim(string(tqGLPrim.tiGL_ID))
                       viCounter = viCounter + 1.
                if viCounter >= 90 or last(tqGLPrim.tiGL_ID)
                then do :
                    create tReplicaDaemonQueueDomain.
                    assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = trim(tDomainSharedSet.tcSharedSetTypeCode) + chr(4) + trim(string(tDomains.PrimaryCompany_ID))
                           tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListIDs, 2, (length(vcListIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                           tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 3
                           vcListIDs                                             = "":U
                           viCounter                                             = 0.
                end. /* if viCounter >= 90 */
            end. /* for each tq */
        end. /* GL */       

        /* ============================== */
        /* Actions for the Creditor-SS    */
        /* ============================== */
        when {&SHAREDSETTYPECODE-CREDITOR}
        then do :
            <Q-7 run CreditorPrim (all) (Read) (NoCache)
               (input tDomains.PrimaryCompany_ID, (CompanyId)
                input 0, (CreditorId)
                input '':U, (CreditorCode)
                output dataset tqCreditorPrim) in BCreditor >
            assign viCounter = 0
                   vcListIDs = "":U.
            for each tqCreditorPrim break by tqCreditorPrim.tiCreditor_ID:
                assign vcListIds = vcListIDs + chr(4) + trim(string(tqCreditorPrim.tiCreditor_ID))
                       viCounter = viCounter + 1.
                if viCounter >= 90 or last(tqCreditorPrim.tiCreditor_ID)
                then do :
                    create tReplicaDaemonQueueDomain.
                    assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = trim(tDomainSharedSet.tcSharedSetTypeCode) + chr(4) + trim(string(tDomains.PrimaryCompany_ID))
                           tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListIDs, 2, (length(vcListIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                           tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 4
                           vcListIDs                                             = "":U
                           viCounter                                             = 0.
                end. /* if viCounter >= 90 */
            end. /* for each tq */
        end. /* Creditor */
        
        /* ============================== */
        /* Actions for the Debtor-SS      */
        /* ============================== */
        when {&SHAREDSETTYPECODE-DEBTOR}
        then do :
            <Q-9 run DebtorPrim (all) (Read) (NoCache)
               (input tDomains.PrimaryCompany_ID, (CompanyId)
                input '':U, (DebtorCode)
                input 0, (Debtor_ID)
                output dataset tqDebtorPrim) in BDebtor >
            assign viCounter        = 0
                   viCntShipto      = 0
                   viCntEndUser     = 0
                   vcListIDs        = "":U
                   vcListShiptoIDs  = "":U
                   vcListEndUserIDs = "":U.
            for each tqDebtorPrim break by tqDebtorPrim.tiDebtor_ID:
                assign vcListIds = vcListIDs + chr(4) + trim(string(tqDebtorPrim.tiDebtor_ID))
                       viCounter = viCounter + 1.
                if viCounter >= 90 or last(tqDebtorPrim.tiDebtor_ID)
                then do :
                    create tReplicaDaemonQueueDomain.
                    assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = trim(tDomainSharedSet.tcSharedSetTypeCode) + chr(4) + trim(string(tDomains.PrimaryCompany_ID))
                           tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListIDs, 2, (length(vcListIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                           tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 5
                           vcListIDs                                             = "":U
                           viCounter                                             = 0.
                end. /* if viCounter >= 90 */
                                
                <Q-22 run DebtorShiptoByDebtor (all) (Read) (NoCache)
                   (input tqDebtorPrim.tiDebtor_ID, (DebtorId)
                    input tDomains.PrimaryCompany_ID, (CompanyId)
                    output dataset tqDebtorShiptoByDebtor) in BDebtorShipTo>
                    
                for each tqDebtorShiptoByDebtor:
                    assign vcListShiptoIDs = vcListShiptoIDs + chr(4) + trim(string(tqDebtorShiptoByDebtor.tiDebtorShipTo_ID))
                           viCntShipto     = viCntShipto + 1.
                    if viCntShipto >= 90
                    then do:
                        create tReplicaDaemonQueueDomain.
                        assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = {&REPLICATIONDAEMON-DEBTORSHIPTO} + chr(4) + trim(string(tDomains.PrimaryCompany_ID))
                               tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListShiptoIDs, 2, (length(vcListShiptoIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                               tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 10
                               vcListShiptoIDs                                       = "":U
                               viCntShipto                                           = 0.                            
                    end. /* if viCntShipto >= 90 */                               
                end. /* for each tqDebtorShipToByDebtor */                     
                if last(tqDebtorPrim.tiDebtor_ID) and vcListShiptoIDs <> "":U
                then do:
                    create tReplicaDaemonQueueDomain.
                    assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = {&REPLICATIONDAEMON-DEBTORSHIPTO} + chr(4) + trim(string(tDomains.PrimaryCompany_ID))
                           tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListShiptoIDs, 2, (length(vcListShiptoIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                           tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 10
                           vcListShiptoIDs                                       = "":U
                           viCntShipto                                           = 0.                                                
                end.
                
                /* DebtorEndUser */
                if vlStartDebtorEndUser = false
                then do:                       
                    <Q-28 run DebtorEndUserByDebtorByAddress  (Start) in BDebtorEndUser >
                    assign vlStartDebtorEndUser = true.
                end.
                <Q-24 run DebtorEndUserByDebtorByAddress (all) (Read) (NoCache)
                   (input 0, (AddressID)
                    input ?, (DebtorEndUserIsShipto)
                    input ?, (DebtorEndUserIsDebtor)
                    input '':U, (DebtorShipToCode)
                    input tqDebtorPrim.tiDebtor_ID, (DebtorID)
                    input ?, (CompanyId)
                    output dataset tqDebtorEndUserByDebtorByAddress) in BDebtorEndUser >
                for each tqDebtorEndUserByDebtorByAddress:
                    assign vcListEndUserIDs = vcListEndUserIDs + chr(4) + trim(string(tqDebtorEndUserByDebtorByAddress.tiDebtorEndUser_ID))
                           viCntEndUser     = viCntEndUser + 1.
                    if viCntEndUser >= 90
                    then do:
                        create tReplicaDaemonQueueDomain.
                        assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = {&REPLICATIONDAEMON-DEBTORENDUSER} + chr(4) + trim(string(tDomains.PrimaryCompany_ID))
                               tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListEndUserIDs, 2, (length(vcListEndUserIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                               tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 11
                               vcListEndUserIDs                                      = "":U
                               viCntEndUser                                          = 0.                            
                    end. /* if viCntEndUser >= 90 */                               
                end. /* for each tqDebtorEndUserByDebtorByAddress */                     
                if last(tqDebtorPrim.tiDebtor_ID) and vcListEndUserIDs <> "":U
                then do:
                    create tReplicaDaemonQueueDomain.
                    assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = {&REPLICATIONDAEMON-DEBTORENDUSER} + chr(4) + trim(string(tDomains.PrimaryCompany_ID))
                           tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListEndUserIDs, 2, (length(vcListEndUserIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                           tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 11
                           vcListEndUserIDs                                      = "":U
                           viCntEndUser                                          = 0.                            
                end.                    
            end. /* for each tq */
        end. /* Debtor */       

        /* ============================== */
        /* Actions for the Project-SS     */
        /* ============================== */
        when {&SHAREDSETTYPECODE-PROJECT}
        then do :
            <Q-11 run ProjectPrim (all) (Read) (NoCache)
               (input tDomains.PrimaryCompany_ID, (CompanyId)
                input 0, (ProjectID)
                input '':U, (ProjectCode)
                output dataset tqProjectPrim) in BProject >
            assign viCounter = 0
                   vcListIDs = "":U.
            for each tqProjectPrim break by tqProjectPrim.tiProject_ID:
                assign vcListIds = vcListIDs + chr(4) + trim(string(tqProjectPrim.tiProject_ID))
                       viCounter = viCounter + 1.
                if viCounter >= 90 or last(tqProjectPrim.tiProject_ID)
                then do :
                    create tReplicaDaemonQueueDomain.
                    assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = trim(tDomainSharedSet.tcSharedSetTypeCode) + chr(4) + trim(string(tDomains.PrimaryCompany_ID))
                           tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListIDs, 2, (length(vcListIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                           tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 6
                           vcListIDs                                             = "":U
                           viCounter                                             = 0.
                end. /* if viCounter >= 90 */
            end. /* for each tq */
        end. /* Project */       
               
        /* ============================== */
        /* Actions for the CostCentre-SS  */
        /* ============================== */
        when {&SHAREDSETTYPECODE-COSTCENTRE}
        then do :
            <Q-13 run CostCentrePrim (all) (Read) (NoCache)
               (input tDomains.PrimaryCompany_ID, (CompanyId)
                input 0, (CostCentreID)
                input '':U, (CostCentreCode)
                output dataset tqCostCentrePrim) in BCostCentre >
            assign viCounter = 0
                   vcListIDs = "":U.
            for each tqCostCentrePrim break by tqCostCentrePrim.tiCostCentre_ID:
                assign vcListIds = vcListIDs + chr(4) + trim(string(tqCostCentrePrim.tiCostCentre_ID))
                       viCounter = viCounter + 1.
                if viCounter >= 90 or last(tqCostCentrePrim.tiCostCentre_ID)
                then do :
                    create tReplicaDaemonQueueDomain.
                    assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = trim(tDomainSharedSet.tcSharedSetTypeCode) + chr(4) + trim(string(tDomains.PrimaryCompany_ID))
                           tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListIDs, 2, (length(vcListIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                           tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 7
                           vcListIDs                                             = "":U
                           viCounter                                             = 0.
                end. /* if viCounter >= 90 */
            end. /* for each tq */
        end. /* CostCentre */       

        /* ================================ */
        /* Actions for the Exchange Rate-SS */
        /* ================================ */
        when {&SHAREDSETTYPECODE-EXCHANGERATE}
        then do :
            <Q-15 run ExchangeRatePrim (all) (Read) (NoCache)
               (input ?, (ValidDateFrom)
                input 0, (FromCurrencyId)
                input 0, (ToCurrencyId)
                input 0, (ExchangeRateTypeId)
                input 0, (ExchangeRateId)
                input tDomains.PrimaryCompany_ID, (CompanyId)
                input '':U, (FromCurrencyCode)
                input '':U, (ToCurrencyCode)
                input '':U, (ExchangeRateTypeCode)
                output dataset tqExchangeRatePrim) in BExchangeRate >
            assign viCounter = 0
                   vcListIDs = "":U.
            for each tqExchangeRatePrim where
                     tqExchangeRatePrim.tcExchangeRateTypeCode = {&EXCHANGERATETYPE-ACCOUNTING} or 
                     tqExchangeRatePrim.tcExchangeRateTypeCode = {&EXCHANGERATETYPE-STATUTORY}  or 
                     tqExchangeRatePrim.tcExchangeRateTypeCode = {&EXCHANGERATETYPE-INVENTORY}  or 
                     tqExchangeRatePrim.tcExchangeRateTypeCode = {&EXCHANGERATETYPE-INTRASTAT}
                     break by tqExchangeRatePrim.tiExchangeRate_ID:
                assign vcListIds = vcListIDs + chr(4) + trim(string(tqExchangeRatePrim.tiExchangeRate_ID))
                       viCounter = viCounter + 1.
                if viCounter >= 90 or last(tqExchangeRatePrim.tiExchangeRate_ID)
                then do :
                    create tReplicaDaemonQueueDomain.
                    assign tReplicaDaemonQueueDomain.tcDaemonQueueRef            = trim(tDomainSharedSet.tcSharedSetTypeCode) + chr(4) + trim(string(tDomains.PrimaryCompany_ID))
                           tReplicaDaemonQueueDomain.tcDaemonQueueRefDescription = substring(vcListIDs, 2, (length(vcListIDs, "CHARACTER":U) - 1),"CHARACTER":U)
                           tReplicaDaemonQueueDomain.tiDaemonQueuePriority       = 8
                           vcListIDs                                             = "":U
                           viCounter                                             = 0.
                end. /* if viCounter >= 90 */
            end. /* for each tq */
        end. /* ExchangeRate */                   
      end case.
    end. /* for each tDomainSharedSet */    
end. /* DOMAINBLOCK */

/* Stop queries */
if vlStartDebtorEndUser = true
then do:                       
    <Q-29 run DebtorEndUserByDebtorByAddress  (Stop) in BDebtorEndUser >
    assign vlStartDebtorEndUser = false.
end.
if vlStartEmployee = true
then do:
    <Q-33 run EmployeePrim  (Stop) in BEmployee >
    assign vlStartEmployee = false.
end.    


/* ============================== */
/* Create daemon-requests         */
/* ============================== */
if can-find (first tReplicaDaemonQueueDomain) 
then do :
    /* (Start and) open BReplicaDaemonQueue */
    if viBReplicaDaemonQueueDomainID = 0 or
       viBReplicaDaemonQueueDomainID = ?
    then do:
        <I-16 {bFcStartAndOpenInstance
            &ADD-TO-TRANSACTION = "true"
            &CLASS              = "BReplicaDaemonQueue"}>
    end.
    else do:
        <I-17 {bFcOpenInstance
            &CLASS           = "BReplicaDaemonQueue"}>
    end.
        
    /* ApiCreateReplicationDaemonQueue */
    <M-18 run ApiCreateReplicationDaemonQueue (input  tReplicaDaemonQueueDomain (tReplicationDaemonQueue), 
                                           output viExternalReturnStatus (oiReturnStatus)) in BReplicaDaemonQueue>    
    <I-19 {bFcCloseInstance
            &CLASS           = "BReplicaDaemonQueue"}>
    if viExternalReturnStatus <> 0 
    then assign oiReturnStatus = viExternalReturnStatus.
    if viExternalReturnStatus < 0
    then leave.
end. /* if can find */

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