Changed from using obj_tables to Database_Services

This commit is contained in:
Infineon\Ouellette 2024-12-02 11:33:16 -07:00
parent cb5df15264
commit 56d992b961

View File

@ -15,12 +15,12 @@ COMPILE FUNCTION obj_WO_Mat_QA(Method,Parms)
#pragma precomp SRP_PreCompiler
DECLARE SUBROUTINE Set_Status, Msg, obj_Tables, ErrMsg, Btree.Extract
DECLARE SUBROUTINE Set_Status, Msg, obj_Tables, ErrMsg, Btree.Extract, Database_Services, Logging_Services
DECLARE FUNCTION Get_Status, Msg, Utility, obj_Tables, Dialog_Box, obj_WO_Log, NextKey, obj_WO_Mat_QA
DECLARE FUNCTION obj_Prod_Spec, obj_RDS_Test, SRP_Math
DECLARE FUNCTION Get_Status, Msg, Utility, obj_Tables, Dialog_Box, obj_WO_Log, NextKey, obj_WO_Mat_QA, Environment_Services
DECLARE FUNCTION obj_Prod_Spec, obj_RDS_Test, SRP_Math, Database_Services, Error_Services, Logging_Services
$INSERT LOGICAL
$Insert APP_INSERTS
$INSERT MSG_EQUATES
$INSERT WO_LOG_EQUATES
$INSERT WO_MAT_EQUATES
@ -31,8 +31,14 @@ $INSERT PRS_STAGE_EQUATES
$INSERT PROD_VER_EQUATES
$INSERT QA_MET_EQUATES ;* Used in GetQAMet data structure return variable
LogPath = Environment_Services('GetApplicationRootPath') : '\WO_MAT_QA'; //Define the directory where the log will be saved to. This happens the first time of the day that the log is written to.
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
EQU CRLF$ TO \0D0A\
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' WO_MAT_QA_Writes.csv'; //Define the file name that will get created.
Headers = 'Logging DTM' : @FM : 'WOMatKey' : @FM : 'Message'; //Define the column names in the log file, delimited by a Field Mark.
objLogWOMatQAWrite = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', Headers, '', False$, False$); //Actually creates the log.
ErrTitle = 'Error in Stored Procedure "obj_WO_Mat_QA"'
ErrorMsg = ''
@ -233,8 +239,9 @@ EpiProPSRec = ''
MetLine = 1
WOMatKey = WONo:'*':CassNo
WOMatQARec = ''
WOMatRec = XLATE('WO_MAT',WONo:'*':CassNo,'','X') ;* WOMat record used to check for pre-existing signatures jch 6/7/2015
WOMatRec = XLATE('WO_MAT',WOMatKey,'','X') ;* WOMat record used to check for pre-existing signatures jch 6/7/2015
FOR WOStepNo = 1 TO StepCnt
@ -322,12 +329,15 @@ FOR WOStepNo = 1 TO StepCnt
NEXT StageNo
NEXT WOStepNo
wommParms = 'WO_MAT_QA':@RM:WONo:'*':CassNo:@RM:@RM:WOMatQARec ;* Both table use the WO_Mat_Key
obj_Tables('WriteRec',wommParms)
Database_Services('WriteDataRow', 'WO_MAT_QA', WOMatKey, WOMatQARec, True$, False$, False$)
If Error_Services('HasError') then
ErrorMessage = Error_Services('GetMessage')
LogData = ''
LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = WOMatKey
LogData<3> = ErrorMessage
Logging_Services('AppendLog', objLogWOMatQAWrite, LogData, @RM, @FM, False$)
end
* * * * * * * * * * * *
@ -411,36 +421,32 @@ IF ErrorMsg NE '' THEN RETURN
NewMetKey = WOStep:'*':Stage:'*':MetProp
WOMatKey = WONo:'*':CassNo
otParms = 'WO_MAT_QA':@RM:WOMatKey
WOMatQARec = obj_Tables('ReadRec',otParms)
WOMatRec = XLATE('WO_MAT',WOMatKey,'','X')
HaveLock = Database_Services('GetKeyIDLock', 'WO_MAT_QA', WOMatKey, True$)
If HaveLock then
WOMatQARec = Database_Services('ReadDataRow', 'WO_MAT_QA', WOMatKey, True$, 0, False$)
WOMatRec = XLATE('WO_MAT',WOMatKey,'','X')
AllQAMetKeysStruct = obj_WO_Mat_QA('GetQAMetKeys',WOMatKey:@RM:WOMatQARec) ;* All QAMetSort Keys Specified for this Work Order Returns Keys in <1> and Sequence numbers = <2>
AllQAMetKeysStruct = obj_WO_Mat_QA('GetQAMetKeys',WOMatKey:@RM:WOMatQARec) ;* All QAMetSort Keys Specified for this Work Order Returns Keys in <1> and Sequence numbers = <2>
AllMetKeys = AllQAMetKeysStruct<1> ;* Correctly sorted list of all possible QA Met keys built from the PRS_SPEC records for all WO Steps
AllLines = AllQAMetKeysStruct<2> ;* List of position numbers for each of the met keys
AllMetKeys = AllQAMetKeysStruct<1> ;* Correctly sorted list of all possible QA Met keys built from the PRS_SPEC records for all WO Steps
AllLines = AllQAMetKeysStruct<2> ;* List of position numbers for each of the met keys
CurrMetKeys = ''
CurrLines = ''
cmqCnt = COUNT(WOMatQARec<WO_MAT_QA_PROFILE$>,@VM) + (WOMatQARec<WO_MAT_QA_PROFILE$> NE '')
CurrMetKeys = ''
CurrLines = ''
cmqCnt = COUNT(WOMatQARec<WO_MAT_QA_PROFILE$>,@VM) + (WOMatQARec<WO_MAT_QA_PROFILE$> NE '')
FOR M = 1 to cmqCnt
FOR M = 1 to cmqCnt
CurrMetKey = WOMatQARec<WO_MAT_QA_PROFILE$,M>[1,1]:'*':WOMatQARec<WO_MAT_QA_STAGE$,M>:'*':WOMatQARec<WO_MAT_QA_PROP$,M>
CurrMetKeys<1,M> = CurrMetKey
LOCATE CurrMetKey IN AllMetKeys USING @VM SETTING AllPos THEN
CurrLines<1,M> = AllPos ;* Builds a list of CurrLines for the Met Keys on the existing WO_MAT records
END
NEXT M
NEXT M
LOCATE NewMetKey IN AllMetKeys USING @VM SETTING SpecLine THEN
LOCATE NewMetKey IN AllMetKeys USING @VM SETTING SpecLine THEN
LOCATE SpecLine IN CurrLines BY 'AR' USING @VM SETTING InsertPos THEN
obj_Tables('UnlockRec',otParms)
END ELSE
LOCATE SpecLine IN CurrLines BY 'AR' USING @VM SETTING InsertPos ELSE
CurrLines = INSERT(CurrLines,1,InsertPos,0,SpecLine)
@ -478,20 +484,25 @@ LOCATE NewMetKey IN AllMetKeys USING @VM SETTING SpecLine THEN
WOMatQARec = INSERT(WOMatQARec, WO_MAT_QA_STD_MAX$, InsertPos, 0, '' )
WOMatQARec = INSERT(WOMatQARec, WO_MAT_QA_STD_RESULT$, InsertPos, 0, '' )
END
otParms = FIELDSTORE(otParms,@RM,4,0,WOMatQARec)
obj_Tables('WriteRec',otParms)
Database_Services('WriteDataRow', 'WO_MAT_QA', WOMatKey, WOMatQARec, True$, False$, False$)
If Error_Services('HasError') then
ErrorMessage = Error_Services('GetMessage')
LogData = ''
LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = WOMatKey
LogData<3> = ErrorMessage
Logging_Services('AppendLog', objLogWOMatQAWrite, LogData, @RM, @FM, False$)
end
END ;* End of SpecLine LOCATE
END ELSE
obj_Tables('UnlockRec',otParms)
END ;* End of NewMetKey LOCATE
END
end else
LogData = ''
LogData<1> = LoggingDTM;//Defined at entry of subroutine
LogData<2> = WOMatKey
LogData<3> = 'Error getting lock on WO_MAT_QA record.'
Logging_Services('AppendLog', objLogWOMatQAWrite, LogData, @RM, @FM, False$)
end
RETURN
@ -737,3 +748,4 @@ Next I
RETURN