project QadFinancials > class BMfgEndUser > 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/bmfgenduser.p)

/* commented out as additional updates needs access to previously opend business relation instance 
<M-2 run StopExternalInstances
   (output viFcReturnSuper (oiReturnStatus)) in BMfgEndUser>*/


if can-find (first t_seu_mstr where t_seu_mstr.tc_Status = 'D')
then do :
    <ANCESTOR-CODE>
end.
else do :
    for each t_seu_mstr where
             t_seu_mstr.tc_Status = "N":U or
             t_seu_mstr.tc_Status = "C":U:
    
        /* Check, if the record is unique */
        if t_seu_mstr.tc_Status = "N":U
        then do:
            <Q-14 assign vlFcQueryRecordsAvailable = EuMstrByAddrDomain (NoCache)
               (input t_seu_mstr.eu_domain, (Domain)
                input t_seu_mstr.eu_addr, (Addr)) in BMfgEndUser >
            if vlFcQueryRecordsAvailable <> false
            then do:
                assign vcMessage =  #T-37'End user with code &1 in the Domain &2 already exists.':255(238626389)T-37#
                       vcMessage = substitute(vcMessage, t_seu_mstr.eu_addr, t_seu_mstr.eu_domain).
                <M-25 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'eu_mstr.eu_addr':U (icFieldName), 
                    input  t_seu_mstr.eu_addr (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_seu_mstr.tc_Rowid (icRowid), 
                    input  'QadFin-292711':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BMfgEndUser>
                assign oiReturnStatus = -1.
            end.
        end.
    
        for each t_seud_det where
                 t_seud_det.tc_ParentRowid = t_seu_mstr.tc_Rowid and
                 (t_seud_det.tc_Status       = "N":U  or
                  t_seud_det.tc_Status      = "C":U):
            if t_seud_det.tc_Status = "N":U
            then do:
                <Q-32 assign vlFcQueryRecordsAvailable = EudDetByDomAddrSort (NoCache)
                   (input t_seud_det.eud_domain, (Domain)
                    input t_seud_det.eud_addr, (Address)
                    input t_seud_det.eud_sort, (Sort)) in BMfgEndUser >
                if vlFcQueryRecordsAvailable <> false
                then do:
                    assign vcMessage =  #T-9'End user detail with code &1 and sort &2 in the Domain &3 already exists.':255(770078534)T-9#
                           vcMessage = substitute(vcMessage,t_seud_det.eud_addr,t_seud_det.eud_sort, t_seud_det.eud_domain).
                    <M-78 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '':U (icArguments), 
                        input  'eu_mstr.eu_addr':U (icFieldName), 
                        input  t_seu_mstr.eu_addr (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  t_seu_mstr.tc_Rowid (icRowid), 
                        input  'QadFin-644196':U (icFcMsgNumber), 
                        input  '':U (icFcExplanation), 
                        input  '':U (icFcIdentification), 
                        input  '':U (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BMfgEndUser>
                    assign oiReturnStatus = -1.
                end.
            end.
        end. /* for each t_seud_det where */
                
    end. /* for each t_seu_mstr where */
end.