project QadFinancials > class BFRWReportMaster > method ValidateComponentPre

Description

Validation to take place prior to validating the component


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BFRWReportMaster.ValidateComponent


program code (program1/bfrwreportmaster.p)

/* ================================================================= */
/* get each role and save to FRWRepMstrRole table                    */
/* ================================================================= */

for each t_sFRWRepMstr where
         t_sFRWRepMstr.tc_Status <> "D":U:

    /* remove any roles from the database which are not part of the role list */
    
    for each t_sFRWRepMstrRole where
             t_sFRWRepMstrRole.tc_ParentRowid = t_sFRWRepMstr.tc_Rowid:

        if index(t_sFRWRepMstr.tcFRWRepMstrRoles, t_sFRWRepMstrRole.tcRoleName) = 0
        then do:
            if t_sFRWRepMstrRole.tc_Status = "D":U
            then delete t_sFRWRepMstrRole.
            else assign t_sFRWRepMstrRole.tc_Status = "D":U.
        end.    
    end.
    
    for each tFRWRepMstrRole where
             tFRWRepMstrRole.tc_ParentRowid = tFRWRepMstr.tc_Rowid:

        if index(tFRWRepMstr.tcFRWRepMstrRoles, tFRWRepMstrRole.tcRoleName) = 0
        then do:
            if tFRWRepMstrRole.tc_Status = "D":U
            then delete tFRWRepMstrRole.
            else assign tFRWRepMstrRole.tc_Status = "D":U.
        end.    
    end.

    /* add each of the roles in the list to the database if they are not already added */

    repeat viix = 1 to num-entries(t_sFRWRepMstr.tcFRWRepMstrRoles):  
        if not can-find(t_sFRWRepMstrRole where
                        t_sFRWRepMstrRole.tc_ParentRowid = t_sFRWRepMstr.tc_Rowid and 
                        t_sFRWRepMstrRole.tc_Status <> "D":U and
                        t_sFRWRepMstrRole.tcRoleName = entry(viix, t_sFRWRepMstr.tcFRWRepMstrRoles))
        then do:
        
            if entry(viix, t_sFRWRepMstr.tcFRWRepMstrRoles) <> '':U
            then do:
        
                /* check if the record was not already created during the last save */
                find tFRWRepMstrRole where
                     tFRWRepMstrRole.tc_ParentRowid = t_sFRWRepMstr.tc_Rowid and 
                     tFRWRepMstrRole.tc_Status <> "D":U and
                     tFRWRepMstrRole.tcRoleName = entry(viix, t_sFRWRepMstr.tcFRWRepMstrRoles) no-error.
                         
                if not available tFRWRepMstrRole
                then do:
                
                    <M-90 run AddDetailLine
                       (input  'FRWRepMstrRole':U (icTable), 
                        input  t_sFRWRepMstr.tc_Rowid (icParentRowid), 
                        output viFcReturnSuper (oiReturnStatus)) in BFRWReportMaster>
                        
                    if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
                    if oiReturnStatus < 0 then return.
                    
                end. /* if not available tFRWRepMstrRole */
                           
                create t_sFRWRepMstrRole.
                buffer-copy tFRWRepMstrRole to t_sFRWRepMstrRole.
                assign t_sFRWRepMstrRole.tcRoleName = entry(viix, t_sFRWRepMstr.tcFRWRepMstrRoles)
                       tFRWRepMstrRole.tcRoleName = entry(viix, t_sFRWRepMstr.tcFRWRepMstrRoles).
                       
            end. /* if entry(viix, t_sFRWRepMstr.tcFRWRepMstrRoles) <> '':U */
                           
        end.
        
    end. /* repeat viix = 1 to num-entries(t_sFRWRepMstr.tcFRWRepMstrRoles): */
    
end. /* for each t_sFRWRepMstr where */