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

403 lines
15 KiB
Plaintext

Compile function Report_Services_Dev4(@Service, @Params)
/***********************************************************************************************************************
Name : Report_Services
Description : Handler program for all Report services.
Notes : Application errors should be logged using the Error Services module. There are a few methodological
assumptions built into way errors are managed which are important to understand in order to properly
work with Error Services:
- The term 'top' refers to the originating procedure of a call stack and the term 'bottom' refers to
the last routine (or the current routine) within a call stack. Within the OpenInsight Debugger
this will appear backwards since the originating procedure always appears at the bottom of the
list and the current routine appears at the top of the list. We are using this orientation because
it is common to refer to the process of calling other procedures as 'drilling down'.
- The reason for defining the orientation of the call stack is because Error_Services allows for
multiple error conditions to be appended to an original error. In most cases this will happen when
a procedure at the bottom of the stack generates an error condition and then returns to its
calling procedure. This higher level procedure can optionally add more information relevant to
itself. This continues as the call stack 'bubbles' its way back to the top to where the
originating procedure is waiting.
- Native OpenInsight commands that handle errors (e.g., Set_Status, Set_FSError, Set_EventStatus)
preserve their error state until explicitly cleared. This can hinder the normal execution of code
since subsequent procedures (usually SSPs) will fail if a pre-existing error condition exists.
Our philosophy is that error conditions should automatically be cleared before a new procedure
is executed to avoid this problem. However, the nature of Basic+ does not make this easy to
automate for any given stored procedure. Therefore, if a stored procedure wants to conform to our
philosophy then it should include a call into the 'Clear' service request at the top of the
program. Alternatively this can be done through a common insert (see SERVICE_SETUP for example.)
- Service modules will use the SERVICE_SETUP insert and therefore automatically clear out any
error conditions that were set before.
Parameters :
Service [in] -- Name of the service being requested
Param1-10 [in/out] -- Additional request parameter holders
Response [out] -- Response to be sent back to the Controller (MCP) or requesting procedure
Metadata :
History : (Date, Initials, Notes)
07/28/21 djs Copied original source code from Report_Services. Modified GetMaterialTrackReport
to use the SCHED_DET_NG table (i.e. Scheduler 2.0) instead of the SCHED_DET table.
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
$Insert SERVICE_SETUP
$Insert LOGICAL
$Insert OIPRINT_EQUATES
$Insert SCHED_DET_NG_EQUATES
$Insert WO_LOG_EQUATES
$Insert APPCOLORS
$Insert MSG_EQUATES
$Insert SCHEDULE_EQU
$Insert LOCATION_EQUATES
$Insert RLIST_EQUATES
Declare subroutine Utility, ErrMsg, Set_Status, Set_Printer, RList, SRP_Stopwatch, Btree.Extract, Error_Services, V119
Declare subroutine Push.Select, Pop.Select, SRP_Stopwatch, Database_Services
Declare function Set_Printer, Get_Printer, Msg, Get_Status, Printer_Select, obj_Install, Dialog_Box, obj_Location
Declare function Error_Services, Location_Services, SRP_Array, Signature_Services
Declare function Epi_Part_Services, SRP_Math, Datetime, Database_Services
Equ TAB$ TO \09\
GoToService
Return Response or ""
//-----------------------------------------------------------------------------
// SERVICES
//-----------------------------------------------------------------------------
Service GetMaterialTrackReport(RptColumns, LocationFilter, NoMatFlag)
SRP_Stopwatch('Reset')
SRP_Stopwatch('Start', 'Select')
NoMatFlag = False$
LocationFilter = ''
LocationFilter<1, 1> = 'SR*KTR]'
LocationFilter<1, 2> = '1K*PTI'
LocationFilter<1, 3> = 'CR*BE'
LocationFilter<1, 4> = 'CR*BO'
LocationFilter<1, 5> = 'CR*TUN'
LocationFilter<1, 6> = 'CR*EPR'
LocationFilter<1, 7> = 'CR*FE'
LocationFilter<1, 8> = 'CR*FEH'
LocationFilter<1, 9> = 'CR*FO'
LocationFilter<1, 10> = 'CR*FOH'
// All Possible Report Columns
AllRptColumns = ''
AllRptColumns<1, 1> = 'React No'
AllRptColumns<1, 2> = 'React Type'
AllRptColumns<1, 3> = 'WO No'
AllRptColumns<1, 4> = 'SAP Prod No'
AllRptColumns<1, 5> = 'Sub Part No'
AllRptColumns<1, 6> = 'Epi Part No'
AllRptColumns<1, 7> = 'WO Qty'
AllRptColumns<1, 8> = 'RX Qty'
AllRptColumns<1, 9> = 'UnRel Qty'
AllRptColumns<1, 10> = 'Kit Location'
AllRptColumns<1, 11> = 'Kit Qty'
AllRptColumns<1, 12> = '+/-'
AllRptColumns<1, 13> = 'Kit RO'
AllRptColumns<1, 14> = 'PTI RO'
AllRptColumns<1, 15> = 'Load'
AllRptColumns<1, 16> = 'Comments'
RptColumns = AllRptColumns
ErrorTitle = 'Error in service ':Service
ErrCode = ''
ErrorMsg = ''
OPEN 'SCHED_DET_NG' TO SchedDetTable then
OPEN 'DICT.SCHED_DET_NG' TO @DICT then
Today = Datetime() - 45
ReactList = ''
WOList = ''
SchedDetKeys = ''
PrevReactNo = ''
PrevWO = ''
SelectSent = 'SELECT SCHED_DET_NG WITH STOP_DTM GE ':Today:' BY REACT_NO'
RList(SelectSent,TARGET_ACTIVELIST$,'','','')
IF Get_Status(errCode) THEN
ErrMsg(errCode)
RETURN
END
Done = 0
@ID = ''
LOOP
PrevSchedDetKey = @ID
READNEXT @ID ELSE Done = 1
UNTIL Done
READ SchedDetRec FROM SchedDetTable,@ID THEN
ReactNo = SchedDetRec<SCHED_DET_NG.REACT_NO$>
WONo = SchedDetRec<SCHED_DET_NG.WO_NO$>
If ReactNo NE '' then
LOCATE ReactNo IN ReactList BY 'AR' USING @FM SETTING Pos ELSE
ReactList = INSERT(ReactList,Pos,0,0,ReactNo)
END
END
If WONo NE '' then
LOCATE WONo IN WOList<Pos> USING @VM SETTING WPos ELSE
WOList = INSERT(WOList,Pos,-1,0,WONo)
SchedDetKeys = INSERT(SchedDetKeys,-1,0,0,@ID)
END
END
END
REPEAT
CALL Make.List(0,SchedDetKeys,SchedDetTable,@DICT)
DateRange = 'Effective ':OCONV(Date(),'D4')
RowIndex = 0
AllReportData = ''
@RECCOUNT = 0
FirstPass = 1
LastRecord = 0
FirstLine = 1
fontSpacing = 100
* Zero Accumulators For Each Break
Prev.ReactNo = ''
Last.ReactNo.Break = 1
GoTo ReadRecord
end else
ErrorMsg = 'Unable to open "SCHED_DET_NG" table.'
ErrMsg(ErrorTitle:@SVM:ErrorMsg)
end
end else
ErrorMsg = 'Unable to open "SCHED_DET_NG" table.'
ErrMsg(ErrorTitle:@SVM:ErrorMsg)
end
End Service
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal GoSubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ReadRecord:
* Zero Break Flags To False
ReactNo.Break=0
READNEXT @ID, Which.Value ELSE
LastRecord = 1
ReactNo.Break = 1
ReactNo = Prev.ReactNo
END
S.ATID = @ID
IF FirstPass AND LastRecord THEN
GOTO Bail
END
IF LastRecord THEN GOTO BREAKS
READO @RECORD FROM SchedDetTable,@ID ELSE
GOTO ReadRecord
END
@RECCOUNT += 1
* Calculate Value(s) For Column(s)
SRP_Stopwatch('Start', 'Read Record 1.1')
S.ATID = {@ID}
I.ATID = S.ATID
S.ReactNo = {REACT_NO}
I.ReactNo = S.ReactNo
S.WoNo = {WO_NO}
I.WoNo = S.WoNo
S.SubPartNo = XLATE('WO_LOG', S.WoNo, 'ORD_SUB_PART_NO', 'X')
I.SubPartNo = S.SubPartNo
S.EpiPartNo = XLATE('WO_LOG', S.WoNo, WO_LOG_EPI_PART_NO$, 'X')
I.EpiPartNo = S.EpiPartNo
S.WO_Qty = Xlate('WO_LOG', {WO_NO}, WO_LOG_WO_QTY$, 'X')
I.WO_Qty = S.WO_Qty
S.WO_RX_Qty = Xlate('WO_LOG', {WO_NO}, 'RX_QTY', 'X')
I.WO_RX_Qty = S.WO_RX_Qty
S.WO_UnRel_QTY = Xlate('WO_LOG', {WO_NO}, 'UNREL_QTY', 'X')
I.WO_UnRel_QTY = S.WO_UnRel_QTY
S.REACT_TYPE = Xlate('WO_LOG', {WO_NO}, 'REACT_TYPE', 'X')
S.ProdOrdNo = Xlate('WO_LOG', {WO_NO}, 'PROD_ORD_NO', 'X')
SRP_Stopwatch('Stop', 'Read Record 1.1')
SRP_Stopwatch('Start', 'Read Record 1.2.1')
Locate 'SR*KTR]' in LocationFilter using @VM setting vPos then
KitData = Database_Services('ReadDataRow', 'WO_LOC', S.WONo:'*':'SR*KTR]')
end else
KitData = ''
end
SRP_Stopwatch('Stop', 'Read Record 1.2.1')
SRP_Stopwatch('Start', 'Read Record 1.2.2')
Swap @VM with ',' in KitData
S.KitLocation = KitData<1>
I.KitLocation = S.KitLocation
S.KitQty = OCONV(SUM(KitData<2>) * 25,'MD0,Z')
I.KitQty = S.KitQty
S.KitCassCnt = KitData<2>
I.KitCassCnt = S.KitCassCnt
KitCassList = KitData<3>
SRP_Stopwatch('Stop', 'Read Record 1.2.2')
SRP_Stopwatch('Start', 'Read Record 1.2.3')
Locate '1K*PTI' in LocationFilter using @VM setting vPos then
PTIData = Database_Services('ReadDataRow', 'WO_LOC', S.WONo:'*':'1K*PTI')
end else
PTIData = ''
end
SRP_Stopwatch('Stop', 'Read Record 1.2.3')
SRP_Stopwatch('Start', 'Read Record 1.3.1')
Swap @VM with ',' in PTIData
PTICassList = PTIData<3>
CRLocs = ''
CRLocs<0, -1> = 'CR*BE'
CRLocs<0, -1> = 'CR*BO'
CRLocs<0, -1> = 'CR*TUN'
CRLocs<0, -1> = 'CR*EPR'
CRLocs<0, -1> = 'CR*FE'
CRLocs<0, -1> = 'CR*FEH'
CRLocs<0, -1> = 'CR*FO'
CRLocs<0, -1> = 'CR*FOH'
LoadedData = ''
LocQueryList = ''
For each Loc in CRLocs using @VM setting crPos
Locate Loc in LocationFilter using @VM setting vPos then
LocQueryList<0, -1> = Loc
end
Next Loc
LoadedCassList = ''
ReactType = Xlate('WO_LOG', S.WONo, 'REACT_TYPE', 'X')
SRP_Stopwatch('Stop', 'Read Record 1.3.1')
SRP_Stopwatch('Start', 'Read Record 1.3.2')
If ReactType NE 'EPP' then
If LocQueryList NE '' then
For each CRLoc in LocQueryList using @VM
CRLocInfo = Database_Services('ReadDataRow', 'WO_LOC', S.WONo:'*':CRLoc)
CRLocCassList = CRLocInfo<3>
LoadedCassList = SRP_Array('Join', LoadedCassList, CRLocCassList, 'OR', @VM)
Next CRLoc
end
end
LoadedCassList = SRP_Array('Clean', LoadedCassList, 'TrimAndMakeUnique', @VM)
* TEST FOR CONTROL BREAK(S)
IF (S.ReactNo NE Prev.ReactNo) OR ReactNo.Break THEN
ReactNo = Prev.ReactNo
Prev.ReactNo = S.ReactNo
ReactNo.Break += 1
END
SRP_Stopwatch('Stop', 'Read Record 1.3.2')
IF FirstPass THEN
FirstPass=0
GOTO DETAIL
END
BREAKS:
* Perform Last Record Output If Done
IF LastRecord THEN
colData = ''
GOTO Bail
END
DETAIL:
SRP_Stopwatch('Start', 'Detail')
* Do Conversion If Any
IF S.REACTNO NE "" THEN S.REACTNO = OCONV(S.REACTNO,"MD0,")
IF S.WONO NE "" THEN S.WONO = OCONV(S.WONO,"MD0")
IF S.WO_QTY NE "" THEN S.WO_QTY = OCONV(S.WO_QTY,"MD0,")
IF S.WO_RX_QTY NE "" THEN S.WO_RX_QTY = OCONV(S.WO_RX_QTY,"MD0,")
IF S.WO_UNREL_QTY NE "" THEN S.WO_UNREL_QTY = OCONV(S.WO_UNREL_QTY,"MD0,")
* PRINT DETAIL LINE
COLDATA = ''
RowNumber = 0
/* ascending sort */
Convert @VM to ',' in KitCassList
Convert @VM to ',' in PTICassList
Convert @VM to ',' in LoadedCassList
KitCassList = SRP_Array('SortSimpleList', KitCassList, 'AscendingNumbers', ',')
PTICassList = SRP_Array('SortSimpleList', PTICassList, 'AscendingNumbers', ',')
LoadedCassList = SRP_Array('SortSimpleList', LoadedCassList, 'AscendingNumbers', ',')
CassNeeded = ''
EpiPartNo = Xlate('WO_LOG', S.WONo, 'EPI_PART_NO', 'X')
If EpiPartNo NE '' then
WPDAdjusted = Epi_Part_Services('GetAdjustedWafersPerDayScheduler', EpiPartNo, S.React_Type)
If WPDAdjusted NE '' then
CPDAdjusted = SRP_Math('CEILING', (WPDAdjusted/25) )
CassInCR = DCount(KittCassList, ',') + DCount(PTICassList, ',') + DCount(LoadedCassList, ',')
CassNeeded = CassInCR - CPDAdjusted
end
end
RowIndex += 1
Swap '.1' with '' in S.ProdOrdNo
AllReportData<RowIndex, 1> = S.ReactNo
AllReportData<RowIndex, 2> = S.React_Type
AllReportData<RowIndex, 3> = S.WONo
AllReportData<RowIndex, 4> = S.ProdOrdNo
AllReportData<RowIndex, 5> = S.SubPartNo
AllReportData<RowIndex, 6> = S.EpiPartNo
AllReportData<RowIndex, 7> = S.WO_Qty
AllReportData<RowIndex, 8> = S.WO_RX_Qty
AllReportData<RowIndex, 9> = S.WO_UnRel_Qty
AllReportData<RowIndex, 10> = S.KitLocation
AllReportData<RowIndex, 11> = S.KitQty
AllReportData<RowIndex, 12> = CassNeeded
AllReportData<RowIndex, 13> = KitCassList
AllReportData<RowIndex, 14> = PTICassList
AllReportData<RowIndex, 15> = LoadedCassList
AllReportData<RowIndex, 16> = ''
SRP_Stopwatch('Stop', 'Detail')
GOTO ReadRecord
Bail:
SRP_Stopwatch('ShowAll')
RETURN