added triggers to calculate and store the scrapped quantity of a work order and auto close the work order when the scrap quantity and ship quantity equal the total work order quantity
added performance improvements to reduce unnecessary writes to the WO_LOG table
This commit is contained in:
@ -920,37 +920,42 @@ 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
|
||||
|
||||
ErrorMsg = ''
|
||||
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
|
||||
RelQty = ''
|
||||
UnRelQty = ''
|
||||
OrigRelQty = ''
|
||||
OrigUnRelQty = ''
|
||||
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$>
|
||||
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
|
||||
Read WORec from hTable, WONo then
|
||||
OrigRelQty = WORec<WO_LOG_REL_QTY_STATIC$>
|
||||
OrigUnRelQty = WORec<WO_LOG_UNREL_QTY_STATIC$>
|
||||
If ( (OrigRelQty NE RelQty) or (OrigUnRelQty NE UnRelQty) ) then
|
||||
WORec<WO_LOG_REL_QTY_STATIC$> = RelQty
|
||||
WORec<WO_LOG_UNREL_QTY_STATIC$> = UnRelQty
|
||||
Write WORec on hTable, WONo else
|
||||
ErrorMsg = 'Error in ':Service:' service. Failed to write unreleased quantity ':UnRelQty
|
||||
ErrorMsg := ' and/or UNREL_QTY_STATIC field of WO_LOG record ':WONo:'.'
|
||||
ErrorMsg := '@FILE_ERROR: ':@FILE_ERROR
|
||||
end
|
||||
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.'
|
||||
@ -994,18 +999,25 @@ Service UpdateReceivedQty(WONo)
|
||||
Headers = 'Logging DTM' : @FM : 'WONo' : @FM : 'Notes'
|
||||
objUpRecLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$)
|
||||
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
|
||||
|
||||
ErrorMsg = ''
|
||||
RXQty = ''
|
||||
OrigRXQty = ''
|
||||
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
|
||||
ReadV OrigRXQty from hTable, WONo, WO_LOG_RX_QTY_STATIC$ then
|
||||
If OrigRXQty NE RXQty 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
|
||||
end else
|
||||
ErrorMsg = 'Error in ':Service:' service. Error reading RX_QTY_STATIC column from WO_LOG ':WONo:'.'
|
||||
end
|
||||
end else
|
||||
ErrorMsg = 'Error in ':Service:' service. Failed to open the WO_LOG table.'
|
||||
@ -1047,18 +1059,25 @@ Service UpdateShippedQty(WONo)
|
||||
Headers = 'Logging DTM' : @FM : 'WONo' : @FM : 'Notes'
|
||||
objUpShipLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$)
|
||||
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
|
||||
|
||||
ErrorMsg = ''
|
||||
ShipQty = ''
|
||||
OrigShipQty = ''
|
||||
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
|
||||
ReadV OrigShipQty from hTable, WONo, WO_LOG_SHIP_QTY_STATIC$ then
|
||||
If OrigShipQty NE ShipQty 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
|
||||
end else
|
||||
ErrorMsg = 'Error in ':Service:' service. Error reading SHIP_QTY_STATIC column from WO_LOG ':WONo:'.'
|
||||
end
|
||||
end else
|
||||
ErrorMsg = 'Error in ':Service:' service. Failed to open the WO_LOG table.'
|
||||
@ -1093,6 +1112,73 @@ Service UpdateShippedQty(WONo)
|
||||
end service
|
||||
|
||||
|
||||
Service UpdateScrappedQty(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 Scrapped Qty Log.csv'
|
||||
Headers = 'Logging DTM' : @FM : 'WONo' : @FM : 'Notes'
|
||||
objUpScrapLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$)
|
||||
LoggingDTM = LogDate : ' ' : LogTime
|
||||
ScrapQty = ''
|
||||
OrigScrapQty = ''
|
||||
ErrorMsg = ''
|
||||
If WONo NE '' then
|
||||
If RowExists('WO_LOG', WONo) then
|
||||
WORec = Database_Services('ReadDataRow', 'WO_LOG', WONo)
|
||||
If Error_Services('NoError') then
|
||||
EpiProFlag = Xlate('WO_LOG', WONo, 'EPI_PRO_FLAG', 'X')
|
||||
If EpiProFlag then
|
||||
ScrapQty = Xlate('WO_STEP', WONo:'*1', 'TOT_REJ_TOTAL', 'X')
|
||||
end else
|
||||
ScrapQty = Sum(Xlate('WO_LOG', WONo, 'WO_MAT_SAP_CONFIRM_SCRAP', 'X'))
|
||||
end
|
||||
Open 'WO_LOG' to hTable then
|
||||
ReadV OrigScrapQty from hTable, WONo, WO_LOG_SCRAP_QTY_STATIC$ then
|
||||
If OrigScrapQty NE ScrapQty then
|
||||
WriteV ScrapQty on hTable, WONo, WO_LOG_SCRAP_QTY_STATIC$ else
|
||||
ErrorMsg = 'Error in ':Service:' service. Failed to write ':ScrapQty
|
||||
ErrorMsg := ' to the SCRAP_QTY_STATIC field of WO_LOG record ':WONo:'.'
|
||||
ErrorMsg := '@FILE_ERROR: ':@FILE_ERROR
|
||||
end
|
||||
end
|
||||
end else
|
||||
ErrorMsg = 'Error in ':Service:' service. Error reading SCRAP_QTY_STATIC column from WO_LOG ':WONo:'.'
|
||||
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 SCRAP_QTY_STATIC '
|
||||
LogResult := 'with scrapped quantity ':ScrapQty:'.'
|
||||
LogData<3> = LogResult
|
||||
Logging_Services('AppendLog', objUpScrapLog, LogData, @RM, @FM)
|
||||
end else
|
||||
LogResult = 'Failed to update WO_LOG record ':WONo:' field SCRAP_QTY_STATIC with scrapped quantity '
|
||||
LogResult := ScrapQty:'. Error message: ':ErrorMsg
|
||||
LogData<3> = LogResult
|
||||
Logging_Services('AppendLog', objUpScrapLog, LogData, @RM, @FM)
|
||||
Error_Services('Add', ErrorMsg)
|
||||
end
|
||||
|
||||
end service
|
||||
|
||||
|
||||
Service ConvertRecordToJSON(WONo, Record, ItemURL)
|
||||
|
||||
jsonRecord = ''
|
||||
|
Reference in New Issue
Block a user