open-insight/LSL2/STPROC/OBJ_REACTOR_PM.txt
Infineon\StieberD 7762b129af pre cutover push
2024-09-04 20:33:41 -07:00

219 lines
4.8 KiB
Plaintext

COMPILE FUNCTION obj_Reactor_PM(Method,Parms)
/*
Methods for REACTOR_PM table
05/29/2013 JCH - Initial Coding
Properties:
Methods:
Find() ;* Lookup Reactor Event key
*/
DECLARE FUNCTION Get_Status, Msg, Utility, obj_Tables, Dialog_Box
DECLARE SUBROUTINE Set_Status, Msg, obj_Tables, Send_Dyn, Btree.Extract, ErrMsg
DECLARE SUBROUTINE obj_Notes, Send_Info
$INSERT MSG_EQUATES
$INSERT REACTOR_EQUATES
$INSERT REACTOR_PM_EQUATES
$INSERT REACT_SERVS_EQU
EQU COL$REACT_PM_ID TO 1
EQU COL$REACT_PM_DUE_DT TO 2
EQU COL$REACT_PM_SERV_ID TO 3
EQU COL$REACT_PM_SERV_DESC TO 4
EQU COL$REACT_PM_SERV_COMP_DT TO 5
ErrTitle = 'Error in Stored Procedure "obj_Reactor_PM"'
ErrorMsg = ''
IF NOT(ASSIGNED(Method)) THEN ErrorMsg = 'Unassigned parameter "Method" passed to subroutine'
IF NOT(ASSIGNED(Parms)) THEN Parms = ''
IF ErrorMsg NE '' THEN
Set_Status(-1,ErrTitle:@SVM:ErrorMsg)
RETURN ''
END
Result = ''
BEGIN CASE
CASE Method = 'Find' ; GOSUB Find
CASE Method = 'Create' ; GOSUB Create
CASE Method = 'ReactServHist' ; GOSUB ReactServHist
CASE Method = 'ReactorHist' ; GOSUB ReactorHist
CASE Method = 'SetStopDTM' ; GOSUB SetStopDTM
CASE 1
ErrorMsg = 'Unknown Method ':QUOTE(Method):' passed to routine.'
END CASE
IF ErrorMsg NE '' THEN
Set_Status(-1,ErrTitle:@SVM:ErrorMsg)
RETURN ''
END
RETURN Result
* * * * * * *
Find:
* * * * * * *
ReactEventKeys = Dialog_Box( 'DIALOG_REACT_EVENT_QUERY', @WINDOW, '' )
Result = ReactEventKeys
RETURN
* * * * * * *
Create:
* * * * * * *
RETURN
* * * * * * *
ReactServHist:
* * * * * * *
ReactNo = Parms[1,@RM]
ReactServID = Parms[COL2()+1,@RM]
OpenFlag = Parms[COL2()+1,@RM]
IF ReactNo = '' THEN ErrorMsg = 'Null parameter "ReactNo" passed to routine. (':Method:')'
*IF ReactServID = '' THEN ErrorMsg = 'Null parameter "ReactServID" passed to routine. (':Method:')'
IF ErrorMsg NE '' THEN RETURN
OPEN 'DICT.REACTOR_PM' TO DictVAR ELSE
ErrMsg('Unable to open "DICT.REACTOR_PM" for index lookup in obj_Reactor_PM routine.')
RETURN
END
SearchString = 'REACTOR':@VM:ReactNo:@FM
IF ReactServID NE '' THEN
SearchString := 'REACT_SERV_ID':@VM:ReactServID:@FM
END
IF OpenFlag THEN
SearchString := 'COMPLETE_DATE':@VM:'':@FM
END ELSE
SearchString := 'DUE_DT':@VM:'>=':OConv(Date() - 1095, 'D4/'):@FM
END
ReactPMIDs = ''
Flag = ''
Btree.Extract(SearchString, 'REACTOR_PM', DictVar, ReactPMIDs, '', Flag)
IF Get_Status(errCode) THEN
RETURN
END
IF ReactPMIDs NE '' THEN
OPEN 'REACTOR_PM' TO ReactPMTable THEN
IDCnt = COUNT(ReactPMIDs,@VM) + (ReactPMIDs NE '')
DueDts = ''
FOR I = 1 TO IDCnt
ReactPMID = ReactPMIDs<1,I>
READ ReactPMRec FROM ReactPMTable,ReactPMID THEN
DueDt = ReactPMRec<REACTOR_PM_DUE_DT$>
ReactPMServID = ReactPMRec<REACTOR_PM_REACT_SERV_ID$>
LOCATE DueDt IN DueDts BY 'DR' USING @FM SETTING Pos ELSE
Null
END
DueDts = INSERT(DueDts,Pos,0,0,DueDt)
ResultLine = ''
ResultLine<1,COL$REACT_PM_ID> = ReactPMID
ResultLine<1,COL$REACT_PM_DUE_DT> = OCONV(ReactPMRec<REACTOR_PM_DUE_DT$>,'D4/')
ResultLine<1,COL$REACT_PM_SERV_ID> = ReactPMServID
ResultLine<1,COL$REACT_PM_SERV_DESC> = XLATE('REACT_SERVS',ReactPMServID,REACT_SERVS_DESCRIPTION$,'X')
ResultLine<1,COL$REACT_PM_SERV_COMP_DT> = OCONV(ReactPMRec<REACTOR_PM_COMPLETE_DATE$>,'D4/')
Result = INSERT(Result,Pos,0,0,ResultLine)
END ;* End of PMRec read
NEXT I
END ;* End of REACTOR_PM table open
END
RETURN
* * * * * * *
ReactorHist:
* * * * * * *
RETURN
* * * * * * *
SetStopDTM:
* * * * * * *
ReactNo = Parms[1,@RM]
EventDTM = Parms[COL2()+1,@RM]
StopDTM = Parms[COL2()+1,@RM]
DEBUG
IF ReactNo = '' THEN ErrorMsg = 'Null parameter "ReactNo" passed to routine. (':Method:')'
IF EventDTM = '' THEN ErrorMsg = 'Null parameter "EventDTM" passed to routine. (':Method:')'
IF StopDTM = '' THEN ErrorMsg = 'Null parameter "StopDTM" passed to routine. (':Method:')'
thisEventDTM = ICONV(EventDTM,'DT')
IF thisEventDTM = '' THEN
ErrorMsg = 'Ivalid Data ':QUOTE(EventDTM):' passed in "EventDTM" parameter. (':Method:')'
END
thisStopDTM = ICONV(StopDTM,'DT')
IF thisStopDTM = '' THEN
ErrorMsg = 'Ivalid Data ':QUOTE(StopDTM):' passed in "StopDTM" parameter. (':Method:')'
END
IF ErrorMsg NE '' THEN RETURN
RETURN
ReactEventKey = ReactNo:'*':thisEventDTM
OtParms = 'REACT_EVENT':@RM:ReactEventKey
ReactEventRec = obj_Tables('ReadRec',OtParms) ;* Locks and reads record for update
IF Get_Status(errCode) THEN DEBUG
ReactEventRec<REACT_EVENT_STOP_DTM$> = thisStopDTM
*OtParms = FieldStore(OtParms,@RM,4,0,ReactEventRec) ;* Put record in 4th field of OtParms
*obj_Tables('WriteRec',OtParms)
RETURN