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

293 lines
6.9 KiB
Plaintext

COMPILE SUBROUTINE Print_ReadyToShip( Dummy )
/*
Print Ready to Ship Routine
04/23/2004 - John C. Henry, J.C. Henry, Inc. - Initial coding
09/17/2008 - Rewritten for conversion to WO_MAT table
*/
DECLARE SUBROUTINE Reduce,MSG,Utility,ErrMsg, Set_Status, Btree.Extract, RList, Make.List
DECLARE FUNCTION Set_Printer,Get_Printer,Msg, Get_Status, Dialog_Box, obj_Install
DECLARE FUNCTION FieldCount,Get_Status,Set_Status,Set_FSError,Printer_Select
$INSERT OIPRINT_EQUATES
$INSERT RDS_EQU
$INSERT WO_MAT_EQUATES
$INSERT APPCOLORS
EQU CRLF TO \0D0A\ ;* CHAR(13):CHAR(10) for multiline messages
EQU TAB TO CHAR(9) ;* TAB character
ErrorTitle = 'Error in Store Procedure Print_ReadyToShip'
OPEN 'WO_MAT' TO WOMatTable ELSE
ErrorMsg = 'Unable to Open "WO_MAT" table!'
Set_Status(1,ErrorTitle:@SVM:ErrorMsg)
RETURN
END
OPEN 'DICT.WO_MAT' TO @DICT ELSE
ErrorMsg = 'Unable to Open "DICT.WO_MAT" table!'
Set_Status(1,ErrorTitle:@SVM:ErrorMsg)
RETURN
END
Results = Dialog_Box( 'RDS_SRPT2', @WINDOW, '' )
IF Results = 'CANCEL' OR Results = '' THEN RETURN
StartDt = Results[1,'*']
EndDt = Results[COL2()+1,'*']
SelectSent = 'SELECT WO_MAT WITH CURR_STATUS = "RTS" "SHOLD" '
HeaderDateLine = ''
BEGIN CASE
CASE EndDt = '' AND StartDt NE ''
SelectSent := ' AND WITH COMMIT_DT GE ':QUOTE(StartDt)
HeaderDateLine = 'Final Commit Dates from ':StartDt:' through ':OCONV(Date(),'D4/')
CASE StartDt = '' AND EndDT NE ''
SelectSent := ' AND WITH COMMIT_DT LE ':QUOTE(EndDt)
HeaderDateLine = 'Final Commit Dates Through ':EndDt
CASE EndDt NE '' AND StartDt NE ''
SelectSent := 'AND WITH COMMIT_DT FROM ':QUOTE(StartDt):' TO ':QUOTE(EndDt)
HeaderDateLine = 'Final Commit Dates from ':StartDt:' through ':EndDt
CASE 1
HeaderDateLine = 'With all Commit Dates'
END CASE
SelectSent := ' BY-DSND SHIP_STATUS BY CUST_NAME BY WO_NO '
Set_Status(0)
EQU TARGET_ACTIVELIST$ TO 5
RList(SelectSent, TARGET_ACTIVELIST$, "", "", "")
IF Get_Status(errCode) THEN
ErrMsg(errCode)
RETURN
END
**START PRINTING PROCESS**
FileName = 'Print Ready To Ship'
Title = 'Printing Ready To Ship':@VM:'Report'
TopMargin = 1.0
BottomMargin = 1.0
LeftMargin = 0.5
RightMargin = 0.5
Margins = LeftMargin:@FM:TopMargin:@FM:RightMargin:@FM:BottomMargin
PageSetup = '1' ;* Portrait
PrintSetup = ''
PrintSetup<1,1> = '2' ;* Preview Normal
PrintSetup<1,2> = '5' ;* Display all buttons except Printer Setup
PrintSetup<1,3> = '0' ;* Display Printing Window
PrintSetup<1,6> = '7' ;* Preview window - keyboard and mouse support
PrintPath = Printer_Select('',1) ;* Get Default printer path
PDFParms = FileName:@FM: '' :@FM:'':@FM: ''
stat = Set_Printer("INIT",FileName,Title,Margins,PageSetup,PrintSetup,PrintPath)
IF stat < 0 THEN GOTO OIPrint_Err
Header = @VM:obj_Install('Get_Prop','CompTitle'):' Ready To Ship Report'
Header<2> = @VM:HeaderDateLine
Header<3> = ''
font = 'Arial'
font<2> = '10'
font<4> = 1 ;* Bold
stat = Set_Printer("FONTHEADFOOT", font)
stat = Set_Printer("HEADER",Header)
footer = " 'D' 'T'":@VM:@VM:" Page: 'P'"
colfooter = " "
stat = Set_Printer("FOOTER",footer,colfooter)
@RECCOUNT = 0
FirstPass = 1
LastRecord = 0
ReadErr = 0
FirstLine = 1
* * * * * * *
READRECORD:
* * * * * * *
READNEXT @ID ELSE
LastRecord = 1
END
IF FirstPass AND LastRecord THEN
GOTO Bail
END
READO @RECORD FROM WOMatTable,@ID ELSE
stat = Set_Printer('TEXT', 'Unable to read record ':QUOTE(@ID):' from WO_MAT table.')
GOTO READRECORD
END
IF @RECORD<WO_MAT_EPO_MAKEUP_BOX$> = 1 THEN
GOTO READRECORD ;* EpiPRO makeup box -> skip it
END
@RECCOUNT += 1
CustName = {CUST_NAME}
CustPartNo = {CUST_PART_NO}
LotNo = {LOT_NO}
WoNo = {WO_NO}
RDSNo = {SHIP_RDS}
CassNo = {CASS_NO}
SAPBatchNo = @RECORD<WO_MAT_SAP_BATCH_NO$>
FinalCommDt = OCONV({COMMIT_DT},'D4/')
ShipPartial = OCONV({SHIP_PARTIAL},'B')
HoldStatus = {HOLD_STATUS}
HotLot = Xlate('WO_LOG', {WO_NO}, 'HOT_FLAG', 'X')
HotLot = OCONV(HotLot,'B')
CurrLoc = {CURR_LOCATION}
*CurrStatus = {CURR_STATUS}
CurrStatus = {SHIP_STATUS}
IF INDEX(CurrStatus,@VM,1) THEN
CurrStatus = CurrStatus[-1,'B':@VM]
END
CurrStatus = OCONV(CurrStatus,'[WO_MAT_CURR_STATUS_CONV]')
*IF CurrStatus NE 'RTS' THEN GOTO READRECORD
colHeader = 'Customer' ; colFmt = '<+2710'
colHeader<1,2> = 'Cust Part No' ; colFmt<1,2> = '<+1620'
colHeader<1,3> = 'Lot Number' ; colFmt<1,3> = '<+1260'
colHeader<1,4> = 'WO No' ; colFmt<1,4> = '<+900'
colHeader<1,5> = 'Batch No' ; colFmt<1,5> = '^+1080'
colHeader<1,6> = 'RDS No' ; colFmt<1,6> = '^+900'
colHeader<1,7> = 'Run':CRLF:'Ord':CRLF:'No' ; colFmt<1,7> = '^+540'
colHeader<1,8> = 'Final':CRLF:'Commit':CRLF:'Date' ; colFmt<1,8> = '^+1080'
colHeader<1,9> = 'Ship':CRLF:'Partl' ; colFmt<1,9> = '^+540'
colHeader<1,10> = 'Hold' ; colFmt<1,10> = '^540'
colHeader<1,11> = 'Hot':CRLF:'Lot' ; colFmt<1,11> = '^+540'
colHeader<1,12> = 'Status' ; colFmt<1,12> = '^1440'
colHeader<1,13> = 'Curr':CRLF:'Location' ; colFmt<1,13> = '<+900'
colData = CustName
colData<1,2> = CustPartNo
colData<1,3> = LotNo
colData<1,4> = WoNo
colData<1,5> = SAPBatchNo
colData<1,6> = RDSNo
colData<1,7> = CassNo
colData<1,8> = FinalCommDt
colData<1,9> = ShipPartial
colData<1,10> = HoldStatus
colData<1,11> = HotLot
colData<1,12> = CurrStatus
colData<1,13> = CurrLoc
fontSpacing = 150
GOSUB PrintTable
IF LastRecord THEN
GOTO Bail
END
* * * * * * *
DETAIL:
* * * * * * *
GOTO READRECORD
* * * * * *
Bail:
* * * * * *
stat = Set_Printer("TERM",1) ;* Terminiate this printing session
IF stat < 0 THEN GOTO OIPrint_Err
Utility('CURSOR','A')
RETURN
* * * * * * *
OIPrint_Err:
* * * * * * *
*Set Error for OIPrint function and return to calling procedure
Msg('',stat)
Error_Msg = 'Set_Printer Returned Error Status: ':QUOTE(stat)
IF Get_Status(errCode) THEN
Stat = Set_Status(-1,'STPROC',ErrorTitle:@SVM:Error_Msg)
END ELSE
Stat = Set_Status(1,'STPROC',ErrorTitle:@SVM:Error_Msg)
END
stat = Set_Printer('TERM',1)
RETURN
* * * * * *
PrintTable:
* * * * * *
stat = Set_Printer('CALCTABLE',colFmt:@FM:colData)
TableSize = Get_Printer('CALCTABLE')
TableHeight = TableSize<2>
Test = Get_Printer('POS')<2>
IF Get_Printer('POS')<2> + TableHeight > 6.50 OR FirstLine THEN
IF NOT(FirstLine) THEN
stat = Set_Printer('PAGEBREAK')
END
FirstLine = 0
font<2> = 8
font<4> = 1 ;* Bold
stat = Set_Printer('FONT',font,'100')
stat = Set_Printer('ADDTABLE',colFmt,colHeader,'',LTGREY$,'',0,TB_ALL)
font<4> = 0
stat = Set_Printer('FONT',font,fontSpacing)
stat = Set_Printer('ADDTABLE',colFmt,'',colData,LTGREY$,'',0,7)
END ELSE
font<2> = 8
font<4> = 0
stat = Set_Printer('FONT',font,fontSpacing)
stat = Set_Printer('ADDTABLE',colFmt,'',colData,LTGREY$,'',1,TB_ALL)
END
RETURN