project BLF > class BSetting > 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/bsetting.p)

<ANCESTOR-CODE>

/*define buffer manually because using method data item will define it like t_ofcSetting*/
define buffer bfcSetting for t_sfcSetting.

/*I also need a buffer on tqSelectConfig and I'm not able to define it in method data item*/
define buffer bSelectConfig for tqSelectConfig.

/*read all settingconfigs because in the standard flow 1 setting per config is loaded*/
<Q-1 run SelectConfig (all) (Read) (NoCache)  (output dataset tqSelectConfig) in BSettingConfiguration >

for each t_sfcSetting where 
         t_sfcSetting.tc_Status = 'N':U or
         t_sfcSetting.tc_Status = 'C':U,
    first tqSelectConfig where
          tqSelectConfig.tiSettingConfig_ID = t_sfcSetting.SettingConfig_ID:

    /* Check dependency of settings: "User Interface Customization" and 
     * "Automatic save of grid settings" / "Allow save of grid settings"*/
    if tqSelectConfig.tcSettingConfigName = {&SETTINGCONFIG-UICUSTOM} and
       t_sfcSetting.SettingIsActive       = false
    then do:
        for each bSelectConfig where 
                 (bSelectConfig.tcSettingConfigName  = {&SETTINGCONFIG-ALLOWSAVEGRID} or
                  bSelectConfig.tcSettingConfigName  = {&SETTINGCONFIG-AUTOSAVEGRID}    ) and
                 bSelectConfig.tcSettingConfigLevel = tqSelectConfig.tcSettingConfigLevel :        
            find first bfcSetting where
                       bfcSetting.SettingConfig_ID = bSelectConfig.tiSettingConfig_ID and
                       bfcSetting.SettingScope     = t_sfcSetting.SettingScope        and
                       bfcSetting.SettingIsActive  = true no-error.
            if available bfcSetting 
            then do:
                assign vcMessage = trim(#T-3'If the setting '$1' is disabled, it is not allowed to enable settings '$2' or '$3'.':255(9098)T-3#)
                       oiReturnStatus = -1.
                <M-2 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  trim({&SETTINGCONFIG-UICUSTOM-TR}) + chr(2) + trim({&SETTINGCONFIG-ALLOWSAVEGRID-TR}) + chr(2) + trim({&SETTINGCONFIG-AUTOSAVEGRID-TR}) (icArguments), 
                    input  '' (icFieldName), 
                    input  '' (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '' (icRowid), 
                    input  'BLF-207':U (icFcMsgNumber), 
                    input  '' (icFcExplanation), 
                    input  '' (icFcIdentification), 
                    input  '' (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BSetting>
            end. /*if available bSelectConfig */            
        end. /*for each bSelectConfig where */
    end. /*if tqSelectConfig.tcSettingConfigName = {&SETTINGCONFIG-UICUSTOM} and*/

end. /*for each t_sfcSetting where*/