project QadFinancials > class BMfgSystemAccountControl > method UpdateRndMthd

Description

This method will update rounding method of gl_ctrl when the rounding method gets modified from currency modify screen.


Parameters


tCopyCurrinputtemp-table
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BMfgCurrency.AdditionalUpdates


program code (program7/bmfgsystemaccountcontrol.p)

MAIN_BLOCK:
do on error undo, leave:

    /* ====================== */
    /* Check input parameters */
    /* ====================== */
    if not can-find(first tCopyCurr)
    then return.
    
    /* ================== */
    /* Exception Handling */
    /* ================== */
    assign oiReturnStatus                  = -98
           viLocalReturnStatus             = 0.
    
    /* ======================= */
    /* Clear the instance Data */
    /* ======================= */
    <M-82 run ClearData  (output viFcReturnSuper (oiReturnStatus)) in BMfgSystemAccountControl>
    if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0   
    then assign viLocalReturnStatus = viFcReturnSuper.
         
    <Q-89 run SystemAccountControlForAll (all) (Read) (NoCache)
       (input ?, (DomainCode)
        output dataset tqSystemAccountControlForAll) in BMfgSystemAccountControl >
               
    for each tCopyCurr where tCopyCurr.tc_Status = "C":U:
    
        for each tqSystemAccountControlForAll where tqSystemAccountControlForAll.tcgl_base_curr = tCopyCurr.CurrencyCode:
    
            
           assign vcPrimLst = vcPrimLst               + 
                              (if vcPrimLst   = '':U
                               then '':U
                               else chr(4))           +
                               string(tqSystemAccountControlForAll.tcgl_domain).
                                               
           if length(vcPrimLst, "CHARACTER") > 10000
           then do:
           /* ========================= */
           /* Load the tgl_ctrl records */
           /* ========================= */
                <M-1 run DataLoad
                    (input  '':U (icRowids), 
                     input  vcPrimLst (icPkeys), 
                     input  '':U (icObjectIds), 
                     input  '':U (icFreeform), 
                     input  true (ilKeepPrevious), 
                     output viFcReturnSuper (oiReturnStatus)) in BMfgSystemAccountControl>
                                
                assign viLocalReturnStatus = viFcReturnSuper 
                       when (viFcReturnSuper > 0 and viLocalReturnStatus > 0)
                       or (viFcReturnSuper < 0 and viLocalReturnStatus > viFcReturnSuper).    
                                
                assign vcPrimLst = '':U.   
           end. /* length */              
        end. /* for each tqSystemAccountControlForAll */
    end. /* for each tCopyCurr */
        
    <M-70 run DataLoad
       (input  '' (icRowids), 
        input  vcPrimLst (icPkeys), 
        input  '' (icObjectIds), 
        input  '' (icFreeform), 
        input  true (ilKeepPrevious), 
        output viFcReturnSuper (oiReturnStatus)) in BMfgSystemAccountControl>
    
    assign viLocalReturnStatus = viFcReturnSuper 
           when (viFcReturnSuper > 0 and viLocalReturnStatus > 0)
           or (viFcReturnSuper < 0 and viLocalReturnStatus > viFcReturnSuper).
       
    GLCTRLBLOCK:
    for each tgl_ctrl break by tgl_ctrl.gl_base_curr:
        
        if first-of(tgl_ctrl.gl_base_curr) 
        then do:
            <Q-61 run CurrencyByCurrRoundingMethod (all) (Read) (NoCache)
               (input ?, (CurrencyID)
                input tgl_ctrl.gl_base_curr, (CurrencyCode)
                input ?, (RoundingMethodCode)
                output dataset tqCurrencyByCurrRoundingMethod) in BCurrency >
                
            find first tCopyCurr where tCopyCurr.CurrencyCode = tgl_ctrl.gl_base_curr no-error.
    
            find first tqCurrencyByCurrRoundingMethod no-error.
    
            if not available tqCurrencyByCurrRoundingMethod 
            then do:
        
                assign vcMessageText  = trim(#T-30'The currency with the key $1 does not exist.':100(48939)T-30#)
                       viLocalReturnStatus = -3 when viLocalReturnStatus > -3
                       oiReturnStatus = viLocalReturnStatus.
            
                <M-44 run SetMessage
                   (input  vcMessageText (icMessage), 
                    input  tCopyCurr.CurrencyCode (icArguments), 
                    input  '' (icFieldName), 
                    input  '' (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '' (icRowid), 
                    input  'qadfin-726356':U (icFcMsgNumber), 
                    input  '' (icFcExplanation), 
                    input  '' (icFcIdentification), 
                    input  '' (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BMfgSystemAccountControl>
                    
                assign viLocalReturnStatus = viFcReturnSuper 
                       when (viFcReturnSuper > 0 and viLocalReturnStatus > 0)
                       or (viFcReturnSuper < 0 and viLocalReturnStatus > viFcReturnSuper).

                next GLCTRLBLOCK.
            end. /* if not available */
        end. /* if first-of(gl_base_curr) */
        
        if not available tCopyCurr then
           next GLCTRLBLOCK.
        else
        do: 
            if tgl_ctrl.gl_rnd_mthd <> tCopyCurr.tcRoundingMethodCode then
                assign tgl_ctrl.gl_rnd_mthd = tCopyCurr.tcRoundingMethodCode
                       tgl_ctrl.tc_Status = 'C':U when tgl_ctrl.tc_Status <> 'N':U.
        end.
                    
    end. /* for each tgl_ctrl */
           
           
    VALIDATEBLOCK:
    do:
        if viLocalReturnStatus < 0
        then leave VALIDATEBLOCK.
    
        /* ========== */
        /* ValidateBC */
        /* ========== */
        <M-42 run ValidateBC  (output viFcReturnSuper (oiReturnStatus)) in BMfgSystemAccountControl>
        if viFcReturnSuper <> 0
        then assign viLocalReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0
        then leave VALIDATEBLOCK.
    
        /* ================== */
        /* Additional Updates */
        /* ================== */
        <M-95 run AdditionalUpdates  (output viFcReturnSuper (oiReturnStatus)) in BMfgSystemAccountControl>
        if viFcReturnSuper <> 0
        then assign viLocalReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0
        then leave VALIDATEBLOCK.
        
        /* ======== */
        /* DataSave */
        /* ======== */
        <M-15 run DataSave  (output viFcReturnSuper (oiReturnStatus)) in BMfgSystemAccountControl>
        if viFcReturnSuper <> 0
        then assign viLocalReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0
        then leave VALIDATEBLOCK.
    end. /* VALIDATEBLOCK */
end. /* of MAIN_BLOCK */   

/* ================== */                        
/* Exception Handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.