COMPILE FUNCTION Comm_Dialog_WO_Find(Method, Parm1) /* Commuter module for Dialog_WO_Find window. 01/14/2005 - John C. Henry, J.C. Henry & Co., Inc. */ DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, ErrMsg, Btree.Extract, Msg, Send_Info DECLARE SUBROUTINE obj_Appwindow, Start_Window DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility, Send_Message, Popup, Collect.IXVals, Msg DECLARE FUNCTION SRP_Array $INSERT LOGICAL $INSERT PS_EQUATES $INSERT POPUP_EQUATES $INSERT MSG_EQUATES $INSERT WO_LOG_EQUATES $INSERT WO_STEP_EQUATES $INSERT WO_MAT_EQUATES EQU CRLF$ TO \0D0A\ EQU COL$CUST_NO TO 1 ;* Customer edit table column equates EQU COL$CUST_NAME TO 2 EQU COL$REACT_TYPE TO 1 EQU LTGREY$ TO 229 + (229*256) + (229*65536) ;* JCH standard colors for edittable backgrounds EQU GREY$ TO 192 + (192*256) + (192*65536) EQU GREEN$ TO 192 + (220*256) + (192*65536) EQU RED$ TO 255 + (128*256) + (128*65536) EQU BLUE$ TO 128 + (255*256) + (255*65536) EQU WHITE$ TO 255 + (255*256) + (255*65536) EQU YELLOW$ TO 255 + (255*256) + (202*65536) EQU LTBLUE$ TO 128 + (255*256) + (255*65536) EQU PURPLE$ TO 225 + (181*256) + (255*65536) EQU DTS_MULTIROW$ TO 512 EQU DTS_LARGEDATA$ TO 4096 ErrTitle = 'Error in Comm_Dialog_Order_Find' ErrorMsg = '' Result = '' BEGIN CASE CASE Method = 'Create' ; GOSUB Create CASE Method = 'CustChar' ; GOSUB CustChar CASE Method = 'CustPC' ; GOSUB CustPC CASE Method = 'CustDC' ; GOSUB CustDC CASE Method = 'CustPNDC' ; GOSUB CustPNDC CASE Method = 'SubPNDC' ; GOSUB SubPNDC CASE Method = 'LotNoDC' ; GOSUB LotNoDC CASE Method = 'PSNoDC' ; GOSUB PSNoDC CASE Method = 'ReactTypeDC' ; GOSUB ReactTypeDC CASE Method = 'LUDate' ; GOSUB LUDate CASE Method = 'Cancel' ; GOSUB Cancel CASE Method = 'Refresh' ; GOSUB Refresh CASE Method = 'PerformQuery' ; GOSUB PerformQuery CASE Otherwise$ ErrMsg(ErrTitle:@SVM:'Unknown method ':QUOTE(Method):' passed to routine.') END CASE RETURN Result * * * * * * * Create: * * * * * * * obj_AppWindow('Create') Set_Property(@WINDOW,'STATUSLINE',@WINDOW:'.STATUSLINE_FIX') GOSUB Refresh RETURN * * * * * * * Refresh: * * * * * * * * Turn edit table symbolic column backgrounds to green stat = Send_Message(@WINDOW:'.CUST_INFO','COLOR_BY_POS',COL$CUST_NAME,0,GREEN$) ;* Turn names column all rows green RETURN * * * * * * * CustChar: * * * * * * * CtrlName = @WINDOW:'.CUST_INFO' CustArray = Get_Property(CtrlName,'ARRAY') ;* Customer Information table CurrPos = Get_Property(CtrlName,'SELPOS') CurrRow = CurrPos<2> DataIn = CustArray IF LEN(DataIn) > 2 THEN ReturnToCtrl = CtrlName ReturnToPos = CurrPos IF NOT(NUM(DataIn)) THEN Set_Property(CtrlName,'CELLPOS','',CurrPos) ;* Clear characters input Start_Window('COMP_LOOKUP',@WINDOW,DataIn:@VM:'C':@FM:ReturnToCtrl:@FM:ReturnToPos,'','') END END RETURN * * * * * * * CustPC: * * * * * * * CtrlName = @WINDOW:'.CUST_INFO' CustList = Get_Property(CtrlName,'LIST') ;* Customer Information table CurrPos = Get_Property(CtrlName,'SELPOS') CurrCol = CurrPos<1> CurrRow = CurrPos<2> CustNo = CustList IF CustNo NE '' THEN Set_Property(CtrlName,'CELLPOS',XLATE('COMPANY',CustNo,4,'X'),COL$CUST_NAME:@FM:CurrRow) END RETURN * * * * * * * CustDC: * * * * * * * CtrlName = @WINDOW:'.CUST_INFO' CustList = Get_Property(CtrlName,'LIST') ;* Customer Information table CurrPos = Get_Property(CtrlName,'SELPOS') CurrCol = CurrPos<1> CurrRow = CurrPos<2> CustNo = CustList LineCnt = COUNT(CustList,@FM) + (CustList NE '') IF CustNo = '' THEN CustNos = Popup(@WINDOW,'','CUSTOMER') CustCnt = COUNT(CustNos,@VM) + (CustNos NE '') IF CustCnt > LineCnt THEN FOR I = 1 TO CustCnt stat = Send_Message(CtrlName,'INSERT',-1,@VM:@FM) ; * Add blank lines NEXT I END FOR I = CurrRow TO CurrRow + CustCnt CustNo = CustNos<1,I> CustName = XLATE('COMPANY',CustNo,4,'X') Set_Property(CtrlName,'CELLPOS',CustNo,COL$CUST_NO:@FM:I) Set_Property(CtrlName,'CELLPOS',CustName,COL$CUST_NAME:@FM:I) Set_Property(CtrlName,'SELPOS',COL$CUST_NO:@FM:I+1) NEXT I END ELSE ErrMsg('DoubleClick on the first empty Cust No field to view a popup of all Customers') END RETURN * * * * * * * SubPNDC: * * * * * * * CustArray = Get_Property(@WINDOW:'.CUST_INFO','ARRAY') CustNos = CustArray LOOP LastCustNo = CustNos[-1,'B':@VM] UNTIL LastCustNo NE '' OR CustNos = '' CustNos[COL1(),99] = '' ;* Trim trailing blanks REPEAT IF CustNos = '' THEN RETURN * display the processing message and do the processing Def = "" Def = "Selecting Substrate Part Numbers..." Def = "U" MsgUp = Msg(@window, Def) OPEN 'DICT.WO_LOG' TO DictVar THEN SearchString = 'CUST_NO':@VM:CustNos:@VM:@FM SearchString := 'SUB_PART_NO':@VM:'#':@FM Btree.Extract(SearchString, 'WO_LOG', DictVar, WOKeys, '', Flag) IF Get_Status(errCode) THEN Msg(@WINDOW,MsgUp) ErrMsg(errCode) RETURN END IF WOKeys NE '' THEN RawPartNos = XLATE('WO_LOG',WOKeys,'SUB_PART_NO','X') ;* Calculated field IF Get_Status(errCode) THEN ErrMsg(errCode) PartNos = '' FOR I = 1 TO COUNT(RawPartNos,@VM) + (RawPartNos NE '') RawPartNo = RawPartNos<1,I> LOCATE RawPartNo IN PartNos BY 'AL' USING @VM SETTING Pos ELSE PartNos = INSERT(PartNos,1,Pos,0,RawPartNo) END NEXT I END ELSE PartNos = '' END Msg(@WINDOW,MsgUp) IF PartNos = '' THEN ErrMsg('No Substrate Part Numbers on file for specified customer.') RETURN END PartNos := @VM CONVERT @VM TO @RM IN PartNos CALL V119('S','','D','R',PartNos,'') IF Get_Status(errCode) THEN ErrMsg(errCode) CONVERT @RM TO @VM IN PartNos PartNos[-1,1] = '' ;* Strip trailing delimiter TypeOver = '' TypeOver = PartNos PartNos = Popup(@WINDow,TypeOver,'CUST_PO') ;****** Need a popup IF Get_Status(errCode) THEN ErrMsg(errCode) IF PartNos NE '' THEN Set_Property(@WINDOW:'.SUB_PART_NO','DEFPROP',PartNos) END END ELSE ErrMsg('Unable to open DICT.WO_LOG in COMM_DIALOG_WO_LOG_FIND.') END RETURN * * * * * * * LotNoDC: * * * * * * * CustNos = Get_Property(@WINDOW:'.CUST_INFO','ARRAY') LOOP LastCustNo = CustNos[-1,'B':@VM] UNTIL LastCustNo NE '' OR CustNos = '' CustNos[COL1(),99] = '' ;* Trim trailing blanks REPEAT IF CustNos = '' THEN RETURN * display the processing message and do the processing Def = "" Def = "Selecting Lot Numbers..." Def = "U" MsgUp = Msg(@window, Def) OPEN 'DICT.WO_LOG' TO DictVar THEN SearchString = 'CUST_NO':@VM:CustNos:@VM:@FM SearchString := 'LOT_NO':@VM:'#':@FM Btree.Extract(SearchString, 'WO_LOG', DictVar, WOKeys, '', Flag) IF Get_Status(errCode) THEN Msg(@WINDOW,MsgUp) ErrMsg(errCode) RETURN END IF WOKeys NE '' THEN RawLotNos = XLATE('WO_LOG',WOKeys,'LOT_NO','X') ;* Calculated field IF Get_Status(errCode) THEN ErrMsg(errCode) LotNos = '' FOR I = 1 TO COUNT(RawLotNos,@VM) + (RawLotNos NE '') RawLotNo = RawLotNos<1,I> LOCATE RawLotNo IN LotNos BY 'AL' USING @VM SETTING Pos ELSE LotNos = INSERT(LotNos,1,Pos,0,RawLotNo) END NEXT I END ELSE LotNos = '' END Msg(@WINDOW,MsgUp) IF LotNos = '' THEN ErrMsg('No Lot Numbers on file for specified customer.') RETURN END LotNos := @VM CONVERT @VM TO @RM IN LotNos CALL V119('S','','D','R',LotNos,'') IF Get_Status(errCode) THEN ErrMsg(errCode) CONVERT @RM TO @VM IN LotNos LotNos[-1,1] = '' ;* Strip trailing delimiter TypeOver = '' TypeOver = LotNos LotNos = Popup(@WINDow,TypeOver,'CUST_PO') ;****** Need a popup IF Get_Status(errCode) THEN ErrMsg(errCode) IF LotNos NE '' THEN Set_Property(@WINDOW:'.LOT_NO','DEFPROP',LotNos) END END ELSE ErrMsg('Unable to open DICT.WO_LOG in COMM_DIALOG_WO_LOG_FIND.') END RETURN * * * * * * * PSNoDC: * * * * * * * CustArray = Get_Property(@WINDOW:'.CUST_INFO','ARRAY') CustNos = CustArray LOOP LastCustNo = CustNos[-1,'B':@VM] UNTIL LastCustNo NE '' OR CustNos = '' CustNos[COL1(),99] = '' ;* Trim trailing blanks REPEAT IF CustNos = '' THEN RETURN * display the processing message and do the processing Def = "" Def = "Selecting Product Specifications..." Def = "U" MsgUp = Msg(@window, Def) OPEN 'DICT.WO_LOG' TO DictVar THEN SearchString = 'CUST_NO':@VM:CustNos:@VM:@FM SearchString := 'PS_NO':@VM:'#':@FM Btree.Extract(SearchString, 'WO_LOG', DictVar, WOKeys, '', Flag) IF Get_Status(errCode) THEN Msg(@WINDOW,MsgUp) ErrMsg(errCode) RETURN END IF WOKeys NE '' THEN PSNs = '' FOR N = 1 TO COUNT(WOKeys,@VM) + (WOKeys NE '') WOKey = WOKeys<1,N> RawPSNs = XLATE('WO_LOG',WOKey,'PS_NO','X') FOR I = 1 TO COUNT(RawPSNs,@VM) + (RawPSNs NE '') RawPSN = RawPSNs<1,I> LOCATE RawPSN IN PSNs BY 'AL' USING @VM SETTING Pos ELSE PSNs = INSERT(PSNs,1,Pos,0,RawPSN) END NEXT I NEXT N END ELSE PSNs = '' END Msg(@WINDOW,MsgUp) IF PSNs = '' THEN ErrMsg('No Product Specifications on file for specified customer.') RETURN END PSNs := @VM CONVERT @VM TO @RM IN PSNs CALL V119('S','','D','R',PSNs,'') IF Get_Status(errCode) THEN ErrMsg(errCode) CONVERT @RM TO @VM IN PSNs PSNs[-1,1] = '' ;* Strip trailing delimiter TypeOver = '' TypeOver = PSNs PSNs = Popup(@WINDow,TypeOver,'CUST_PO') IF Get_Status(errCode) THEN ErrMsg(errCode) IF PSNs NE '' THEN CONVERT @VM TO @FM IN PSNs Set_Property(@WINDOW:'.PS_NO','LIST',PSNs) END END ELSE ErrMsg('Unable to open DICT.WO_LOG in COMM_DIALOG_WO_LOG_FIND.') END RETURN * * * * * * * ReactTypeDC: * * * * * * * CtrlName = @WINDOW:'.REACT_TYPE' RTypeList = Get_Property(CtrlName,'LIST') ;* Customer Information table CurrPos = Get_Property(CtrlName,'SELPOS') CurrCol = CurrPos<1> CurrRow = CurrPos<2> RType = RTypeList LineCnt = COUNT(RTypeList,@FM) + (RTypeList NE '') IF RType = '' THEN RTypes = Popup(@WINDOW,'','REACTOR_TYPE') rCnt = COUNT(RTypes,@VM) + (RTypes NE '') IF rCnt > LineCnt THEN FOR I = 1 TO rCnt stat = Send_Message(CtrlName,'INSERT',-1,@VM:@FM) ; * Add blank lines NEXT I END FOR I = CurrRow TO CurrRow + rCnt RType = RTypes<1,I> Set_Property(CtrlName,'CELLPOS',RType,COL$REACT_TYPE:@FM:I) NEXT I END ELSE ErrMsg('DoubleClick on the first empty Cust No field to view a popup of all Customers') END RETURN * * * * * * * CustPNDC: * * * * * * * CustArray = Get_Property(@WINDOW:'.CUST_INFO','ARRAY') CustNos = CustArray LOOP LastCustNo = CustNos[-1,'B':@VM] UNTIL LastCustNo NE '' OR CustNos = '' CustNos[COL1(),99] = '' ;* Trim trailing blanks REPEAT IF CustNos = '' THEN RETURN * display the processing message and do the processing Def = "" Def = "Selecting Part Numbers..." Def = "U" MsgUp = Msg(@window, Def) OPEN 'DICT.WO_LOG' TO DictVar THEN SearchString = 'CUST_NO':@VM:CustNos:@VM:@FM SearchString := 'CUST_PART_NO':@VM:'#':@FM Btree.Extract(SearchString, 'WO_LOG', DictVar, WOKeys, '', Flag) IF Get_Status(errCode) THEN Msg(@WINDOW,MsgUp) ErrMsg(errCode) RETURN END IF WOKeys NE '' THEN PartNos = '' FOR N = 1 TO COUNT(WOKeys,@VM) + (WOKeys NE '') WOKey = WOKeys<1,N> RawPartNos = XLATE('WO_LOG',WOKey,'PART_NO','X') FOR I = 1 TO COUNT(RawPartNos,@VM) + (RawPartNos NE '') RawPartNo = RawPartNos<1,I> LOCATE RawPartNo IN PartNos BY 'AL' USING @VM SETTING Pos ELSE PartNos = INSERT(PartNos,1,Pos,0,RawPartNo) END NEXT I NEXT N END ELSE PartNos = '' END Msg(@WINDOW,MsgUp) IF PartNos = '' THEN ErrMsg('No Customer Part Numbers on file for specified customer.') RETURN END PartNos := @VM CONVERT @VM TO @RM IN PartNos CALL V119('S','','D','R',PartNos,'') IF Get_Status(errCode) THEN ErrMsg(errCode) CONVERT @RM TO @VM IN PartNos PartNos[-1,1] = '' ;* Strip trailing delimiter TypeOver = '' TypeOver = PartNos PartNos = Popup(@WINDow,TypeOver,'CUST_PO') ;* Needs a popup IF Get_Status(errCode) THEN ErrMsg(errCode) IF PartNos NE '' THEN Set_Property(@WINDOW:'.CUST_PART_NO','DEFPROP',PartNos) END END ELSE ErrMsg('Unable to open DICT.WO_LOG in COMM_DIALOG_WO_LOG_FIND.') END RETURN * * * * * * * LUDate: * * * * * * * ReturnCtrl = Parm1[1,@RM] IF ReturnCtrl = '' THEN ReturnCtrl = Get_Property(@WINDOW,'FOCUS') DateSelected = Dialog_Box('POPUP_YEAR',@WINDOW) RetVal = OCONV(DateSelected, 'D4/') obj_Appwindow('LUValReturn',RetVal:@RM:ReturnCtrl) RETURN * * * * * * * Cancel: * * * * * * * RETURN * * * * * * * PerformQuery: * * * * * * * SearchString = '' CustNos = Get_Property(@WINDOW:'.CUST_INFO','ARRAY') CustNos = SRP_Array('Clean', CustNos, 'TrimAndMakeUnique', @VM) IF CustNos NE '' THEN SearchString := 'CUST_NO':@VM:CustNos:@FM CustPNs = Get_Property(@WINDOW:'.CUST_PART_NO','ARRAY')<1> CustPNs = SRP_Array('Clean', CustPNs, 'TrimAndMakeUnique', @VM) IF CustPNs NE '' THEN SearchString := 'CUST_PART_NO':@VM:CustPNs:@FM SubPartNos = Get_Property(@WINDOW:'.SUB_PART_NO','ARRAY')<1> SubPartNos = SRP_Array('Clean', SubPartNos, 'TrimAndMakeUnique', @VM) IF SubPartNos NE '' THEN SearchString := 'ORD_SUB_PART_NO':@VM:SubPartNos:@FM ReactTypes = Get_Property(@WINDOW:'.REACT_TYPE','ARRAY') ReactTypes = SRP_Array('Clean', ReactTypes, 'TrimAndMakeUnique', @VM) IF ReactTypes NE '' THEN SearchString := 'REACT_TYPE':@VM:ReactTypes:@FM StartDt = ICONV(Get_Property(@WINDOW:'.START_DT','TEXT'),'D') EndDt = ICONV(Get_Property(@WINDOW:'.END_DT','TEXT'),'D') BEGIN CASE CASE StartDt NE '' AND EndDt = '' SearchString := 'ENTRY_DATE':@VM:'>=':StartDt:@FM CASE StartDt = '' AND EndDt NE '' SearchString := 'ENTRY_DATE':@VM:'<=':EndDt:@FM CASE StartDt NE '' AND EndDt NE '' // Modify the dates by one day. The '~' operator is not inclusive of the end dates. StartDt -= 1 EndDt += 1 SearchString := 'ENTRY_DATE':@VM:StartDt:'~':EndDt:@FM CASE Otherwise$ NULL END CASE StartDt = ICONV(Get_Property(@WINDOW:'.MTL_RX_START_DT','TEXT'),'D') EndDt = ICONV(Get_Property(@WINDOW:'.MTL_RX_END_DT','TEXT'),'D') OrdStatus = Get_Property(@WINDOW:'.STATUS','VALUE') IF OrdStatus NE 'I' THEN IF OrdStatus = 1 THEN SearchString := 'CLOSE_DATE':@VM:'#':@FM END ELSE SearchString := 'CLOSE_DATE':@VM:'=':@FM END END WONos = '' If SearchString NE '' then OPEN 'DICT.WO_LOG' TO DictVar THEN Btree.Extract(SearchString,'WO_LOG',DictVar,WOKeys,'',flag) IF Get_Status(errCode) THEN ErrorMsg = 'Error querying WO_LOG table with supplied fields.' end END ELSE ErrMsg('Unable to open DICT.WO_LOG in routine COMM_DIALOG_WO_LOG_FIND') END end LotNos = Get_Property(@WINDOW:'.LOT_NO','ARRAY')<1> LotNos = SRP_Array('Clean', LotNos, 'TrimAndMakeUnique', @VM) If LotNos NE '' then Query = 'LOT_NO':@VM:LotNos:@FM dWoMat = '' WOMatWONos = '' Open 'DICT.WO_MAT' to dWoMat then Flag = '' WOMatKeys = '' Btree.Extract(Query, 'WO_MAT', dWoMat, WOMatKeys, 'E', Flag) If Not(Get_status(errCode)) then If WOMatKeys NE '' then WOMatWONos = SRP_Array('Rotate', WOMatKeys, @VM, '*') WOMatWONos = Delete(WOMatWONos, 0, 2, 0) Convert '*' to @VM in WOMatWONos WOMatWONos = SRP_Array('Clean', WOMatWONos, 'TrimAndMakeUnique', @VM) WOKeys = SRP_Array('Join', WOKeys, WOMatWONos, 'OR', @VM) end end else ErrorMsg = 'Error querying LOT_NO field of the WO_MAT table.' end end else ErrorMsg = 'Error opening DICT.WO_MAT table in order to query on LOT_NO field' end end PSNos = Get_Property(@WINDOW:'.PS_NO','ARRAY')<1> PSNos = SRP_Array('Clean', PSNos, 'TrimAndMakeUnique', @VM) If PSNos NE '' then Query = 'PROD_SPEC_ID':@VM:PSNos:@FM dWOStep = '' WOStepWONos = '' Open 'DICT.WO_STEP' to dWOStep then Flag = '' WOStepKeys = '' Btree.Extract(Query, 'WO_STEP', dWOStep, WOStepKeys, 'E', Flag) If Not(Get_Status(ErrCode)) then If WOStepKeys NE '' then WOStepWONos = SRP_Array('Rotate', WOStepKeys, @VM, '*') WOStepWONos = Delete(WOStepWONos, 0, 2, 0) Convert '*' to @VM in WOStepWONos WOStepWONos = SRP_Array('Clean', WOStepWONos, 'TrimAndMakeUnique', @VM) WOKeys = SRP_Array('Join', WOKeys, WOStepWONos, 'OR', @VM) end end else ErrorMsg = 'Error querying PROD_SPEC_ID field in WO_STEP table.' end end else ErrorMsg = 'Error opening DICT.WO_STEP table in order to query on PROD_SPEC_ID field. Error code: ':ErrCode end end If ( (StartDt NE '') or (EndDt NE '') ) then Begin Case Case ( (StartDt NE '') and (EndDt EQ '') ) Query = 'RX_DT':@VM:'>=':OConv(StartDt, 'D4/'):@FM Case ( (StartDt EQ '') and (EndDt NE '') ) Query = 'RX_DT':@VM:'<=':OConv(EndDt, 'D4/'):@FM Case ( (StartDt NE '') and (EndDt NE '') ) // Modify the dates by one day. The '~' operator is not inclusive of the end dates. StartDt -= 1 EndDt += 1 Query = 'RX_DT':@VM:OConv(StartDt, 'D4/'):'~':OConv(EndDt, 'D4/'):@FM End case dWOMat = '' WOMatWONos = '' Open 'DICT.WO_MAT' to dWOMat then Flag = '' WOMatKeys = '' Btree.Extract(Query, 'WO_MAT', dWOMat, WOMatKeys, 'E', Flag) If Not(Get_Status(ErrCode)) then If WOMatKeys NE '' then WOMatWONos = SRP_Array('Rotate', WOMatKeys, @VM, '*') WOMatWONos = Delete(WOMatWONos, 0, 2, 0) Convert '*' to @VM in WOMatWONos WOMatWONos = SRP_Array('Clean', WOMatWONos, 'TrimAndMakeUnique', @VM) WOKeys = SRP_Array('Join', WOKeys, WOMatWONos, 'OR', @VM) end end else ErrorMsg = 'Error querying on RX_DT field in WO_MAT table.' end end else ErrorMsg = 'Error opening DICT.WO_MAT table in order to query on RX_DT field.' end end If ErrorMsg EQ '' then WOKeys = SRP_Array('SortSimpleList', WOKeys, 'DescendingNumbers', @VM) End_Dialog(@WINDOW,WOKeys) end else Msg(@Window, '', 'OK', '', 'Process Error':@FM:ErrorMsg) end RETURN