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

222 lines
9.3 KiB
Plaintext

compile function WO_LOG_RPT2()
begin condition
pre:
post:
end condition
declare function msg, set_property, send_event, dialog_box, utility, get_property
declare function set_printer, fieldcount, Printer_Select
declare subroutine rlist, activate_save_select, yield, btree.extract, extract_si_keys
$insert rlist_equates
$insert logical
$insert msg_equates
$insert oiprint_equates
$insert wo_log_equ
$insert rds_equ
* THERE WILL NOT BE A WINDOW FOR THIS REPORT
MsgInfo = ''
MsgInfo<mtext$> = 'This report will take between 5 to 8 minutes to run...':CrLf$:'Do you wish to continue???'
MsgInfo<mtype$> = 'BNY'
MsgInfo<micon$> = '?'
Resp = msg( '', MsgInfo )
if Resp else
return 0
end
open 'WO_LOG' to WOLogTable else
Void = msg( '', 'Unable to open WO_LOG' )
return 0
end
open 'DICT.RDS' to DictRDSTable else
Void = msg( '', 'Unable to open DICT_RDS' )
return 0
end
Void = utility( 'CURSOR', 'H' )
Stmt = 'SELECT WO_LOG WITH STATUS = "O" BY CUST_NAME BY PROD_SPEC_ID'
rlist( Stmt, target_activelist$, '', '', '' )
TableColInfo = '<+1800':@vm:'>+806':@vm:'>+806':@vm:'>+9':@vm:'>+9':@vm:'>+9':@vm:'>+806':@vm:'>+806':@vm:'>+806':@vm:'>+806':@vm:'>+806':@vm:'>+806'
TableColInfo:=@vm:'>+806':@vm:'>+9':@vm:'>+9':@vm:'>+9':@vm:'>+806':@vm:'>+806':@vm:'>+806':@vm:'>+806':@vm:'>+806':@vm:'>+806':@vm:'>+806'
SpaceOut = str( ' ', 17 )
SpaceOut2 = str( ' ', 20 )
PrintPath = Printer_Select('',1) ;* Get default printer path
Void = set_printer( 'INIT', '', '', .38:@fm:.75:@fm:.38:@fm:.75, 1, 3:@vm:'':@vm:'':@vm:2:@fm:96, PrintPath )
Void = utility( 'CURSOR', 'H' )
Font = "Courier New,8,L,1"
convert ',' to @fm in Font
TFont = font
TFont<2> = 12
Void = set_printer( 'FONTHEADFOOT', TFont )
ColLen = 1.25:@fm:.56:@fm:.56:@fm:.56:@fm:.56:@fm:.56:@fm:.56:@fm:.56:@fm:.56:@fm:.56:@fm:.56:@fm:.56:@fm:.56:@fm:.56:@fm:.56:@fm:.56:@fm:.56
ColHeader = 'Customer':@vm:'PSN':@vm:'Thk':@vm:'Rec':@vm:'Pre':@vm:'In':@vm:'Post':@vm:'Ready':@vm:'Hold':@vm:'Yld':@vm:'Day1':@vm:'Day2':@vm:'Day3':@vm:'-WK1':@vm:'WK2':@vm:'WK3':@vm:'WK4+'
ColJust = 'C':@fm:'C':@fm:'C':@fm:'C':@fm:'C':@fm:'C':@fm:'C':@fm:'C':@fm:'C':@fm:'C':@fm:'C':@fm:'C':@fm:'C':@fm:'C':@fm:'C':@fm:'C':@fm:'C'
Void = set_printer( 'HEADER', str(' ',43):"BLISS":@fm:"'D' 'T'":SpaceOut:"Inventory report":SpaceOut2:"Demand/Schedule", ColLen, ColHeader, ColJust )
TFont<2> = 8
TFont<4> = 0
Void = set_printer( 'FONT', TFont )
* SET UP VARIABLES FOR THE REPORT
WeekResultArray = 0:@fm:0:@fm:0:@fm:0:@fm:0:@fm:0:@fm:0
ReceivedQty = 0
PreEpiQty = 0
InProcessQty = 0
PostEpiQty = 0
ReadyToShipQty = 0
HoldQty = 0
CalcYield = 0
WeekResultArrayTot = 0:@fm:0:@fm:0:@fm:0:@fm:0:@fm:0:@fm:0
ReceivedQtyTot = 0
PreEpiQtyTot = 0
InProcessQtyTot = 0
PostEpiQtyTot = 0
ReadyToShipQtyTot = 0
HoldQtyTot = 0
CalcYieldTot = 0
Today = date()
W1 = Today
W2 = Today+1
W3 = Today+2
W4 = Today+6
W5 = Today+13
W6 = Today+20
W7 = Today+9999 ;* CAUSE YOU WANT IT TO NOT LOCATE PAST 7 IN THE ARRAY
WeekArray = W1:@fm:W2:@fm:W3:@fm:W4:@fm:W5:@fm:W6:@fm:W7
ThisPSN = ''
OrigPSN = ''
* END OF REPORT VARIABLES
Eof = false$
loop
readnext @id else Eof = true$
until Eof
read @record from WOLogTable, @id else
Void = msg( '', 'Unable to read ':@id:' from WO_LOG Table...' )
return 0
end
ThisPSN = @record<wo_log_prod_spec_id$>
if ( ThisPSN <> OrigPSN ) and ( OrigPSN <> '' ) then
gosub PrintPSNLine
end
OrigPSN = ThisPSN
CommitDate = @record<wo_log_commit_date$>
locate CommitDate in WeekArray by 'AR' using @fm setting FPos then
* IF IT LOCATED IT THEN THE COMMIT DATE RIGHT ON ONE OF THE WEEKARRAY VALUES
* WHAT WE ARE DOING HERE IS FINDING WHICH WEEK IT FALLS INTO
end
* GO AGAINST THE RDS AND FIND ALL RDSS FOR THAT WO AND SUM UP THE QUANTITY THAT HAS NOT SHIPPED
* WE CAN'T JUST ADD THE QUANITY FROM THE WO_LOG CAUSE SOME OF THE WAFERS ARE ALREADY SHIPPED
Keys = ''
SearchStr = ''
SearchStr<-1> = 'WO':@vm:@id
SearchStr<-1> = 'STATUS':@vm:'#S':@fm
btree.extract( SearchStr, 'RDS', DictRDSTable, Keys, '', Flag )
if Flag <> 0 then
Void = msg( '', 'Error while extracting RDS records...' )
return 0
end
if Keys <> '' then
WeekResultArray<FPos> = WeekResultArray<FPos> + sum( xlate( 'RDS', Keys, 'WAFERS_SCHEDULED', 'X' ) )
end else
KeyList = ''
extract_si_keys( 'RDS', 'WO', @id, KeyList )
if KeyList = '' then
* ONLY THE WORK ORDER HAS BEEN ENTERED SO WE WILL WANT TO USE THE WO_LOG QTY SO IT SHOWS UP
* ON THE REPORT
WeekResultArray<FPos> = WeekResultArray<FPos> + @record<wo_log_qty$>
end else
* OBVIOUSLY THEY HAVE ALL SHIPPED BUT THE WO IS STILL OPEN
WeekResultArray<FPos> = WeekResultArray<FPos> + 0
end
end
repeat
gosub PrintPSNLine
* PRINT THE TOTAL LINE AT THE BOTTOM OF THE REPORT
TFont<4> = 1
Void = set_printer( 'FONT', TFont )
TotInFabTot = ReceivedQtyTot + PreEpiQtyTot + InProcessQtyTot + PostEpiQtyTot + ReadyToShipQtyTot
CalcYieldTot = oconv( (( TotInFabTot - ReadyToShipQtyTot )*.99), 'MD0' )
CalcYieldTot += ReadyToShipQtyTot
Table = 'Totals:':@vm:'NA':@vm:'NA':@vm:'':@vm:'':@vm:'':@vm:oconv(ReceivedQtyTot,'MD0,'):@vm:oconv(PreEpiQtyTot,'MD0,'):@vm:oconv(InProcessQtyTot,'MD0,'):@vm:oconv(PostEpiQtyTot,'MD0,')
Table:= @vm:oconv(ReadyToShipQtyTot,'MD0,'):@vm:oconv(HoldQtyTot,'MD0,'):@vm:oconv(CalcYieldTot,'MD0,'):@vm:'':@vm:'':@vm:'':@vm:oconv(WeekResultArrayTot<1>,'MD0,'):@vm:oconv(WeekResultArrayTot<2>,'MD0,'):@vm:oconv(WeekResultArrayTot<3>,'MD0,'):@vm:oconv(WeekResultArrayTot<4>,'MD0,'):@vm:oconv(WeekResultArrayTot<5>,'MD0,'):@vm:oconv(WeekResultArrayTot<6>,'MD0,'):@vm:oconv(WeekResultArrayTot<7>,'MD0,')
x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
Void = utility( 'CURSOR', 'A' )
Void = set_printer( 'TERM', 1 )
return 0
************************************************************************
PrintPSNLine:
* DO PRINTING LOGIC FOR THE OrigPSN
* SET ALL VARIABLES TO NULL
Customer = xlate( 'PROD_SPEC', OrigPSN, 'ABBREV_OR_CO_NAME', 'X' )
Thickness = oconv( xlate( 'PROD_SPEC', OrigPSN, 'THICK_TARGET_L1', 'X' ), 'MD2' )
* NOW GET INVENTORY ITEMS
Keys = ''
SearchStr = ''
SearchStr<-1> = 'STATUS':@vm:'#S'
SearchStr<-1> = 'PROD_SPEC_ID':@vm:OrigPSN:@fm
btree.extract( SearchStr, 'RDS', DictRDSTable, Keys, '', Flag )
if Flag <> 0 then
Void = msg( '', 'Error while extracting RDS records...' )
return 0
end
*
RDSStatus = xlate( 'RDS', Keys, rds_status$, 'X' )
SchedQtys = xlate( 'RDS', Keys, 'WAFERS_SCHEDULED', 'X' )
HoldStatus = xlate( 'RDS', Keys, rds_hold$, 'X' )
RCnt = fieldcount( Keys, @vm )
for i = 1 to RCnt
ThisStatus = RDSStatus<1,i>
ThisSchedQty = SchedQtys<1,i>
ThisHoldStatus = HoldStatus<1,i>
if ThisHoldStatus then
HoldQty += ThisSchedQty
end else
begin case
case ThisStatus = 'C'
ReceivedQty += ThisSchedQty
case ThisStatus = 'E'
PreEpiQty += ThisSchedQty
case ThisStatus = 'I'
InProcessQty += ThisSchedQty
case ThisStatus = 'T'
PostEpiQty += ThisSchedQty
case ThisStatus = 'R'
ReadyToShipQty += ThisSchedQty
case otherwise$
* DO NOTHING THE STATUS MUST BE NULL BAD RDS
end case
end
next i
* IF REPORT LINE IS ALL ZERO THEN DO NOT PRINT A LINE
* IF THE SHIPMENT WENT OUT AND THE WO_LOG RECORD HAS NOT BEEN CLOSED
* THIS WILL HAPPEN BECAUSE THE NIGHTLY PROCESS IS RUN MANUALLY EVERY
* MORNING AND IT THEN CLOSES OUT ALL SHIPPED WORK ORDERS
if ( sum( WeekResultArray ) = 0 ) and ( ( HoldQty + ReceivedQty + PreEpiQty + InProcessQty + PostEpiQty + ReadyToShipQty ) = 0 ) else
TotInFab = ReceivedQty + PreEpiQty + InProcessQty + PostEpiQty + ReadyToShipQty
CalcYield = oconv( (( TotInFab - ReadyToShipQty )*.99), 'MD0' )
CalcYield += ReadyToShipQty
Table = Customer:@vm:OrigPSN:@vm:Thickness:@vm:'':@vm:'':@vm:'':@vm:oconv(ReceivedQty,'MD0,'):@vm:oconv(PreEpiQty,'MD0,'):@vm:oconv(InProcessQty,'MD0,'):@vm:oconv(PostEpiQty, 'MD0,')
Table:= @vm:oconv(ReadyToShipQty,'MD0,'):@vm:oconv(HoldQty,'MD0,'):@vm:oconv(CalcYield,'MD0,'):@vm:'':@vm:'':@vm:'':@vm:oconv(WeekResultArray<1>,'MD0,'):@vm:oconv(WeekResultArray<2>,'MD0,'):@vm:oconv(WeekResultArray<3>,'MD0,'):@vm:oconv(WeekResultArray<4>,'MD0,'):@vm:oconv(WeekResultArray<5>,'MD0,'):@vm:oconv(WeekResultArray<6>,'MD0,'):@vm:oconv(WeekResultArray<7>,'MD0,')
x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
end
* ADD THE TOTALS FOR THISORIGPSN
WeekResultArrayTot = WeekResultArrayTot +++ WeekResultArray
ReceivedQtyTot += ReceivedQty
PreEpiQtyTot += PreEpiQty
InProcessQtyTot += InProcessQty
PostEpiQtyTot += PostEpiQty
ReadyToShipQtyTot += ReadyToShipQty
HoldQtyTot += HoldQty
* AND THEN CLEAR OUT THE REST OF THE VARIABLES
WeekResultArray = 0:@fm:0:@fm:0:@fm:0:@fm:0:@fm:0:@fm:0
ReceivedQty = 0
PreEpiQty = 0
InProcessQty = 0
PostEpiQty = 0
ReadyToShipQty = 0
HoldQty = 0
CalcYield = 0
return