project BLF > class BDomain > method AdditionalUpdates

Description

This method is part of the SetPublicTables flow.
When executed, data in the input class tables (prefix t_s) is validated and found correct, and copied into the class tables (prefix t_o).
This method can be extended to do updates that do not require a validation or that involve running business methods of other business classes. These classes should be started with ADD-TO-TRANSACTION = 'true'. Also make sure to add these classes in method StopExternalInstances.


Parameters


oiReturnStatusoutputinteger


Internal usage


BLF
method BDomain.SetDomainTypeAsSystem
method BDomain.SetPrimaryCompany
method BDomain.SynchronizeSharedSet

QadFinancials
method BDomain.ApiSynchronise
method BDomain.ValidateBCAdditionalUpdates


program code (program/bdomain.p)

<ANCESTOR-CODE>


/* ================================================================================= */
/* Validation: for a domain there should be an underlaying DomainSharedSet record    */
/* for every type of SharedSet. The reason that this validation was written here, is */
/* that this is the first place where you have all records of an instance available. */
/* In method ValidateComponent, you do not have records with tc_status = "":U        */
/* ================================================================================= */

assign vcListSharedSetTypeCode = <M-5 GetSharedSetTypes () in BDomain>.
for each tDomains where tDomains.tc_Status <> "D":U on error undo, throw:
    do viSharedSetCounter = num-entries(vcListSharedSetTypeCode,chr(2)) to 1 by -2 :
        find tDomainSharedSet where 
             tDomainSharedSet.tc_ParentRowid        = tDomains.tc_Rowid and
             tDomainSharedSet.tc_Status            <> "D":U             and
             tDomainSharedSet.tcSharedSetTypeCode  = entry(viSharedSetCounter,vcListSharedSetTypeCode,chr(2)) 
             no-lock no-error.
        if not available tDomainSharedSet
        then do :
            assign oiReturnStatus = -1.
            find first tDomainSharedSet where 
                       tDomainSharedSet.tc_ParentRowid        = tDomains.tc_Rowid and
                       tDomainSharedSet.tc_Status            <> "D":U             and
                       tDomainSharedSet.tcSharedSetTypeCode   = entry(viSharedSetCounter,vcListSharedSetTypeCode,chr(2)) 
                       no-lock no-error.
            if not available tDomainSharedSet
            then assign vcMessage = trim(substitute(#T-1'The domain (&1) has no shared set for shared set type '&2'.':80(6672)T-1#,tDomains.DomainCode,entry(viSharedSetCounter - 1,vcListSharedSetTypeCode,chr(2)))).
            else assign vcMessage = trim(substitute(#T-2'The domain (&1) has multiple shared sets for shared set type '&2'.':80(6673)T-2#,tDomains.DomainCode,entry(viSharedSetCounter - 1,vcListSharedSetTypeCode,chr(2)))) + chr(10) + trim(#T-3'Only one specification is allowed per shared set type.':255(6603)T-3#).
            <M-4 run SetMessage (input  vcMessage (icMessage), 
                     input  '':U (icArguments), 
                     input  '':U (icFieldName), 
                     input  '':U (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  tDomains.tc_Rowid (icRowid), 
                     input  'BLF-68':U (icFcMsgNumber), 
                     input  '':U (icFcExplanation), 
                     input  '':U (icFcIdentification), 
                     input  '':U (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BDomain>
            return.
        end. /* if not available tDomainSharedSet */
    end. /* do */
end. /* for each tDomains where */

/* ================================================================= */
/* When deleting a domain also delete all related violations.        */
/* This cannot be done with a cascaded delete in the data model as   */
/* this delete must also trigger a create in the SODLog table.       */
/* ================================================================= */
if can-find (first tDomains where tDomains.tc_Status = "D")
then do:
    <Q-13 assign vlFcQueryRecordsAvailable = SystSODActive (NoCache)  () in BSystem >
    if vlFcQueryRecordsAvailable
    then do:
        <I-6 {bFcAddToTransaction
             &CLASS           = "BSODViolationRule2"}>
    
        for each tDomains where tDomains.tc_Status = "D" on error undo, throw:
            <M-7 run DeleteByDomain
               (input  tDomains.Domain_ID (iiDomainID), 
                output viFcReturnSuper (oiReturnStatus)) in BSODViolationRule2>
            if viFcReturnSuper = -4
            then viFcReturnSuper = 0.
            else vlDeletesDone = yes.
            if viFcReturnSuper <> 0
            then oiReturnStatus = viFcReturnSuper.
            if viFcReturnSuper < 0
            then do:
                <M-8 run StopExternalInstances  (output viFcReturnSuper (oiReturnStatus)) in BDomain>
                return.
            end.
        end.
    
        if vlDeletesDone
        then do:
            <M-9 run DeleteFinish  (output viFcReturnSuper (oiReturnStatus)) in BSODViolationRule2>
            if viFcReturnSuper <> 0
            then oiReturnStatus = viFcReturnSuper.
            if viFcReturnSuper < 0
            then do:
                <M-10 run StopExternalInstances  (output viFcReturnSuper (oiReturnStatus)) in BDomain>
                return.
            end.
            <I-11 {bFcCloseInstance
                 &CLASS           = "BSODViolationRule2"}>
        end.
        else do:
            <I-12 {bFcCloseAndStopInstance
                 &CLASS           = "BSODViolationRule2"}>
        end.
    end.
end.