refactored quantity update services to not lock the work order record

This commit is contained in:
Infineon\StieberD 2025-04-01 10:24:10 -07:00 committed by Stieber Daniel (CSC FI SPS MESLEO)
parent c477b8df58
commit 72df0cbe37

View File

@ -51,7 +51,7 @@ $Insert WM_OUT_EQUATES
Declare subroutine Error_Services, Work_Order_Services, Memory_Services, RList, Database_Services, SRP_JSON
Declare subroutine Btree.Extract, Set_Status, obj_WO_Log, obj_Notes, Print_Wo_Mat_In_Labels, Print_Wo_Mat_Out_Labels
Declare subroutine Print_Wmi_Labels, Print_Wmo_Labels, ErrMsg, Print_Cass_Labels, Logging_Services, Service_Services
Declare subroutine obj_WO_Mat_Log, WO_MAT_SERVICES
Declare subroutine obj_WO_Mat_Log, WO_Mat_Services
Declare function SRP_Array, Work_Order_Services, Memory_Services, Database_Services, SRP_Sort_Array, SRP_JSON
Declare function Company_Services, obj_Prod_Spec, Schedule_Services, Datetime, obj_WO_Log, obj_WO_Step, Memberof
Declare function Environment_Services, Logging_Services, Hold_Services
@ -63,12 +63,12 @@ LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Re
Headers = 'Logging DTM' : @FM : 'User' : @FM : 'Notes'
objReleaseLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$)
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\WO_LOG'
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Void Log.csv'
Headers = 'Logging DTM' : @FM : 'User' : @FM : 'CassetteId' : @FM : 'Notes'
objVoidLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$)
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\WO_LOG'
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Void Log.csv'
Headers = 'Logging DTM' : @FM : 'User' : @FM : 'CassetteId' : @FM : 'Notes'
objVoidLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$)
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
@ -631,8 +631,6 @@ Service ReleaseCassettes(WONo)
CassCnt = DCount(CassList, @VM)
//(SAPCassIDs<0, I> = '')
UnReleasedCassNos = ''
For I = 1 to CassCnt
If ( (RelDTMs<0, I> = '') and (CassStatus<0, I> EQ '') ) then
@ -705,7 +703,7 @@ Service ReleaseCassettes(WONo)
end
end
Work_Order_Services('UpdateReleasedQty', WONo)
Service_Services('PostProcedure', 'WORK_ORDER_SERVICES', 'UpdateReleasedQty':@VM:WONo)
If ErrorMsg NE '' then Error_Services('Add', ErrorMsg)
Response = DCount(UnReleasedCassNos, @VM)
@ -831,20 +829,14 @@ Service UpdateWOStepStatus(WONo)
WOStepKey = WONo:'*':1
WOStepRec = Database_Services('ReadDataRow', 'WO_STEP', WOStepKey)
WOStepCurrStatus = obj_WO_Step('CurrStatus', WOStepKey:@RM:WOStepRec)
* HaveLock = Database_Services('GetKeyIDLock', 'WO_STEP', WOStepKey)
* If HaveLock then
// Get a fresh copy of the record
WOStepRec = Database_Services('ReadDataRow', 'WO_STEP', WOStepKey)
WOStepCurrStatusStatic = WOStepRec<WO_STEP_CURR_STATUS_STATIC$>
If WOStepCurrStatus NE WOStepCurrStatusStatic then
WOStepRec<WO_STEP_CURR_STATUS_STATIC$> = WOStepCurrStatus
Database_Services('WriteDataRow', 'WO_STEP', WOStepKey, WOStepRec, True$, False$, True$)
end
Database_Services('ReleaseKeyIDLock', 'WO_STEP', WOStepKey)
* end else
* // Failed to lock record for update. Throw an error to keep the request in the queue.
* Error_Services('Add', 'Failed to lock WO_STEP record ':WOStepKey:' in ':Service:' service.')
* end
// Get a fresh copy of the record
WOStepRec = Database_Services('ReadDataRow', 'WO_STEP', WOStepKey)
WOStepCurrStatusStatic = WOStepRec<WO_STEP_CURR_STATUS_STATIC$>
If WOStepCurrStatus NE WOStepCurrStatusStatic then
WOStepRec<WO_STEP_CURR_STATUS_STATIC$> = WOStepCurrStatus
Database_Services('WriteDataRow', 'WO_STEP', WOStepKey, WOStepRec, True$, False$, True$)
end
Database_Services('ReleaseKeyIDLock', 'WO_STEP', WOStepKey)
end
end service
@ -932,48 +924,182 @@ end service
Service UpdateReleasedQty(WONo)
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\WO_LOG'
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Update Released Qty Log.csv'
Headers = 'Logging DTM' : @FM : 'WONo' : @FM : 'Notes'
objUpRelLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$)
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
WORec = Database_Services('ReadDataRow', 'WO_LOG', WONo)
If Error_Services('NoError') then
RelQty = obj_WO_Log('RelQty', WONo:@RM:WORec)
WORec<WO_LOG_REL_QTY_STATIC$> = RelQty
WOQty = WORec<WO_LOG_QTY$>
If RelQty GT WOQty then
UnRelQty = 0
end else
UnRelQty = WOQty - RelQty
end
WORec<WO_LOG_UNREL_QTY_STATIC$> = UnRelQty
Database_Services('WriteDataRow', 'WO_LOG', WONo, WORec, True$, False$, False$)
end
ErrorMsg = ''
If WONo NE '' then
If RowExists('WO_LOG', WONo) then
WORec = Database_Services('ReadDataRow', 'WO_LOG', WONo)
If Error_Services('NoError') then
RelQty = obj_WO_Log('RelQty', WONo:@RM:WORec)
WOQty = WORec<WO_LOG_QTY$>
If RelQty GT WOQty then
UnRelQty = 0
end else
UnRelQty = WOQty - RelQty
end
Open 'WO_LOG' to hTable then
WriteV RelQty on hTable, WONo, WO_LOG_REL_QTY_STATIC$ then
WriteV UnRelQty on hTable, WONo, WO_LOG_UNREL_QTY_STATIC$ else
ErrorMsg = 'Error in ':Service:' service. Failed to write unreleased quantity ':UnRelQty
ErrorMsg := ' to the UNREL_QTY_STATIC field of WO_LOG record ':WONo:'.'
ErrorMsg := '@FILE_ERROR: ':@FILE_ERROR
end
end else
ErrorMsg = 'Error in ':Service:' service. Failed to write released quantity ':RelQty
ErrorMsg := ' to the REL_QTY_STATIC field of WO_LOG record ':WONo:'.'
ErrorMsg := '@FILE_ERROR: ':@FILE_ERROR
end
end else
ErrorMsg = 'Error in ':Service:' service. Failed to open the WO_LOG table.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Failed to read record ':WONo:' from the WO_LOG table. '
ErrorMsg := 'Error message: ':Error_Services('GetMessage')
end
end else
ErrorMsg = 'Error in ':Service:' service. ':WONo:' does not exist in the WO_LOG table.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Null WONo passed into service'
end
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = WONo
If ErrorMsg EQ '' then
LogResult = 'Successfully updated WO_LOG record ':WONo:' field REL_QTY_STATIC with released quantity ':RelQty
LogResult := ' and field UNREL_QTY_STATIC with unreleased quantity ':UnRelQty:'.'
LogData<3> = LogResult
Logging_Services('AppendLog', objUpRelLog, LogData, @RM, @FM)
end else
LogResult = 'Failed to update WO_LOG record ':WONo:' field REL_QTY_STATIC with released quantity ':RelQty
LogResult := ' or field UNREL_QTY_STATIC with unreleased quantity ':UnRelQty:'. Error message: ':ErrorMsg
LogData<3> = LogResult
Logging_Services('AppendLog', objUpRelLog, LogData, @RM, @FM)
Error_Services('Add', ErrorMsg)
end
end service
Service UpdateReceivedQty(WONo)
WORec = Database_Services('ReadDataRow', 'WO_LOG', WONo)
If Error_Services('NoError') then
RXQty = obj_WO_Log('RxQty', WONo:@RM:WORec)
WORec<WO_LOG_RX_QTY_STATIC$> = RXQty
Database_Services('WriteDataRow', 'WO_LOG', WONo, WORec, True$, False$, False$)
end
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\WO_LOG'
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Update Received Qty Log.csv'
Headers = 'Logging DTM' : @FM : 'WONo' : @FM : 'Notes'
objUpRecLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$)
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
ErrorMsg = ''
If WONo NE '' then
If RowExists('WO_LOG', WONo) then
WORec = Database_Services('ReadDataRow', 'WO_LOG', WONo)
If Error_Services('NoError') then
RXQty = obj_WO_Log('RxQty', WONo:@RM:WORec)
Open 'WO_LOG' to hTable then
WriteV RXQty on hTable, WONo, WO_LOG_RX_QTY_STATIC$ else
ErrorMsg = 'Error in ':Service:' service. Failed to write received quantity ':RXQty
ErrorMsg := ' to the RX_QTY_STATIC field of WO_LOG record ':WONo:'.'
ErrorMsg := '@FILE_ERROR: ':@FILE_ERROR
end
end else
ErrorMsg = 'Error in ':Service:' service. Failed to open the WO_LOG table.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Failed to read record ':WONo:' from the WO_LOG table. '
ErrorMsg := 'Error message: ':Error_Services('GetMessage')
end
end else
ErrorMsg = 'Error in ':Service:' service. ':WONo:' does not exist in the WO_LOG table.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Null WONo passed into service'
end
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = WONo
If ErrorMsg EQ '' then
LogData<3> = 'Successfully updated WO_LOG record ':WONo:' field RX_QTY_STATIC with received quantity ':RXQty:'.'
Logging_Services('AppendLog', objUpRecLog, LogData, @RM, @FM)
end else
LogResult = 'Failed to update WO_LOG record ':WONo:' field RX_QTY_STATIC with received quantity ':RXQty
LogResult := '. Error message: ':ErrorMsg
LogData<3> = LogResult
Logging_Services('AppendLog', objUpRecLog, LogData, @RM, @FM)
Error_Services('Add', ErrorMsg)
end
end service
Service UpdateShippedQty(WONo)
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\WO_LOG'
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Update Shipped Qty Log.csv'
Headers = 'Logging DTM' : @FM : 'WONo' : @FM : 'Notes'
objUpShipLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$)
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
WORec = Database_Services('ReadDataRow', 'WO_LOG', WONo)
If Error_Services('NoError') then
ShipQty = obj_WO_Log('ShipQty', WONo:@RM:WORec)
WORec<WO_LOG_SHIP_QTY_STATIC$> = ShipQty
Database_Services('WriteDataRow', 'WO_LOG', WONo, WORec)
end
ErrorMsg = ''
If WONo NE '' then
If RowExists('WO_LOG', WONo) then
WORec = Database_Services('ReadDataRow', 'WO_LOG', WONo)
If Error_Services('NoError') then
ShipQty = obj_WO_Log('ShipQty', WONo:@RM:WORec)
Open 'WO_LOG' to hTable then
WriteV ShipQty on hTable, WONo, WO_LOG_SHIP_QTY_STATIC$ else
ErrorMsg = 'Error in ':Service:' service. Failed to write ':ShipQty
ErrorMsg := ' to the SHIP_QTY_STATIC field of WO_LOG record ':WONo:'.'
ErrorMsg := '@FILE_ERROR: ':@FILE_ERROR
end
end else
ErrorMsg = 'Error in ':Service:' service. Failed to open the WO_LOG table.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Failed to read record ':WONo:' from the WO_LOG table. '
ErrorMsg := 'Error message: ':Error_Services('GetMessage')
end
end else
ErrorMsg = 'Error in ':Service:' service. ':WONo:' does not exist in the WO_LOG table.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Null WONo passed into service'
end
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = WONo
If ErrorMsg EQ '' then
LogResult = 'Successfully updated WO_LOG record ':WONo:' field SHIP_QTY_STATIC '
LogResult := 'with shipped quantity ':ShipQty:'.'
LogData<3> = LogResult
Logging_Services('AppendLog', objUpShipLog, LogData, @RM, @FM)
end else
LogResult = 'Failed to update WO_LOG record ':WONo:' field SHIP_QTY_STATIC with shipped quantity '
LogResult := ShipQty:'. Error message: ':ErrorMsg
LogData<3> = LogResult
Logging_Services('AppendLog', objUpShipLog, LogData, @RM, @FM)
Error_Services('Add', ErrorMsg)
end
end service
Service ConvertRecordToJSON(WONo, Record, ItemURL)
jsonRecord = ''
IF WONo NE '' then
If Record EQ '' then Record = Database_Services('ReadDataRow', 'WO_LOG', WONo)
@ -1052,9 +1178,12 @@ Service ConvertRecordToJSON(WONo, Record, ItemURL)
Error_Services('Add', 'KeyID argument was missing in the ' : Service : ' service.')
end
Response = jsonRecord
end service
Service RemoveWoMatCassetteFromWO(WoMatKey, Username)
ErrorMessage = ''
If RowExists('WO_MAT', WoMatKey) then
WoNo = Field(WoMatKey, '*', 1)
@ -1083,9 +1212,12 @@ Service RemoveWoMatCassetteFromWO(WoMatKey, Username)
If ErrorMessage NE '' then
Error_Services('Add', ErrorMessage)
end
end service
Service SignVoidNonEpp(WOMatKey, Username)
ErrorMessage = ''
WONo = Field(WOMatKey, '*', 1)
CassNo = Field(WoMatKey, '*', 2)
@ -1166,7 +1298,9 @@ Service SignVoidNonEpp(WOMatKey, Username)
end service
Service SignVoidWMI(WMInKey, Username)
ErrorMessage = ''
WONo = Field(WMInKey, '*', 1)
CassNo = Field(WMInKey, '*', 3)
@ -1239,7 +1373,9 @@ Service SignVoidWMI(WMInKey, Username)
end service
Service SignVoidWMO(WMOutKey, Username)
ErrorMessage = ''
WONo = Field(WMOutKey, '*', 1)
CassNo = Field(WMOutKey, '*', 3)
@ -1312,15 +1448,16 @@ Service SignVoidWMO(WMOutKey, Username)
end service
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal GoSubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ClearCursors:
For counter = 0 to 8
ClearSelect counter
Next counter
return