project QadFinancials > class BRole > method ValidateComponent

Description

Write here all tests on database update (new / modify / delete) that cannot be coded with a validation mask.
The type of update can be found in tc_status (N/C/D).
If you find incorrect data, you must write an entry in tFcMessages (using SetMessage) and set the return status of this method to either +1 or -1.
Return status +1 = data will still be accepted.
Return status -1 = data will not be accepted.
This method is run from SetPublicTables, before transferring the received data into the class temp-tables.


Parameters


oiReturnStatusoutputinteger


Internal usage


unused


program code (program/brole.p)

<ANCESTOR-CODE>

assign viLocalReturnStatus = 0.

/* You cannot delete a role if a journal exists which is associated with it */
<Q-93 run JournalByRoleID  (Start) in BJournal >

for each t_sRole 
    where t_sRole.tc_Status = 'D':U:
    
    <Q-1 run JournalByRoleID (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input t_sRole.Role_ID, (RoleID)
        output dataset tqJournalByRoleID) in BJournal >        
    
    for each tqJournalByRoleID 
        where tqJournalByRoleID.tiRole_ID = t_sRole.Role_ID:
        <M-13 run SetMessage
           (input  trim(#T-25'You cannot delete this role because the daybook $1 is associated with it':255(932597887)T-25#) (icMessage), 
            input  tqJournalByRoleID.tcJournalCode (icArguments), 
            input  't_sRole.RoleName':U (icFieldName), 
            input  t_sRole.RoleName (icFieldValue), 
            input  'E':U (icType), 
            input  1 (iiSeverity), 
            input  t_sRole.tc_Rowid (icRowid), 
            input  'QadFin-814787':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BRole>
        assign viLocalReturnStatus = -1.
    end.
end.
<Q-27 run JournalByRoleID  (Stop) in BJournal >

/* Return */
if viLocalReturnStatus <> 0
then assign oiReturnStatus = viLocalReturnStatus.