COMPILE ROUTINE Fix_SAP_Comm(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE obj_Schedule,Send_Dyn,Send_Info
DECLARE FUNCTION Get_Status, Set_Printer, obj_WO_Mat


$INSERT WO_MAT_EQUATES

OPEN 'SAP_COMM' TO FileIn ELSE
	DEBUG
	GOTO Bail
END

SELECT FileIn

DEBUG

Done = 0
LOOP
	READNEXT Seq ELSE Done = 1
UNTIL Done
	READ SapRec FROM FileIn,Seq THEN
		IF SapRec<1> = 'CASS_COMP' THEN
			
			WONo = SAPRec<3>
			CassNo = SAPRec<4>
			
			WOMatRec = XLATE('WO_MAT',WONo:'*':CassNo,'','X')
			
			IF WOMatRec<WO_MAT_MAKEUP_BOX$> THEN
				DELETE FileIn,Seq THEN
					Send_Dyn(Seq:' ':WONo:'*':CassNo:' removed')
				END
			END ELSE
			
				WfrCnt = obj_WO_Mat('CurrWaferCnt',WONo:'*':CassNo:@RM:WOMatRec:@RM:1)
				SapRec<5> = WfrCnt
			
				WRITE SapRec ON FileIn,Seq THEN
					Send_Dyn(WONo:'*':CassNo:' ':WfrCnt)
				END
			END
			
		END
	END
REPEAT



* * * * * * *
Bail:
* * * * * * *

END
