compile subroutine print_coc_back_orig( LayerIds, SepLayCnt, Prelim )
begin condition 
pre:
post:
end condition
$insert company_equ
$insert coc_equ
$insert logical
$insert lsl_users_equ
$insert msg_equates
$insert popup_equates
$insert rds_equ
$insert rds_layer_info_equ
$insert quote_equ
$insert quote_spec_equ
$insert oiprint_equates
$insert schedule_equ
$insert security_rights_equ
$insert prod_spec_equ
$insert srp_coc_results_equ

declare function fieldcount, msg, key_sort, set_printer, dialog_box, entid
declare function repository, next_key, security_check, calc_wo_stats
declare subroutine update_index, extract_si_keys, record_lock, security_err_msg
declare subroutine create_note, btree.extract
* 	THIS IS THE ID CODE NUMBER FOR FIRST WAFER INSPECTION OUT OF THE TW_CODES TABLE
equ FirstWaferInspection$ to 5

* i IS THE FIRST LOOP VAR AVAILABLE
TRdsRec = xlate( 'RDS', LayerIds<1,1>, '', 'X' )
Dopant = xlate( 'RDS', LayerIds<1,1>, 'DOPANT_L1', 'X' )
SuppliedBy = xlate( 'PROD_SPEC', xlate( 'RDS', LayerIDS<1,1>, rds_prod_spec_id$, 'X' ), 'SUB_SUPPLIED_BY', 'X' )
Font = "Courier New,9,L,1"
convert ',' to @fm in Font
Tfont = Font
Tfont<2> = 12
Tfont<3> = 'C'
Tfont<4> = 1
Void = set_printer( 'FONT', Tfont )
if Prelim then
    Void = set_printer( 'TEXT', 'PRELIMINARY WAFER SHIPMENT LIST' )    
end else
    Void = set_printer( 'TEXT', 'CERTIFICATE OF COMPLIANCE' )
