project QadFinancials > class BBankPayFormat > 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/bbankpayformat.p)

<ANCESTOR-CODE>

for each t_sBankPayFormat:
    /* backwards compatibility : fill new mandatory field when not filled yet */
    if t_sBankPayFormat.BankPayFormatIsBankCharge = ? then
    assign t_sBankPayFormat.BankPayFormatIsBankCharge = false.
 
    if t_sBankPayFormat.tc_status = "D":U
    then do:
        assign vlBankPayFormatIsReferenced = <M-1 GetBankPayFormatIsReferenced
                                                (input  t_sBankPayFormat.BankPayFormat_ID (iiBankPayFormatId), 
                                                 output viFcReturnSuper (oiReturnStatus)) in BBankPayFormat>.
    
        if vlBankPayFormatIsReferenced
        then do:    
            assign vcMessage = trim(substitute(#T-2'The bank payment format for payment type &1 is referenced.':150(56462)t-2#, t_sBankPayFormat.PayFormatTypeCode))
                   oiReturnStatus = -1.
    
            <M-3 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'QadFin-5700':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BBankPayFormat>
        end. /* end of if vlBankPayFormatIsReferenced */
    end. /* end of if if t_sBankPayFormat.tc_status = "D":U */
    /* status = N or C, validate if there is duplicate Bank File Format*/
    else do:
        /* currently we have manually to do this to set ID to null when code was blank */
        if t_sBankPayFormat.tcBankFileFormatCode = '':U or
           t_sBankPayFormat.tcBankFileFormatCode = ? 
        then assign t_sBankPayFormat.BankFileFormat_ID = ?.        
        else do:
            find first bBankPayFormat where bBankPayFormat.tcBankFileFormatCode = t_sBankPayFormat.tcBankFileFormatCode and
                                            bBankPayFormat.BankPayFormat_ID    <> t_sBankPayFormat.BankPayFormat_ID                         and
                                            bBankPayFormat.PayFormatTypeCode    = t_sBankPayFormat.PayFormatTypeCode                      and
                                            bBankPayFormat.tcPayFormatTypeModule = t_sBankPayFormat.tcPayFormatTypeModule
                                            no-error.
            if available bBankPayFormat and bBankPayFormat.tc_Status <> "D":U
            then do:
                assign vcMessage = trim(substitute(#T-5'The bank number and Bank File Format &1 combination already exists for the same payment format.':150(68405)t-5#, t_sBankPayFormat.tcBankFileFormatCode))
                       oiReturnStatus = -1.
                <M-4 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '':U (icRowid), 
                    input  'QadFin-7586':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BBankPayFormat>
                /* return to avaoid two duplicate error message */
                return.
            end. /* end of if available */
        end. /* end of else do. if code is blank */
    end. /* end of else do */
end.