COMPILE ROUTINE Import_Costing(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE obj_Schedule, RList,Send_Dyn, Print_Carton_Labels, Print_Cleanroom_Labels_Thermal
DECLARE FUNCTION Get_Status,Security_Check


$INSERT PROD_SPEC_EQU

OPEN 'PROD_SPEC' TO ProdSpecTable ELSE
	DEBUG
	GOTO Bail
END


DosFile = 'P:\JCHenry\PSNCost.CSV'
FileSize = Dir(DosFile)<1>

OSOPEN DosFile TO FileIn ELSE
	debug
	GOTO Bail
END

OffSet = 0

OSClose FileIn

OSBRead RawData FROM FileIn AT OffSet LENGTH FileSize

SWAP CHAR(13):CHAR(10) WITH @FM IN RawData
SWAP ' - ' WITH '  ' IN RawData

Result = ''

FOR I = 5 TO COUNT(RawData,@FM) + (RawData NE '')
	LineData = RawData<I>
	IF INDEX(LineData,'"',1) THEN
		IgnoreFlag = 0
		FOR C = 1 TO LEN(LineData)
			TestChar = LineData[C,1]
			IF TestChar = '"' THEN
				IgnoreFlag = NOT(IgnoreFlag)
			END 
			IF TestChar = ',' THEN
				IF NOT(IgnoreFlag) THEN
					LineData[C,1] = @VM
				END
			END
		NEXT C
		CONVERT '"' TO '' IN LineData
	END ELSE
		CONVERT ',' TO @VM IN LineData
	END
	
	
	IRFab		= TRIM(LineData<1,1>)
	PSN			= TRIM(LineData<1,2>)
	CustName	= TRIM(LineData<1,3>)
	
	Substrate	= ICONV(TRIM(LineData<1,4>),'MD2')
	StdOverHead	= ICONV(TRIM(LineData<1,5>),'MD2')
	StdCost		= ICONV(TRIM(LineData<1,6>),'MD2')
	
	IF StdCost NE '' THEN
		Result<-1> = PSN:@VM:IRFab:@VM:Substrate:@VM:StdOverHead:@VM:StdCost
		
		READ ProdSpecRec FROM ProdSpecTable,PSN THEN
			
			ProdSpecRec<PROD_SPEC_STD_OH_COST$> = StdOverHead 
			ProdSpecRec<PROD_SPEC_MTL_COST$>	= Substrate
			ProdSpecRec<PROD_SPEC_IR_FAB$>		= IRFab
			
			WRITE ProdSpecRec ON ProdSpecTable,PSN THEN
				Send_Dyn(PSN)
			END
			
			
			
		END ELSE
			DEBUG
		END
	END
NEXT I


GOTO Bail

/*
LOOP
	
	

readOffset = 0
writeOffset = 0
Loop
  OSBRead data From inputFileHandle At offset
           length RECSIZE$
Until data = NULL$
  offset += RECSIZE$
  state = data[STATE_START$, STATE_LEN$]
  Locate state in stateList Using COMMA$ setting POS Then
    * if state is listed then write to output file 
    OSWrite data On outputFileHandle At writeOffset 
           length RECSIZE$
    writeOffset += RECSIZE$
  End
Repeat
OSClose inputFileHandle
OSClose outputFileHandle
*/




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

RETURN