end
Void = set_printer( 'TEXT', '' )
Void = set_printer( 'TEXT', '' )
Void = set_printer( 'TEXT', '' )    
stat = set_printer( 'LINESTYLE', ps_solid:@fm:5 )
stat = set_printer( 'LINE', 0:@fm:.25:@fm:7.5:@fm:.25, 0 )
stat = set_printer( 'LINESTYLE', ps_solid:@fm:0 )                
Tfont<3> = 'L'
Void = set_printer( 'FONT', Tfont )
Void = set_printer( 'TEXT', 'CUSTOMER: ':oconv( TRdsRec<rds_cust_no$>, '[XLATE_CONV,COMPANY*CO_NAME]' ) )
Tfont<3> = 'R'
Void = set_printer( 'FONT', Tfont )
Void = set_printer( 'TEXT', 'DATE:':oconv( date(), 'D2/' ) )
Tfont<3> = 'L'
Tfont<6> = 1 ;* underline
Void = set_printer( 'FONT', Tfont )
Void = set_printer( 'TEXT', 'P.O. NUMBER: ':TrdsRec<rds_po$> )
Void = set_printer( 'TEXT', 'W.O. NUMBER: ':TrdsRec<rds_wo$> )
Void = set_printer( 'TEXT', 'MFG Quote#: ':TrdsRec<rds_quote_no$> )
Tfont<2> = 9
Tfont<4> = 0
Tfont<1> = 'MS LineDraw'
Tfont<6> = 0 
Void = set_printer( 'FONT', Tfont )
Table = ''
Tline = ''
Table<1> = 'Dopant: ':Dopant:',Minimum,Target,Maximum'
TrueLayer = 1
for i = 1 to SepLayCnt
    ThisSepLayer  = xlate( 'RDS', LayerIds<i,1>, '', 'X' )
    Dopant        = xlate( 'RDS', LayerIds<i,1>, 'DOPANT_L1', 'X' )
    * load base layer
    Tline = ''
    if i = 1 else
        * print dopant for 2-zillion
        TrueLayer += 1
    	Tline = 'Layer ':TrueLayer:' Dopant: ':Dopant:',Minimum,Target,Maximum'
    	Table<-1> = TLine
    end
	Tline = 'Thickness,':fmt( oconv( ThisSepLayer<rds_thick_min$>, 'MD2' ), 'R#10'):' ':fmt( ThisSepLayer<rds_thick_units$>, 'R#4' ):','
	Tline:= fmt( oconv( ThisSepLayer<rds_thick_target$>, 'MD2' ),'R#10'):' ':fmt( ThisSepLayer<rds_thick_units$>, 'R#4' ):','
    Tline:= fmt( oconv( ThisSepLayer<rds_thick_max$>, 'MD2' ),'R#10'):' ':fmt( ThisSepLayer<rds_thick_units$>, 'R#4' )	
	Table<-1> = Tline
	Tline = 'Resistivity,':fmt( oconv( ThisSepLayer<rds_res_min$>, 'MD3' ),'R#10'):' ':fmt( ThisSepLayer<rds_res_units$>, 'R#4' ):','
	Tline:= fmt( oconv( ThisSepLayer<rds_res_target$>, 'MD3' ),'R#10'):' ':fmt( ThisSepLayer<rds_res_units$>, 'R#4' ):','
    Tline:= fmt( oconv( ThisSepLayer<rds_res_max$>, 'MD3' ),'R#10'):' ':fmt( ThisSepLayer<rds_res_units$>, 'R#4' )	
	Table<-1> = Tline
	Tline = 'Concentration,':fmt( oconv( ThisSepLayer<rds_con_min$,1>, 'MS21' ),'R#10'):' ':fmt( ThisSepLayer<rds_con_units$>, 'R#4' ):','
	Tline:= fmt( oconv( ThisSepLayer<rds_con_target$,1>, 'MS21' ),'R#10'):' ':fmt( ThisSepLayer<rds_con_units$>, 'R#4' ):','
    Tline:= fmt( oconv( ThisSepLayer<rds_con_max$,1>, 'MS21' ),'R#10'):' ':fmt( ThisSepLayer<rds_con_units$>, 'R#4' )
    Table<-1> = TLine
    if ThisSepLayer<rds_con_min$> then	
		Tline = ',':fmt( oconv( ThisSepLayer<rds_con_min$,2>, 'MS21' ),'R#10'):' ':fmt( ThisSepLayer<rds_con_units$>, 'R#4' ):','
		Tline:= fmt( oconv( ThisSepLayer<rds_con_target$,2>, 'MS21' ),'R#10'):' ':fmt( ThisSepLayer<rds_con_units$>, 'R#4' ):','
	    Tline:= fmt( oconv( ThisSepLayer<rds_con_max$,2>, 'MS21' ),'R#10'):' ':fmt( ThisSepLayer<rds_con_units$>, 'R#4' )
	end else
	    TLine = ',,,'
	end
    Table<-1> = TLine
    SameLayers = ThisSepLayer<rds_layer_info$> 
    SameLCnt = fieldcount( SameLayers, char(248) )
    for j = 1 to SameLCnt
        TSLay = field( SameLayers, char(248), j )
        TrueLayer += 1
       Dopant = xlate( 'RDS', LayerIds<i,1>, 'DOPANT_L':j+1, 'X' )
    	Tline = 'Layer ':TrueLayer:' Dopant: ':Dopant:',Minimum,Target,Maximum'
    	Table<-1> = TLine
   		Tline = 'Thickness,':fmt( oconv( TSLay<1,RLThickMin$>, 'MD2' ), 'R#10'):' ':fmt( TSLay<1,RLThickUnits$>, 'R#4' ):','
    	Tline:= fmt( oconv( TSLay<1,RLThickTarget$>, 'MD2' ),'R#10'):' ':fmt( TSLay<1,RLThickUnits$>, 'R#4' ):','
   	    Tline:= fmt( oconv( TSLay<1,RLThickMax$>, 'MD2' ),'R#10'):' ':fmt( TSLay<1,RLThickUnits$>, 'R#4' )	
    	Table<-1> = Tline
	    Tline = 'Resistivity,':fmt( oconv( TSLay<1,RLResMin$>, 'MD3' ),'R#10'):' ':fmt( TSLay<1,RLResUnits$>, 'R#4' ):','
	    Tline:= fmt( oconv( TSLay<1,RLResTarget$>, 'MD3' ),'R#10'):' ':fmt( TSLay<1,RLResUnits$>, 'R#4' ):','
        Tline:= fmt( oconv( TSLay<1,RLResMax$>, 'MD3' ),'R#10'):' ':fmt( TSLay<1,RLResUnits$>, 'R#4' )	
	    Table<-1> = Tline
        Tline = 'Concentration,':fmt( oconv( TSLay<1,RLConMin$,1>, 'MS21' ),'R#10'):' ':fmt( TSLay<1,RLConUnits$>, 'R#4' ):','
	    Tline:= fmt( oconv( TSLay<1,RLConTarget$,1>, 'MS21' ),'R#10'):' ':fmt( TSLay<1,RLConUnits$>, 'R#4' ):','
        Tline:= fmt( oconv( TSLay<1,RLConMax$,1>, 'MS21' ),'R#10'):' ':fmt( TSLay<1,RLConUnits$>, 'R#4' )
        Table<-1> = TLine	
        if TSLay<1,RlConMin$,1> then
		    Tline = ',':fmt( oconv( TSLay<1,RLConMin$,2>, 'MS21' ),'R#10'):' ':fmt( TSLay<1,RLConUnits$>, 'R#4' ):','
		    Tline:= fmt( oconv( TSLay<1,RLConTarget$,2>, 'MS21' ),'R#10'):' ':fmt( TSLay<1,RLConUnits$>, 'R#4' ):','
	        Tline:= fmt( oconv( TSLay<1,RLConMax$,2>, 'MS21' ),'R#10'):' ':fmt( TSLay<1,RLConUnits$>, 'R#4' )
	    end else
	        TLine = ',,,'
	    end
        Table<-1> = TLine
    next j	
