project QadFinancials > class BBankStateImport > 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/bbankstateimport.p)

/* =============================================================================== */
    /* Make sure all external instances are stopped: start from a clear situation      */
    /* =============================================================================== */
    <M-7 run StopExternalInstances  (output viFcReturnSuper (oiReturnStatus)) in BBankStateImport>
    
    /* =============================================================================== */
    /* Set the date and time: used as information the next time an import is performed */
    /* =============================================================================== */
    for each t_sBankStateImport where 
             t_sBankStateImport.tc_Status <> "D":U :
        assign t_sBankStateImport.BankStateImportDate = today
               t_sBankStateImport.BankStateImportTime = time.
    end.               
    
    
<ANCESTOR-CODE>
    
    
    /* ============================================================================== */
    /* This component only supports a single BankStateImport record for every company */
    /* This component only supports a single BankStateImport-record for every SAVE    */
    /* ============================================================================== */
    for each t_sBankStateImport where 
             t_sBankStateImport.tc_Status <> "D":U :
        assign viCounter = viCounter + 1.
        if viCounter > 1
        then leave.
    end. /* for each */
    if viCounter > 1
    then do :
        assign oiReturnStatus = -1
               vcMsg          = trim(#T-5'The Bank Statement Import component only supports single record handling. You can only pass information for one import at a time.':255(415)T-5#).
        <M-1 run SetMessage
           (input  vcMsg (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QADFIN-1701':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BBankStateImport>
        Return.        
    end. /* if viCounter > 1 */
    if viCounter = 1 
    then do :
        find first t_sBankStateImport where 
                   t_sBankStateImport.tc_Status <> "D":U 
                   no-lock no-error. /* error has been tested before */
        <Q-2 assign vlFcQueryRecordsAvailable = BankStateImportByIDCompany (NoCache)
           (input t_sBankStateImport.Company_ID, (CompanyId)
            input ?, (BankStateImportID)
            input t_sBankStateImport.tc_Rowid, (RowIDToSkip)) in BBankStateImport >
        if vlFcQueryRecordsAvailable <> false
        then do :
            assign oiReturnStatus = -1
                   vcMsg          = trim(substitute(#T-6'Multiple bank statement import records were detected for a single entity (&1).':255(416)t-6#,string(t_sBankStateImport.Company_ID))).

            <M-3 run SetMessage
               (input  vcMsg (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'QADFIN-1702':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BBankStateImport>
        Return.       
        end. /* if vlFcQueryRecordsAvailable <> false */
    end. /* if viCounter = 1 */