project QadFinancials > class BAltCOAStruct > 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/baltcoastruct.p)

assign oiReturnStatus      = -98
       viLocalReturnStatus = 0.

/* ================================================================ */
/* Do the validations that need to be done before the ancestor code */
/* ================================================================ */
<M-4 run ValidateComponentPre  (output viFcReturnSuper (oiReturnStatus)) in BAltCOAStruct>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.

<ANCESTOR-CODE>

if oiReturnStatus <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = oiReturnStatus.
assign oiReturnStatus = -98.

/* ============= */
/* Start Queries */
/* ============= */
<Q-7 run COACrossRefDetByDomainID  (Start) in BCOACrossRef >

/* ============================================================================================================================= */
/* When modifying a COA Structure, if the user inserts a new COA Account and its parent account has used in COA cross reference, */
/* an error should be reported: Cannot insert child account for an account that is used in COA cross reference                   */
/* ============================================================================================================================= */
for each t_sAltCOAStruct:
    <Q-3 run COACrossRefDetByDomainID (all) (Read) (NoCache)
       (input viDomainID, (DomainID)
        input t_sAltCOAStruct.AltCOAStruct_ID, (AltCOAStructID)
        input ?, (COACrossRefID)
        input ?, (AltCOAStructDetCode)
        input ?, (AltCOAStructDetSeq)
        input ?, (COACrossRefCode)
        output dataset tqCOACrossRefDetByDomainID) in BCOACrossRef >
    for each t_sAltCOAStructDet where t_sAltCOAStructDet.tc_Status <> "D":U:
        /*if can-find(first tqCOACrossRefDetByDomainID where tqCOACrossRefDetByDomainID.tiTargetAlternateCOA_ID = t_sAltCOAStructDet.ParentAltCOAStructDet_ID)
        then do:*/
        find first tqCOACrossRefDetByDomainID where tqCOACrossRefDetByDomainID.tiTargetAlternateCOA_ID = t_sAltCOAStructDet.ParentAltCOAStructDet_ID no-error.
        if available tqCOACrossRefDetByDomainID
        then do:
            <M-10 run SetMessage
               (input  trim(#T-11'Cannot insert child account $1 for account $2 that is used in COA cross reference.':255(999890114)T-11#) (icMessage), 
                input  t_sAltCOAStructDet.AltCOAStructDetCode + chr(2) + tqCOACrossRefDetByDomainID.tcAltCOAStructDetCode (icArguments), 
                input  'tAltCOAStructDet.AltCOAStructDetCode':U (icFieldName), 
                input  t_sAltCOAStructDet.AltCOAStructDetCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sAltCOAStructDet.AltCOAStructDet_ID (icRowid), 
                input  'QadFin-8868':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BAltCOAStruct>
        end.
        /*end.*/
    end.
end.
/* ============ */
/* Stop Queries */
/* ============ */
<Q-6 run COACrossRefDetByDomainID  (Stop) in BCOACrossRef >

if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.

assign oiReturnStatus = viLocalReturnStatus.

if oiReturnStatus = -98
then assign oiReturnStatus = 0.