icDomainCode | input | character | Optional parameter holding the domain wherefor this check is needed. If this parameter is empty, then we will check if the current domain is enabled for Periodic-costing or not. |
olPeriodicCostingModuleIsActive | output | logical | Indicates if the periodic-costing module has been enabled for the domain mentioned in the input or not |
oiReturnStatus | output | integer | Return status of the method. |
/* =============================== */ /* Exception handling - main block */ /* Default output */ /* =============================== */ assign oiReturnStatus = -98 olPeriodicCostingModuleIsActive = ? viLocalReturnStatus = 0. MAINPCBLOCK: DO : /* ====================================================================== */ /* In case the domain is not specified in the input; take the current one */ /* ====================================================================== */ if icDomainCode = "":U or icDomainCode = ? then assign icDomainCode = vcDomainCode. /* ==================================================================================== */ /* First check the MfgPro version: */ /* If the MfgPro version is eB3.SP5 or lower then Periodidc-costing is not active as */ /* it is even not implemented in these older versions. */ /* If the MfgPro version if higher than eB3.SP5 then we need to check the control-file */ /* (pcsc_ctrl) to find out if periodic-costing has been activated for the domain or not */ /* We can't just check the control-file straight away without taking the MfgPro-version */ /* into account as accessing table pcsc_ctrl via the associated BMfgxxxx-class when the */ /* table is not in the db would result in progress-errors */ /* ==================================================================================== */ <M-35 run StartCacher (output vhFcComponent (ohCacher), output viExternalReturnStatus (oiReturnStatus)) in BPeriod> if viExternalReturnStatus <> 0 then assign viLocalReturnStatus = viExternalReturnStatus. if viExternalReturnStatus < 0 then do : assign olPeriodicCostingModuleIsActive = false. Leave MAINPCBLOCK. end. /* if viExternalReturnStatus < 0 */ <M-68 run GetIntegerValueFromSession (input viSessionID (iiSessionId), input 'MfgProMajorVersion' (icDataItemName), output viMfgProMajorVersion (oiValue), output viExternalReturnStatus (oiReturnStatus)) in Cacher> if viExternalReturnStatus <> 0 then assign viLocalReturnStatus = viExternalReturnStatus. if viExternalReturnStatus < 0 then do : assign olPeriodicCostingModuleIsActive = false. Leave MAINPCBLOCK. end. /* if viExternalReturnStatus < 0 */ <M-46 run GetIntegerValueFromSession (input viSessionID (iiSessionId), input 'MfgProMinorVersion' (icDataItemName), output viMfgProMinorVersion (oiValue), output viExternalReturnStatus (oiReturnStatus)) in Cacher> if viExternalReturnStatus <> 0 then assign viLocalReturnStatus = viExternalReturnStatus. if viExternalReturnStatus < 0 then do : assign olPeriodicCostingModuleIsActive = false. Leave MAINPCBLOCK. end. /* if viExternalReturnStatus < 0 */ if viMfgProMajorVersion > 3 /* Meaning eB3 */ or (viMfgProMajorVersion = 3 /* Meaning eB3 */and viMfgProMinorVersion >= 6 /* Meaning SP6 */) then do : <Q-1 run PeriodicCostingControlByDomain (all) (Read) (NoCache) (input icDomainCode, (DomainCode) output dataset tqPeriodicCostingControlByDomain) in BMfgPeriodicCostingCtrl > Find first tqPeriodicCostingControlByDomain where tqPeriodicCostingControlByDomain.tcpcsc_domain = icDomainCode no-lock no-error. if available tqPeriodicCostingControlByDomain and tqPeriodicCostingControlByDomain.tlpcsc_enable = true then assign olPeriodicCostingModuleIsActive = true. else assign olPeriodicCostingModuleIsActive = false. end. /* if true /* needs to be replaced by a proper check on the MfgPro version */ */ else assign olPeriodicCostingModuleIsActive = false. /* =============================== */ /* Exception handling - main block */ /* =============================== */ END. /* MAINPCBLOCK */ assign oiReturnStatus = viLocalReturnStatus.