next i
convert ',' to @vm in Table
TableColInfo = '<+4320':@vm:'^+2160':@vm:'^+2160':@vm:'^+2160'
x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
Void = set_printer( 'TEXT', '' )
TFont = "Courier New,8,L,1"
convert ',' to @fm in TFont
Void = set_printer( 'FONT', Tfont )
LastSepLayIds = LayerIds<SepLayCnt>
LlCnt = fieldcount( LastSepLayIds, @vm )
Tcust = TRdsRec<rds_cust_no$>
if Prelim then
	Void = set_printer( 'TEXT', Lout )
	Lout = fmt( 'PART #', 'L#12' ):' '
	Lout:= fmt( 'LOT #', 'L#14' ):' '
	Lout:= fmt( 'RUN #', 'L#9' ):' '
	Lout:= fmt( 'QTY', 'L#5' ):' '
	Lout:= fmt( 'MFG Pre Epi Rej', 'L#15' ):' '
	Lout:= fmt( 'MFG Post Epi Rej', 'L#16' ):' '
	Lout:= fmt( 'Cust Pre Epi Rej', 'L#16' ):' '
	Lout:= fmt( 'Cust Post Epi Rej', 'L#17' )
	Void = set_printer( 'TEXT', Lout )
	Lout = '____________ ______________ _________ _____ _______________ ________________ ________________ _________________'
	Void = set_printer( 'TEXT', Lout )
	QtyOut = 0
	Tfont<4> = 0
	Void = set_printer( 'FONT', Tfont )
	for i = 1 to LlCnt
	    ThisRdsRec = xlate( 'RDS', LastSepLayIds<1,i>, '', 'X' )
	    Lout = fmt( ThisRdsRec<rds_part_num$>, 'L#12' ):' '
	    Lout:= fmt( ThisRdsRec<rds_lot_num$>, 'L#14' ):' '
	    Lout:= fmt( ThisRdsRec<rds_reactor$>:'-':LastSeplayIds<1,i>, 'L#9' ):' '
	    WafOut = ThisRdsRec<rds_wafers_out$>
	    Lout:= fmt( WafOut, 'R#5' ):' '
	    QtyOut += WafOut
	    Lout:= fmt( ThisRdsRec<rds_lsl_pre_epi_rej$>+0, 'R#15' ):' '
	    Lout:= fmt( ThisRdsRec<rds_lsl_post_epi_rej$>+0, 'R#16' ):' '
	    Lout:= fmt( ThisRdsRec<rds_cust_pre_epi_rej$>+0, 'R#16' ):' '
	    Lout:= fmt( ThisRdsRec<rds_cust_post_epi_rej$>+0, 'R#17' )
	    Void = set_printer( 'TEXT', Lout )
	next i
