project BLF > class BUDCConfiguration > 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/budcconfiguration.p)

<M-4 run StopExternalInstances  (output viFcReturnSuper (oiReturnStatus)) in BUDCConfiguration>

<ANCESTOR-CODE>

for each t_sUDCConfig where
         t_sUDCConfig.tc_Status = "N" or
         t_sUDCConfig.tc_Status = "C":
    if t_sUDCConfig.tc_Status = "C"
    then do:
        find t_iUDCConfig where
             t_iUDCConfig.tc_Rowid = t_sUDCConfig.tc_Rowid
             no-error.

        if not available t_iUDCConfig
        then do:
            assign oiReturnStatus = -98.
            return.
        end.

        if t_sUDCConfig.UDCConfigCode <> t_iUDCConfig.UDCConfigCode
        then do:
            <M-1 run SetMessage
               (input  trim(#T-1'It is not allowed to change the code of a user-defined component.':255(998716593)T-1#) (icMessage), 
                input  '' (icArguments), 
                input  'tUDCConfig.UDCConfigCode' (icFieldName), 
                input  t_sUDCConfig.UDCConfigCode (icFieldValue), 
                input  'E' (icType), 
                input  3 (iiSeverity), 
                input  t_sUDCConfig.tc_Rowid (icRowid), 
                input  'BLF-218':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BUDCConfiguration>

            assign oiReturnStatus= -1.
        end.
    end.

    if t_sUDCConfig.tc_Status                    = "N"                                             or
       t_sUDCConfig.tc_Status                    = "C"                                             and
      (t_sUDCConfig.UDCConfigHasCreate   <> t_iUDCConfig.UDCConfigHasCreate   or
       t_sUDCConfig.UDCConfigHasDelete   <> t_iUDCConfig.UDCConfigHasDelete   or
       t_sUDCConfig.UDCConfigHasMaintain <> t_iUDCConfig.UDCConfigHasMaintain or
       t_sUDCConfig.UDCConfigHasModify   <> t_iUDCConfig.UDCConfigHasModify   or
       t_sUDCConfig.UDCConfigHasView     <> t_iUDCConfig.UDCConfigHasView)
    then do:
        if t_sUDCConfig.UDCConfigHasCreate   <> true and
           t_sUDCConfig.UDCConfigHasDelete   <> true and
           t_sUDCConfig.UDCConfigHasMaintain <> true and
           t_sUDCConfig.UDCConfigHasModify   <> true and
           t_sUDCConfig.UDCConfigHasView     <> true
        then do:
            <M-2 run SetMessage
               (input  trim(#T-2'You have to select at least one activity for user-defined component $1.':255(998716591)T-2#) (icMessage), 
                input  t_sUDCConfig.UDCConfigCode (icArguments), 
                input  '' (icFieldName), 
                input  '' (icFieldValue), 
                input  'E' (icType), 
                input  3 (iiSeverity), 
                input  t_sUDCConfig.tc_Rowid (icRowid), 
                input  'BLF-219':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BUDCConfiguration>

            assign oiReturnStatus = -1.
        end.

        if t_sUDCConfig.UDCConfigHasMaintain = true and
          (t_sUDCConfig.UDCConfigHasCreate   = true or
           t_sUDCConfig.UDCConfigHasDelete   = true or
           t_sUDCConfig.UDCConfigHasModify   = true or
           t_sUDCConfig.UDCConfigHasView     = true)
        then do:
            <M-3 run SetMessage
               (input  trim(#T-3'The maintain activity should be the only selected activity for component $1. If you still want to use any of the other activities, please deselect the maintain activity.':255(998716592)T-3#) (icMessage), 
                input  t_sUDCConfig.UDCConfigCode (icArguments), 
                input  '' (icFieldName), 
                input  '' (icFieldValue), 
                input  'E' (icType), 
                input  3 (iiSeverity), 
                input  t_sUDCConfig.tc_Rowid (icRowid), 
                input  'BLF-221':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BUDCConfiguration>

            assign oiReturnStatus = -1.
        end.
    end.
end.