compile function PRINT_PSN_DATA_MODS( PSNID )
begin condition
pre:
post:
end condition
declare function msg, set_property, send_event, dialog_box, utility, get_property
declare function set_printer, fieldcount,Printer_Select
declare subroutine rlist, activate_save_select, yield, btree.extract

$insert dict_equates
$insert rlist_equates
$insert logical
$insert msg_equates
$insert oiprint_equates
$insert prod_spec_equ
$insert prod_spec_log_equ
$insert rds_equ
$insert wo_log_equ

* THERE WILL NOT BE A WINDOW FOR THIS REPORT AND WILL BE PASSED THE PSNID 
if assigned( PSNID ) else
   return 0
end
open 'PROD_SPEC_LOG' to PSLTable else
   Void = msg( '', 'Unable to open PROD_SPEC_LOG' )
   return 0
end
read PSLRec from PSLTable, PSNID else
   MsgInfo = ''
   MsgInfo<mtext$> = 'There is no modification history for PSN ':PSNID
   MsgInfo<micon$> = '!'
   Void = msg( '', MsgInfo )
   return 0
end
TableColInfo = '<+2100':@vm:'<+3960':@vm:'<+3960':@vm:'<+2100':@vm:'<+1267':@vm:'<+1267'
SpecSubstrateFields = 'SUB_ORIENTATION/SUB_WAFER_TYPE/SUB_WAFER_SIZE/SUB_RESIST/SUB_RESIST_UNITS/SUB_DOPANT/SUB_PRE_CLEAN/'
SpecSubstrateFields:= 'SUB_BURIED_DOPANT1/SUB_BURIED_DOPANT2/SUB_OXIDE_STRIP/SUB_POST_CLEAN/SUB_BACKSEAL/SUB_MFG/'
SpecSubstrateFields:= 'SUB_SUBSTRATE/SPECIAL_INST//SUB_SUPPLIED_BY/SPEC_TYPE/SUB_POLISH/SUB_PRODUCT/SUB_BURIED_DOPANT3/'
SpecSubstrateFields:= 'SUB_OXIDE_ANGSTROMS/PRE_AKRION_RECIPE/POST_AKRION_RECIPE'

SpecEpiFields = 'CON_MIN_L1/CON_MAX_L1/CON_UNITS_L1/RES_MIN_L1/RES_MAX_L1/RES_UNITS_L1/THICK_MIN_L1/THICK_MAX_L1/'
SpecEpiFields:= 'THICK_UNITS_L1/DOPANT_L1/RECIPE_NO_L1/RECIPE_NAME_L1/THICK_MEASURE_L1/RES_MEASURE_L1/CON_MEASURE_L1/'

SpecAddtlFields = 'PROD_SIGNATURE/QUAL_SIGNATURE/PROVEIN_INST/STRESS_MEASURE/TRANS_MEASURE/STRESS_MIN/STRESS_MAX/'
SpecAddtlFields:= 'TRANS_SPEC/PRE_PROD_SIGNATURE/PRE_QUAL_SIGNATURE'

SpecNewDevFields = 'NEW_DEV_INST/NEW_DEV_EXP_PLAN/NEW_DEV_TEST_RESULTS/NEW_DEV_SPECIAL_INST'

SpecPreProdFields = 'PRE_PROD_INST/PRE_PROD_SPECIAL_INST/PRE_PROD_PROVEIN'

convert '/' to @vm in SpecSubstrateFields
convert '/' to @vm in SpecEpiFields
convert '/' to @vm in SpecAddtlFields
convert '/' to @vm in SpecNewDevFields
convert '/' to @vm in SpecPreProdFields

SpaceOut = str( ' ', 17 )
SpaceOut2 = str( ' ', 20 )

PrintPath = Printer_Select('',1)		;* Get default printer path
Void = set_printer( 'INIT', '', '', .38:@fm:.75:@fm:.38:@fm:.75, 1, 3 ,PrintPath)