end else
 begin case
	case Tcust = '615' or Tcust = '6443'
		Lout = fmt( ' ', 'L#44' ):fmt( 'THICKNESS', 'C#15' ):fmt( '', 'L#2' ):fmt( 'RESISTIVITY', 'C#15' )
		Void = set_printer( 'TEXT', Lout )
		Lout = fmt( 'PART #', 'L#12' ):' '
		Lout:= fmt( 'LOT #', 'L#14' ):' '
		Lout:= fmt( 'RUN #', 'L#9' ):' '
		Lout:= fmt( 'QTY', 'L#5' ):' '
		Lout:= fmt( 'MEAN', 'L#8' ):' '
		Lout:= fmt( 'STDEV', 'L#8' ):' '
		Lout:= fmt( 'MEAN', 'L#8' ):' '
		Lout:= fmt( 'STDEV', 'L#8' ):' '
		Lout:= fmt( 'QXJ Pre','L#8' ):' '
		Lout:= fmt( 'QXJ Post','L#8' )
		Void = set_printer( 'TEXT', Lout )
		Lout = '____________ ______________ _________ _____ ________ ________ ________ ________ ________ ________'
		Void = set_printer( 'TEXT', Lout )
		QtyOut = 0
		Tfont<4> = 0
		Void = set_printer( 'FONT', Tfont )
		for i = 1 to LlCnt
		    ThisRdsRec = xlate( 'RDS', LastSepLayIds<1,i>, '', 'X' )
		    Lout = fmt( ThisRdsRec<rds_part_num$>, 'L#12' ):' '
		    Lout:= fmt( ThisRdsRec<rds_lot_num$>, 'L#14' ):' '
		    Lout:= fmt( ThisRdsRec<rds_reactor$>:'-':LastSeplayIds<1,i>, 'L#9' ):' '
		    WafOut = ThisRdsRec<rds_wafers_out$>
		    Lout:= fmt( WafOut, 'R#5' ):' '
		    QtyOut += WafOut
		    Lout:= fmt( oconv( ThisRdsRec<rds_tthick_avg$>, 'MD2' ), 'R#8' ):' '
		    Lout:= fmt( oconv( ThisRdsRec<rds_tthick_stdev$>, 'MD3' ), 'R#8' ):' '
		    Lout:= fmt( oconv( ThisRdsRec<rds_tres_avg$>, 'MD3' ), 'R#8' ):' '
		    Lout:= fmt( oconv( ThisRdsRec<rds_tres_stdev$>, 'MD3' ), 'R#8' ):' '
		    Lout:= fmt( oconv( ThisRdsRec<rds_qxj_pre$>, 'MD3' ), 'R#8' ):' '
		    Lout:= fmt( oconv( ThisRdsREc<rds_qxj_post$>, 'MD3' ), 'R#8' )
		    Void = set_printer( 'TEXT', Lout )
		next i
	case TCust = '621' ;* SSI
	   TempWO = xlate( 'RDS', LastSepLayIds<1,1>, rds_wo$, 'X' )
	   extract_si_keys( 'RDS', 'WO', TempWO, TempKeys )
	   convert @vm to @fm in TempKeys
	   TempKeys = key_sort( TempKeys, 'RDS', 'RUN_ORDER_NUM', 1, '', '' )
	   FirstRO = Tempkeys<1>
		EtchDelta = xlate( 'RDS', FirstRO, 'QXJ_DELTA', 'X' )
		StandardT = xlate( 'RDS', FirstRO, rds_standard_t$, 'X' )
		StandardR = xlate( 'RDS', FirstRO, rds_standard_r$, 'X' )		
		EtchDelta = str( EtchDelta:@fm, LlCnt )
		EtchDelta[-1,1] = ''
      StandardT = str( StandardT:@fm, LlCnt )
      StandardT[-1,1] = ''
      StandardR = str( StandardR:@fm, Llcnt )
      StandardR[-1,1] = ''			
		Lout = fmt( ' ', 'L#39' ):fmt( 'THICKNESS', 'C#17' ):fmt( '', 'L#2' ):fmt( 'RESISTIVITY', 'C#15' ):fmt( '', 'L#3' ):'ETCH':fmt( '', 'L#3' ):'STANDARD':fmt( ' ', 'L#3'):'PRE SLIP POST SLIP'
		Void = set_printer( 'TEXT', Lout )
		Lout = fmt( 'PART #', 'L#12' ):' '
		Lout:= fmt( 'LOT #', 'L#12' ):' '
		Lout:= fmt( 'RUN #', 'L#9' ):' '
		Lout:= fmt( 'QTY', 'L#3' ):' '
		Lout:= fmt( 'MEAN', 'L#8' ):' '
		Lout:= fmt( 'STDEV', 'L#8' ):' '
		Lout:= fmt( 'MEAN', 'L#8' ):' '
		Lout:= fmt( 'STDEV', 'L#8' ):' '
		Lout:= fmt( 'DELTA','L#5' ):' '
		Lout:= fmt( 'THK', 'L#5' ):' '
		Lout:= fmt( 'RES', 'L#5' ):' '
		Lout:= fmt( 'SPOT/FOV', 'L#8' ):' '
		Lout:= fmt( 'SPOT/FOV', 'L#9' )
		Void = set_printer( 'TEXT', Lout )
		Lout = '____________ ____________ _________ ___ ________ ________ ________ ________ _____ _____ _____ ________ _________' 
		Void = set_printer( 'TEXT', Lout )
		QtyOut = 0
		Tfont<4> = 0
		Void = set_printer( 'FONT', Tfont )
		for i = 1 to LlCnt
		    ThisRdsRec = xlate( 'RDS', LastSepLayIds<1,i>, '', 'X' )
		    Lout = fmt( ThisRdsRec<rds_part_num$>, 'L#12' ):' '
		    Lout:= fmt( ThisRdsRec<rds_lot_num$>, 'L#12' ):' '
		    Lout:= fmt( ThisRdsRec<rds_reactor$>:'-':LastSeplayIds<1,i>, 'L#9' ):' '
		    WafOut = ThisRdsRec<rds_wafers_out$>
		    Lout:= fmt( WafOut, 'R#3' ):' '
		    QtyOut += WafOut
		    Lout:= fmt( oconv( ThisRdsRec<rds_tthick_avg$>, 'MD2' ), 'R#8' ):' '
		    Lout:= fmt( oconv( ThisRdsRec<rds_tthick_stdev$>, 'MD3' ), 'R#8' ):' '
		    Lout:= fmt( oconv( ThisRdsRec<rds_tres_avg$>, 'MD3' ), 'R#8' ):' '
		    Lout:= fmt( oconv( ThisRdsRec<rds_tres_stdev$>, 'MD3' ), 'R#8' ):' '
		    Lout:= fmt( oconv( EtchDelta<i>, 'MD3' ), 'C#5' ):' '
		    Lout:= fmt( oconv( StandardT<i>, 'MD2' ), 'R#5' ):' '
		    TStandard = field( oconv( StandardR<i>, 'MD2' ), '.', 1 )
		    Lout:= fmt( TStandard, 'R#5' ):' '
          PreSpotFov = ThisRdsRec<rds_pre_spots$>+0:'/':ThisRdsRec<rds_pre_fov$>+0
          PostSpotFov = ThisRdsRec<rds_post_spots$>+0:'/':ThisRdsRec<rds_post_fov$>+0
          Lout:= fmt( PreSpotFov, 'C#8' ):' '
          Lout:= fmt( PostSpotFov, 'C#9' )
		    Void = set_printer( 'TEXT', Lout )
		next i
	case otherwise$
      Um = xlate( 'RDS', LastSepLayIds<1,1>, rds_res_units$, 'X' )
      if Um = 'ê/Ü' then
         * ohms squared label sheetRHO
         Lout = fmt( ' ', 'L#44' ):fmt( 'THICKNESS', 'C#33' ):' ':fmt( ' ', 'L#12' ):'SHEET RHO'
      end else
    		Lout = fmt( ' ', 'L#44' ):fmt( 'THICKNESS', 'C#33' ):' ':fmt( ' ', 'L#10' ):'RESISTIVITY'
      end
  		if TCust = 6448 then
  		   Lout := fmt( '', 'L#11'):'Fab'
  		end
		Void = set_printer( 'TEXT', Lout )
		Lout = fmt( 'PART #', 'L#12' ):' '
		Lout:= fmt( 'LOT #', 'L#14' ):' '
		Lout:= fmt( 'RUN #', 'L#9' ):' '
		Lout:= fmt( 'QTY', 'L#5' ):' '
		Lout:= fmt( 'MEAN', 'L#7' ):' '
		Lout:= fmt( 'STDEV', 'L#7' ):' '
		Lout:= fmt( 'CP', 'L#7' ):' '
		Lout:= fmt( 'CPK', 'L#7' ):' '
		Lout:= fmt( 'MEAN', 'L#8' ):' '
		Lout:= fmt( 'STDEV', 'L#7' ):' '
		Lout:= fmt( 'CP', 'L#7' ):' '
		Lout:= fmt( 'CPK', 'L#7' )
		* CONEXANT WANTS THE TOTAL EPITRONICS FAB HOURS
		if TCust = 6448 then
		   Lout:= fmt( ' Hours', 'L#6' )
		end
		Void = set_printer( 'TEXT', Lout )
		Lout = '____________ ______________ _________ _____ _______ _______ _______ _______ ________ _______ _______ _______'
		if TCust = 6448 then
		   Lout:= ' ______'
		end
		Void = set_printer( 'TEXT', Lout )
		*
		QtyOut = 0
		Tfont<4> = 0
		Void = set_printer( 'FONT', Tfont )
		for i = 1 to LlCnt
		    ThisRdsRec = xlate( 'RDS', LastSepLayIds<1,i>, '', 'X' )
		    HrsReceivedToShip = xlate( 'RDS', LastSepLayIds<1,i>, 'HRS_EPITRONICS_FAB', 'X' )
		    Lout = fmt( ThisRdsRec<rds_part_num$>, 'L#12' ):' '
		    Lout:= fmt( ThisRdsRec<rds_lot_num$>, 'L#14' ):' '
		    Lout:= fmt( ThisRdsRec<rds_reactor$>:'-':LastSeplayIds<1,i>, 'L#9' ):' '
		    WafOut = ThisRdsRec<rds_wafers_out$>
		    Lout:= fmt( WafOut, 'R#5' ):' '
		    QtyOut += WafOut
		    Lout:= fmt( oconv( ThisRdsRec<rds_tthick_avg$>, 'MD2' ), 'R#7' ):' '
		    Lout:= fmt( oconv( ThisRdsRec<rds_tthick_stdev$>, 'MD3' ), 'R#7' ):' '
		    Lout:= fmt( oconv( ThisRdsRec<rds_tthick_cp$>, 'MD2' ), 'R#7' ):' '
		    Lout:= fmt( oconv( ThisRdsRec<rds_tthick_cpk$>, 'MD2' ), 'R#7' ):' '
		    if ThisRdsRec<rds_tres_avg$> <> '' then
		       Lout:= fmt( oconv( ThisRdsRec<rds_tres_avg$>, 'MD3' ), 'R#8' ):' '
		    end else
		       TwProdCnt  = ThisRdsRec<rds_tw_prod_cnt$>
		       TwProdTool = ThisRdsRec<rds_tw_prod_tool$>
		       TwProdRes  = ThisRdsRec<rds_tw_prod_res$>
		       TwProdCon  = ThisRdsRec<rds_tw_prod_con$>
		       TwProdCode = ThisRdsRec<rds_tw_prod_code$>
		       TWCnt = fieldcount( TwProdCnt, @vm )
		       ResFound = false$
		       for j = 1 to TWCnt
		          if ( TwProdTool<1,j> = 'HgCv' ) and ( TwProdCode<1,j> = FirstWaferInspection$ ) then
		             if TwProdRes<1,j> <> '' then
		                Lout := fmt( oconv( TwProdRes<1,j>, 'MD3' ), 'R#8' ):' '
		             end else
		                Lout := fmt( oconv( TwProdCon<1,j>, 'MS21' ), 'R#8' ):' '
		             end
		             ResFound = true$   
		          end
		         until ResFound
		       next j
		       if ResFound else
		          Lout := fmt( '', 'R#8' ):' '		       
		       end
		    end
		    Lout:= fmt( oconv( ThisRdsRec<rds_tres_stdev$>, 'MD3' ), 'R#7' ):' '
		    Lout:= fmt( oconv( ThisRdsRec<rds_tres_cp$>, 'MD3' ), 'R#7' ):' '
		    Lout:= fmt( oconv( ThisRdsRec<rds_tres_cpk$>, 'MD3' ), 'R#7' )
		    if TCust = 6448 then
		       Lout:= ' ':fmt( oconv( HrsReceivedToShip, 'MD2' ), 'R#6' )
		    end		    
		    Void = set_printer( 'TEXT', Lout )
		    * NOW CHECK FOR SAME REACTOR LAYERS AND PRINT THE STATISTICAL INFO IT IT EXISTS
		    LayerInfo = xlate( 'RDS', LastSepLayIds<1,i>, rds_layer_info$, 'X' )
		    convert char(248) to @fm in LayerInfo
		    CurLCnt = fieldcount( LayerInfo, @fm )
		    for j = 1 to CurLCnt
			    ThisLayer = LayerInfo<CurLCnt>
		       * IF NO DATA THEN DON'T PRINT
		       Tvar = ''
			    Tvar:= ThisLayer<1,RLTThickAvg$>:ThisLayer<1,RLTThickStdev$>
			    Tvar:= ThisLayer<1,RLTThickCP$>:ThisLayer<1,RLTThickCPK$>
			    Tvar:= ThisLayer<1,RLTResAvg$>:ThisLayer<1,RLTResStdev$>
			    Tvar:= ThisLayer<1,RLTResCP$>:ThisLayer<1,RLTResCPK$>
		       ********
		       if Tvar <> '' then
				    Lout = fmt( ThisRdsRec<rds_part_num$>, 'L#12' ):' '
				    Lout:= fmt( ThisRdsRec<rds_lot_num$>, 'L#14' ):' '
				    Lout:= fmt( 'Layer ':j+1, 'L#9' ):' '
				    Lout:= fmt( '', 'R#5' ):' '
				    Lout:= fmt( oconv( ThisLayer<1,RLTThickAvg$>, 'MD2' ), 'R#7' ):' '
				    Lout:= fmt( oconv( ThisLayer<1,RLTThickStdev$>, 'MD3' ), 'R#7' ):' '
				    Lout:= fmt( oconv( ThisLayer<1,RLTThickCP$>, 'MD2' ), 'R#7' ):' '
				    Lout:= fmt( oconv( ThisLayer<1,RLTThickCPK$>, 'MD2' ), 'R#7' ):' '
				    Lout:= fmt( oconv( ThisLayer<1,RLTResAvg$>, 'MD3' ), 'R#8' ):' '
				    Lout:= fmt( oconv( ThisLayer<1,RLTResStdev$>, 'MD3' ), 'R#7' ):' '
				    Lout:= fmt( oconv( ThisLayer<1,RLTResCP$>, 'MD3' ), 'R#7' ):' '
				    Lout:= fmt( oconv( ThisLayer<1,RLTResCPK$>, 'MD3' ), 'R#7' )
				    Void = set_printer( 'TEXT', Lout )
				 end
			 next j
		next i
  end case
	Tots = str( 0:@fm, 7 )
	Tots[-1,1] = ''
	RejString = ''
	MpSRPString = ''
	for i = 1 to SepLayCnt
	    ThisSepLay = LayerIds<i>
	    Tcnt = fieldcount( ThisSepLay, @vm )
	    for j = 1 to Tcnt
	       Trds = xlate( 'RDS', ThisSepLay<1,j>, '', 'X' )
	       CurRunNo = Trds<rds_reactor$>:'-':ThisSepLay<1,j>
	       Tots<1> = Tots<1> + Trds<rds_lsl_pre_epi_rej$>
	       Tots<2> = Tots<2> + Trds<rds_lsl_post_epi_rej$>
	       Tots<3> = Tots<3> + Trds<rds_cust_pre_epi_rej$>
	       Tots<4> = Tots<4> + Trds<rds_cust_post_epi_rej$>
	       *Tots<5> = Tots<5> + Trds<rds_test_wafers$>
	       *Tots<6> = Tots<6> + Trds<rds_mp_wafers$>
	       Tots<7> = Tots<7> + Trds<rds_research_srp_billable$>
	       TWProdCnt = Trds<rds_tw_prod_cnt$>
	       TWProdTool = Trds<rds_tw_prod_tool$>
	       Pcnt = fieldcount( TWProdCnt, @vm )
	       for k = 1 to Pcnt
	          if TWProdTool<1,k> = 'SRP' or TWProdTool<1,k> = 'HgCv' then
	             Tots<6> = Tots<6> + TWProdCnt<1,k>
                MpSRPString := ' ':CurRunNo:' ':TWProdCnt<1,K>:' used for ':TWProdTool<1,k>:', '  	             
	          end
	       next k 
	       *
		    * LSL Pre Epi
		    LPreRej     = xlate( 'RDS', ThisSepLay<1,j>, 'L_PRE_REJ_CNT', 'X' )
		    LPreRejLoss = xlate( 'RDS', ThisSepLay<1,j>, 'L_PRE_REJ_LOSS_DESC', 'X' )    
		    Tkcnt = fieldcount( LPreRej, @vm )
		    for k = 1 to Tkcnt
		       RejString := ' ':CurRunNo:' ':LPreRej<1,k>:' MFG Pre Epi Reject(s) for ':LPreRejLoss<1,k>:';'
		    next k
		    * LSL Post Epi
		    LPostRej     = xlate( 'RDS', ThisSepLay<1,j>, 'L_POST_REJ_CNT', 'X' )
		    LPostRejLoss = xlate( 'RDS', ThisSepLay<1,j>, 'L_POST_REJ_LOSS_DESC', 'X' )
		    Tkcnt = fieldcount( LPostRej, @vm )
		    for k = 1 to Tkcnt
		       RejString := ' ':CurRunNo:' ':LPostRej<1,k>:' MFG Post Epi Reject(s) for ':LPostRejLoss<1,k>:';'
		    next k
		    * Cust Pre Epi
		    CPreRej     = xlate( 'RDS', ThisSepLay<1,j>, 'C_PRE_REJ_CNT', 'X' )
		    CPreRejLoss = xlate( 'RDS', ThisSepLay<1,j>, 'C_PRE_REJ_LOSS_DESC', 'X' )
		    Tkcnt = fieldcount( CPreRej, @vm )
		    for k = 1 to Tkcnt
		       RejString := ' ':CurRunNo:' ':CPreRej<1,k>:' Customer Pre Epi Reject(s) for ':CPreRejLoss<1,k>:';'
		    next k
		    * Cust Post Epi
		    CPostRej     = xlate( 'RDS', ThisSepLay<1,j>, 'C_POST_REJ_CNT', 'X' )
		    CPostRejLoss = xlate( 'RDS', ThisSepLay<1,j>, 'C_POST_REJ_LOSS_DESC', 'X' )
		    Tkcnt = fieldcount( CPostRej, @vm )
		    for k = 1 to Tkcnt
		       RejString := ' ':CurRunNo:' ':CPostRej<1,k>:' Customer Post Epi Reject(s) for ':CPostRejLoss<1,k>:';'
		    next k    
	    next j
	next i
	Void = set_printer( 'TEXT', '' )
	Tfont<4> = 1
	Tfont<2> = 10
	Void = set_printer( 'FONT', Tfont )	
	*******************************************************************
	LayerIdCnt = fieldcount( LayerIds<1>, @vm )
	if LayerIdCnt > 9 then
	   * SHOW THE CP AND CPK FOR THE WORK ORDER
	   Results = calc_wo_stats(LayerIds<1>)
	   Void = set_printer( 'TEXT', 'TOTAL THICKNESS CP:  ':Results<1,11> )
	   Void = set_printer( 'TEXT', 'TOTAL THICKNESS CPK: ':Results<1,13> )
	   Void = set_printer( 'TEXT', 'TOTAL RESISTIVITY CP:  ':Results<1,12> )
	   Void = set_printer( 'TEXT', 'TOTAL RESISTIVITY CPK: ':Results<1,14> )   
	end
	*******************************************************************
	Void = set_printer( 'TEXT', 'TOTAL QUANTITY: ':QtyOut )
	if SuppliedBy = 'C' then
		Lout = 'REJECTS DUE TO MFG ------ PRE EPI: ':Tots<1>:' - POST EPI: ':Tots<2>
		Void = set_printer( 'TEXT', Lout )
		Lout = 'REJECTS DUE TO CUSTOMER - PRE EPI: ':Tots<3>:' - POST EPI: ':Tots<4>
		Void = set_printer( 'TEXT', Lout )
	end
	*Void = set_printer( 'TEXT', 'TEST WAFERS: ':Tots<5> )
	Void = set_printer( 'TEXT', 'HgCv/SRP WAFERS: ':Tots<6> )
	Void = set_printer( 'TEXT', 'Billable Test: ':Tots<7> )
   RejString[-1,1] = ''
   if RejString then
      Void = set_printer( 'TEXT', 'Wafer Rejection Information:' )
	   RejString = fmt( RejString, 'T#85' )
	   convert @tm to @fm in RejString
	   Void = set_printer( 'TEXT', '' )
	   Tcnt = fieldcount( RejString, @fm )
	   for j = 1 to Tcnt
	       Void = set_printer( 'TEXT', RejString<j> )
	   next j
   end
   *
   MpSRPString[-2,2] = ''
   if MpSRPString then
      Void = set_printer( 'TEXT', 'HgCv/SRP Information:' )
	   MpSRPString = fmt( MpSRPString, 'T#85' )
	   convert @tm to @fm in MpSRPString
	   Void = set_printer( 'TEXT', '' )
	   Tcnt = fieldcount( MpSRPString, @fm )
	   for j = 1 to Tcnt
	       Void = set_printer( 'TEXT', MpSRPString<j> )
	   next j
   end
   PSNId = xlate( 'RDS', LastSepLayIds<1,1>, rds_prod_spec_id$, 'X' )
	SpecNum = xlate( 'PROD_SPEC', PSNId, prod_spec_spec_num$, 'X' )<1,1>
	if TCust = 6448 then
      * CONEXANT WANTS THE SPEC NUMBER ON EACH COC BACK PAGE
      *Void = set_printer( 'TEXT', '' )
      Void = set_printer( 'TEXT', 'Specification Number: ':SpecNum )		   
	end
	***********************************
	open 'DICT.SRP_COC_RESULTS' to DictSRPCOCResultsTable else
      Void = msg( '', 'Unable to open DICT.SRP_COC_RESULTS...' )
      return 0
   end
   SearchStr = ''
   SearchStr<-1> = 'PROD_SPEC_ID':@vm:PSNId
   SupVerSigDate = xlate( 'RDS', LastSepLayIds<1,1>, rds_sup_ver_sig_date$, 'X' )	   
   AMonthAgo = oconv( SupVerSigDate - 31, 'D2/' )
   SupVerSigDate = oconv( SupVerSigDate, 'D2/' )
	SearchStr<-1> = 'SRP_DATE':@vm:AMonthAgo:'...':SupVerSigDate
	SearchStr := @fm
	* do a btree.extract
	btree.extract( SearchStr, 'SRP_COC_RESULTS', DictSRPCOCResultsTable, Keys, '', Flag )
	if Flag <> 0 then
	   Void = msg( '', 'Error while extracting SRP_COC_RESULTS records...' )
	   return 0
   end
	if Keys then
	   convert @vm to @fm in Keys
	   Keys = key_sort( Keys, 'SRP_COC_RESULTS', '#SRP_DATE', 0 )
	   * NEWEST FIRST NOW LOOP THROUGH AND ARRAY BY PSN
	   KCnt = fieldcount( Keys, @fm )
	   PSNAndReactorIds = ''
	   NewSRPCOCIds = ''
	   for i = 1 to KCnt
	      ThisKey = Keys<i>
	      CurPSN = xlate( 'SRP_COC_RESULTS', ThisKey, srp_coc_results_prod_spec_id$, 'X' )
	      CurReactor = xlate( 'SRP_COC_RESULTS', ThisKey, srp_coc_results_reactor$, 'X' )
	      CurValToCheck = CurPSN:CurReactor
	      locate CurValToCheck in PSNAndReactorIds using @fm setting CPos else
	         * PSN AND REACTOR NOT FOUND SO PUT INTO ARRAY
	         NewSRPCOCIds<-1> = ThisKey
	         PSNAndReactorIds<-1> = CurValToCheck
	      end
	   next i
	   KCnt = fieldcount( NewSRPCOCIds, @fm )
	   for i = 1 to KCnt
	      ThisSRPCOCId = NewSRPCOCIds<i>
	      ThisSRPCOCRec = xlate( 'SRP_COC_RESULTS', ThisSRPCOCId, '', 'X' )
	      PSN = ThisSRPCOCRec<srp_coc_results_prod_spec_id$>
	      Reactor = ThisSRPCOCRec<srp_coc_results_reactor$>
	      Thick   = oconv( ThisSRPCOCRec<srp_coc_results_thick$>, 'MD2' )
	      Con     = oconv( ThisSRPCOCRec<srp_coc_results_con$>, 'MS21' )
	      Trans   = oconv( ThisSRPCOCRec<srp_coc_results_trans$>, 'MD2' )
	      SRPDate = oconv( ThisSRPCOCRec<srp_coc_results_srp_date$>, 'D2/' )
	      SpecNum = xlate( 'PROD_SPEC', PSN, prod_spec_spec_num$, 'X' )<1,1>
	      * NOW PRINT THE STUFF
	      LineOut = 'Reactor: ':Reactor:', Spec Num: ':SpecNum: ', SRP Date: ':SRPDate:', Thick: ':Thick:', Con: ':Con:', Trans: ':Trans
	      Void = set_printer( 'TEXT', LineOut )
	   next i
	end else
	   * NO SRP COC RECORD FOUND SO NOTHING NEEDS TO PRINT
	end
	***********************************
end ;* preliminary or full shipment
*Void = set_printer( 'PAGEBREAK' )	
return
