project BLF > class BSODCategoryExclusion > 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 BSODCategoryExclusion.ApiSetMatrixData


program code (program/bsodcategoryexclusion.p)

<ANCESTOR-CODE>

/* ================================================================= */
/* When deleting an exclusion 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.       */
/* ================================================================= */
viSOD1 = -1.
viSOD2 = -1.

<Q-70 assign vlFcQueryRecordsAvailable = SystSODActive (NoCache)  () in BSystem >
if vlFcQueryRecordsAvailable
then do:
    if can-find (first tSODExclusion where tSODExclusion.tc_Status = "D")
    then do:
        <I-1 {bFcAddToTransaction
             &CLASS           = "BSODViolationRule1"}>
        <I-8 {bFcAddToTransaction
             &CLASS           = "BSODViolationRule2"}>
    
        for each tSODExclusion where tSODExclusion.tc_Status = "D" on error undo, throw:
        
            /* ================================================================= */
            /* Exclusions are normally always deleted in pairs, so this can-find */
            /* should always return true.                                        */
            /* Make sure that each deletion is only done once.                   */
            /* ================================================================= */
            if tSODExclusion.SODCategory1_ID > tSODExclusion.SODCategory2_ID
            then if can-find (first bSODExclusion where
                                    bSODExclusion.SODCategory1_ID = tSODExclusion.SODCategory2_ID and
                                    bSODExclusion.SODCategory2_ID = tSODExclusion.SODCategory1_ID and
                                    bSODExclusion.tc_Status       = "D")
                 then next.
                 
            <M-2 run DeleteBySODCategoryExclusion
               (input  tSODExclusion.SODCategory1_ID (iiSODCategory1ID), 
                input  tSODExclusion.SODCategory2_ID (iiSODCategory2ID), 
                output viFcReturnSuper (oiReturnStatus)) in BSODViolationRule1>
            if viFcReturnSuper = -4
            then viFcReturnSuper = 0.
            else vlDeletes1Done = yes.
            if viFcReturnSuper <> 0
            then oiReturnStatus = viFcReturnSuper.
            if viFcReturnSuper < 0
            then return.
            
            <M-15 run DeleteByUserRoleCompanyCategory
               (input  0 (iiUsrID), 
                input  0 (iiRoleID), 
                input  0 (iiDomainID), 
                input  0 (iiCompanyID), 
                input  tSODExclusion.SODCategory1_ID (iiSODCategory1ID), 
                input  tSODExclusion.SODCategory2_ID (iiSODCategory2ID), 
                output viFcReturnSuper (oiReturnStatus)) in BSODViolationRule2>
            if viFcReturnSuper = -4
            then viFcReturnSuper = 0.
            else vlDeletes2Done = yes.
            if viFcReturnSuper <> 0
            then oiReturnStatus = viFcReturnSuper.
            if viFcReturnSuper < 0
            then return.
        end.
    
        if vlDeletes1Done
        then do:
            <M-6 run DeleteFinish  (output viFcReturnSuper (oiReturnStatus)) in BSODViolationRule1>
            if viFcReturnSuper <> 0
            then oiReturnStatus = viFcReturnSuper.
            if viFcReturnSuper < 0
            then return.
            <I-4 {bFcCloseInstance
                 &CLASS           = "BSODViolationRule1"}>
        end.
        else do:
            <I-5 {bFcCloseAndStopInstance
                 &CLASS           = "BSODViolationRule1"}>
        end.
    
        if vlDeletes2Done
        then do:
            <M-14 run DeleteFinish  (output viFcReturnSuper (oiReturnStatus)) in BSODViolationRule2>
            if viFcReturnSuper <> 0
            then oiReturnStatus = viFcReturnSuper.
            if viFcReturnSuper < 0
            then return.
            <I-12 {bFcCloseInstance
                 &CLASS           = "BSODViolationRule2"}>
        end.
        else do:
            <I-13 {bFcCloseAndStopInstance
                 &CLASS           = "BSODViolationRule2"}>
        end.
    end.
    
    if not vlBlockSOD
    then for each tSODExclusion where tSODExclusion.tc_Status = "N" on error undo, throw:
        if viSOD1 = -1
        then viSOD1 = tSODExclusion.SODCategory1_ID.
        else if  viSOD1 <> tSODExclusion.SODCategory1_ID
             and viSOD1 <> tSODExclusion.SODCategory2_ID
             then viSOD1 = 0.
        if viSOD2 = -1
        then viSOD2 = tSODExclusion.SODCategory2_ID.
        else if  viSOD2 <> tSODExclusion.SODCategory1_ID
             and viSOD2 <> tSODExclusion.SODCategory2_ID
             then viSOD2 = 0.
    end.
end.

viSODCategoryIDToCheck = (if viSOD2 = 0 then viSOD1 else viSOD2).

finally:
    if oiReturnStatus < 0
    then do:
        <M-65 run StopExternalInstances  (output viFcReturnSuper (oiReturnStatus)) in BSODCategoryExclusion>
    end.
end finally.