Void = utility( 'CURSOR', 'H' )
Font = "MS Linedraw,8,L,1"
*Font = "Courier New,8,L,1"
convert ',' to @fm in Font
TFont = font
TFont<2> = 12
Void = set_printer( 'FONTHEADFOOT', TFont )
ColLen    = 1.5:@fm:2.75:@fm:2.75:@fm:1.5:@fm:.88:@fm:.88
ColHeader = 'Field':@vm:'Original Value':@vm:'New Value':@vm:'User Name':@vm:'Date':@vm:'Time'
ColJust   = 'L':@fm:'L':@fm:'L':@fm:'L':@fm:'L':@fm:'L'
Void = set_printer( 'HEADER', str(' ',38):"PSN Modification History", ColLen, ColHeader, ColJust )
TFont<2> = 10
TFont<4> = 0
Void = set_printer( 'FONT', TFont )
OrigValues = PSLRec<PROD_SPEC_LOG_ORIG_VALUES$>
NewValues  = PSLRec<PROD_SPEC_LOG_NEW_VALUES$>
ModDates   = oconv( PSLRec<PROD_SPEC_LOG_DATE$>, 'D2/' )
ModTimes   = oconv( PSLRec<PROD_SPEC_LOG_TIME$>, 'MTH' )
ModIds     = oconv( PSLRec<PROD_SPEC_LOG_USER_ID$>, '[XLATE_CONV,LSL_USERS*FIRST_LAST]' )
OCnt = fieldcount( OrigValues, @vm )
for i = 1 to OCnt
  	ModDate      = ModDates<1,i>
   ModTime      = ModTimes<1,i>
   ModId        = ModIds<1,i>
   if ( i = prod_spec_spec_substrate$ ) or ( i = prod_spec_spec_epi$ ) or ( i = prod_spec_spec_addtl$ ) or ( i = prod_spec_spec_new_dev$ ) or ( i = prod_spec_spec_pre_prod$ ) then
      * THESE FIELDS IN THE PSN ARE DELIMITED BY @VM FOR EACH FIELD AND THE CONCENTRATION WILL HAVE @SVM WHICH
      * IS STORED WITH A ` IN THE LOG TABLE
      if i = prod_spec_spec_epi$ then
         * ONLY GET THE FIRST LAYER
         OrigValues<1,i> = field( OrigValues<1,i>, char(248), 1 )
      end
      begin case
         case i = prod_spec_spec_substrate$
            FieldsToUse = SpecSubstrateFields
         case i = prod_spec_spec_epi$
            FieldsToUse = SpecEpiFields
         case i = prod_spec_spec_addtl$
            FieldsToUse = SpecAddtlFields
         case i = prod_spec_spec_new_dev$
         	FieldsToUse = SpecNewDevFields
         case i = prod_spec_spec_pre_prod$
         	FieldsToUse = SpecPreProdFields                                    
      end case
		if ( OrigValues<1,i> <> '' ) or ( NewValues<1,i> <> '' ) then
		   ThisOrigValues = OrigValues<1,i>
		   ThisNewValues  = NewValues<1,i>
 			MVCnt = fieldcount( ThisOrigValues, @svm )
			MVCnt2 = fieldcount( ThisNewValues, @svm )
			if MVCnt2 > MVCnt then
			   MVCnt = MVCnt2
			end
			for j = 1 to MVCnt
				DictRecord = xlate( 'DICT.PROD_SPEC', FieldsToUse<1,j>, '', 'X' )
				OutConv = DictRecord<dict_conv$>
				***********
				TFIELDTOUSE = FIELDSTOUSE<1,J>
				IF TFIELDTOUSE[1,5] = 'CON_M' AND OUTCONV = 'MS21' THEN
				   * THIS IS A QUICK FIX FOR THE CONCENTRATION "`"  MS21 MESS
				   OUTCONV = ''
				END
				***********
		 		FieldNameOut = DictRecord<dict_display$>
				ThisOrigValues = oconv( OrigValues<1,i>, OutConv )
				ThisNewValues  = oconv( NewValues<1,i>, OutConv )
				swap @tm with CrLf$ in ThisOrigValues
				swap @tm with CrLf$ in ThisNewValues			
			   if ThisNewValues<1,1,j> <> ThisOrigValues<1,1,j> then
			      Table = FieldNameOut:@vm:ThisOrigValues<1,1,j>:@vm:ThisNewValues<1,1,j>:@vm:ModId<1,1,j>:@vm:ModDate<1,1,j>:@vm:ModTime<1,1,j>
			      * PRINT THE FIRST LINE AND THEN THE MULTIVALUE STUFF
			      x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
			   end
			next j
	   end
	end else
		if ( OrigValues<1,i> <> '' ) or ( NewValues<1,i> <> '' ) then
		   * GET DICTIONARY INFORMATION
		   clearselect 0
			Void = set_status(0)
			Stmt = 'SELECT DICT.PROD_SPEC WITH F2 = ':i
			rlist( Stmt, target_activelist$, '', '', '' )
			Err = get_status()
			if Err then
			   msg( '', 'Error while selecting DICT.PROD_SPEC' )
			   return 0
			end
			readnext FieldName else FieldName = ''
			*
			DictRecord = xlate( 'DICT.PROD_SPEC', FieldName, '', 'X' )
			OutConv = DictRecord<dict_conv$>
	 		FieldNameOut = DictRecord<dict_display$>
			ThisOrigValues = oconv( OrigValues<1,i>, OutConv )
			ThisNewValues  = oconv( NewValues<1,i>, OutConv )
			swap @tm with CrLf$ in ThisOrigValues
			swap @tm with CrLf$ in ThisNewValues
			MVCnt = fieldcount( ThisOrigValues, @svm )
			MVCnt2 = fieldcount( ThisNewValues, @svm )
			if MVCnt2 > MVCnt then
			   MVCnt = MVCnt2
			end
			for j = 1 to MVCnt
			   if ThisNewValues<1,1,j> <> ThisOrigValues<1,1,j> then
			      Table = FieldNameOut:@vm:ThisOrigValues<1,1,j>:@vm:ThisNewValues<1,1,j>:@vm:ModId<1,1,j>:@vm:ModDate<1,1,j>:@vm:ModTime<1,1,j>
			      * PRINT THE FIRST LINE AND THEN THE MULTIVALUE STUFF
			      x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
			   end
			next j
	   end
	end
next i
Void = set_printer( 'TERM', 1 ) 
RETURN 0
