project QadFinancials > class BCOAMaskCC > method CheckCOAMaskCCBeforeDelete


Parameters


iiCOAMaskCCIdinputinteger
ocWarningMessageoutputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program8/bcoamaskcc.p)

assign oiReturnStatus = -98
       viLocalReturn  = 0.

MAIN_BLOCK:
do on error undo, return:
    /* ============================================================================================= */
    /* Suppose more than two domains share a CostCenter COA Mask but no Divisions linked to it.      */
    /* If the user will delete the CostCenter CoA Mask, it is allowed now but will pop up a warning. */
    /* ============================================================================================= */
    do viSharedSetCount = 1 to 3:
        assign vcGLSharedSetCode[viSharedSetCount]  = '':U
               vcDivSharedSetCode[viSharedSetCount] = '':U.
    end.
    assign viSharedSetCount = 0
           ocWarningMessage = '':U.
    
    <Q-3 run COAMaskCCForDelGL (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input iiCOAMaskCCId, (COAMaskCCId)
        output dataset tqCOAMaskCCForDelGL) in BCOAMaskCC >
    for each tqCOAMaskCCForDelGL
        break by tqCOAMaskCCForDelGL.tcSharedSetCode:
        if first-of(tqCOAMaskCCForDelGL.tcSharedSetCode)
        then do:
            assign viSharedSetCount = viSharedSetCount + 1.
            case viSharedSetCount:
                when 1
                then assign vcGLSharedSetCode[viSharedSetCount] = tqCOAMaskCCForDelGL.tcSharedSetCode.
                when 2 or when 3
                then assign vcGLSharedSetCode[viSharedSetCount] = ", " + tqCOAMaskCCForDelGL.tcSharedSetCode.
                when 4
                then assign vcGLSharedSetCode[3] = vcGLSharedSetCode[3] + "... ".
                otherwise leave.
            end case. 
        end. /* if first-of(tqCOAMaskCCForDelGL.tcSharedSetCode) */
    end. /* for each tqCOAMaskCCForDelGL */
    
    if vcGLSharedSetCode[2] <> ''
    then assign ocWarningMessage = substitute(#T-5'Deleting this shared mask code will also delete ranges specified for GL SharedSet &1&2&3 that were created for other domains!':255(999890773)T-5#, 
                                         vcGLSharedSetCode[1], vcGLSharedSetCode[2], vcGLSharedSetCode[3]).
    
    assign viSharedSetCount= 0.
    <Q-4 run COAMaskCCForDelDiv (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input iiCOAMaskCCId, (COAMaskCCId)
        output dataset tqCOAMaskCCForDelDiv) in BCOAMaskCC >
    for each tqCOAMaskCCForDelDiv
        break by tqCOAMaskCCForDelDiv.tcSharedSetCode:
        if first-of(tqCOAMaskCCForDelDiv.tcSharedSetCode)
        then do:
            assign viSharedSetCount = viSharedSetCount + 1.
            case viSharedSetCount:
                when 1
                then assign vcDivSharedSetCode[viSharedSetCount] = tqCOAMaskCCForDelDiv.tcSharedSetCode.
                when 2 or when 3
                then assign vcDivSharedSetCode[viSharedSetCount] = ", " + tqCOAMaskCCForDelDiv.tcSharedSetCode.
                when 4
                then assign vcDivSharedSetCode[3] = vcDivSharedSetCode[3] + "... ".
                otherwise leave.
            end case. 
        end. /* if first-of(tqCOAMaskCCForDelDiv.tcSharedSetCode) */
    end. /* for each tqCOAMaskCCForDelDiv */
    
    if vcDivSharedSetCode[2] <> ''
    then assign ocWarningMessage = ocWarningMessage + chr(10) + 
                                   substitute(#T-6'Deleting this shared mask code will also delete ranges specified for Sub-Account SharedSet &1&2&3 that were created for other domains!':255(999890774)T-6#, 
                                   vcDivSharedSetCode[1], vcDivSharedSetCode[2], vcDivSharedSetCode[3]).
end. /* MAIN_BLOCK */

/* Error handling */
assign oiReturnStatus = viLocalReturn.