<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://in.compucrete.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Chanson</id>
	<title>KeystoneIntranet - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://in.compucrete.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Chanson"/>
	<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php/Special:Contributions/Chanson"/>
	<updated>2026-05-15T14:38:26Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>http://in.compucrete.com/index.php?title=A/P_Balancing_Queries&amp;diff=1152</id>
		<title>A/P Balancing Queries</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=A/P_Balancing_Queries&amp;diff=1152"/>
		<updated>2025-12-29T19:16:34Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Irregular Use of A/P account in A/P system */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==A/P Raw Balance==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select sum(gross_amount-paid_amount-disc_taken) ap_apsys,&lt;br /&gt;
-(select sum(trx_amount) from glttrx  where gl_account=:ap_account) ap_glsys,&lt;br /&gt;
sum(gross_amount-paid_amount-disc_taken)+(select sum(trx_amount) from glttrx  where gl_account=:ap_account) difference&lt;br /&gt;
 from aptinvhd&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A/P Transactions not from A/P system==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select session_no, gl_account, trx_date, trx_amount, last_change_datetime, description_1, source_app, source_table from glttrx &lt;br /&gt;
where gl_account=:ap_account and source_app&amp;lt;&amp;gt;'P' &lt;br /&gt;
  and imported_flag='N'  and trx_date&amp;gt;=:begdate order by trx_date desc&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Irregular Use of A/P account in A/P system==&lt;br /&gt;
&lt;br /&gt;
===Non-AP Tranasctions from AP Account===&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select session_no,trans_no,gl_account,trx_date,trx_amount,last_change_datetime,description_1,&lt;br /&gt;
source_app,source_table,source_TRANS_TYPE  from glttrx&lt;br /&gt;
where source_app='P' and source_trans_type not in ('IP','CP','HP','VP','HX','HY')&lt;br /&gt;
and gl_account=:ap_account&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
Updated 12/29/2025 to add HX and HY to exclude list.&lt;br /&gt;
&lt;br /&gt;
===AP Tranasctions from Non-AP Account===&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select session_no,trans_no,gl_account,trx_date,trx_amount,last_change_datetime,description_1,&lt;br /&gt;
source_app,source_table,source_TRANS_TYPE  from glttrx&lt;br /&gt;
where source_app='P' and source_trans_type in  ('IP','CP','HP','VP','HX','HY')&lt;br /&gt;
and gl_account&amp;lt;&amp;gt;:ap_account&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
12/29/2025&lt;br /&gt;
&lt;br /&gt;
==A/P Crossover Query==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
Select 'A',session_no,g.trans_no gl_trans,i.trans_no ap_inv_trans,vend_id,invoice_no,invoice_date,g.trx_date gldate,i.gross_amount,&lt;br /&gt;
(select user_id from cctsessn cs where cs.session_no=i.session_no) chg_user,&lt;br /&gt;
g.last_change_datetime enter_date&lt;br /&gt;
 from aptinvhd i&lt;br /&gt;
inner join  glttrx g on&lt;br /&gt;
 (g.source_session_no=i.session_no and g.source_trans_no=i.trans_no&lt;br /&gt;
  and g.gl_account=:ap_account and g.trx_date&amp;lt;=:crossdate)&lt;br /&gt;
where i.invoice_date&amp;gt;:crossdate&lt;br /&gt;
union&lt;br /&gt;
Select 'B',session_no,g.trans_no gl_trans,i.trans_no ap_inv_trans,vend_id,invoice_no,invoice_date,g.trx_date gldate,i.gross_amount,&lt;br /&gt;
(select user_id from cctsessn cs where cs.session_no=i.session_no) chg_user,&lt;br /&gt;
g.last_change_datetime enter_date&lt;br /&gt;
 from aptinvhd i&lt;br /&gt;
inner join  glttrx g on&lt;br /&gt;
 (g.source_session_no=i.session_no and g.source_trans_no=i.trans_no&lt;br /&gt;
  and g.gl_account=:ap_account and g.trx_date&amp;gt;:crossdate)&lt;br /&gt;
where i.invoice_date&amp;lt;=:crossdate&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Invoices Paid before Invoice Date ==&lt;br /&gt;
&amp;lt;PRE&amp;gt;select c.trx_date,AI.INVOICE_DATE AP_HD_INV_DATE,ac.* from aptchkdt ac&lt;br /&gt;
inner join cmttrx c on c.session_no=ac.session_no and c.trans_no=ac.trans_no&lt;br /&gt;
INNER JOIN APTINVHD AI ON AC.AP_SESSION_NO=AI.SESSION_NO AND AC.AP_TRANS_NO=AI.TRANS_NO&lt;br /&gt;
where (ac.invoice_date&amp;gt;:Crossover_Date) and (c.trx_date&amp;lt;=:Crossover_Date)&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Invoice Gross Not Equal G/L Detail &amp;quot;IP&amp;quot; transactions==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select  (select sum (trx_amount) from glttrx tx where tx.source_session_no=ih.session_no and tx.source_trans_no=ih.trans_no and source_trans_type='IP') &amp;quot;GL Amount&amp;quot;,&lt;br /&gt;
IH.* from aptinvhd ih&lt;br /&gt;
where invoice_date &amp;gt; :&amp;quot;Begin Date&amp;quot;&lt;br /&gt;
and gross_amount+&lt;br /&gt;
(select sum (trx_amount) from glttrx tx where tx.source_session_no=ih.session_no and tx.source_trans_no=ih.trans_no and source_trans_type='IP') &amp;lt;&amp;gt;0&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Generic G/L Payments = Invoice Paid (W.I.P.  Work needed)==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select &lt;br /&gt;
TX.GL_ACCOUNT,TX.TRX_AMOUNT,&lt;br /&gt;
cd.*,ih.paid_amount,ih.*&lt;br /&gt;
 from aptinvhd ih&lt;br /&gt;
inner join aptchkdt cd on cd.ap_session_no=ih.session_no and cd.ap_trans_no=ih.trans_no&lt;br /&gt;
inner join glttrx tx on tx.source_session_no=cd.session_no and tx.source_trans_no=cd.trans_no and tx.source_line_no=cd.line_no and source_trans_type='CP'&lt;br /&gt;
where ih.invoice_date &amp;gt; :&amp;quot;Begin Date&amp;quot;&lt;br /&gt;
AND PAID_THIS_CHECK&amp;lt;&amp;gt;PAID_AMOUNT&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=A/P_Balancing_Queries&amp;diff=1151</id>
		<title>A/P Balancing Queries</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=A/P_Balancing_Queries&amp;diff=1151"/>
		<updated>2025-12-29T18:52:24Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Irregular Use of A/P account in A/P system */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==A/P Raw Balance==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select sum(gross_amount-paid_amount-disc_taken) ap_apsys,&lt;br /&gt;
-(select sum(trx_amount) from glttrx  where gl_account=:ap_account) ap_glsys,&lt;br /&gt;
sum(gross_amount-paid_amount-disc_taken)+(select sum(trx_amount) from glttrx  where gl_account=:ap_account) difference&lt;br /&gt;
 from aptinvhd&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A/P Transactions not from A/P system==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select session_no, gl_account, trx_date, trx_amount, last_change_datetime, description_1, source_app, source_table from glttrx &lt;br /&gt;
where gl_account=:ap_account and source_app&amp;lt;&amp;gt;'P' &lt;br /&gt;
  and imported_flag='N'  and trx_date&amp;gt;=:begdate order by trx_date desc&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Irregular Use of A/P account in A/P system==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
===Non-AP Tranasctions from AP Account===&lt;br /&gt;
select session_no,trans_no,gl_account,trx_date,trx_amount,last_change_datetime,description_1,&lt;br /&gt;
source_app,source_table,source_TRANS_TYPE  from glttrx&lt;br /&gt;
where source_app='P' and source_trans_type not in ('IP','CP','HP','VP','HX','HY')&lt;br /&gt;
and gl_account=:ap_account&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
Updated 12/29/2025 to add HX and HY to exclude list.&lt;br /&gt;
&lt;br /&gt;
===AP Tranasctions from Non-AP Account===&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select session_no,trans_no,gl_account,trx_date,trx_amount,last_change_datetime,description_1,&lt;br /&gt;
source_app,source_table,source_TRANS_TYPE  from glttrx&lt;br /&gt;
where source_app='P' and source_trans_type in  ('IP','CP','HP','VP','HX','HY')&lt;br /&gt;
and gl_account&amp;lt;&amp;gt;:ap_account&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
12/29/2025&lt;br /&gt;
&lt;br /&gt;
==A/P Crossover Query==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
Select 'A',session_no,g.trans_no gl_trans,i.trans_no ap_inv_trans,vend_id,invoice_no,invoice_date,g.trx_date gldate,i.gross_amount,&lt;br /&gt;
(select user_id from cctsessn cs where cs.session_no=i.session_no) chg_user,&lt;br /&gt;
g.last_change_datetime enter_date&lt;br /&gt;
 from aptinvhd i&lt;br /&gt;
inner join  glttrx g on&lt;br /&gt;
 (g.source_session_no=i.session_no and g.source_trans_no=i.trans_no&lt;br /&gt;
  and g.gl_account=:ap_account and g.trx_date&amp;lt;=:crossdate)&lt;br /&gt;
where i.invoice_date&amp;gt;:crossdate&lt;br /&gt;
union&lt;br /&gt;
Select 'B',session_no,g.trans_no gl_trans,i.trans_no ap_inv_trans,vend_id,invoice_no,invoice_date,g.trx_date gldate,i.gross_amount,&lt;br /&gt;
(select user_id from cctsessn cs where cs.session_no=i.session_no) chg_user,&lt;br /&gt;
g.last_change_datetime enter_date&lt;br /&gt;
 from aptinvhd i&lt;br /&gt;
inner join  glttrx g on&lt;br /&gt;
 (g.source_session_no=i.session_no and g.source_trans_no=i.trans_no&lt;br /&gt;
  and g.gl_account=:ap_account and g.trx_date&amp;gt;:crossdate)&lt;br /&gt;
where i.invoice_date&amp;lt;=:crossdate&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Invoices Paid before Invoice Date ==&lt;br /&gt;
&amp;lt;PRE&amp;gt;select c.trx_date,AI.INVOICE_DATE AP_HD_INV_DATE,ac.* from aptchkdt ac&lt;br /&gt;
inner join cmttrx c on c.session_no=ac.session_no and c.trans_no=ac.trans_no&lt;br /&gt;
INNER JOIN APTINVHD AI ON AC.AP_SESSION_NO=AI.SESSION_NO AND AC.AP_TRANS_NO=AI.TRANS_NO&lt;br /&gt;
where (ac.invoice_date&amp;gt;:Crossover_Date) and (c.trx_date&amp;lt;=:Crossover_Date)&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Invoice Gross Not Equal G/L Detail &amp;quot;IP&amp;quot; transactions==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select  (select sum (trx_amount) from glttrx tx where tx.source_session_no=ih.session_no and tx.source_trans_no=ih.trans_no and source_trans_type='IP') &amp;quot;GL Amount&amp;quot;,&lt;br /&gt;
IH.* from aptinvhd ih&lt;br /&gt;
where invoice_date &amp;gt; :&amp;quot;Begin Date&amp;quot;&lt;br /&gt;
and gross_amount+&lt;br /&gt;
(select sum (trx_amount) from glttrx tx where tx.source_session_no=ih.session_no and tx.source_trans_no=ih.trans_no and source_trans_type='IP') &amp;lt;&amp;gt;0&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Generic G/L Payments = Invoice Paid (W.I.P.  Work needed)==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select &lt;br /&gt;
TX.GL_ACCOUNT,TX.TRX_AMOUNT,&lt;br /&gt;
cd.*,ih.paid_amount,ih.*&lt;br /&gt;
 from aptinvhd ih&lt;br /&gt;
inner join aptchkdt cd on cd.ap_session_no=ih.session_no and cd.ap_trans_no=ih.trans_no&lt;br /&gt;
inner join glttrx tx on tx.source_session_no=cd.session_no and tx.source_trans_no=cd.trans_no and tx.source_line_no=cd.line_no and source_trans_type='CP'&lt;br /&gt;
where ih.invoice_date &amp;gt; :&amp;quot;Begin Date&amp;quot;&lt;br /&gt;
AND PAID_THIS_CHECK&amp;lt;&amp;gt;PAID_AMOUNT&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=A/P_Balancing_Queries&amp;diff=1150</id>
		<title>A/P Balancing Queries</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=A/P_Balancing_Queries&amp;diff=1150"/>
		<updated>2025-12-29T17:17:34Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Irregular Use of A/P account in A/P system */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==A/P Raw Balance==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select sum(gross_amount-paid_amount-disc_taken) ap_apsys,&lt;br /&gt;
-(select sum(trx_amount) from glttrx  where gl_account=:ap_account) ap_glsys,&lt;br /&gt;
sum(gross_amount-paid_amount-disc_taken)+(select sum(trx_amount) from glttrx  where gl_account=:ap_account) difference&lt;br /&gt;
 from aptinvhd&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A/P Transactions not from A/P system==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select session_no, gl_account, trx_date, trx_amount, last_change_datetime, description_1, source_app, source_table from glttrx &lt;br /&gt;
where gl_account=:ap_account and source_app&amp;lt;&amp;gt;'P' &lt;br /&gt;
  and imported_flag='N'  and trx_date&amp;gt;=:begdate order by trx_date desc&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Irregular Use of A/P account in A/P system==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select session_no,trans_no,gl_account,trx_date,trx_amount,last_change_datetime,description_1,&lt;br /&gt;
source_app,source_table,source_TRANS_TYPE  from glttrx&lt;br /&gt;
where source_app='P' and source_trans_type not in ('IP','CP','HP','VP','HX','HY')&lt;br /&gt;
and gl_account=:ap_account&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Updated 12/29/2025 to add HX and HY to exclude list.&lt;br /&gt;
&lt;br /&gt;
==A/P Crossover Query==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
Select 'A',session_no,g.trans_no gl_trans,i.trans_no ap_inv_trans,vend_id,invoice_no,invoice_date,g.trx_date gldate,i.gross_amount,&lt;br /&gt;
(select user_id from cctsessn cs where cs.session_no=i.session_no) chg_user,&lt;br /&gt;
g.last_change_datetime enter_date&lt;br /&gt;
 from aptinvhd i&lt;br /&gt;
inner join  glttrx g on&lt;br /&gt;
 (g.source_session_no=i.session_no and g.source_trans_no=i.trans_no&lt;br /&gt;
  and g.gl_account=:ap_account and g.trx_date&amp;lt;=:crossdate)&lt;br /&gt;
where i.invoice_date&amp;gt;:crossdate&lt;br /&gt;
union&lt;br /&gt;
Select 'B',session_no,g.trans_no gl_trans,i.trans_no ap_inv_trans,vend_id,invoice_no,invoice_date,g.trx_date gldate,i.gross_amount,&lt;br /&gt;
(select user_id from cctsessn cs where cs.session_no=i.session_no) chg_user,&lt;br /&gt;
g.last_change_datetime enter_date&lt;br /&gt;
 from aptinvhd i&lt;br /&gt;
inner join  glttrx g on&lt;br /&gt;
 (g.source_session_no=i.session_no and g.source_trans_no=i.trans_no&lt;br /&gt;
  and g.gl_account=:ap_account and g.trx_date&amp;gt;:crossdate)&lt;br /&gt;
where i.invoice_date&amp;lt;=:crossdate&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Invoices Paid before Invoice Date ==&lt;br /&gt;
&amp;lt;PRE&amp;gt;select c.trx_date,AI.INVOICE_DATE AP_HD_INV_DATE,ac.* from aptchkdt ac&lt;br /&gt;
inner join cmttrx c on c.session_no=ac.session_no and c.trans_no=ac.trans_no&lt;br /&gt;
INNER JOIN APTINVHD AI ON AC.AP_SESSION_NO=AI.SESSION_NO AND AC.AP_TRANS_NO=AI.TRANS_NO&lt;br /&gt;
where (ac.invoice_date&amp;gt;:Crossover_Date) and (c.trx_date&amp;lt;=:Crossover_Date)&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Invoice Gross Not Equal G/L Detail &amp;quot;IP&amp;quot; transactions==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select  (select sum (trx_amount) from glttrx tx where tx.source_session_no=ih.session_no and tx.source_trans_no=ih.trans_no and source_trans_type='IP') &amp;quot;GL Amount&amp;quot;,&lt;br /&gt;
IH.* from aptinvhd ih&lt;br /&gt;
where invoice_date &amp;gt; :&amp;quot;Begin Date&amp;quot;&lt;br /&gt;
and gross_amount+&lt;br /&gt;
(select sum (trx_amount) from glttrx tx where tx.source_session_no=ih.session_no and tx.source_trans_no=ih.trans_no and source_trans_type='IP') &amp;lt;&amp;gt;0&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Generic G/L Payments = Invoice Paid (W.I.P.  Work needed)==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select &lt;br /&gt;
TX.GL_ACCOUNT,TX.TRX_AMOUNT,&lt;br /&gt;
cd.*,ih.paid_amount,ih.*&lt;br /&gt;
 from aptinvhd ih&lt;br /&gt;
inner join aptchkdt cd on cd.ap_session_no=ih.session_no and cd.ap_trans_no=ih.trans_no&lt;br /&gt;
inner join glttrx tx on tx.source_session_no=cd.session_no and tx.source_trans_no=cd.trans_no and tx.source_line_no=cd.line_no and source_trans_type='CP'&lt;br /&gt;
where ih.invoice_date &amp;gt; :&amp;quot;Begin Date&amp;quot;&lt;br /&gt;
AND PAID_THIS_CHECK&amp;lt;&amp;gt;PAID_AMOUNT&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Main_Page&amp;diff=1081</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Main_Page&amp;diff=1081"/>
		<updated>2025-01-30T14:29:12Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| border=&amp;quot;0&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot; align=&amp;quot;right&amp;quot;&lt;br /&gt;
|[[Tags &amp;amp; Formatting Guide ]]&lt;br /&gt;
|- &lt;br /&gt;
|[[GH Wiki Standards Guide ]] &lt;br /&gt;
|-&lt;br /&gt;
|[[More Wiki Info]]&lt;br /&gt;
|}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&amp;lt;p&amp;gt;&amp;amp;nbsp;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&amp;lt;font size=&amp;quot;6&amp;quot;&amp;gt;GivenHansco Intranet&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;4&amp;quot; color=&amp;quot;#000080&amp;quot;&amp;gt;Online Support &amp;amp; Documentation System&amp;lt;/font&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Announcements'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''What's New'''&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
:[[New Keystone Releases]] 4.7.13 - 1/23/2025&lt;br /&gt;
:[[Support Alerts]]&lt;br /&gt;
:[https://givenhansco.sharepoint.com/:x:/s/supportteam/EVr7IrPNSghNruEGW9odUvcB-MeaRucs3z9tJBJH1RIKJw?e=PE3iQR Keystone 5.x Internal Build Testing Spreadsheet]&lt;br /&gt;
:[https://givenhansco.sharepoint.com/:x:/s/supportteam/ET5kQCpCQuBCu46qHGtYwgABmovrGxOC8jOlUtpVITGmng?e=VMY2iN Keystone 4.x Internal Build Testing Spreadsheet]&lt;br /&gt;
:[https://onedrive.live.com/redir.aspx?cid=c163067a39df96c2&amp;amp;resid=C163067A39DF96C2!4481&amp;amp;parId=C163067A39DF96C2!4480&amp;amp;authkey=!AqcheqeKn8ris7g&amp;amp;Bpub=SDX.SkyDrive&amp;amp;Bsrc=Share&amp;amp;ref=button Keystone 3.x Internal Build Testing Spreadsheet]&lt;br /&gt;
:[https://1drv.ms/x/s!AklOmdIh80nxrCJJA_D6IVxpE4RL Development Tasks Spreadsheet]&lt;br /&gt;
:[https://ghwebdev.azurewebsites.net Keystone Online Dev Site]&lt;br /&gt;
:[https://givenhansco.sharepoint.com/Lists/Share%20Calendars/Color%20Calendar.aspx Company SharePoint Calendar]&lt;br /&gt;
|&lt;br /&gt;
:[[iSolved Keystone Integration]] Jan. 2025&lt;br /&gt;
:[[Support_Alerts#Dispatch_Schedule_order_shows_the_wrong_Qty_Delivered_-_12/5/2024 |Dispatch Schedule order shows the wrong Qty Delivered]] 12/5/24&lt;br /&gt;
:[[Support_Alerts#Tickets_may_be_associated_with_the_wrong_invoice_using_Print_Invoices_in_Keystone_4.7_and_4.7.1_-_10/10/2024 |Tickets associated with wrong invoice in Keystone 4.7/4.7.1]] 10/10/24&lt;br /&gt;
:[[Do This after updating number of licensed InterBase users]] 2/29/24&lt;br /&gt;
:[[Backup/Restore Issues#Before_Restoring_a_company_database,_check_this!_(version_4.0.1+) |Before Restoring a company backup, check this!]] 1/11/22&lt;br /&gt;
:[[Install/Update Issues#Keystone_database_upgrade_fails_.28version_4.0.1.2B.29 |Improved handling for database upgrade failures in Keystone 4.0.1+]] 10/27/21&lt;br /&gt;
:[[Microsoft Edge Chromium required for Keystone 4]] 08/22/21&lt;br /&gt;
:[[Configure InterBase ODBC Access]] 03/05/21&lt;br /&gt;
:[[AR: Fix Leading/Trailing Spaces in Jobs|Fix Leading/Trailing Spaces in Jobs]] (09/23/20)&lt;br /&gt;
:[[AR: Update Sales Costs from Product Standard Cost|Update Sales Costs from Product Standard Cost]] 11/4/19&lt;br /&gt;
:[[Configuring Keystone for E-Ticketing]] 10/04/18&lt;br /&gt;
:[[Fixing a Double AR void Invoice]] 10/03/18&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Keystone =&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; cellspacing=&amp;quot;5&amp;quot; cellpadding=&amp;quot;5&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|[[Accounts Receivable And Billing Info |AR]]&lt;br /&gt;
|[[Inventory Module|Inv]]&lt;br /&gt;
|[[Accounts Payable System|A/P]]&lt;br /&gt;
|[[General Ledger System|G/L]]&lt;br /&gt;
|[[Payroll System|PR]]&lt;br /&gt;
|[[Cash Management System|Cash]]&lt;br /&gt;
|[[Job Cost System|JC]]&lt;br /&gt;
|[[Keystone Ticket Printing System|Ticketing]]&lt;br /&gt;
|[[Keystone Dispatch System |Dispatch]]&lt;br /&gt;
|[[Keystone Document Imaging |Doc Img]]&lt;br /&gt;
|[[Keystone On Demand | On Demand (mobile)]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Keystone Quick Links ==&lt;br /&gt;
&lt;br /&gt;
===Common System Topics===&lt;br /&gt;
:[[Keystone REST Server (KServer)]]&lt;br /&gt;
:[[Keystone Company Database Backup Utility]]&lt;br /&gt;
:[[QueryGen]]&lt;br /&gt;
:[[Keystone Security]]&lt;br /&gt;
:[[Keystone Constants]] Decodes tables lookup values e.g. payroll run types, cash man. trans types. (Updated 01/06/23)&lt;br /&gt;
:[[Keystone Installation and Configuration]]&lt;br /&gt;
:[[Command Import]]&lt;br /&gt;
&lt;br /&gt;
===Common Software Topics===&lt;br /&gt;
:[[Export Tickets to Accounting]] (Including EXF)&lt;br /&gt;
:[http://keystonehelp.compucrete.com Customer Help Website]&lt;br /&gt;
:[[A/R and Billing: Training Outline]]&lt;br /&gt;
:[[DeReconcile Inventory]] Undo 1 or more Inv. Recon sessions. (7/24/13)&lt;br /&gt;
:[[Payroll: Federal &amp;amp; State Electronic Filing Guides]]&lt;br /&gt;
&lt;br /&gt;
===External/Third Party Devices===&lt;br /&gt;
:[[Device Server and Device Aggregator]]&lt;br /&gt;
:[[Device Aggregator/Device Server Issues]]&lt;br /&gt;
:[[Batch Control Devices]]&lt;br /&gt;
:[[GPS/Status Devices]]&lt;br /&gt;
:[[Notification Devices]]&lt;br /&gt;
:[[HaulHub (Tickets to State DOT)]]&lt;br /&gt;
&lt;br /&gt;
===Interbase Database===&lt;br /&gt;
:[[InterBase]]&lt;br /&gt;
:[[Interbase System Table Queries ( RDB$ )]]&lt;br /&gt;
:[[Database Tips]] (Restore Empty DB)&lt;br /&gt;
:[[InterBase Issues]]&amp;lt;BR&amp;gt;&lt;br /&gt;
:[[InterBase#Installation_on_64-bit_Windows_10_Creators_Update_.28Build_1703.29_and_higher | Interbase Install Fix for Windows 10 Creators]]  (07/17/17) &lt;br /&gt;
:[[Database Corruption]] Using '''GHIBDataPump'''&lt;br /&gt;
:[[Configure InterBase ODBC Access]]&lt;br /&gt;
:[[Do This after updating number of licensed InterBase users]]&lt;br /&gt;
&lt;br /&gt;
===Windows===&lt;br /&gt;
:[[Windows 7 and Keystone]]&lt;br /&gt;
:[[Keystone 2.5 Changes]] '''with new directory chart'''&lt;br /&gt;
&lt;br /&gt;
===Keystone Software Info===&lt;br /&gt;
====Accounting====&lt;br /&gt;
:[[General Ledger: Financial Statements with Bigger Print]]&lt;br /&gt;
:[[DeReconcile Inventory]] Undo 1 or more Inv. Recon sessions. (7/24/13)&lt;br /&gt;
:[[Sales Tax Handling in Keystone 2.3]] (Includes Sales Tax Collection) 10/15/09 10/13/17&lt;br /&gt;
:[[Updating the Base Product Code for 1.8 System]] - Methods for setting up Base Product Codes&lt;br /&gt;
:[[Time Calculation Queries]] - Demonstration query for time calculation 5/19/08&lt;br /&gt;
:[[Zone History Analysis]] - Analyze Zone Times for Dispatch - 5/15/08&lt;br /&gt;
&lt;br /&gt;
====Forms====&lt;br /&gt;
:[[Keystone Forms]]&lt;br /&gt;
:[[Sample Forms]]&lt;br /&gt;
:[[Keystone Form Colors]] The Color De-Coder Ring. (Yes we support the colors blanched almond and lemon chiffon!)&lt;br /&gt;
:[[Payroll: Form Versions]] Now supports '''*SUM''' to total all defs in a check group.  (07/07/17)&lt;br /&gt;
&lt;br /&gt;
:[[Invoice Form Fields]] (also includes sample adding ticket image to form) &lt;br /&gt;
:[[Ticket Form Fields]]&lt;br /&gt;
:[[Quote Form Fields]] 10/10/19&lt;br /&gt;
:[[Plant Cash Receipt Form Fields]] 03/07/18&lt;br /&gt;
:[[PO Form Fields]] 03/07/2018&lt;br /&gt;
&lt;br /&gt;
:[[AP Check Form Fields]] 12/14/2022&lt;br /&gt;
&lt;br /&gt;
====Config====&lt;br /&gt;
:[[Company Database Connection Pooling]]&lt;br /&gt;
:[[iSolved Keystone Integration]]&lt;br /&gt;
:[[Keystone Constants]] Decodes tables lookup values e.g. payroll run types, cash man. trans types.&lt;br /&gt;
:[[Keystone Experimental Features]]&lt;br /&gt;
:[[Keystone Security]]  (Wiki Page)&lt;br /&gt;
:[[Keystone Telemetry]]&lt;br /&gt;
&lt;br /&gt;
===Documents===&lt;br /&gt;
:[[Media:Web Update.pdf]]&lt;br /&gt;
:[[Keystone Accounting Installer Guidelines]]&lt;br /&gt;
&lt;br /&gt;
===Development Etc===&lt;br /&gt;
:[[Online Users Conference 2011]] - 3/2/2011&lt;br /&gt;
:[[Keystone 3.x Development]]&lt;br /&gt;
:[[Development Topics]]&lt;br /&gt;
:[[Development How To]]&lt;br /&gt;
&lt;br /&gt;
==Batch Controls Importing==&lt;br /&gt;
:[[Batch Control Ticket Interfaces]]&lt;br /&gt;
:[[Batch Ticket Import]]&lt;br /&gt;
&lt;br /&gt;
==GPS==&lt;br /&gt;
*[[GPS System Setup]] Modern GPS System Notes&lt;br /&gt;
*[[GPS System Diagnostics]] Diagnostic information for GPS systems&lt;br /&gt;
&lt;br /&gt;
== Keystone Tools ==&lt;br /&gt;
:[[Query Export]]&lt;br /&gt;
::[[Most Excellent Queries]]&lt;br /&gt;
:[[Keystone Email Setup]]&lt;br /&gt;
:[[Datascope System | DataScope]] &lt;br /&gt;
::[[DataScope Examples]] * [[DataScope G/L Finanacial Statements]]&lt;br /&gt;
&lt;br /&gt;
== Tools for Supporting Keystone ==&lt;br /&gt;
:[[QueryGen]]&lt;br /&gt;
:[[Importing Accounting Data]]&lt;br /&gt;
:[[Communications Tools]]&lt;br /&gt;
:[[Keystone Support Backup]] Company Database Backup utility for support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
:[[Application Server Diagnostics]]&lt;br /&gt;
:[[Install/Update Issues]]&amp;lt;BR&amp;gt;&lt;br /&gt;
:[[Backup/Restore Issues]]&amp;lt;BR&amp;gt;&lt;br /&gt;
:[[Keystone System Cache]]&amp;lt;BR&amp;gt;&lt;br /&gt;
:[[Error Messages and Meanings]]&amp;lt;BR&amp;gt;&lt;br /&gt;
:[[Restoring the Empty Database Template]]&amp;lt;BR&amp;gt;&lt;br /&gt;
:[[Disk Space Issues]]&amp;lt;BR&amp;gt;&lt;br /&gt;
:[[PC/Network Support]]&amp;lt;br&amp;gt;&lt;br /&gt;
:[[Remote Desktop Tips]]&lt;br /&gt;
:[[Performance Issues]]&lt;br /&gt;
&lt;br /&gt;
= General Info =&lt;br /&gt;
:[[Windows Utilities]]&lt;br /&gt;
:[http://technet.microsoft.com/en-us/windows/jj728757 Windows Shortcut Keys (TechNet)]&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Main_Page&amp;diff=1080</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Main_Page&amp;diff=1080"/>
		<updated>2025-01-30T14:28:51Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| border=&amp;quot;0&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot; align=&amp;quot;right&amp;quot;&lt;br /&gt;
|[[Tags &amp;amp; Formatting Guide ]]&lt;br /&gt;
|- &lt;br /&gt;
|[[GH Wiki Standards Guide ]] &lt;br /&gt;
|-&lt;br /&gt;
|[[More Wiki Info]]&lt;br /&gt;
|}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&amp;lt;p&amp;gt;&amp;amp;nbsp;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&amp;lt;font size=&amp;quot;6&amp;quot;&amp;gt;GivenHansco Intranet&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;4&amp;quot; color=&amp;quot;#000080&amp;quot;&amp;gt;Online Support &amp;amp; Documentation System&amp;lt;/font&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Announcements'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''What's New'''&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
:[[New Keystone Releases]] 4.7.13 - 1/23/2025&lt;br /&gt;
:[[Support Alerts]]&lt;br /&gt;
:[https://givenhansco.sharepoint.com/:x:/s/supportteam/EVr7IrPNSghNruEGW9odUvcB-MeaRucs3z9tJBJH1RIKJw?e=PE3iQR Keystone 5.x Internal Build Testing Spreadsheet]&lt;br /&gt;
:[https://givenhansco.sharepoint.com/:x:/s/supportteam/ET5kQCpCQuBCu46qHGtYwgABmovrGxOC8jOlUtpVITGmng?e=VMY2iN Keystone 4.x Internal Build Testing Spreadsheet]&lt;br /&gt;
:[https://onedrive.live.com/redir.aspx?cid=c163067a39df96c2&amp;amp;resid=C163067A39DF96C2!4481&amp;amp;parId=C163067A39DF96C2!4480&amp;amp;authkey=!AqcheqeKn8ris7g&amp;amp;Bpub=SDX.SkyDrive&amp;amp;Bsrc=Share&amp;amp;ref=button Keystone 3.x Internal Build Testing Spreadsheet]&lt;br /&gt;
:[https://1drv.ms/x/s!AklOmdIh80nxrCJJA_D6IVxpE4RL Development Tasks Spreadsheet]&lt;br /&gt;
:[https://ghwebdev.azurewebsites.net Keystone Online Dev Site]&lt;br /&gt;
:[https://givenhansco.sharepoint.com/Lists/Share%20Calendars/Color%20Calendar.aspx Company SharePoint Calendar]&lt;br /&gt;
|&lt;br /&gt;
::[[iSolved Keystone Integration]] Jan. 2025&lt;br /&gt;
:[[Support_Alerts#Dispatch_Schedule_order_shows_the_wrong_Qty_Delivered_-_12/5/2024 |Dispatch Schedule order shows the wrong Qty Delivered]] 12/5/24&lt;br /&gt;
:[[Support_Alerts#Tickets_may_be_associated_with_the_wrong_invoice_using_Print_Invoices_in_Keystone_4.7_and_4.7.1_-_10/10/2024 |Tickets associated with wrong invoice in Keystone 4.7/4.7.1]] 10/10/24&lt;br /&gt;
:[[Do This after updating number of licensed InterBase users]] 2/29/24&lt;br /&gt;
:[[Backup/Restore Issues#Before_Restoring_a_company_database,_check_this!_(version_4.0.1+) |Before Restoring a company backup, check this!]] 1/11/22&lt;br /&gt;
:[[Install/Update Issues#Keystone_database_upgrade_fails_.28version_4.0.1.2B.29 |Improved handling for database upgrade failures in Keystone 4.0.1+]] 10/27/21&lt;br /&gt;
:[[Microsoft Edge Chromium required for Keystone 4]] 08/22/21&lt;br /&gt;
:[[Configure InterBase ODBC Access]] 03/05/21&lt;br /&gt;
:[[AR: Fix Leading/Trailing Spaces in Jobs|Fix Leading/Trailing Spaces in Jobs]] (09/23/20)&lt;br /&gt;
:[[AR: Update Sales Costs from Product Standard Cost|Update Sales Costs from Product Standard Cost]] 11/4/19&lt;br /&gt;
:[[Configuring Keystone for E-Ticketing]] 10/04/18&lt;br /&gt;
:[[Fixing a Double AR void Invoice]] 10/03/18&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Keystone =&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; cellspacing=&amp;quot;5&amp;quot; cellpadding=&amp;quot;5&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|[[Accounts Receivable And Billing Info |AR]]&lt;br /&gt;
|[[Inventory Module|Inv]]&lt;br /&gt;
|[[Accounts Payable System|A/P]]&lt;br /&gt;
|[[General Ledger System|G/L]]&lt;br /&gt;
|[[Payroll System|PR]]&lt;br /&gt;
|[[Cash Management System|Cash]]&lt;br /&gt;
|[[Job Cost System|JC]]&lt;br /&gt;
|[[Keystone Ticket Printing System|Ticketing]]&lt;br /&gt;
|[[Keystone Dispatch System |Dispatch]]&lt;br /&gt;
|[[Keystone Document Imaging |Doc Img]]&lt;br /&gt;
|[[Keystone On Demand | On Demand (mobile)]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Keystone Quick Links ==&lt;br /&gt;
&lt;br /&gt;
===Common System Topics===&lt;br /&gt;
:[[Keystone REST Server (KServer)]]&lt;br /&gt;
:[[Keystone Company Database Backup Utility]]&lt;br /&gt;
:[[QueryGen]]&lt;br /&gt;
:[[Keystone Security]]&lt;br /&gt;
:[[Keystone Constants]] Decodes tables lookup values e.g. payroll run types, cash man. trans types. (Updated 01/06/23)&lt;br /&gt;
:[[Keystone Installation and Configuration]]&lt;br /&gt;
:[[Command Import]]&lt;br /&gt;
&lt;br /&gt;
===Common Software Topics===&lt;br /&gt;
:[[Export Tickets to Accounting]] (Including EXF)&lt;br /&gt;
:[http://keystonehelp.compucrete.com Customer Help Website]&lt;br /&gt;
:[[A/R and Billing: Training Outline]]&lt;br /&gt;
:[[DeReconcile Inventory]] Undo 1 or more Inv. Recon sessions. (7/24/13)&lt;br /&gt;
:[[Payroll: Federal &amp;amp; State Electronic Filing Guides]]&lt;br /&gt;
&lt;br /&gt;
===External/Third Party Devices===&lt;br /&gt;
:[[Device Server and Device Aggregator]]&lt;br /&gt;
:[[Device Aggregator/Device Server Issues]]&lt;br /&gt;
:[[Batch Control Devices]]&lt;br /&gt;
:[[GPS/Status Devices]]&lt;br /&gt;
:[[Notification Devices]]&lt;br /&gt;
:[[HaulHub (Tickets to State DOT)]]&lt;br /&gt;
&lt;br /&gt;
===Interbase Database===&lt;br /&gt;
:[[InterBase]]&lt;br /&gt;
:[[Interbase System Table Queries ( RDB$ )]]&lt;br /&gt;
:[[Database Tips]] (Restore Empty DB)&lt;br /&gt;
:[[InterBase Issues]]&amp;lt;BR&amp;gt;&lt;br /&gt;
:[[InterBase#Installation_on_64-bit_Windows_10_Creators_Update_.28Build_1703.29_and_higher | Interbase Install Fix for Windows 10 Creators]]  (07/17/17) &lt;br /&gt;
:[[Database Corruption]] Using '''GHIBDataPump'''&lt;br /&gt;
:[[Configure InterBase ODBC Access]]&lt;br /&gt;
:[[Do This after updating number of licensed InterBase users]]&lt;br /&gt;
&lt;br /&gt;
===Windows===&lt;br /&gt;
:[[Windows 7 and Keystone]]&lt;br /&gt;
:[[Keystone 2.5 Changes]] '''with new directory chart'''&lt;br /&gt;
&lt;br /&gt;
===Keystone Software Info===&lt;br /&gt;
====Accounting====&lt;br /&gt;
:[[General Ledger: Financial Statements with Bigger Print]]&lt;br /&gt;
:[[DeReconcile Inventory]] Undo 1 or more Inv. Recon sessions. (7/24/13)&lt;br /&gt;
:[[Sales Tax Handling in Keystone 2.3]] (Includes Sales Tax Collection) 10/15/09 10/13/17&lt;br /&gt;
:[[Updating the Base Product Code for 1.8 System]] - Methods for setting up Base Product Codes&lt;br /&gt;
:[[Time Calculation Queries]] - Demonstration query for time calculation 5/19/08&lt;br /&gt;
:[[Zone History Analysis]] - Analyze Zone Times for Dispatch - 5/15/08&lt;br /&gt;
&lt;br /&gt;
====Forms====&lt;br /&gt;
:[[Keystone Forms]]&lt;br /&gt;
:[[Sample Forms]]&lt;br /&gt;
:[[Keystone Form Colors]] The Color De-Coder Ring. (Yes we support the colors blanched almond and lemon chiffon!)&lt;br /&gt;
:[[Payroll: Form Versions]] Now supports '''*SUM''' to total all defs in a check group.  (07/07/17)&lt;br /&gt;
&lt;br /&gt;
:[[Invoice Form Fields]] (also includes sample adding ticket image to form) &lt;br /&gt;
:[[Ticket Form Fields]]&lt;br /&gt;
:[[Quote Form Fields]] 10/10/19&lt;br /&gt;
:[[Plant Cash Receipt Form Fields]] 03/07/18&lt;br /&gt;
:[[PO Form Fields]] 03/07/2018&lt;br /&gt;
&lt;br /&gt;
:[[AP Check Form Fields]] 12/14/2022&lt;br /&gt;
&lt;br /&gt;
====Config====&lt;br /&gt;
:[[Company Database Connection Pooling]]&lt;br /&gt;
:[[iSolved Keystone Integration]]&lt;br /&gt;
:[[Keystone Constants]] Decodes tables lookup values e.g. payroll run types, cash man. trans types.&lt;br /&gt;
:[[Keystone Experimental Features]]&lt;br /&gt;
:[[Keystone Security]]  (Wiki Page)&lt;br /&gt;
:[[Keystone Telemetry]]&lt;br /&gt;
&lt;br /&gt;
===Documents===&lt;br /&gt;
:[[Media:Web Update.pdf]]&lt;br /&gt;
:[[Keystone Accounting Installer Guidelines]]&lt;br /&gt;
&lt;br /&gt;
===Development Etc===&lt;br /&gt;
:[[Online Users Conference 2011]] - 3/2/2011&lt;br /&gt;
:[[Keystone 3.x Development]]&lt;br /&gt;
:[[Development Topics]]&lt;br /&gt;
:[[Development How To]]&lt;br /&gt;
&lt;br /&gt;
==Batch Controls Importing==&lt;br /&gt;
:[[Batch Control Ticket Interfaces]]&lt;br /&gt;
:[[Batch Ticket Import]]&lt;br /&gt;
&lt;br /&gt;
==GPS==&lt;br /&gt;
*[[GPS System Setup]] Modern GPS System Notes&lt;br /&gt;
*[[GPS System Diagnostics]] Diagnostic information for GPS systems&lt;br /&gt;
&lt;br /&gt;
== Keystone Tools ==&lt;br /&gt;
:[[Query Export]]&lt;br /&gt;
::[[Most Excellent Queries]]&lt;br /&gt;
:[[Keystone Email Setup]]&lt;br /&gt;
:[[Datascope System | DataScope]] &lt;br /&gt;
::[[DataScope Examples]] * [[DataScope G/L Finanacial Statements]]&lt;br /&gt;
&lt;br /&gt;
== Tools for Supporting Keystone ==&lt;br /&gt;
:[[QueryGen]]&lt;br /&gt;
:[[Importing Accounting Data]]&lt;br /&gt;
:[[Communications Tools]]&lt;br /&gt;
:[[Keystone Support Backup]] Company Database Backup utility for support&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
:[[Application Server Diagnostics]]&lt;br /&gt;
:[[Install/Update Issues]]&amp;lt;BR&amp;gt;&lt;br /&gt;
:[[Backup/Restore Issues]]&amp;lt;BR&amp;gt;&lt;br /&gt;
:[[Keystone System Cache]]&amp;lt;BR&amp;gt;&lt;br /&gt;
:[[Error Messages and Meanings]]&amp;lt;BR&amp;gt;&lt;br /&gt;
:[[Restoring the Empty Database Template]]&amp;lt;BR&amp;gt;&lt;br /&gt;
:[[Disk Space Issues]]&amp;lt;BR&amp;gt;&lt;br /&gt;
:[[PC/Network Support]]&amp;lt;br&amp;gt;&lt;br /&gt;
:[[Remote Desktop Tips]]&lt;br /&gt;
:[[Performance Issues]]&lt;br /&gt;
&lt;br /&gt;
= General Info =&lt;br /&gt;
:[[Windows Utilities]]&lt;br /&gt;
:[http://technet.microsoft.com/en-us/windows/jj728757 Windows Shortcut Keys (TechNet)]&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=DataScope:_Match_G/L_Activity_to_Cash_Posting_Detail_by_Session_/_Date&amp;diff=1058</id>
		<title>DataScope: Match G/L Activity to Cash Posting Detail by Session / Date</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=DataScope:_Match_G/L_Activity_to_Cash_Posting_Detail_by_Session_/_Date&amp;diff=1058"/>
		<updated>2025-01-02T22:13:08Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Verify &amp;quot;CC&amp;quot; transactions againste change in cash: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Diagnose Cash Posting vs. G/L postings:&lt;br /&gt;
&lt;br /&gt;
==Verify &amp;quot;CC&amp;quot; transactions againste change in cash:==&lt;br /&gt;
THIS NEEDS WORK!!!&lt;br /&gt;
&lt;br /&gt;
===DataScope Method===&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,-TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type='CC'&lt;br /&gt;
and  trx_date between '1/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT-D.ALLOW_AMOUNT-D.DISC_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '1/1/24' and '12/31/24'&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Query Method===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (Src,SesNo,TrxDate,TrxAmt) as&lt;br /&gt;
(&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,-TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type='CC'&lt;br /&gt;
and  trx_date between '1/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT-D.ALLOW_AMOUNT-D.DISC_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '1/1/24' and '12/31/24'&lt;br /&gt;
)&lt;br /&gt;
select sesno,trxdate,sum(trxamt) Total from aaa&lt;br /&gt;
group by sesno,trxdate&lt;br /&gt;
having sum(trxamt)&amp;lt;&amp;gt;0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Verify &amp;quot;CR&amp;quot; transactions against change in receivables:==&lt;br /&gt;
&lt;br /&gt;
===DataScope Method:===&lt;br /&gt;
All sessions are included.  Use datascope to total the G and C and look for non zero amounts.&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type IN ('CR','PR','CV')&lt;br /&gt;
and trx_date between '1/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '1/1/24' and '12/31/24'&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Data:''' Amount&amp;lt;BR&amp;gt;&lt;br /&gt;
'''Row:''' Trx_Date,Session_no&amp;lt;BR&amp;gt;&lt;br /&gt;
'''Column:''' SRC&lt;br /&gt;
&lt;br /&gt;
Look for Grand Total column with a non-zero amount.&lt;br /&gt;
&lt;br /&gt;
===Query Method:===&lt;br /&gt;
Finds only the mismatched items.  Use modern IB that support derived (with) queries:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (Src,SesNo,TrxDate,TrxAmt) as&lt;br /&gt;
(&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type IN ('CR','PR','CV')&lt;br /&gt;
and trx_date between '7/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '7/1/24' and '12/31/24'&lt;br /&gt;
)&lt;br /&gt;
select sesno,trxdate,sum(trxamt) Total from aaa&lt;br /&gt;
group by sesno,trxdate&lt;br /&gt;
having sum(trxamt)&amp;lt;&amp;gt;0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=DataScope:_Match_G/L_Activity_to_Cash_Posting_Detail_by_Session_/_Date&amp;diff=1057</id>
		<title>DataScope: Match G/L Activity to Cash Posting Detail by Session / Date</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=DataScope:_Match_G/L_Activity_to_Cash_Posting_Detail_by_Session_/_Date&amp;diff=1057"/>
		<updated>2025-01-02T22:11:35Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Diagnose Cash Posting vs. G/L postings:&lt;br /&gt;
&lt;br /&gt;
==Verify &amp;quot;CC&amp;quot; transactions againste change in cash:==&lt;br /&gt;
&lt;br /&gt;
===DataScope Method===&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,-TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type='CC'&lt;br /&gt;
and  trx_date between '1/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT-D.ALLOW_AMOUNT-D.DISC_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '1/1/24' and '12/31/24'&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Query Method===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (Src,SesNo,TrxDate,TrxAmt) as&lt;br /&gt;
(&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,-TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type='CC'&lt;br /&gt;
and  trx_date between '1/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT-D.ALLOW_AMOUNT-D.DISC_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '1/1/24' and '12/31/24'&lt;br /&gt;
)&lt;br /&gt;
select sesno,trxdate,sum(trxamt) Total from aaa&lt;br /&gt;
group by sesno,trxdate&lt;br /&gt;
having sum(trxamt)&amp;lt;&amp;gt;0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Verify &amp;quot;CR&amp;quot; transactions against change in receivables:==&lt;br /&gt;
&lt;br /&gt;
===DataScope Method:===&lt;br /&gt;
All sessions are included.  Use datascope to total the G and C and look for non zero amounts.&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type IN ('CR','PR','CV')&lt;br /&gt;
and trx_date between '1/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '1/1/24' and '12/31/24'&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Data:''' Amount&amp;lt;BR&amp;gt;&lt;br /&gt;
'''Row:''' Trx_Date,Session_no&amp;lt;BR&amp;gt;&lt;br /&gt;
'''Column:''' SRC&lt;br /&gt;
&lt;br /&gt;
Look for Grand Total column with a non-zero amount.&lt;br /&gt;
&lt;br /&gt;
===Query Method:===&lt;br /&gt;
Finds only the mismatched items.  Use modern IB that support derived (with) queries:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (Src,SesNo,TrxDate,TrxAmt) as&lt;br /&gt;
(&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type IN ('CR','PR','CV')&lt;br /&gt;
and trx_date between '7/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '7/1/24' and '12/31/24'&lt;br /&gt;
)&lt;br /&gt;
select sesno,trxdate,sum(trxamt) Total from aaa&lt;br /&gt;
group by sesno,trxdate&lt;br /&gt;
having sum(trxamt)&amp;lt;&amp;gt;0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=DataScope:_Match_G/L_Activity_to_Cash_Posting_Detail_by_Session_/_Date&amp;diff=1056</id>
		<title>DataScope: Match G/L Activity to Cash Posting Detail by Session / Date</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=DataScope:_Match_G/L_Activity_to_Cash_Posting_Detail_by_Session_/_Date&amp;diff=1056"/>
		<updated>2025-01-02T22:10:00Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Verify &amp;quot;CC&amp;quot; transactions againste change in cash: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Diagnose Cash Posting vs. G/L postings:&lt;br /&gt;
&lt;br /&gt;
==Verify &amp;quot;CC&amp;quot; transactions againste change in cash:==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,-TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type='CC'&lt;br /&gt;
and  trx_date between '1/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT-D.ALLOW_AMOUNT-D.DISC_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '1/1/24' and '12/31/24'&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Verify &amp;quot;CR&amp;quot; transactions againste change in receivables:==&lt;br /&gt;
&lt;br /&gt;
===DataScope Method:===&lt;br /&gt;
All sessions are included.  Use datascope to total the G and C and look for non zero amounts.&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type IN ('CR','PR','CV')&lt;br /&gt;
and trx_date between '1/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '1/1/24' and '12/31/24'&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Data:''' Amount&amp;lt;BR&amp;gt;&lt;br /&gt;
'''Row:''' Trx_Date,Session_no&amp;lt;BR&amp;gt;&lt;br /&gt;
'''Column:''' SRC&lt;br /&gt;
&lt;br /&gt;
Look for Grand Total column with a non-zero amount.&lt;br /&gt;
&lt;br /&gt;
===Query Method:===&lt;br /&gt;
Finds only the mismatched items.  Use modern IB that support derived (with) queries:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (Src,SesNo,TrxDate,TrxAmt) as&lt;br /&gt;
(&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type IN ('CR','PR','CV')&lt;br /&gt;
and trx_date between '7/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '7/1/24' and '12/31/24'&lt;br /&gt;
)&lt;br /&gt;
select sesno,trxdate,sum(trxamt) Total from aaa&lt;br /&gt;
group by sesno,trxdate&lt;br /&gt;
having sum(trxamt)&amp;lt;&amp;gt;0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=DataScope:_Match_G/L_Activity_to_Cash_Posting_Detail_by_Session_/_Date&amp;diff=1055</id>
		<title>DataScope: Match G/L Activity to Cash Posting Detail by Session / Date</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=DataScope:_Match_G/L_Activity_to_Cash_Posting_Detail_by_Session_/_Date&amp;diff=1055"/>
		<updated>2025-01-02T22:08:29Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Diagnose Cash Posting vs. G/L postings:&lt;br /&gt;
&lt;br /&gt;
==Verify &amp;quot;CC&amp;quot; transactions againste change in cash:==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,-TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type='CC'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT-D.ALLOW_AMOUNT-D.DISC_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
==Verify &amp;quot;CR&amp;quot; transactions againste change in receivables:==&lt;br /&gt;
&lt;br /&gt;
===DataScope Method:===&lt;br /&gt;
All sessions are included.  Use datascope to total the G and C and look for non zero amounts.&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type IN ('CR','PR','CV')&lt;br /&gt;
and trx_date between '1/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '1/1/24' and '12/31/24'&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Data:''' Amount&amp;lt;BR&amp;gt;&lt;br /&gt;
'''Row:''' Trx_Date,Session_no&amp;lt;BR&amp;gt;&lt;br /&gt;
'''Column:''' SRC&lt;br /&gt;
&lt;br /&gt;
Look for Grand Total column with a non-zero amount.&lt;br /&gt;
&lt;br /&gt;
===Query Method:===&lt;br /&gt;
Finds only the mismatched items.  Use modern IB that support derived (with) queries:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (Src,SesNo,TrxDate,TrxAmt) as&lt;br /&gt;
(&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type IN ('CR','PR','CV')&lt;br /&gt;
and trx_date between '7/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '7/1/24' and '12/31/24'&lt;br /&gt;
)&lt;br /&gt;
select sesno,trxdate,sum(trxamt) Total from aaa&lt;br /&gt;
group by sesno,trxdate&lt;br /&gt;
having sum(trxamt)&amp;lt;&amp;gt;0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=DataScope:_Match_G/L_Activity_to_Cash_Posting_Detail_by_Session_/_Date&amp;diff=1054</id>
		<title>DataScope: Match G/L Activity to Cash Posting Detail by Session / Date</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=DataScope:_Match_G/L_Activity_to_Cash_Posting_Detail_by_Session_/_Date&amp;diff=1054"/>
		<updated>2025-01-02T22:07:49Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Diagnose Cash Posting vs. G/L postings:&lt;br /&gt;
&lt;br /&gt;
==Verify &amp;quot;CC&amp;quot; transactions againste change in cash:==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,-TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type='CC'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT-D.ALLOW_AMOUNT-D.DISC_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
==Verify &amp;quot;CR&amp;quot; transactions againste change in receivables:==&lt;br /&gt;
&lt;br /&gt;
DataScope Method:&lt;br /&gt;
All sessions are included.  Use datascope to total the G and C and look for non zero amounts.&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type IN ('CR','PR','CV')&lt;br /&gt;
and trx_date between '1/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '1/1/24' and '12/31/24'&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Data:''' Amount&amp;lt;BR&amp;gt;&lt;br /&gt;
'''Row:''' Trx_Date,Session_no&amp;lt;BR&amp;gt;&lt;br /&gt;
'''Column:''' SRC&lt;br /&gt;
&lt;br /&gt;
Query Method:&lt;br /&gt;
Finds only the mismatched items.  Use modern IB that support derived (with) queries:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (Src,SesNo,TrxDate,TrxAmt) as&lt;br /&gt;
(&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type IN ('CR','PR','CV')&lt;br /&gt;
and trx_date between '7/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '7/1/24' and '12/31/24'&lt;br /&gt;
)&lt;br /&gt;
select sesno,trxdate,sum(trxamt) Total from aaa&lt;br /&gt;
group by sesno,trxdate&lt;br /&gt;
having sum(trxamt)&amp;lt;&amp;gt;0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Look for Grand Total column with a non-zero amount.&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=DataScope:_Match_G/L_Activity_to_Cash_Posting_Detail_by_Session_/_Date&amp;diff=1053</id>
		<title>DataScope: Match G/L Activity to Cash Posting Detail by Session / Date</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=DataScope:_Match_G/L_Activity_to_Cash_Posting_Detail_by_Session_/_Date&amp;diff=1053"/>
		<updated>2025-01-02T20:03:17Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Diagnose Cash Posting vs. G/L postings:&lt;br /&gt;
&lt;br /&gt;
Verify &amp;quot;CC&amp;quot; transactions againste change in cash:&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,-TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type='CC'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT-D.ALLOW_AMOUNT-D.DISC_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Verify &amp;quot;CR&amp;quot; transactions againste change in receivables:&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select 'G' SRC,SESSION_NO,TRX_DATE,TRX_AMOUNT AMOUNT from glttrx&lt;br /&gt;
where  source_app='R' and source_trans_type IN ('CR','PR','CV')&lt;br /&gt;
and trx_date between '1/1/24' and '12/31/24'&lt;br /&gt;
UNION&lt;br /&gt;
SELECT 'C',D.SESSION_NO,H.POST_DATE,D.CREDIT_AMOUNT AMOUNT&lt;br /&gt;
 FROM ARTCSHDT D&lt;br /&gt;
INNER JOIN ARTCSHHD H ON H.SESSION_NO=D.SESSION_NO AND H.TRANS_NO=D.TRANS_NO&lt;br /&gt;
where post_date between '1/1/24' and '12/31/24'&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Data:''' Amount&amp;lt;BR&amp;gt;&lt;br /&gt;
'''Row:''' Trx_Date,Session_no&amp;lt;BR&amp;gt;&lt;br /&gt;
'''Column:''' SRC&lt;br /&gt;
&lt;br /&gt;
Look for Grand Total column with a non-zero amount.&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Sitenotice&amp;diff=1009</id>
		<title>Sitenotice</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Sitenotice&amp;diff=1009"/>
		<updated>2024-09-03T12:29:25Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Copyright GivenHansco 2005-2024&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Scale_Setup&amp;diff=1003</id>
		<title>Scale Setup</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Scale_Setup&amp;diff=1003"/>
		<updated>2024-08-27T19:40:32Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* View Scale Output */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Tools=&lt;br /&gt;
&lt;br /&gt;
*HyperTerminal (for viewing and capturing scale output)&lt;br /&gt;
*[https://notepad-plus-plus.org/ Notepad++] (for decoding special control characters in scale output)&lt;br /&gt;
&lt;br /&gt;
=Procedure=&lt;br /&gt;
&lt;br /&gt;
===Setup Keystone Device Server===&lt;br /&gt;
&lt;br /&gt;
On the PC connected to the scale, either Keystone must be installed (with the Device Server service running) or the Keystone Device Server must be manually installed (for example if the PC uses Remote Desktop to run Keystone.) If you need to manually install Keystone Device Server, use the following procedure:&lt;br /&gt;
#Create a folder in the root of the C: drive called &amp;quot;CCDeviceServer&amp;quot;&lt;br /&gt;
#Copy the CCDeviceServer.exe from a PC at the site that has Keystone installed (located in C:\Program Files (x86)\Keystone\Bin) into the C:\CCDeviceServer folder&lt;br /&gt;
#Run a Command Prompt as Administrator&lt;br /&gt;
#Type: C:\CCDeviceServer\CCDeviceServer.exe /install&lt;br /&gt;
#Start the &amp;quot;Keystone Device Server&amp;quot; service&lt;br /&gt;
&lt;br /&gt;
===Configure Keystone Device Server===&lt;br /&gt;
&lt;br /&gt;
#Open a web browser&lt;br /&gt;
#Navigate to &amp;quot;http://127.0.0.1:6021&amp;quot;&lt;br /&gt;
#Click &amp;quot;Configuration&amp;quot;&lt;br /&gt;
#Setup a unique Device Server ID (DS followed by plant number is usually a good choice)&lt;br /&gt;
#Enter the WAN IP address of the main server in the Aggregator IP Address field&lt;br /&gt;
#Click &amp;quot;Submit&amp;quot;&lt;br /&gt;
[[File:DeviceServerRemoteConfigA.PNG|480px]]&lt;br /&gt;
&lt;br /&gt;
===Capture Scale Output===&lt;br /&gt;
&lt;br /&gt;
#Using HyperTerminal, connect to the scale&lt;br /&gt;
#Once the scale is reading properly,  select Transfer-&amp;gt;Capture Text, select a filename to save the scale output and click Start&lt;br /&gt;
#Let the scale read for about 10 seconds (it is useful to have some weight on the scale if possible)&lt;br /&gt;
#Select Transfer-&amp;gt;Capture Text-&amp;gt;Stop&lt;br /&gt;
[[File:HyperTerminalScale.PNG]]&lt;br /&gt;
&lt;br /&gt;
===View Scale Output===&lt;br /&gt;
&lt;br /&gt;
#Open the file in Notepad++&lt;br /&gt;
#Select View-&amp;gt;Show Symbol-&amp;gt;Show All Characters (this will allow you to see any special characters in the scale output)&lt;br /&gt;
[[File:NotepadPlusPlusScale.PNG]]&lt;br /&gt;
&lt;br /&gt;
===Determine End of Line and Record Length===&lt;br /&gt;
&lt;br /&gt;
#On a complete scale data line, hit the END key and note the &amp;quot;Col&amp;quot; number in the status bar&lt;br /&gt;
#Add the number of end of line characters to the value from step #1 (for example, is you see CRLF you would add 2)&lt;br /&gt;
#This number is the RECL device parameter&lt;br /&gt;
#[Keystone 4.3.6+] If there are end of line characters after the cursor, these will become the EOLHEX device parameter (convert to hex)&lt;br /&gt;
&lt;br /&gt;
===Determine Check Code===&lt;br /&gt;
&lt;br /&gt;
#Look for one or more characters that are repeated on each line of the scale output (preferably before the weight)&lt;br /&gt;
#Note the starting position of the repeated characters, this will become the CHECKCOL device parameter&lt;br /&gt;
#Note the characters themselves, this will become the CHECKCODE or CHECKCODEHEX device parameter (if the check code contains special control codes, use the chart below to determine the hex values for the characters)&lt;br /&gt;
[[File:ASCIIControlCodes.png]]&lt;br /&gt;
&lt;br /&gt;
===Determine Weight===&lt;br /&gt;
&lt;br /&gt;
#Look for the weight (if the weight is zero or a low number, allow for at least 6 digits)&lt;br /&gt;
#Note the starting position of the weight, this will become the WEIGHTCOL device parameter&lt;br /&gt;
#Note the length of the weight (usually 6), this will become the WEIGHTLEN device parameter&lt;br /&gt;
&lt;br /&gt;
===Configure Unit of Measure===&lt;br /&gt;
&lt;br /&gt;
#The default U/M for scales is LB (pounds.)&lt;br /&gt;
#If the scale sends weight in a different U/M, set the UNITOFMEASURE device parameter to the U/M that the scale is sending.&lt;br /&gt;
&lt;br /&gt;
===Determine Overcapacity Indicator===&lt;br /&gt;
&lt;br /&gt;
(Keystone 4.3.9.5+)&lt;br /&gt;
#Consult the scale documentation to determine which character(s)/code(s) indicate an over-capacity condition&lt;br /&gt;
#Note the starting position of this indicator, this will become the OVERCAPCOL device parameter&lt;br /&gt;
#Note the characters themselves, this will become the OVERCAPCODE or OVERCAPCODEHEX device parameter (if the over-capacity code contains special control codes, use the chart in the &amp;quot;Determine Check Code&amp;quot; section to determine the hex values for the characters)&lt;br /&gt;
&lt;br /&gt;
===Update Keystone Device Information===&lt;br /&gt;
&lt;br /&gt;
#Open Device Maintenance&lt;br /&gt;
#Select or create the scale device&lt;br /&gt;
#Enter the scale parameters in the Device Configuration tab (sample below)&lt;br /&gt;
[[File:DeviceMaintenanceScale.PNG]]&lt;br /&gt;
&lt;br /&gt;
===Start/Restart Services===&lt;br /&gt;
&lt;br /&gt;
#On the main server, start or restart the Device Aggregator&lt;br /&gt;
#Wait a few seconds, then start or restart the Device Server&lt;br /&gt;
#On the PC connected to the scale, start or restart the Device Server&lt;br /&gt;
&lt;br /&gt;
=Old outdated information=&lt;br /&gt;
&lt;br /&gt;
Sample scale settings using classic device server (pre aggregator):&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
Start Device server on computer that will be connected to the scale:&lt;br /&gt;
Start/Run &amp;quot;c:\program files\GivenHansco\cc\bin\ccdevsv&amp;quot; /i /l &lt;br /&gt;
Login as ADMIN&lt;br /&gt;
Open Device Maint. off of the System Maint Menu&lt;br /&gt;
Create new device:&lt;br /&gt;
Device ID e.g.: SCALE01&lt;br /&gt;
Description: e.g. SMITHFIELD SCALE&lt;br /&gt;
type: SCALE&lt;br /&gt;
Dev Server ID: Leave Blank (Used for Device Server/Aggregator)&lt;br /&gt;
In Device Aggregator Box:&lt;br /&gt;
 ip address -- if stand alone 127.0.0.1&lt;br /&gt;
 port 6000&lt;br /&gt;
&lt;br /&gt;
Copy and paste the sample device config settings&lt;br /&gt;
&lt;br /&gt;
COMPort=1&lt;br /&gt;
BaudRate=9600&lt;br /&gt;
DataBits=8&lt;br /&gt;
StopBits=1&lt;br /&gt;
Parity=N&lt;br /&gt;
CheckCode=LB&lt;br /&gt;
CheckCol=9&lt;br /&gt;
WeightCol=2&lt;br /&gt;
WeightLen=6&lt;br /&gt;
RECL=17&lt;br /&gt;
UnitOfMeasure=LB&lt;br /&gt;
&lt;br /&gt;
modify baud, databits, stopbits, parity to match what scale guy tells you.&lt;br /&gt;
&lt;br /&gt;
Make sure scale is connected&lt;br /&gt;
F5 - test &lt;br /&gt;
Automatic &lt;br /&gt;
F2 TEST&lt;br /&gt;
&lt;br /&gt;
hopefully it finds it&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Scale_Setup&amp;diff=1002</id>
		<title>Scale Setup</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Scale_Setup&amp;diff=1002"/>
		<updated>2024-08-27T19:40:04Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Update Keystone Device Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Tools=&lt;br /&gt;
&lt;br /&gt;
*HyperTerminal (for viewing and capturing scale output)&lt;br /&gt;
*[https://notepad-plus-plus.org/ Notepad++] (for decoding special control characters in scale output)&lt;br /&gt;
&lt;br /&gt;
=Procedure=&lt;br /&gt;
&lt;br /&gt;
===Setup Keystone Device Server===&lt;br /&gt;
&lt;br /&gt;
On the PC connected to the scale, either Keystone must be installed (with the Device Server service running) or the Keystone Device Server must be manually installed (for example if the PC uses Remote Desktop to run Keystone.) If you need to manually install Keystone Device Server, use the following procedure:&lt;br /&gt;
#Create a folder in the root of the C: drive called &amp;quot;CCDeviceServer&amp;quot;&lt;br /&gt;
#Copy the CCDeviceServer.exe from a PC at the site that has Keystone installed (located in C:\Program Files (x86)\Keystone\Bin) into the C:\CCDeviceServer folder&lt;br /&gt;
#Run a Command Prompt as Administrator&lt;br /&gt;
#Type: C:\CCDeviceServer\CCDeviceServer.exe /install&lt;br /&gt;
#Start the &amp;quot;Keystone Device Server&amp;quot; service&lt;br /&gt;
&lt;br /&gt;
===Configure Keystone Device Server===&lt;br /&gt;
&lt;br /&gt;
#Open a web browser&lt;br /&gt;
#Navigate to &amp;quot;http://127.0.0.1:6021&amp;quot;&lt;br /&gt;
#Click &amp;quot;Configuration&amp;quot;&lt;br /&gt;
#Setup a unique Device Server ID (DS followed by plant number is usually a good choice)&lt;br /&gt;
#Enter the WAN IP address of the main server in the Aggregator IP Address field&lt;br /&gt;
#Click &amp;quot;Submit&amp;quot;&lt;br /&gt;
[[File:DeviceServerRemoteConfigA.PNG|480px]]&lt;br /&gt;
&lt;br /&gt;
===Capture Scale Output===&lt;br /&gt;
&lt;br /&gt;
#Using HyperTerminal, connect to the scale&lt;br /&gt;
#Once the scale is reading properly,  select Transfer-&amp;gt;Capture Text, select a filename to save the scale output and click Start&lt;br /&gt;
#Let the scale read for about 10 seconds (it is useful to have some weight on the scale if possible)&lt;br /&gt;
#Select Transfer-&amp;gt;Capture Text-&amp;gt;Stop&lt;br /&gt;
[[File:HyperTerminalScale.PNG]]&lt;br /&gt;
&lt;br /&gt;
===View Scale Output===&lt;br /&gt;
&lt;br /&gt;
#Open the file in Notepad++&lt;br /&gt;
#Select View-&amp;gt;Show Symbol-&amp;gt;Show All Characters (this will allow you to see any special characters in the scale output)&lt;br /&gt;
[[File:NotepadPlusPlusScale.PNG|480px]]&lt;br /&gt;
&lt;br /&gt;
===Determine End of Line and Record Length===&lt;br /&gt;
&lt;br /&gt;
#On a complete scale data line, hit the END key and note the &amp;quot;Col&amp;quot; number in the status bar&lt;br /&gt;
#Add the number of end of line characters to the value from step #1 (for example, is you see CRLF you would add 2)&lt;br /&gt;
#This number is the RECL device parameter&lt;br /&gt;
#[Keystone 4.3.6+] If there are end of line characters after the cursor, these will become the EOLHEX device parameter (convert to hex)&lt;br /&gt;
&lt;br /&gt;
===Determine Check Code===&lt;br /&gt;
&lt;br /&gt;
#Look for one or more characters that are repeated on each line of the scale output (preferably before the weight)&lt;br /&gt;
#Note the starting position of the repeated characters, this will become the CHECKCOL device parameter&lt;br /&gt;
#Note the characters themselves, this will become the CHECKCODE or CHECKCODEHEX device parameter (if the check code contains special control codes, use the chart below to determine the hex values for the characters)&lt;br /&gt;
[[File:ASCIIControlCodes.png]]&lt;br /&gt;
&lt;br /&gt;
===Determine Weight===&lt;br /&gt;
&lt;br /&gt;
#Look for the weight (if the weight is zero or a low number, allow for at least 6 digits)&lt;br /&gt;
#Note the starting position of the weight, this will become the WEIGHTCOL device parameter&lt;br /&gt;
#Note the length of the weight (usually 6), this will become the WEIGHTLEN device parameter&lt;br /&gt;
&lt;br /&gt;
===Configure Unit of Measure===&lt;br /&gt;
&lt;br /&gt;
#The default U/M for scales is LB (pounds.)&lt;br /&gt;
#If the scale sends weight in a different U/M, set the UNITOFMEASURE device parameter to the U/M that the scale is sending.&lt;br /&gt;
&lt;br /&gt;
===Determine Overcapacity Indicator===&lt;br /&gt;
&lt;br /&gt;
(Keystone 4.3.9.5+)&lt;br /&gt;
#Consult the scale documentation to determine which character(s)/code(s) indicate an over-capacity condition&lt;br /&gt;
#Note the starting position of this indicator, this will become the OVERCAPCOL device parameter&lt;br /&gt;
#Note the characters themselves, this will become the OVERCAPCODE or OVERCAPCODEHEX device parameter (if the over-capacity code contains special control codes, use the chart in the &amp;quot;Determine Check Code&amp;quot; section to determine the hex values for the characters)&lt;br /&gt;
&lt;br /&gt;
===Update Keystone Device Information===&lt;br /&gt;
&lt;br /&gt;
#Open Device Maintenance&lt;br /&gt;
#Select or create the scale device&lt;br /&gt;
#Enter the scale parameters in the Device Configuration tab (sample below)&lt;br /&gt;
[[File:DeviceMaintenanceScale.PNG]]&lt;br /&gt;
&lt;br /&gt;
===Start/Restart Services===&lt;br /&gt;
&lt;br /&gt;
#On the main server, start or restart the Device Aggregator&lt;br /&gt;
#Wait a few seconds, then start or restart the Device Server&lt;br /&gt;
#On the PC connected to the scale, start or restart the Device Server&lt;br /&gt;
&lt;br /&gt;
=Old outdated information=&lt;br /&gt;
&lt;br /&gt;
Sample scale settings using classic device server (pre aggregator):&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
Start Device server on computer that will be connected to the scale:&lt;br /&gt;
Start/Run &amp;quot;c:\program files\GivenHansco\cc\bin\ccdevsv&amp;quot; /i /l &lt;br /&gt;
Login as ADMIN&lt;br /&gt;
Open Device Maint. off of the System Maint Menu&lt;br /&gt;
Create new device:&lt;br /&gt;
Device ID e.g.: SCALE01&lt;br /&gt;
Description: e.g. SMITHFIELD SCALE&lt;br /&gt;
type: SCALE&lt;br /&gt;
Dev Server ID: Leave Blank (Used for Device Server/Aggregator)&lt;br /&gt;
In Device Aggregator Box:&lt;br /&gt;
 ip address -- if stand alone 127.0.0.1&lt;br /&gt;
 port 6000&lt;br /&gt;
&lt;br /&gt;
Copy and paste the sample device config settings&lt;br /&gt;
&lt;br /&gt;
COMPort=1&lt;br /&gt;
BaudRate=9600&lt;br /&gt;
DataBits=8&lt;br /&gt;
StopBits=1&lt;br /&gt;
Parity=N&lt;br /&gt;
CheckCode=LB&lt;br /&gt;
CheckCol=9&lt;br /&gt;
WeightCol=2&lt;br /&gt;
WeightLen=6&lt;br /&gt;
RECL=17&lt;br /&gt;
UnitOfMeasure=LB&lt;br /&gt;
&lt;br /&gt;
modify baud, databits, stopbits, parity to match what scale guy tells you.&lt;br /&gt;
&lt;br /&gt;
Make sure scale is connected&lt;br /&gt;
F5 - test &lt;br /&gt;
Automatic &lt;br /&gt;
F2 TEST&lt;br /&gt;
&lt;br /&gt;
hopefully it finds it&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Scale_Setup&amp;diff=1001</id>
		<title>Scale Setup</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Scale_Setup&amp;diff=1001"/>
		<updated>2024-08-27T19:39:39Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Tools=&lt;br /&gt;
&lt;br /&gt;
*HyperTerminal (for viewing and capturing scale output)&lt;br /&gt;
*[https://notepad-plus-plus.org/ Notepad++] (for decoding special control characters in scale output)&lt;br /&gt;
&lt;br /&gt;
=Procedure=&lt;br /&gt;
&lt;br /&gt;
===Setup Keystone Device Server===&lt;br /&gt;
&lt;br /&gt;
On the PC connected to the scale, either Keystone must be installed (with the Device Server service running) or the Keystone Device Server must be manually installed (for example if the PC uses Remote Desktop to run Keystone.) If you need to manually install Keystone Device Server, use the following procedure:&lt;br /&gt;
#Create a folder in the root of the C: drive called &amp;quot;CCDeviceServer&amp;quot;&lt;br /&gt;
#Copy the CCDeviceServer.exe from a PC at the site that has Keystone installed (located in C:\Program Files (x86)\Keystone\Bin) into the C:\CCDeviceServer folder&lt;br /&gt;
#Run a Command Prompt as Administrator&lt;br /&gt;
#Type: C:\CCDeviceServer\CCDeviceServer.exe /install&lt;br /&gt;
#Start the &amp;quot;Keystone Device Server&amp;quot; service&lt;br /&gt;
&lt;br /&gt;
===Configure Keystone Device Server===&lt;br /&gt;
&lt;br /&gt;
#Open a web browser&lt;br /&gt;
#Navigate to &amp;quot;http://127.0.0.1:6021&amp;quot;&lt;br /&gt;
#Click &amp;quot;Configuration&amp;quot;&lt;br /&gt;
#Setup a unique Device Server ID (DS followed by plant number is usually a good choice)&lt;br /&gt;
#Enter the WAN IP address of the main server in the Aggregator IP Address field&lt;br /&gt;
#Click &amp;quot;Submit&amp;quot;&lt;br /&gt;
[[File:DeviceServerRemoteConfigA.PNG|480px]]&lt;br /&gt;
&lt;br /&gt;
===Capture Scale Output===&lt;br /&gt;
&lt;br /&gt;
#Using HyperTerminal, connect to the scale&lt;br /&gt;
#Once the scale is reading properly,  select Transfer-&amp;gt;Capture Text, select a filename to save the scale output and click Start&lt;br /&gt;
#Let the scale read for about 10 seconds (it is useful to have some weight on the scale if possible)&lt;br /&gt;
#Select Transfer-&amp;gt;Capture Text-&amp;gt;Stop&lt;br /&gt;
[[File:HyperTerminalScale.PNG]]&lt;br /&gt;
&lt;br /&gt;
===View Scale Output===&lt;br /&gt;
&lt;br /&gt;
#Open the file in Notepad++&lt;br /&gt;
#Select View-&amp;gt;Show Symbol-&amp;gt;Show All Characters (this will allow you to see any special characters in the scale output)&lt;br /&gt;
[[File:NotepadPlusPlusScale.PNG|480px]]&lt;br /&gt;
&lt;br /&gt;
===Determine End of Line and Record Length===&lt;br /&gt;
&lt;br /&gt;
#On a complete scale data line, hit the END key and note the &amp;quot;Col&amp;quot; number in the status bar&lt;br /&gt;
#Add the number of end of line characters to the value from step #1 (for example, is you see CRLF you would add 2)&lt;br /&gt;
#This number is the RECL device parameter&lt;br /&gt;
#[Keystone 4.3.6+] If there are end of line characters after the cursor, these will become the EOLHEX device parameter (convert to hex)&lt;br /&gt;
&lt;br /&gt;
===Determine Check Code===&lt;br /&gt;
&lt;br /&gt;
#Look for one or more characters that are repeated on each line of the scale output (preferably before the weight)&lt;br /&gt;
#Note the starting position of the repeated characters, this will become the CHECKCOL device parameter&lt;br /&gt;
#Note the characters themselves, this will become the CHECKCODE or CHECKCODEHEX device parameter (if the check code contains special control codes, use the chart below to determine the hex values for the characters)&lt;br /&gt;
[[File:ASCIIControlCodes.png]]&lt;br /&gt;
&lt;br /&gt;
===Determine Weight===&lt;br /&gt;
&lt;br /&gt;
#Look for the weight (if the weight is zero or a low number, allow for at least 6 digits)&lt;br /&gt;
#Note the starting position of the weight, this will become the WEIGHTCOL device parameter&lt;br /&gt;
#Note the length of the weight (usually 6), this will become the WEIGHTLEN device parameter&lt;br /&gt;
&lt;br /&gt;
===Configure Unit of Measure===&lt;br /&gt;
&lt;br /&gt;
#The default U/M for scales is LB (pounds.)&lt;br /&gt;
#If the scale sends weight in a different U/M, set the UNITOFMEASURE device parameter to the U/M that the scale is sending.&lt;br /&gt;
&lt;br /&gt;
===Determine Overcapacity Indicator===&lt;br /&gt;
&lt;br /&gt;
(Keystone 4.3.9.5+)&lt;br /&gt;
#Consult the scale documentation to determine which character(s)/code(s) indicate an over-capacity condition&lt;br /&gt;
#Note the starting position of this indicator, this will become the OVERCAPCOL device parameter&lt;br /&gt;
#Note the characters themselves, this will become the OVERCAPCODE or OVERCAPCODEHEX device parameter (if the over-capacity code contains special control codes, use the chart in the &amp;quot;Determine Check Code&amp;quot; section to determine the hex values for the characters)&lt;br /&gt;
&lt;br /&gt;
===Update Keystone Device Information===&lt;br /&gt;
&lt;br /&gt;
#Open Device Maintenance&lt;br /&gt;
#Select or create the scale device&lt;br /&gt;
#Enter the scale parameters in the Device Configuration tab (sample below)&lt;br /&gt;
[[File:DeviceMaintenanceScale.PNG|480px]]&lt;br /&gt;
&lt;br /&gt;
===Start/Restart Services===&lt;br /&gt;
&lt;br /&gt;
#On the main server, start or restart the Device Aggregator&lt;br /&gt;
#Wait a few seconds, then start or restart the Device Server&lt;br /&gt;
#On the PC connected to the scale, start or restart the Device Server&lt;br /&gt;
&lt;br /&gt;
=Old outdated information=&lt;br /&gt;
&lt;br /&gt;
Sample scale settings using classic device server (pre aggregator):&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
Start Device server on computer that will be connected to the scale:&lt;br /&gt;
Start/Run &amp;quot;c:\program files\GivenHansco\cc\bin\ccdevsv&amp;quot; /i /l &lt;br /&gt;
Login as ADMIN&lt;br /&gt;
Open Device Maint. off of the System Maint Menu&lt;br /&gt;
Create new device:&lt;br /&gt;
Device ID e.g.: SCALE01&lt;br /&gt;
Description: e.g. SMITHFIELD SCALE&lt;br /&gt;
type: SCALE&lt;br /&gt;
Dev Server ID: Leave Blank (Used for Device Server/Aggregator)&lt;br /&gt;
In Device Aggregator Box:&lt;br /&gt;
 ip address -- if stand alone 127.0.0.1&lt;br /&gt;
 port 6000&lt;br /&gt;
&lt;br /&gt;
Copy and paste the sample device config settings&lt;br /&gt;
&lt;br /&gt;
COMPort=1&lt;br /&gt;
BaudRate=9600&lt;br /&gt;
DataBits=8&lt;br /&gt;
StopBits=1&lt;br /&gt;
Parity=N&lt;br /&gt;
CheckCode=LB&lt;br /&gt;
CheckCol=9&lt;br /&gt;
WeightCol=2&lt;br /&gt;
WeightLen=6&lt;br /&gt;
RECL=17&lt;br /&gt;
UnitOfMeasure=LB&lt;br /&gt;
&lt;br /&gt;
modify baud, databits, stopbits, parity to match what scale guy tells you.&lt;br /&gt;
&lt;br /&gt;
Make sure scale is connected&lt;br /&gt;
F5 - test &lt;br /&gt;
Automatic &lt;br /&gt;
F2 TEST&lt;br /&gt;
&lt;br /&gt;
hopefully it finds it&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Scale_Setup&amp;diff=1000</id>
		<title>Scale Setup</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Scale_Setup&amp;diff=1000"/>
		<updated>2024-08-27T19:33:36Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Tools=&lt;br /&gt;
&lt;br /&gt;
*HyperTerminal (for viewing and capturing scale output)&lt;br /&gt;
*[https://notepad-plus-plus.org/ Notepad++] (for decoding special control characters in scale output)&lt;br /&gt;
&lt;br /&gt;
=Procedure=&lt;br /&gt;
&lt;br /&gt;
===Setup Keystone Device Server===&lt;br /&gt;
&lt;br /&gt;
On the PC connected to the scale, either Keystone must be installed (with the Device Server service running) or the Keystone Device Server must be manually installed (for example if the PC uses Remote Desktop to run Keystone.) If you need to manually install Keystone Device Server, use the following procedure:&lt;br /&gt;
#Create a folder in the root of the C: drive called &amp;quot;CCDeviceServer&amp;quot;&lt;br /&gt;
#Copy the CCDeviceServer.exe from a PC at the site that has Keystone installed (located in C:\Program Files (x86)\Keystone\Bin) into the C:\CCDeviceServer folder&lt;br /&gt;
#Run a Command Prompt as Administrator&lt;br /&gt;
#Type: C:\CCDeviceServer\CCDeviceServer.exe /install&lt;br /&gt;
#Start the &amp;quot;Keystone Device Server&amp;quot; service&lt;br /&gt;
&lt;br /&gt;
===Configure Keystone Device Server===&lt;br /&gt;
&lt;br /&gt;
#Open a web browser&lt;br /&gt;
#Navigate to &amp;quot;http://127.0.0.1:6021&amp;quot;&lt;br /&gt;
#Click &amp;quot;Configuration&amp;quot;&lt;br /&gt;
#Setup a unique Device Server ID (DS followed by plant number is usually a good choice)&lt;br /&gt;
#Enter the WAN IP address of the main server in the Aggregator IP Address field&lt;br /&gt;
#Click &amp;quot;Submit&amp;quot;&lt;br /&gt;
[[File:DeviceServerRemoteConfigA.PNG|480px]]&lt;br /&gt;
&lt;br /&gt;
===Capture Scale Output===&lt;br /&gt;
&lt;br /&gt;
#Using HyperTerminal, connect to the scale&lt;br /&gt;
#Once the scale is reading properly,  select Transfer-&amp;gt;Capture Text, select a filename to save the scale output and click Start&lt;br /&gt;
#Let the scale read for about 10 seconds (it is useful to have some weight on the scale if possible)&lt;br /&gt;
#Select Transfer-&amp;gt;Capture Text-&amp;gt;Stop&lt;br /&gt;
[[File:HyperTerminalScale.PNG|480px]]&lt;br /&gt;
&lt;br /&gt;
===View Scale Output===&lt;br /&gt;
&lt;br /&gt;
#Open the file in Notepad++&lt;br /&gt;
#Select View-&amp;gt;Show Symbol-&amp;gt;Show All Characters (this will allow you to see any special characters in the scale output)&lt;br /&gt;
[[File:NotepadPlusPlusScale.PNG|480px]]&lt;br /&gt;
&lt;br /&gt;
===Determine End of Line and Record Length===&lt;br /&gt;
&lt;br /&gt;
#On a complete scale data line, hit the END key and note the &amp;quot;Col&amp;quot; number in the status bar&lt;br /&gt;
#Add the number of end of line characters to the value from step #1 (for example, is you see CRLF you would add 2)&lt;br /&gt;
#This number is the RECL device parameter&lt;br /&gt;
#[Keystone 4.3.6+] If there are end of line characters after the cursor, these will become the EOLHEX device parameter (convert to hex)&lt;br /&gt;
&lt;br /&gt;
===Determine Check Code===&lt;br /&gt;
&lt;br /&gt;
#Look for one or more characters that are repeated on each line of the scale output (preferably before the weight)&lt;br /&gt;
#Note the starting position of the repeated characters, this will become the CHECKCOL device parameter&lt;br /&gt;
#Note the characters themselves, this will become the CHECKCODE or CHECKCODEHEX device parameter (if the check code contains special control codes, use the chart below to determine the hex values for the characters)&lt;br /&gt;
[[File:ASCIIControlCodes.png|720px]]&lt;br /&gt;
&lt;br /&gt;
===Determine Weight===&lt;br /&gt;
&lt;br /&gt;
#Look for the weight (if the weight is zero or a low number, allow for at least 6 digits)&lt;br /&gt;
#Note the starting position of the weight, this will become the WEIGHTCOL device parameter&lt;br /&gt;
#Note the length of the weight (usually 6), this will become the WEIGHTLEN device parameter&lt;br /&gt;
&lt;br /&gt;
===Configure Unit of Measure===&lt;br /&gt;
&lt;br /&gt;
#The default U/M for scales is LB (pounds.)&lt;br /&gt;
#If the scale sends weight in a different U/M, set the UNITOFMEASURE device parameter to the U/M that the scale is sending.&lt;br /&gt;
&lt;br /&gt;
===Determine Overcapacity Indicator===&lt;br /&gt;
&lt;br /&gt;
(Keystone 4.3.9.5+)&lt;br /&gt;
#Consult the scale documentation to determine which character(s)/code(s) indicate an over-capacity condition&lt;br /&gt;
#Note the starting position of this indicator, this will become the OVERCAPCOL device parameter&lt;br /&gt;
#Note the characters themselves, this will become the OVERCAPCODE or OVERCAPCODEHEX device parameter (if the over-capacity code contains special control codes, use the chart in the &amp;quot;Determine Check Code&amp;quot; section to determine the hex values for the characters)&lt;br /&gt;
&lt;br /&gt;
===Update Keystone Device Information===&lt;br /&gt;
&lt;br /&gt;
#Open Device Maintenance&lt;br /&gt;
#Select or create the scale device&lt;br /&gt;
#Enter the scale parameters in the Device Configuration tab (sample below)&lt;br /&gt;
[[File:DeviceMaintenanceScale.PNG|480px]]&lt;br /&gt;
&lt;br /&gt;
===Start/Restart Services===&lt;br /&gt;
&lt;br /&gt;
#On the main server, start or restart the Device Aggregator&lt;br /&gt;
#Wait a few seconds, then start or restart the Device Server&lt;br /&gt;
#On the PC connected to the scale, start or restart the Device Server&lt;br /&gt;
&lt;br /&gt;
=Old outdated information=&lt;br /&gt;
&lt;br /&gt;
Sample scale settings using classic device server (pre aggregator):&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
Start Device server on computer that will be connected to the scale:&lt;br /&gt;
Start/Run &amp;quot;c:\program files\GivenHansco\cc\bin\ccdevsv&amp;quot; /i /l &lt;br /&gt;
Login as ADMIN&lt;br /&gt;
Open Device Maint. off of the System Maint Menu&lt;br /&gt;
Create new device:&lt;br /&gt;
Device ID e.g.: SCALE01&lt;br /&gt;
Description: e.g. SMITHFIELD SCALE&lt;br /&gt;
type: SCALE&lt;br /&gt;
Dev Server ID: Leave Blank (Used for Device Server/Aggregator)&lt;br /&gt;
In Device Aggregator Box:&lt;br /&gt;
 ip address -- if stand alone 127.0.0.1&lt;br /&gt;
 port 6000&lt;br /&gt;
&lt;br /&gt;
Copy and paste the sample device config settings&lt;br /&gt;
&lt;br /&gt;
COMPort=1&lt;br /&gt;
BaudRate=9600&lt;br /&gt;
DataBits=8&lt;br /&gt;
StopBits=1&lt;br /&gt;
Parity=N&lt;br /&gt;
CheckCode=LB&lt;br /&gt;
CheckCol=9&lt;br /&gt;
WeightCol=2&lt;br /&gt;
WeightLen=6&lt;br /&gt;
RECL=17&lt;br /&gt;
UnitOfMeasure=LB&lt;br /&gt;
&lt;br /&gt;
modify baud, databits, stopbits, parity to match what scale guy tells you.&lt;br /&gt;
&lt;br /&gt;
Make sure scale is connected&lt;br /&gt;
F5 - test &lt;br /&gt;
Automatic &lt;br /&gt;
F2 TEST&lt;br /&gt;
&lt;br /&gt;
hopefully it finds it&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=File:DeviceServerRemoteConfigA.PNG&amp;diff=999</id>
		<title>File:DeviceServerRemoteConfigA.PNG</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=File:DeviceServerRemoteConfigA.PNG&amp;diff=999"/>
		<updated>2024-08-27T19:33:24Z</updated>

		<summary type="html">&lt;p&gt;Chanson: File uploaded with MsUpload&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=QueryGen_Case:_Add_missing_item_to_all_Jobs&amp;diff=969</id>
		<title>QueryGen Case: Add missing item to all Jobs</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=QueryGen_Case:_Add_missing_item_to_all_Jobs&amp;diff=969"/>
		<updated>2024-03-27T15:34:36Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Sometimes you want to add an detail item to all jobs.&lt;br /&gt;
&lt;br /&gt;
In this case, we will add the item ENVIRO.01 (adjusted to plant) to all jobs wher it is missing.  In the query below we select all jobs and identify which do NOT have a product like ENVIRO.&lt;br /&gt;
Artjob as d1 represents the detail line that should exist if ENVIRO.XX is in the job detail.&lt;br /&gt;
Artjob as d0 is used to find a valid plant number on a product.  (you can't count on the job header).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
select h.session_no,h.trans_no,h.cust_no,c.name, h.job_po_loc, h.start_date, h.stop_date,coalesce(min(p0.plant_no),'1A') Plant,h.active_flag,h.job_tax_code from artjobhd h&lt;br /&gt;
inner join artcust c on c.cust_no=h.cust_no&lt;br /&gt;
left outer join artjobdt d0 ON d0.session_no=h.session_no and d0.trans_no=h.trans_no &lt;br /&gt;
left outer  join artprod p0 on p0.product_code=d0.product_code&lt;br /&gt;
left outer join artjobdt d1 ON d1.session_no=h.session_no and d1.trans_no=h.trans_no AND D1.PRODUCT_CODE LIKE 'ENVIRO.%'&lt;br /&gt;
where (d1.product_code is null)&lt;br /&gt;
and h.active_flag='Y' AND C.ACTIVE_FLAG='Y'&lt;br /&gt;
group by h.session_no,h.trans_no, h.cust_no,c.name, h.job_po_loc, h.start_date, h.stop_date,h.active_flag,h.job_tax_code&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjust this query to your case:&lt;br /&gt;
*Change 'ENVIRO.%' to the product you wish to work with.&lt;br /&gt;
*Change the job selection to your situation.  (START_DATE, STOP_DATE etc.)&lt;br /&gt;
&lt;br /&gt;
Then use the following QG model Update Query:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
INSERT INTO &lt;br /&gt;
artjobdt&lt;br /&gt;
( SESSION_NO, TRANS_NO, CUST_NO, JOB_PO_LOC, LINE_NO, PRICE_CODE, PRODUCT_CODE, UNIT_PRICE, QTY_ORDERED, TAX_CODE, QTY_PER_LOAD, UNIT_OF_MEASURE, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER )  VALUES &lt;br /&gt;
( {SESSION_NO}, {TRANS_NO}, '{CUST_NO}', '{JOB_PO_LOC}', 99, 'P', 'ENVIRO.{PLANT}', 55, 0, '{JOB_TAX_CODE}', 0, '/L', 'ENVIRONMENTAL FEE PER LOAD', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT'    );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjust the model update query:&lt;br /&gt;
*Line No: 99 must not exist.  If multiptle products being processed change for each product.&lt;br /&gt;
*Price: Here it's 55.  NOTE: you can come back and fix the price later.&lt;br /&gt;
*Product Code: Change ENVIRO to yoru product&lt;br /&gt;
*Unit of Measure: Match Product&lt;br /&gt;
*Desription: Match Product&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=QueryGen_Case:_Add_missing_item_to_all_Jobs&amp;diff=968</id>
		<title>QueryGen Case: Add missing item to all Jobs</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=QueryGen_Case:_Add_missing_item_to_all_Jobs&amp;diff=968"/>
		<updated>2024-03-27T15:34:09Z</updated>

		<summary type="html">&lt;p&gt;Chanson: Created page with &amp;quot;Sometimes you want to add an detail item to all jobs.  In this case, we will add the item ENVIRO.01 (adjusted to plant) to all jobs wher it is missing.  In the query below we select all jobs and identify which do NOT have a product like ENVIRO. Artjob as d1 represents the detail line that should exist if ENVIRO.XX is in the job detail. Artjob as d0 is used to find a valid plant number on a product.  (you can't count on the job header).  &amp;lt;pre&amp;gt; select h.session_no,h.trans_...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Sometimes you want to add an detail item to all jobs.&lt;br /&gt;
&lt;br /&gt;
In this case, we will add the item ENVIRO.01 (adjusted to plant) to all jobs wher it is missing.  In the query below we select all jobs and identify which do NOT have a product like ENVIRO.&lt;br /&gt;
Artjob as d1 represents the detail line that should exist if ENVIRO.XX is in the job detail.&lt;br /&gt;
Artjob as d0 is used to find a valid plant number on a product.  (you can't count on the job header).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
select h.session_no,h.trans_no,h.cust_no,c.name, h.job_po_loc, h.start_date, h.stop_date,coalesce(min(p0.plant_no),'1A') Plant,h.active_flag,h.job_tax_code from artjobhd h&lt;br /&gt;
inner join artcust c on c.cust_no=h.cust_no&lt;br /&gt;
left outer join artjobdt d0 ON d0.session_no=h.session_no and d0.trans_no=h.trans_no &lt;br /&gt;
left outer  join artprod p0 on p0.product_code=d0.product_code&lt;br /&gt;
left outer join artjobdt d1 ON d1.session_no=h.session_no and d1.trans_no=h.trans_no AND D1.PRODUCT_CODE LIKE 'ENVIRO.%'&lt;br /&gt;
where (d1.product_code is null)&lt;br /&gt;
and h.active_flag='Y' AND C.ACTIVE_FLAG='Y'&lt;br /&gt;
group by h.session_no,h.trans_no, h.cust_no,c.name, h.job_po_loc, h.start_date, h.stop_date,h.active_flag,h.job_tax_code&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjust this query to your case:&lt;br /&gt;
*Change 'ENVIRO.%' to the product you wish to work with.&lt;br /&gt;
*Change the job selection to your situation.  (START_DATE, STOP_DATE etc.)&lt;br /&gt;
&lt;br /&gt;
Then use the following QG model Update Query:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
INSERT INTO &lt;br /&gt;
artjobdt&lt;br /&gt;
( SESSION_NO, TRANS_NO, CUST_NO, JOB_PO_LOC, LINE_NO, PRICE_CODE, PRODUCT_CODE, UNIT_PRICE, QTY_ORDERED, TAX_CODE, QTY_PER_LOAD, UNIT_OF_MEASURE, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER )  VALUES &lt;br /&gt;
( {SESSION_NO}, {TRANS_NO}, '{CUST_NO}', '{JOB_PO_LOC}', 99, 'P', 'ENVIRO.{PLANT}', 55, 0, '{JOB_TAX_CODE}', 0, '/L', 'ENVIRONMENTAL FEE PER LOAD', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT'    );&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adjust the model update query:&lt;br /&gt;
*Line No: 99 must not exist.  If multiptle products being processed change for each product.&lt;br /&gt;
*Price: Here it's 55.  NOTE: you can come back and fix the price later.&lt;br /&gt;
*Product Code: Change ENVIRO to yoru product&lt;br /&gt;
*Unit of Measure: Match Product&lt;br /&gt;
*Desription: Match Product&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=QueryGen&amp;diff=967</id>
		<title>QueryGen</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=QueryGen&amp;diff=967"/>
		<updated>2024-03-27T15:24:40Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* QueryGen Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[CATEGORY: QueryGen]]&lt;br /&gt;
&lt;br /&gt;
==QueryGen Overview==&lt;br /&gt;
QueryGen is intended to create queries for the inserting and updating of databases.   It is really a text generator that repeats for every record of a dataset replacing text from a template with data values.  It can be used for much more than just creating queries - such as lists, .csv formatted text etc.&lt;br /&gt;
&lt;br /&gt;
When Creating data for Keystone, make sure to review [[Keystone Data Manipulation Guidelines]] for creating and updating data by query.&lt;br /&gt;
&lt;br /&gt;
===The QueryGen Screen===&lt;br /&gt;
*'''DB Name''' Database Name/ Connection Information used for connection.&lt;br /&gt;
*'''DB Kind''' Selection of database type (Interbase, FireBird, ODBC, MSSQL, SQLite, Access, Excel)&lt;br /&gt;
*'''Go''' Connects and runs Query.  If active connection, the connection is reset.&lt;br /&gt;
*'''Qry''' Run query without reconnecting.  (This will include uncommitted data others can't see and exclude changes from other users since the connection was established).&lt;br /&gt;
*'''X''' Disonnects current connection.  Useful for unlocking a data source to make changes.&lt;br /&gt;
*'''CON''' Connect Only&lt;br /&gt;
&lt;br /&gt;
*'''Selection Query''' Query to select the source data.&lt;br /&gt;
The following 3 items create the model for the Result query:&lt;br /&gt;
*'''Header''' This query is the first item in the Result query.  It only gets produced once.&lt;br /&gt;
*'''Update Query''' This is the primary model query that is repeated for each record.  See expanded explanation of the query creation process.&lt;br /&gt;
*'''Closing Query''' This query is the Last item in the Result query.  It only gets produced once.&lt;br /&gt;
*'''Repeat Every''' Used for a statement you only want ever x# of lines.  Good to specify '''COMMIT''' statement every so often on a monster query.&lt;br /&gt;
&lt;br /&gt;
*'''Results'''  The resulting query that joins together the source data and the three model queries.&lt;br /&gt;
&lt;br /&gt;
==Connection Options==&lt;br /&gt;
&lt;br /&gt;
===Interbase / Firebird===&lt;br /&gt;
Querygen is first and foremost a good tool to pull data from Interbase:&lt;br /&gt;
&lt;br /&gt;
[[File:QG_IB_Open.PNG]]&lt;br /&gt;
&lt;br /&gt;
DB Kind: '''Interbase''' or '''Firebird'''&lt;br /&gt;
&lt;br /&gt;
*For Local File enter the path and file name of the database (e.g.: c:\program files\givenhansco\cc\cust\data\ccw001.ib)&lt;br /&gt;
*For Remote Files, enter the ipaddress (or computer name) followed by a colon, then the path and file name of the database (e.g. 192.168.0.1:c:\ccgh\data\ccw001.ib)&lt;br /&gt;
&lt;br /&gt;
Query:&lt;br /&gt;
*Create a basic query selecting all necessary fields.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Microsoft Access===&lt;br /&gt;
:DB Kind: '''Access'''&lt;br /&gt;
:Source DB:  Filename of the file&lt;br /&gt;
&lt;br /&gt;
Query:&lt;br /&gt;
*Select from the table within your access database.  (Select * from customers)&lt;br /&gt;
&lt;br /&gt;
===Microsoft Excel===&lt;br /&gt;
Starting with QG2016 this is a simplified way to get to excel files.  It uses ODBC but allows you to just enter the file name and not setup an ODBC connection.&lt;br /&gt;
:DB Kind: '''Excel'''&lt;br /&gt;
:Source DB:  Filename of the file&lt;br /&gt;
&lt;br /&gt;
For OFFICE 365 A Special Driver is Required:  [https://www.microsoft.com/en-us/download/details.aspx?id=54920 Microsoft Office ODBC Driver]  This seems to work best with 64 bit querygen.&lt;br /&gt;
&lt;br /&gt;
[[File:QG Excel Open.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Query:&lt;br /&gt;
*Select from named range or sheet. &lt;br /&gt;
**Select * from [Sheet1$]&lt;br /&gt;
**Select * from MyTable&lt;br /&gt;
See Excel help on naming a range - this feature can be found on the Formula tab.&lt;br /&gt;
&lt;br /&gt;
===ODBC===&lt;br /&gt;
&lt;br /&gt;
====Example ODBC====&lt;br /&gt;
&lt;br /&gt;
#Setup ODBC data Source (Administrtive Tools&amp;gt;Data Sources (ODBC).  Each driver/connection type has variations&lt;br /&gt;
[[Image:Qg odbc1.jpg]]&lt;br /&gt;
#Enter the ODBC name as the Source Path&lt;br /&gt;
#Select from the desired table&lt;br /&gt;
[[Image:Qg openODBCa.jpg]]&lt;br /&gt;
&lt;br /&gt;
====Excel with ODBC Alias====&lt;br /&gt;
Excel Spreadsheet.  (NOTE: QG2016 eliminates the need of setting up an ODBC connection for each spreadsheet.  See &amp;quot;Excel&amp;quot; section above)&lt;br /&gt;
#Set up ODBC datasource using Excel driver.  The spreadsheet dearborn.xls is named the the datasource dearborn1&lt;br /&gt;
#The data to be queried must be a Named Range in excel.&lt;br /&gt;
##Open the spreadsheet&lt;br /&gt;
##Highlight the range the data is in&lt;br /&gt;
##Select Insert&amp;gt;Name&amp;gt;Define from the menu and name the range (in this example called “test”)&lt;br /&gt;
##Multiple names can be Named within a spreadsheet.&lt;br /&gt;
##The Source Path is the ODBC name&lt;br /&gt;
#The Source Query references the Named Range in the spreadsheet&lt;br /&gt;
&lt;br /&gt;
Sample query that selects Sheet 2&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select * from [sheet2$]&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Text File with ODBC====&lt;br /&gt;
'''Note:''' While importing Text via ODBC can be convenient, it also can be very unpredictable.  Automated handling of fields can result in unexpected changes to source data.&lt;br /&gt;
&lt;br /&gt;
This has the advantage of selecting the flat text file from the Source Query line (no need to set up a separate ODBC data source for each file).  The directory of the text files is specified in the ODBC Data source.  The File deliniation is set in the ODBC data source.  The default is csv as in this example.  It can be changed to Tab Delimited.  If changed to Fixed, you need to define all of the columns in the ODBC data source.&lt;br /&gt;
#Set up ODBC data source designating the directory or the text files are to be put.&lt;br /&gt;
[[Image:QG ODBC text.jpg]]&lt;br /&gt;
#The Source Path is the ODBC name (e.g. TEXT)&lt;br /&gt;
#The Source Query references the text file in the designated directory.&lt;br /&gt;
[[Image:QG OpenText.jpg]]&lt;br /&gt;
&lt;br /&gt;
===LOCAL (Query other queries)===&lt;br /&gt;
(starting Sept. 2016)&lt;br /&gt;
&lt;br /&gt;
LOCAL allows you to query up to 4 separate query results which each can come from a different data source.  These 4 queries are setup on the tabs LOC1 to LOC4.  Each LOC tab has the same capability to connect to different data sources such as an Interbase, EXCEL or ODBC.  Each local query is referred to as LQ1 through LQ4.&lt;br /&gt;
&lt;br /&gt;
Examples of what you can do with &amp;quot;LOCAL&amp;quot;:&lt;br /&gt;
*Compare values in 2 databases - to create inserts where data is missing from a target&lt;br /&gt;
*Compare values in 2 databases - to create updates where there are differences&lt;br /&gt;
*Combine data from a live database and an external Excel Sheet&lt;br /&gt;
*Compare data from 2 different systems (e.g. GPS &amp;amp; Dispatch)&lt;br /&gt;
&lt;br /&gt;
====Example: Query GPS and Dispatch databases to match up trucks====&lt;br /&gt;
&lt;br /&gt;
'''Set LOC1:'''&lt;br /&gt;
Set DB Source to '''''Fleet'''''&lt;br /&gt;
&lt;br /&gt;
Connection type to '''''ODBC'''''&lt;br /&gt;
&lt;br /&gt;
Query: &amp;lt;PRE&amp;gt;Select * FROM fleet.dbo.Trucks&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Set LOC2:'''&lt;br /&gt;
Normal IB connection:&lt;br /&gt;
Query:  &amp;lt;PRE&amp;gt;SELECT * FROM arttruck&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Set Standard:'''&lt;br /&gt;
Set DB kind to '''''Local'''''&lt;br /&gt;
&lt;br /&gt;
'''Sample queries:'''&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select * from LQ1&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
SELECT * FROM LQ2&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''See all fields from both tables where trucks exist in both databases (and truck active in dispatch)'''&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
Select LQ1.*,LQ2.* FROM LQ2&lt;br /&gt;
INNER JOIN LQ1 ON LQ1.TRUCK=LQ2.TRUCK_NO&lt;br /&gt;
WHERE LQ2.ACTIVE_FLAG='Y'&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''List all trucks in dispatch (LQ2) that are not in GPS (LQ1)'''&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
Select LQ2.* FROM LQ2&lt;br /&gt;
WHERE NOT EXISTS&lt;br /&gt;
 (SELECT * FROM LQ1 WHERE LQ1.TRUCK=LQ2.TRUCK_NO)&lt;br /&gt;
AND LQ2.ACTIVE_FLAG='Y'&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Azure SQL===&lt;br /&gt;
&lt;br /&gt;
Azure SQL appears almost the same as standard MSSQL database.  This example uses the Microsoft SQL Native driver.  Login to Azure and to open the firewall for the client IP address and to derive the required connection values.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
DriverID=MSSQL&lt;br /&gt;
Server=&amp;lt;Azure Server ID&amp;gt;   (this will start with &amp;quot;tcp:&amp;quot;)&lt;br /&gt;
Database=&amp;lt;azure database name&amp;gt;&lt;br /&gt;
User_Name=&amp;lt;user name&amp;gt;&lt;br /&gt;
Password=&amp;lt;Password&amp;gt;&lt;br /&gt;
Encrypt=Yes&lt;br /&gt;
MetaDefSchema=dbo&lt;br /&gt;
MetaDefCatalog=&amp;lt;Catalog Name&amp;gt;  (likely the same as database name)&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Formatting Options ==&lt;br /&gt;
*'''STRLEN''' - specifies the maximum number of characters to use from the import field.  In the example below, it will select no more than two characters from the A1 field. &amp;lt;CODE&amp;gt;UPDATE ARTPROD SET PRODUCT_CLASS='{A1|STRLEN=2}'&amp;lt;/CODE&amp;gt;&lt;br /&gt;
*'''TRIM''' - (QG2018Nov) Remove blanks before and after the field.  &amp;lt;CODE&amp;gt;UPDATE ARTPROD SET PRODUCT_CLASS='{A1|TRIM=0}'&amp;lt;/CODE&amp;gt;&lt;br /&gt;
*'''ADD''' - Adds a specified value to the field.  In the example below, it sets TRANS_NO to a value imported from T_NO incremented by 1000. &amp;lt;CODE&amp;gt;UPDATE ARTINV SET TRANS_NO='{T_NO|ADD=1000}'&amp;lt;/CODE&amp;gt;&lt;br /&gt;
*'''DATETIME''' - specifies that the data should be in Interbase's DATETIME format.  This is a necessity for any time-stamp fields.  In the example below, it will set CHANGED field into DATETIME format for the field in ARTCUST. &amp;lt;CODE&amp;gt;UPDATE ARTCUST SET LAST_CHANGE_DATE='{CHANGED|DATETIME=0}'&amp;lt;/CODE&amp;gt;&lt;br /&gt;
*DECODEDATE - Decode some odd date formats.&lt;br /&gt;
*'''DEFAULT''' - sets a default value if none is available from the import.  In the example below, it will take the credit terms from the TERMS field in the import, and if none is specified, set it to a default value of 30. &amp;lt;CODE&amp;gt;UPDATE ARTCUST SET CREDIT_TERMS='{TERMS|DEFAULT=30}'&amp;lt;/CODE&amp;gt;&lt;br /&gt;
*'''FORMATINT''' - Format an integer using the Delphi Format command. See:  [http://www.delphibasics.co.uk/RTL.asp?Name=Format Delphi Format Command (delphibasics.com)]&lt;br /&gt;
Example - the format command %.5d means left fill the number with 0s.  In the case below the text value 1 appears right before the number.  If you had a trans_no of 243 it would be formatted as 00243.  With the 1 appearing right before you would get 100243.  This is useful if you want to add transactions to an existing session based on data already in that session. &amp;lt;CODE&amp;gt;{SESSION_NO},1{TRANS_NO|FORMATINT=%.5d}&amp;lt;/CODE&amp;gt;&lt;br /&gt;
*'''FORMATFLT''' - Format a floating point number using the Format command.  See: [http://www.delphibasics.co.uk/RTL.asp?Name=FormatFloat Delphi Format Command (delphibasics.com)]&lt;br /&gt;
Essentially for any non-integer you can apply formatting.&lt;br /&gt;
*'''NULL''' - specifies to replace the value with NULL if the value of the imported field matches what is specified.  In the eaxmple below, if the GL field contains a 0, it will instead set it to null in the COGS_GL field. &amp;lt;CODE&amp;gt;UPDATE ARTPROD SET COGS_GL='{GL|NULL=0}'&amp;lt;/CODE&amp;gt;&lt;br /&gt;
*'''INC''' - (QG2014)  An automatically Incrementing Value that starts at 1 and increase by 1.  Useful for transaction numbers. &amp;lt;CODE&amp;gt;Insert Into ... '{A1|INC=0}'&amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Incrementors and Generators==&lt;br /&gt;
&lt;br /&gt;
Incrementors:  QG has incrementors that create incremental values in the generated query.  The INC function, the COUNTER function and INCA through INCZ can all be used in the model query.  These will create integer values in the query.  There is no dependency on the database being targeted.&lt;br /&gt;
&lt;br /&gt;
Generators: Databases such as Interbase have Generators that create incremental values at the time the query is run.  These should be used when the queries are creating data that needs to fall in line with existing sequence values in the database.  (Think &amp;quot;Session No.&amp;quot; and &amp;quot;Seq. No&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
===Incrementors===&lt;br /&gt;
&lt;br /&gt;
The QG INC syntax is as follows ''{FIELD_NAME|INC=1}''   The field name is required and must match an existing field from the input data but it does nothing.  The &amp;quot;=1&amp;quot; indicates to increase the incementor value by 1.  You can also use &amp;quot;INC=0&amp;quot; to repeat a value.  To Reset the value of an incrementor to 1 use &amp;quot;INC=R&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The values &amp;quot;INCA&amp;quot; through &amp;quot;INCZ&amp;quot; work exactly the same.&lt;br /&gt;
&lt;br /&gt;
In this simplified example these values in the Update (model) query:&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
{TRANS_NO|INC=1},{LINE_NO|INCA=R},&lt;br /&gt;
{TRANS_NO|INC=0},{LINE_NO|INCA=1},&lt;br /&gt;
{TRANS_NO|INC=0},{LINE_NO|INCA=1},&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
result an output like:&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
1,1,&lt;br /&gt;
1,2,&lt;br /&gt;
1,3,&lt;br /&gt;
&lt;br /&gt;
2,1,&lt;br /&gt;
2,2,&lt;br /&gt;
2,3,&lt;br /&gt;
&lt;br /&gt;
3,1,&lt;br /&gt;
3,2,&lt;br /&gt;
3,3,&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Generators===&lt;br /&gt;
Generators are database dependent.  In Interbase the Generator syntax looks like ''GEN_ID(GEN_CCSESSION,1)''  where &amp;quot;GEN_CCSESION&amp;quot; references a specific generator in the system and the value 1 reference the value to increment the generator by.  &lt;br /&gt;
&lt;br /&gt;
When each record will use a new generated value - simply put the generator in the Update (Model) Query:&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
INSERT INTO  CCTCONT&lt;br /&gt;
( RECKEY, ENTITY_TYPE, ENTITY_ID, TITLE, NAME ... LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( GEN_ID(GEN_CCCONTKEY,1), '{ENTITY_TYPE}', '{ENTITY_ID}', '{TITLE}', '{NAME}' ... 'HIT', '{ACTIVE_FLAG}'    );&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Reusing the same Generator Value====&lt;br /&gt;
When you need to use the same Generator Value for each transaction you don't want the generator creating a new value, so you can't use the above method.&lt;br /&gt;
&lt;br /&gt;
In some cases you can get the last value of a generator by calling GEN_ID with the Generator increment set to 0, e.g. ''GEN_ID(GEN_CCSESSION,0)''.   This is only safe when there is no possibility of the generator being updated from another source during the update process (e.g. you are working on a system stand-alone).&lt;br /&gt;
&lt;br /&gt;
A safer option to store the value in a temporary table.  In Keystone it's a best practice to use the table '''TMP_SNO'''.  If this doesn't exist, create it with: &amp;lt;CODE&amp;gt;CREATE TABLE TMP_SNO(SNO INTEGER);&amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the table exists you need to clear it: &amp;lt;CODE&amp;gt;DELETE FROM TMP_SNO;&amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In theory you could just store the session no: &amp;lt;CODE&amp;gt;INSERT INTO X1 (XVAL) VALUES (GEN_ID(GEN_CCSESSION,1));&amp;lt;/CODE&amp;gt;.   This method doesn't leave any info in the cctsessn table. &lt;br /&gt;
&lt;br /&gt;
To create one session Number and  record an entry in CCTSESSN enter the following for the &amp;quot;Header Query.&amp;quot;    &lt;br /&gt;
&amp;lt;PRE&amp;gt;INSERT INTO TMP_SNO (SNO)  SELECT session_no FROM CCP_SESSION_BEGIN('ADMIN', '&amp;lt;MY SCRIPT&amp;gt;', '127.0.0.1', '3.3.3.9');&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot;&amp;gt;(This procedure was created in Keystone 3.0)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Pre 3.0 Method:&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
INSERT INTO TMP_SNO (SNO) VALUES (GEN_ID(GEN_CCSESSION,1));&lt;br /&gt;
INSERT INTO cctsessn&lt;br /&gt;
  (SESSION_NO, TRANS_NO, GROUP_SESSION_NO, USER_ID, STATUS_FLAG, START_DATETIME, STOP_DATETIME, DESCRIPTION, IP_ADDRESS, SERVER_VERSION )  VALUES (&lt;br /&gt;
  (SELECT SNO FROM TMP_SNO), 0, NULL, 'HIT', 'I', CAST('NOW' AS TIMESTAMP),CAST('NOW' AS TIMESTAMP),  'INSERT SCRIPT', NULL, NULL );&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once you've created this value in TMP_SNO, you can use &amp;lt;CODE&amp;gt;(SELECT SNO FROM TMP_SNO)&amp;lt;/CODE&amp;gt; for the value in the Update (model) query.  See examples below...&lt;br /&gt;
&lt;br /&gt;
===Sample of Putting together Generators and Incrementors===&lt;br /&gt;
In a situation where you are inserting Master and Detail records, and you are dealing with line numbers a mix of Incrementors and Generators can be used.&lt;br /&gt;
&lt;br /&gt;
For example, creating a PRTNETPAYHST record and several PRTEMPDEFHST records.  Assume the following spreadsheet is being used as source data.  For each record in the sheet we will want to create one PRTNETPAYHST record and a separate PRTEMPDEFHST record for each of the data columns.  There should be one session number for all of the records.  There should be one transaction number for each input record that ties the single PRTNETPAYHST record to the multiple PRTEMPDEFHST records and there should be line numbers starting at one for the PRTEMPDEFHST records - these should restart each time there is a new input record.&lt;br /&gt;
[[File:QG_Example_Excel_Payimp.PNG]]&lt;br /&gt;
&lt;br /&gt;
For all of the records we want to create we want 1 session Number.  Create the following for the &amp;quot;Header Query.&amp;quot;  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;PRE&amp;gt;CREATE  TABLE TMP_SNO(SNO INTEGER);&lt;br /&gt;
INSERT INTO TMP_SNO (SNO)  SELECT session_no FROM CCP_SESSION_BEGIN('ADMIN', 'Insert Emp Balances', '127.0.0.1', '3.3.3');&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Header query will process just once no matter how many input records there are.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here's a sample of the Update (Model) query for both PRTNETPAYHST and multiple PRTEMPDEFHST.&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
/* Employee {EMPLOYEE} */&lt;br /&gt;
INSERT INTO prtnetpayhst  (SESSION_NO, TRANS_NO, RUN_NO, EMP_ID, CHECK_SEQ, CHECK_DATE, CHECK_NO, WEEK_END_DATE, NET_PAY, PAYFREQ, DED_WEEK, DED_PERIODS, TAX_PERIODS, REC_TYPE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER )  VALUES (&lt;br /&gt;
(SELECT SNO FROM TMP_SNO), {EMP_ID|INC=1}, NULL, '{EMP_ID}', 1, '{TRX_DATE}', NULL, NULL, '0', NULL, NULL, NULL, NULL, 'A', 'N', CAST('TODAY' AS TIMESTAMP), 'HIT' );&lt;br /&gt;
INSERT INTO  prtempdefhst  (SESSION_NO, TRANS_NO, LINE_NO, EMP_ID, DEF_ID, DB_GL_ACCOUNT, CR_GL_ACCOUNT, TRX_DATE, TRX_TYPE, DEF_VALUE, OVERRIDE_FLAG, RUN_NO) VALUES (&lt;br /&gt;
(SELECT SNO FROM TMP_SNO), {EMP_ID|INC=0}, {EMP_ID|INCA=R}, '{EMP_ID}', 'FEDGRS', NULL, NULL, '{TRX_DATE}', 'S', '{FEDGRS}', 'Y', NULL );&lt;br /&gt;
INSERT INTO  prtempdefhst  (SESSION_NO, TRANS_NO, LINE_NO, EMP_ID, DEF_ID, DB_GL_ACCOUNT, CR_GL_ACCOUNT, TRX_DATE, TRX_TYPE, DEF_VALUE, OVERRIDE_FLAG, RUN_NO) VALUES (&lt;br /&gt;
(SELECT SNO FROM TMP_SNO), {EMP_ID|INC=0}, {EMP_ID|INCA=1}, '{EMP_ID}', 'FEDTAX', NULL, NULL, '{TRX_DATE}', 'S', '{FEDTAX}', 'Y', NULL );&lt;br /&gt;
INSERT INTO  prtempdefhst  (SESSION_NO, TRANS_NO, LINE_NO, EMP_ID, DEF_ID, DB_GL_ACCOUNT, CR_GL_ACCOUNT, TRX_DATE, TRX_TYPE, DEF_VALUE, OVERRIDE_FLAG, RUN_NO) VALUES (&lt;br /&gt;
(SELECT SNO FROM TMP_SNO), {EMP_ID|INC=0}, {EMP_ID|INCA=1}, '{EMP_ID}', 'SSGROSS', NULL, NULL, '{TRX_DATE}', 'S', '{SS_GROSS}', 'Y', NULL );&lt;br /&gt;
INSERT INTO  prtempdefhst  (SESSION_NO, TRANS_NO, LINE_NO, EMP_ID, DEF_ID, DB_GL_ACCOUNT, CR_GL_ACCOUNT, TRX_DATE, TRX_TYPE, DEF_VALUE, OVERRIDE_FLAG, RUN_NO) VALUES (&lt;br /&gt;
(SELECT SNO FROM TMP_SNO), {EMP_ID|INC=0}, {EMP_ID|INCA=1}, '{EMP_ID}', 'SSTAX', NULL, NULL, '{TRX_DATE}', 'S', '{SS_TAX}', 'Y', NULL );&lt;br /&gt;
INSERT INTO  prtempdefhst  (SESSION_NO, TRANS_NO, LINE_NO, EMP_ID, DEF_ID, DB_GL_ACCOUNT, CR_GL_ACCOUNT, TRX_DATE, TRX_TYPE, DEF_VALUE, OVERRIDE_FLAG, RUN_NO) VALUES (&lt;br /&gt;
(SELECT SNO FROM TMP_SNO), {EMP_ID|INC=0}, {EMP_ID|INCA=1}, '{EMP_ID}', 'MCGROSS', NULL, NULL, '{TRX_DATE}', 'S', '{MC_GROSS}', 'Y', NULL );&lt;br /&gt;
INSERT INTO  prtempdefhst  (SESSION_NO, TRANS_NO, LINE_NO, EMP_ID, DEF_ID, DB_GL_ACCOUNT, CR_GL_ACCOUNT, TRX_DATE, TRX_TYPE, DEF_VALUE, OVERRIDE_FLAG, RUN_NO) VALUES (&lt;br /&gt;
(SELECT SNO FROM TMP_SNO), {EMP_ID|INC=0}, {EMP_ID|INCA=1}, '{EMP_ID}', 'MCTAX', NULL, NULL, '{TRX_DATE}', 'S', '{MC_TAX}', 'Y', NULL );&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Closing query:&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
UPDATE CCTSESSN SET STATUS_FLAG='I', STOP_DATETIME=CAST('NOW' AS TIMESTAMP) WHERE SESSION_NO=(SELECT SNO FROM TMP_SNO);&lt;br /&gt;
COMMIT; DROP TABLE TMP_SNO;&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Using ''Select SNO from TMP_SNO''  sets every record to use the one session_no created by the Header Query.  &lt;br /&gt;
*Alternatively we could have used''GEN_ID(GEN_CCSESSION,0)'' for the session number so long as nothing else will impact the generator value during processing.&lt;br /&gt;
*Using {EMP_ID|INC=1} creates a new transaction number for the PRTNETPAYHST transaction - this happens once per input record.  Because each following transaction uses {EMP_ID|INC=0} the repeat the value.&lt;br /&gt;
*Using {EMP_ID|INCA=R} for the LINE_NO value for the first PRTEMPDEFHST line forces the value if the incrementor INCA to 1.  Using {EMP_ID|INCA=1} sets it to 2 through 6 for the next 5 lines.  The pattern of 1 through 6 recurs for each input record.&lt;br /&gt;
&lt;br /&gt;
==Conditional Inserts (Merging Data)==&lt;br /&gt;
&lt;br /&gt;
Sometimes you want to insert data only if it doesn't exist, such as when merging 2 sets of g/l accounts where some overlap exists.  Since the Interbase INSERT statement has no where clause, we can accomplish this by creating our insert statement using special select statement.  &lt;br /&gt;
&lt;br /&gt;
In the example below, we use the artloc table (where location=0) because we can count on it returning the values just once, and add the additional conditions appropriate for the situation.  If the condition is not bet then there will be no records returned from the select query therefor an insert will not be attempted.&lt;br /&gt;
&lt;br /&gt;
Example of a condition insert into A/R Allowance class:&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
INSERT INTO ARTALCLS&lt;br /&gt;
( CLASS_NO, DESCRIPTION, ALLOW_GL, ALLOW_INCLUDES_TAX, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG)  &lt;br /&gt;
SELECT  'B', 'Bad Debt', '6290.1.00', 'P', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y' &lt;br /&gt;
 from artloc where loc_id=0 and not EXISTS (SELECT 'AAA' FROM ARTALCLS   WHERE CLASS_NO= 'B'  );&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
If a record with CLASS_NO = 'B' exists then no insert is attempted.&lt;br /&gt;
&lt;br /&gt;
===Using QG Query Builder to create a merge query===&lt;br /&gt;
&lt;br /&gt;
In QG 2016 the Query Builder can be used to simplify the process of creating Interbase Conditional Insert statements.  In this example we will create a merge insert for Customer Classes.&lt;br /&gt;
&lt;br /&gt;
First Create your simple select:&lt;br /&gt;
[[File:QG_Example_Merge_1.PNG]]&lt;br /&gt;
&lt;br /&gt;
Click Build Query&lt;br /&gt;
[[File:QG_Example_Merge_2.PNG]]&lt;br /&gt;
&lt;br /&gt;
Set the Update (Model) Insert Template to:&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
INSERT INTO ~TableName~&lt;br /&gt;
( ~FieldLabels~)  &lt;br /&gt;
SELECT&lt;br /&gt;
 ~FieldValues~ &lt;br /&gt;
 from artloc where loc_id=0 and not EXISTS (SELECT 'A' FROM ~TableName~ WHERE ID= '{ID}'  );&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:QG_Example_Merge_3.PNG]]&lt;br /&gt;
&lt;br /&gt;
Additionally you need to change the value &amp;quot;ID&amp;quot; to represent the actual key values of the target table.&lt;br /&gt;
&lt;br /&gt;
Optionally you can override values on the field list.  Here &amp;quot;IMPORTED_FLAG&amp;quot; is modified to 'Y' rather than pulling the value from the source table.&lt;br /&gt;
&lt;br /&gt;
The Resulting insert script (abbreviated):&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
INSERT INTO ARTCUCLS&lt;br /&gt;
  ( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG)  &lt;br /&gt;
  SELECT  'C', 'COD Customer', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y' &lt;br /&gt;
   from artloc where loc_id=0 and not EXISTS (SELECT 'A' FROM ARTCUCLS   WHERE CLASS_NO= 'C'  );&lt;br /&gt;
INSERT INTO ARTCUCLS&lt;br /&gt;
  ( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG)  &lt;br /&gt;
  SELECT  'CC', 'Commercial Contractor', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y' &lt;br /&gt;
   from artloc where loc_id=0 and not EXISTS (SELECT 'A' FROM ARTCUCLS   WHERE CLASS_NO= 'CC'  );&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===More Samples===&lt;br /&gt;
Merging CC Options:&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
INSERT INTO cctoptn&lt;br /&gt;
( USER_GROUP_ID, SECTION_NAME, OPTION_NAME, OPTION_VALUE, LAST_CHANGE_DATETIME, LAST_CHANGE_USER)  &lt;br /&gt;
SELECT '{USER_GROUP_ID}', '{SECTION_NAME}', '{OPTION_NAME}', '{OPTION_VALUE}', CAST('TODAY' AS TIMESTAMP), 'HIT' &lt;br /&gt;
 from artloc where loc_id=0 and not EXISTS &lt;br /&gt;
  (SELECT 'A' FROM cctoptn WHERE USER_GROUP_ID= '{USER_GROUP_ID}' AND SECTION_NAME= '{SECTION_NAME}' AND OPTION_NAME= '{OPTION_NAME}'  );&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
In this example we test for three key fields when determining if the record exists.&lt;br /&gt;
&lt;br /&gt;
Inserting GL Groups&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
INSERT INTO gltacgrp (&lt;br /&gt;
GROUP_ID, HEAD_DESCRIPTION, TOTAL_DESCRIPTION, LINE_DESCRIPTION, PARENT_GROUP_ID, SPECIAL_FUNCTION, DETAIL_LEVEL, SEQUENCE, ALLOC_RULE_ID, SECURITY_CLASS, DR_CR_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  &lt;br /&gt;
SELECT&lt;br /&gt;
'{GROUP_ID}', '{HEAD_DESCRIPTION}', '{TOTAL_DESCRIPTION}', '{LINE_DESCRIPTION}', '{PARENT_GROUP_ID}', '{SPECIAL_FUNCTION}', '{DETAIL_LEVEL}', '{SEQUENCE}', '{ALLOC_RULE_ID}', '{SECURITY_CLASS}', '{DR_CR_FLAG}', '{LAST_CHANGE_DATETIME|DATETIME=0}', '{LAST_CHANGE_USER}', '{ACTIVE_FLAG}' &lt;br /&gt;
 from artloc where loc_id=0 and not EXISTS (SELECT 'A' FROM GLTACGRP WHERE GROUP_ID= '{GROUP_ID}'  );&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
This will insert only the groups that do not exist.&lt;br /&gt;
&lt;br /&gt;
=QueryGen Cases=&lt;br /&gt;
*[[QueryGen Case: Fix Standard Cost]]&lt;br /&gt;
*[[QueryGen Case: Create Inventory Transactions From Structure]]&lt;br /&gt;
*[[QueryGen Case: Replicate Tickets]] e.g. copying tickets from one database to another.&lt;br /&gt;
*[[Replicating Keystone Data with QueryGen]]&lt;br /&gt;
*[[QueryGen Case: Create Tax Records From Invoices]]&lt;br /&gt;
*[[QueryGen Case: Replicating Forms]]&lt;br /&gt;
*[[QueryGen Case: Import Keystone Batch Mixes]]&lt;br /&gt;
*[[QueryGen Case: Security Work]]&lt;br /&gt;
*[[QueryGen Case: Generate Security Reports]]&lt;br /&gt;
*[[QueryGen Case: Move Sales to Plant Tickets]]&lt;br /&gt;
*[[QueryGen Case: Add missing item to all Jobs]]&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Microsoft_SQL_Server_Query_Features&amp;diff=961</id>
		<title>Microsoft SQL Server Query Features</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Microsoft_SQL_Server_Query_Features&amp;diff=961"/>
		<updated>2024-02-27T16:25:04Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* iif */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===trim===&lt;br /&gt;
Commands: trim, ltrim, rtrim&lt;br /&gt;
The trim commands will trim spaces from the beginning and end of strings.&lt;br /&gt;
&lt;br /&gt;
In older MS SQL you must use ltrim and rtrim together to trim both ends of a string...&lt;br /&gt;
&amp;lt;code&amp;gt;select rtrim(ltrim(address1)) from Customer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modern MS SQL allows for just trim...&lt;br /&gt;
&amp;lt;code&amp;gt;select trim(address1) from Customer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Concat===&lt;br /&gt;
Use concat instead of the &amp;quot;||&amp;quot; characters used in Interbase to concatenate.&lt;br /&gt;
&lt;br /&gt;
Example...&lt;br /&gt;
&amp;lt;code&amp;gt;CONCAT('Acct Cat Code: ',RTRIM(LTRIM(ACCT_CAT_CODE))) USER_2,&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===replace===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Replace singele quote with 2 single quotes:&lt;br /&gt;
&amp;lt;code&amp;gt;replace(rtrim(ltrim(NAME)),'''','''''') &amp;quot;DRIVER_NAME&amp;quot;,&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===left, right===&lt;br /&gt;
===case===&lt;br /&gt;
===iif===&lt;br /&gt;
Similar to using a case statement, iif gives allows you 2 responses to an if condition..&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;iif(rtrim(LTRIM(INACTIVE_CODE))='00','Y','N') active_flag,&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===windowing functions===&lt;br /&gt;
&lt;br /&gt;
===rank===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===derived queries===&lt;br /&gt;
Derived queries, fequently seen as a &amp;quot;with&amp;quot; statement... allow for querying queries.&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Microsoft_SQL_Server_Query_Features&amp;diff=960</id>
		<title>Microsoft SQL Server Query Features</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Microsoft_SQL_Server_Query_Features&amp;diff=960"/>
		<updated>2024-02-27T16:24:12Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* concat */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===trim===&lt;br /&gt;
Commands: trim, ltrim, rtrim&lt;br /&gt;
The trim commands will trim spaces from the beginning and end of strings.&lt;br /&gt;
&lt;br /&gt;
In older MS SQL you must use ltrim and rtrim together to trim both ends of a string...&lt;br /&gt;
&amp;lt;code&amp;gt;select rtrim(ltrim(address1)) from Customer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modern MS SQL allows for just trim...&lt;br /&gt;
&amp;lt;code&amp;gt;select trim(address1) from Customer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Concat===&lt;br /&gt;
Use concat instead of the &amp;quot;||&amp;quot; characters used in Interbase to concatenate.&lt;br /&gt;
&lt;br /&gt;
Example...&lt;br /&gt;
&amp;lt;code&amp;gt;CONCAT('Acct Cat Code: ',RTRIM(LTRIM(ACCT_CAT_CODE))) USER_2,&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===replace===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Replace singele quote with 2 single quotes:&lt;br /&gt;
&amp;lt;code&amp;gt;replace(rtrim(ltrim(NAME)),'''','''''') &amp;quot;DRIVER_NAME&amp;quot;,&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===left, right===&lt;br /&gt;
===case===&lt;br /&gt;
===iif===&lt;br /&gt;
&lt;br /&gt;
===windowing functions===&lt;br /&gt;
&lt;br /&gt;
===rank===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===derived queries===&lt;br /&gt;
Derived queries, fequently seen as a &amp;quot;with&amp;quot; statement... allow for querying queries.&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Microsoft_SQL_Server_Query_Features&amp;diff=959</id>
		<title>Microsoft SQL Server Query Features</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Microsoft_SQL_Server_Query_Features&amp;diff=959"/>
		<updated>2024-02-27T16:20:58Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* trim */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===trim===&lt;br /&gt;
Commands: trim, ltrim, rtrim&lt;br /&gt;
The trim commands will trim spaces from the beginning and end of strings.&lt;br /&gt;
&lt;br /&gt;
In older MS SQL you must use ltrim and rtrim together to trim both ends of a string...&lt;br /&gt;
&amp;lt;code&amp;gt;select rtrim(ltrim(address1)) from Customer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modern MS SQL allows for just trim...&lt;br /&gt;
&amp;lt;code&amp;gt;select trim(address1) from Customer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===concat===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===replace===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Replace singele quote with 2 single quotes:&lt;br /&gt;
&amp;lt;code&amp;gt;replace(rtrim(ltrim(NAME)),'''','''''') &amp;quot;DRIVER_NAME&amp;quot;,&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===left, right===&lt;br /&gt;
===case===&lt;br /&gt;
===iif===&lt;br /&gt;
&lt;br /&gt;
===windowing functions===&lt;br /&gt;
&lt;br /&gt;
===rank===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===derived queries===&lt;br /&gt;
Derived queries, fequently seen as a &amp;quot;with&amp;quot; statement... allow for querying queries.&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Microsoft_SQL_Server_Query_Features&amp;diff=958</id>
		<title>Microsoft SQL Server Query Features</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Microsoft_SQL_Server_Query_Features&amp;diff=958"/>
		<updated>2024-02-27T16:18:27Z</updated>

		<summary type="html">&lt;p&gt;Chanson: Created page with &amp;quot;===trim=== ltrim rtrim  select trim(address1) from Customer  ===concat===   ===replace===   Replace singele quote with 2 single quotes: &amp;lt;code&amp;gt;replace(rtrim(ltrim(NAME)),'''','''''') &amp;quot;DRIVER_NAME&amp;quot;,&amp;lt;/code&amp;gt;  ===left, right=== ===case=== ===iif===  ===windowing functions===  ===rank===    ===derived queries=== Derived queries, fequently seen as a &amp;quot;with&amp;quot; statement... allow for querying queries.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===trim===&lt;br /&gt;
ltrim rtrim&lt;br /&gt;
&lt;br /&gt;
select trim(address1) from Customer&lt;br /&gt;
&lt;br /&gt;
===concat===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===replace===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Replace singele quote with 2 single quotes:&lt;br /&gt;
&amp;lt;code&amp;gt;replace(rtrim(ltrim(NAME)),'''','''''') &amp;quot;DRIVER_NAME&amp;quot;,&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===left, right===&lt;br /&gt;
===case===&lt;br /&gt;
===iif===&lt;br /&gt;
&lt;br /&gt;
===windowing functions===&lt;br /&gt;
&lt;br /&gt;
===rank===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===derived queries===&lt;br /&gt;
Derived queries, fequently seen as a &amp;quot;with&amp;quot; statement... allow for querying queries.&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Command_Import:_Hedger_Work_Notes&amp;diff=957</id>
		<title>Command Import: Hedger Work Notes</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Command_Import:_Hedger_Work_Notes&amp;diff=957"/>
		<updated>2024-02-27T15:48:24Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* =Price Groups */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
2022DEC19&lt;br /&gt;
===Customer Class===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
select  &lt;br /&gt;
ltrim(rtrim(sales_anl_code)) class_no,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sanl&lt;br /&gt;
&lt;br /&gt;
==&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{CLASS_NO}', '{DESCRIPTION|LEN=35}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
==&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Price Groups===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SELECT &lt;br /&gt;
RTRIM(LTRIM(replace(PRICE_CAT,'.',''))) GROUP_NO,&lt;br /&gt;
RTRIM(LTRIM(DESCR)) DESCRIPTION,&lt;br /&gt;
PRCC.* FROM  prcc&lt;br /&gt;
==&lt;br /&gt;
INSERT INTO ARTPRGRP &lt;br /&gt;
( GROUP_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG, MEMO )  VALUES &lt;br /&gt;
( '{GROUP_NO}', '{DESCRIPTION}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y' , 'CMD PRICE CAT:{PRICE_CAT|TRIM=0}'   );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===GL=== &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
LQ1: (LIST OF NUMERIC PLANTS IN CMD)&lt;br /&gt;
SELECT &lt;br /&gt;
ISNUMERIC(plant_code),p.*&lt;br /&gt;
FROM plnt p&lt;br /&gt;
where isnumeric (plant_code)=1&lt;br /&gt;
&lt;br /&gt;
LQ2: (MODEL G/L)&lt;br /&gt;
select * from gltacct&lt;br /&gt;
where segment_4 like '150'&lt;br /&gt;
&lt;br /&gt;
PRIMARY:&lt;br /&gt;
select lq1.plant_code,lq2.* from lq2&lt;br /&gt;
inner join lq1 on 1=1&lt;br /&gt;
ORDER BY 1,2&lt;br /&gt;
&lt;br /&gt;
INSERT INTO &lt;br /&gt;
gltacct&lt;br /&gt;
( GL_ACCOUNT, DESCRIPTION, GL_GROUP, SEQUENCE, ACCOUNT_CLASS, COMPANY_NO, DIVISION_NO, ALLOC_RULE_ID, NRMCA_ACCOUNT, ACCOUNT_TYPE, DR_CR_FLAG, INTRA_COMPANY, JC_REQUIRED, SECURITY_CLASS, IMPORTED_FLAG, VALID_FROM_DATE, VALID_TO_DATE, NOTES_1, NOTES_2, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{segment_1}-00-9999{PLANT_CODE}-{PLANT_CODE}', '{DESCRIPTION}', '{GL_GROUP}', {SEQUENCE}, '{ACCOUNT_CLASS}', '{COMPANY_NO}', '{DIVISION_NO}', '{ALLOC_RULE_ID}', '{NRMCA_ACCOUNT}', '{ACCOUNT_TYPE}', '{DR_CR_FLAG}', '{INTRA_COMPANY}', '{JC_REQUIRED}', '{SECURITY_CLASS}', '{IMPORTED_FLAG}', '{VALID_FROM_DATE}', '{VALID_TO_DATE}', '{NOTES_1}', '{NOTES_2}', CAST('TODAY' AS TIMESTAMP), 'HIT', '{ACTIVE_FLAG}'    );&lt;br /&gt;
&lt;br /&gt;
= gl 000 =&lt;br /&gt;
&lt;br /&gt;
select  * from gltacct&lt;br /&gt;
where segment_4=000&lt;br /&gt;
&lt;br /&gt;
INSERT INTO GLTACCT&lt;br /&gt;
( GL_ACCOUNT, DESCRIPTION, GL_GROUP, SEQUENCE, ACCOUNT_CLASS, COMPANY_NO, DIVISION_NO, ALLOC_RULE_ID, NRMCA_ACCOUNT, ACCOUNT_TYPE, DR_CR_FLAG, INTRA_COMPANY, JC_REQUIRED, SECURITY_CLASS, IMPORTED_FLAG, VALID_FROM_DATE, VALID_TO_DATE, NOTES_1, NOTES_2, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{SEGMENT_1}-00-9999{SEGMENT_4}-{SEGMENT_4}', '{DESCRIPTION}', '{GL_GROUP}', {SEQUENCE}, '{ACCOUNT_CLASS}', '{COMPANY_NO}', '{DIVISION_NO}', '{ALLOC_RULE_ID}', '{NRMCA_ACCOUNT}', '{ACCOUNT_TYPE}', '{DR_CR_FLAG}', '{INTRA_COMPANY}', '{JC_REQUIRED}', '{SECURITY_CLASS}', '{IMPORTED_FLAG}', '{VALID_FROM_DATE}', '{VALID_TO_DATE}', '{NOTES_1}', '{NOTES_2}', CAST('TODAY' AS TIMESTAMP), 'HIT', '{ACTIVE_FLAG}'    );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
TODO - MAP SEGMENT 3 BY PLANT FROM 9999###&lt;br /&gt;
==========&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Plant=== &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
p.*&lt;br /&gt;
FROM plnt p&lt;br /&gt;
where isnumeric (plant_code)=1&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTPLANT ( PLANT_NO, SYS_LOC, PLANT_NAME, ADDRESS_1, ADDRESS_2, PHONE_NO, PLANT_TYPE, PLANT_SCREEN_ID, DIVISION_NO,PLANT_WASH_MINLD, JOB_WASH_MINLD,&lt;br /&gt;
BATCH_CAPACITY,&lt;br /&gt;
MEMO, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{plant_code|trim=0}', 0, '{name}', '{addr_line_1}', '{addr_line_2}', '{PHONE_Num}', 'D', '{short_name}', null, {PLANT_WASHDOWN_TIME}, {JOB_WASHDOWN_TIME},&lt;br /&gt;
{MAX_BATCH_SIZE},&lt;br /&gt;
'{LOC_CODE|trim=0}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
TODO: GL MASK - DEFAULT G/L ACCOUNTS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Tax=== &lt;br /&gt;
(when Flat in Keystone and MultiLevel in CMD)&lt;br /&gt;
Tax Research&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
select j.tax_code,a.descr,sum(prim_rate_curr_pct), sum(1) ct&lt;br /&gt;
from taxj j&lt;br /&gt;
inner join taxc a on a.tax_code=j.tax_code&lt;br /&gt;
inner join taxl l on j.tax_loc=l.tax_loc and l.tax_auth=j.tax_auth&lt;br /&gt;
group by j.tax_code,a.descr;&lt;br /&gt;
&lt;br /&gt;
select *&lt;br /&gt;
from taxj j&lt;br /&gt;
inner join taxc a on a.tax_code=j.tax_code&lt;br /&gt;
inner join taxl l on j.tax_loc=l.tax_loc and l.tax_auth=j.tax_auth&lt;br /&gt;
order by j.tax_code,a.descr;&lt;br /&gt;
&lt;br /&gt;
select * from taxj order by tax_code,tax_auth,tax_loc;&lt;br /&gt;
select * from taxc;&lt;br /&gt;
select * from taxl;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Confirmed FLAT OK&lt;br /&gt;
&lt;br /&gt;
ARTTXLOC/AUT/STR:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
select j.tax_code,a.descr,sum(prim_rate_curr_pct) TAX_RATE, sum(1)  ct&lt;br /&gt;
from taxj j&lt;br /&gt;
inner join taxc a on a.tax_code=j.tax_code&lt;br /&gt;
inner join taxl l on j.tax_loc=l.tax_loc and l.tax_auth=j.tax_auth&lt;br /&gt;
group by j.tax_code,a.descr;&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTTXLOC&lt;br /&gt;
( TAX_LOCALITY, LINE_NO, DESCRIPTION, TAX_COL, LOC_LEVEL, TAX_RATE, CALC_METHOD, EFFECT_DATE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{TAX_CODE}', 1, '{DESCR}', 1, 1, {TAX_RATE}, 1, '01/01/1900', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTTXAUT&lt;br /&gt;
( TAX_AUTHORITY, DESCRIPTION, INCREASE_DISC_FLAG, DISC_INCLUDES_TAX, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{TAX_CODE}', '{DESCR}', 'N', 'Y', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO &lt;br /&gt;
ARTTXSTR&lt;br /&gt;
( SESSION_NO, TRANS_NO, TAX_AUTHORITY, TAX_LOCALITY, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( 0, {TAX_RATE|INC=1}, '{TAX_CODE}', '{TAX_CODE}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Unit of Measure===&lt;br /&gt;
ARTUMS (This finds CMD U/M that are actually used but not in Keystone)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
LQ1:&lt;br /&gt;
SELECT * FROM aRTUMS&lt;br /&gt;
&lt;br /&gt;
LQ2:&lt;br /&gt;
SELECT &lt;br /&gt;
LTRIM(UPPER(ABBR)) UM,&lt;br /&gt;
UOMS,* FROM UOMS&lt;br /&gt;
&lt;br /&gt;
LQ3: -- This finds the uoms used for importable items (no need to import baggage)&lt;br /&gt;
SELECT DISTINCT (order_uom) UMX FROM IMST UNION &lt;br /&gt;
SELECT DISTINCT (price_uom) FROM IMST UNION &lt;br /&gt;
SELECT DISTINCT (invy_uom) FROM IMST UNION &lt;br /&gt;
SELECT DISTINCT (purch_uom) FROM IMST UNION &lt;br /&gt;
SELECT DISTINCT (batch_uom) FROM IMST UNION &lt;br /&gt;
SELECT DISTINCT (rpt_uom) FROM IMST UNION &lt;br /&gt;
SELECT DISTINCT (order_dosage_qty_uom) FROM IMST&lt;br /&gt;
&lt;br /&gt;
SELECT:&lt;br /&gt;
SELECT lq2.* FROM LQ2&lt;br /&gt;
INNER JOIN LQ3 ON LQ2.UOM=LQ3.UMX&lt;br /&gt;
LEFT OUTER JOIN LQ1&lt;br /&gt;
 ON LQ2.UM=LQ1.UNIT_OF_MEASURE&lt;br /&gt;
WHERE UNIT_OF_MEASURE IS  NULL&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTUMS&lt;br /&gt;
( UNIT_OF_MEASURE, EXPANDED_UMS, DESCRIPTION, UMS_TYPE, UMS_SYSTEM,  SUBTOTAL, SYSTEM_FLAG, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{UM}', '{UOM}', '{DESCR}', 'U', 'E',   'N', 'N', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
-- Set UofM Expanded &lt;br /&gt;
SELECT lq1.*,lq2.* FROM LQ2&lt;br /&gt;
INNER JOIN LQ3 ON LQ2.UOM=LQ3.UMX&lt;br /&gt;
LEFT OUTER JOIN LQ1&lt;br /&gt;
 ON cast(LQ2.UM as text)=cast(LQ1.UNIT_OF_MEASURE as text)&lt;br /&gt;
WHERE  (UNIT_OF_MEASURE IS not  NULL)&lt;br /&gt;
&lt;br /&gt;
update ARTUMS set EXPANDED_UMS={uom} where unit_of_measure='{UM}';&lt;br /&gt;
&lt;br /&gt;
Note - the expanded UofM stored for potential linking on imports.  &lt;br /&gt;
&lt;br /&gt;
TODO: Clear expanded at roll out - it will print on reports.&lt;br /&gt;
&lt;br /&gt;
=== artprcls&lt;br /&gt;
Straight rip from Alt Company&lt;br /&gt;
&lt;br /&gt;
===artslspn&lt;br /&gt;
&lt;br /&gt;
SELECT &lt;br /&gt;
ltrim(empl_code) CLASS_NO,&lt;br /&gt;
ltrim(empl_code) USER_1,&lt;br /&gt;
rtrim(LTRIM(NAME)) DESCRIPTION,&lt;br /&gt;
LTRIM(PHONE_NUM) PHONE_NO,&lt;br /&gt;
LTRIM(ASSGN_PLANT_CODE) USER_2&lt;br /&gt;
 FROM empl&lt;br /&gt;
where slsmn_flag='True'&lt;br /&gt;
&lt;br /&gt;
INSERT INTO artslspn &lt;br /&gt;
( CLASS_NO, EMPLOYEE_NO, DESCRIPTION, PHONE_NO, USER_2 )  VALUES &lt;br /&gt;
( SUBSTR(100+{CLASS_NO|INC=1},2,3), '{USER_1}', '{DESCRIPTION}', '{PHONE_NO}', '{USER_2}'    );&lt;br /&gt;
========&lt;br /&gt;
=== arttruck&lt;br /&gt;
select  &lt;br /&gt;
rtrim(ltrim(truck_code)) &amp;quot;TRUCK_NO&amp;quot;,&lt;br /&gt;
rtrim(ltrim(DESCR)) &amp;quot;DESCR&amp;quot;,&lt;br /&gt;
truc.* from truc&lt;br /&gt;
ORDER BY UPDATE_DATE DESC&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTTRUCK &lt;br /&gt;
( TRUCK_NO, TARE_WEIGHT, LAST_TARE_DATE, HOME_PLANT_NO, PLATE_NUMBER, EXPIRATION_DATE,  ACTIVE_FLAG, memo )  VALUES &lt;br /&gt;
( '{TRUCK_CODE|TRIM=0}', {TARE_WGT|null=0}, '{TARE_DATE}', '{FROM_PLANT_CODE|TRIM=0}', '{LIC_NUM}',  '{expir_date_1}',  'Y' ,&lt;br /&gt;
'Cmd Import mm/yy/dddd &lt;br /&gt;
Description: {DESCR}&lt;br /&gt;
Owner: {OWNER_NAME}&lt;br /&gt;
Trk Type: {truck_TYPE}&lt;br /&gt;
Inactive: {INACTIVE_FLAG}&lt;br /&gt;
Max Ld Sz: {MAX_LOAD_SIZE}&lt;br /&gt;
Driver Emp: {assgn_driv_empl_code|TRIM=0}'&lt;br /&gt;
   );  /* ------------------------------------ */&lt;br /&gt;
========&lt;br /&gt;
=== ARTDRIV&lt;br /&gt;
SELECT  &lt;br /&gt;
rtrim(ltrim(empl_code)) &amp;quot;DRIVER_CODE&amp;quot;, -- 12/11&lt;br /&gt;
rtrim(ltrim(NAME)) &amp;quot;DRIVER_NAME&amp;quot;,&lt;br /&gt;
EMPL.* from empl&lt;br /&gt;
where driv_flag = 1&lt;br /&gt;
order by update_date desc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO  artdriv&lt;br /&gt;
( DRIVER_CODE, DRIVER_NAME, PHONE_NO, HOME_PLANT_NO, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG,memo )  VALUES &lt;br /&gt;
( '{empl_CODE|trim=0}', '{NAME}', '{PHONE_Num}', '{assgn_plant_code}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y',&lt;br /&gt;
'Imported mm/dd/yyyy&lt;br /&gt;
 Inactive Date: {Inactive_date} &lt;br /&gt;
 Inactive code: {inactive_code}&lt;br /&gt;
 ' );&lt;br /&gt;
========&lt;br /&gt;
=== ARTPROD &lt;br /&gt;
&lt;br /&gt;
--t22&lt;br /&gt;
(01/05/22 simplified and cleaned up)&lt;br /&gt;
SELECT &lt;br /&gt;
CONCAT(RTRIM(LTRIM(IMST.ITEM_CODE)),'.',&lt;br /&gt;
PLNT.PLANT_CODE)  PRODUCT_CODE_ORIG,&lt;br /&gt;
UPPER(CONCAT(  RTRIM(LTRIM(IMST.ITEM_CODE))    ,'.',PLNT.PLANT_CODE))  &amp;quot;PRODUCT_CODE&amp;quot;, &lt;br /&gt;
UPPER(RTRIM(LTRIM(IMST.ITEM_CODE))) &amp;quot;BASE_PRODUCT&amp;quot;, -- 12/15 ADJ . TO -&lt;br /&gt;
RTRIM(lTRIM(ILOC.LOC_CODE)) LOC_CODE,&lt;br /&gt;
rtrim(LTRIM(PLNT.PLANT_CODE)) PLANT_NO,&lt;br /&gt;
coalesce(max_load_size,0) mxldsz,&lt;br /&gt;
RTRIM(LTRIM(IMST.ITEM_CODE)) ITEM_CODE,UPPER(IU.ABBR) INVUM,UPPER(PU.ABBR) PRICEUM,UPPER(PU.ABBR) BATCH_UMS,&lt;br /&gt;
CASE INVY_FLAG WHEN 'True' then 'Y' else 'N' END STOCKED,&lt;br /&gt;
CASE imst.TAXBLE_CODE WHEN '1' then 'Y' else 'N' END TAX_CODE_1,&lt;br /&gt;
LTRIM(imst.ITEM_CAT) ITEM_CAT,&lt;br /&gt;
case RTRIM(Ltrim(imst.item_cat))  -- icat to product class translation&lt;br /&gt;
   WHEN '1' THEN 'C5'&lt;br /&gt;
   WHEN '3' THEN 'X2'&lt;br /&gt;
   WHEN '4' THEN 'X3'&lt;br /&gt;
   WHEN '5' THEN 'X5'&lt;br /&gt;
   WHEN '6' THEN 'Y1'&lt;br /&gt;
   WHEN '7' THEN 'Y5'&lt;br /&gt;
   WHEN '8' THEN 'Y4'&lt;br /&gt;
   WHEN '9' THEN 'A4'&lt;br /&gt;
   WHEN '10' THEN '23'&lt;br /&gt;
   WHEN '11' THEN 'Y3'&lt;br /&gt;
   WHEN '12' THEN 'Y6'&lt;br /&gt;
   WHEN '15' THEN 'P1'&lt;br /&gt;
   WHEN '18' THEN 'P2'&lt;br /&gt;
   WHEN '21' THEN 'X1'&lt;br /&gt;
   WHEN '23' THEN '23'&lt;br /&gt;
   WHEN '24' THEN 'X4'&lt;br /&gt;
   WHEN '1.1' THEN 'C5'&lt;br /&gt;
   WHEN '1.2' THEN 'C5'&lt;br /&gt;
   WHEN '1.3' THEN 'C5'&lt;br /&gt;
   WHEN '1.4' THEN 'C5'&lt;br /&gt;
   WHEN '1.5' THEN 'C5'&lt;br /&gt;
   WHEN '1.6' THEN 'C5'&lt;br /&gt;
   WHEN '1.7' THEN 'C5'&lt;br /&gt;
   WHEN '1.8' THEN 'C5'&lt;br /&gt;
   WHEN '1.9' THEN 'C5'&lt;br /&gt;
   WHEN '13.1' THEN 'R1'&lt;br /&gt;
   WHEN '13.2' THEN 'R2'&lt;br /&gt;
   WHEN '13.6' THEN 'T1'&lt;br /&gt;
   WHEN '13.8' THEN 'D1'&lt;br /&gt;
   WHEN '20.1' THEN 'P1'&lt;br /&gt;
   WHEN '1.10' THEN 'C5'&lt;br /&gt;
elSe 'Z1' END PRODUCT_CLASS,&lt;br /&gt;
COALESCE (IMST.PCT_AIR,0) PCT_AIR,&lt;br /&gt;
COALESCE (IMST.WATER_CEM_RATIO,0) WATER_CEM_RATIO,&lt;br /&gt;
--IIF( LEN(REPLACE(imst.DESCR, '''', '~' ))&amp;lt;=35, REPLACE(imst.DESCR, '''', '~' ),REPLACE(imst.SHORT_DESCR, '''', '~' )) DESCRIPTION,&lt;br /&gt;
replace(replace(replace(REPLACE(imst.DESCR, '''', '~' ),'    ',' '),'  ',' '),'  ',' ') DESCR2,&lt;br /&gt;
iif(resale_flag=1,'Y','N')  &amp;quot;SELLABLE_FLAG&amp;quot;,&lt;br /&gt;
COALESCE(iloc.curr_std_cost,0) CURR_STD_COST,&lt;br /&gt;
prev_std_cost,&lt;br /&gt;
cost_ext_code,&lt;br /&gt;
prev_cost_ext_code,&lt;br /&gt;
std_cost_effect_date,&lt;br /&gt;
curr_opt_cost,&lt;br /&gt;
prev_opt_cost,&lt;br /&gt;
opt_cost_effect_date&lt;br /&gt;
,imst.short_descr&lt;br /&gt;
,iloc.inactive_code&lt;br /&gt;
,imst.tax_rate_code&lt;br /&gt;
,imst.NON_TAX_RSN_CODE&lt;br /&gt;
,imst.descr&lt;br /&gt;
--,IMST.* &lt;br /&gt;
FROM IMST&lt;br /&gt;
INNER JOIN ILOC ON ILOC.ITEM_CODE=IMST.ITEM_CODE&lt;br /&gt;
INNER JOIN PLNT ON PLNT.LOC_CODE=ILOC.LOC_CODE&lt;br /&gt;
LEFT OUTER JOIN DBO.UOMS IU ON IU.UOM=IMST.INVY_UOM&lt;br /&gt;
LEFT OUTER JOIN DBO.UOMS PU ON PU.UOM=IMST.PRICE_UOM&lt;br /&gt;
LEFT OUTER JOIN DBO.UOMS BU ON BU.UOM=IMST.BATCH_UOM&lt;br /&gt;
where isnumeric (plnt.plant_code)=1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO &lt;br /&gt;
ARTPROD &lt;br /&gt;
( PRODUCT_CODE, UNIT_OF_MEASURE, DESCRIPTION_1, DESCRIPTION_2, LOCATION, STOCKED, TAX_CODE, TAX_CODE_2, TAX_CODE_3, BASE_PRODUCT, PRODUCT_CLASS, PLANT_NO, PRODUCT_TYPE, INGREDIENT_TYPE, EXPORT_FLAG, ROLLUP_FLAG, SELLABLE_FLAG, SEND_TO_BATCH, UPC_CODE, VENDOR_NO, VENDOR_PART_NO, LIST_PRICE, SPECIFIC_GRAVITY, PERCENT_AIR, MIX_WC_RATIO, MIX_YIELD, MIXER_TIME_SEC, MAX_LOAD_SIZE, STD_PCT_DISC, AUTO_QTY, DEFAULT_SLUMP, PURCHASE_UMS, ENTRY_UMS, MIX_UMS, BATCH_UMS, NOTES_1, NOTES_2, NOTES_3, NOTES_4, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG, MEMO )  VALUES &lt;br /&gt;
( '{PRODUCT_CODE}', '{PRICEUM}', '{DESCR2|STRLEN=35}', '{SHORT_DESCR}', NULL, '{STOCKED}', '{TAX_CODE_1}', 'Y', 'Y', '{ITEM_CODE}', '{PRODUCT_CLASS}', '{PLANT_NO}', 'X', NULL, 'N', 'N', 'Y', 'N', NULL, NULL, NULL, 0, 0, {PCT_AIR}, {WATER_CEM_RATIO}, 0 , 0, {MXLDSZ}, NULL, 'N', 0, NULL, NULL, NULL, '{BATCH_UMS}', '{ITEM_CAT}', 'LOC: {LOC_CODE} / INACTIVE: {INACTIVE_CODE}', '{TAX_RATE_CODE}/{NON_TAX_RSN_CODE}', '{DESCR}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y' &lt;br /&gt;
, '***Import Notes  01/03/2023 ***' );&lt;br /&gt;
&lt;br /&gt;
todo:&lt;br /&gt;
Prices&lt;br /&gt;
Apply Product Class Updates&lt;br /&gt;
Update Product, Ingredient Types / G/L from product classes.&lt;br /&gt;
&lt;br /&gt;
To update missing products do main query in LQ1 and use:&lt;br /&gt;
&lt;br /&gt;
select LQ1.* from lq1&lt;br /&gt;
LEFT OUTER JOIN LQ2 ON LQ2.PRODUCT_CODE = LQ1.PRODUCT_CODE&lt;br /&gt;
WHERE LQ2.PRODUCT_CODE IS NULL&lt;br /&gt;
LIMIT 5000;&lt;br /&gt;
(5000 at a time for processing efficiency)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- FIX (01/04/2023  - unneeded since  reprocessed products)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ALTER TRIGGER argprod_bupdate INACTIVE;&lt;br /&gt;
ALTER TRIGGER argprod_Aupdate INACTIVE;&lt;br /&gt;
&lt;br /&gt;
select PRODUCT_CODE,upper(BASE_PRODUCT) BASE_PRODUCT,PLANT_NO from artPROD&lt;br /&gt;
WHERE PRODUCT_CODE &amp;lt;&amp;gt; upper(BASE_PRODUCT)||'.'||PLANT_NO&lt;br /&gt;
ORDER BY PLANT_NO,PRODUCT_CODE&lt;br /&gt;
&lt;br /&gt;
UPDATE ARTPROD SET PRODUCT_CODE='{BASE_PRODUCT}.{PLANT_NO}' WHERE upper(BASE_PRODUCT) =  '{BASE_PRODUCT}' AND PLANT_NO='{PLANT_NO}';&lt;br /&gt;
&lt;br /&gt;
ALTER TRIGGER argprod_bupdate ACTIVE;&lt;br /&gt;
ALTER TRIGGER argprod_Aupdate ACTIVE;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=======&lt;br /&gt;
=== ARTCTCLS&lt;br /&gt;
&lt;br /&gt;
SELECT ltrim(rtrim(terms_code)) terms_code&lt;br /&gt;
      ,descry&lt;br /&gt;
      ,disc_amt_1&lt;br /&gt;
      ,disc_amt_2&lt;br /&gt;
      ,disc_day_1&lt;br /&gt;
      ,disc_day_2&lt;br /&gt;
      ,due_day_1&lt;br /&gt;
      ,due_day_2&lt;br /&gt;
      ,short_descr&lt;br /&gt;
      ,terms_type&lt;br /&gt;
      ,per_uom&lt;br /&gt;
      ,update_date&lt;br /&gt;
  FROM CMDPROD_ARK.dbo.trms&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTCTCLS&lt;br /&gt;
( CLASS_NO, DESCRIPTION, DUE_BY, DUE_BY_PIVOT, DUE_IN, DISC_PCT, DISC_BY, DISC_BY_PIVOT, DISC_IN, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{TERMS_CODE}', '{DESCR}', NULL, NULL, NULL, {DISC_AMT_1}, NULL, NULL, {DISC_DAY_1}, 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTE: Not 100% clear on how to match days -manually edit.&lt;br /&gt;
========&lt;br /&gt;
=== ARTALCLS (FROM alt company)&lt;br /&gt;
select aa.* ,&lt;br /&gt;
a.segment_1,a.segment_2,a.segment_3,a.segment_4&lt;br /&gt;
from artalcls aa&lt;br /&gt;
left outer join gltacct a  on a.gl_account = aa.allow_gl&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTALCLS&lt;br /&gt;
( CLASS_NO, DESCRIPTION, ALLOW_GL, ALLOW_INCLUDES_TAX, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{CLASS_NO}', '{DESCRIPTION}',  '{SEGMENT_1}-00-9999{SEGMENT_4}-{SEGMENT_4}', '{ALLOW_INCLUDES_TAX}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', '{ACTIVE_FLAG}'    );&lt;br /&gt;
&lt;br /&gt;
========&lt;br /&gt;
=== ARTCUST&lt;br /&gt;
&lt;br /&gt;
select &lt;br /&gt;
LTRIM(RTRIM(cust.CUST_CODE)) CUST_NO,&lt;br /&gt;
left(ltrim(rtrim(CUST.NAME)),30) name,&lt;br /&gt;
left(CUST.ADDR_LINE_1,30) addr_line_1,&lt;br /&gt;
left(CUST.ADDR_LINE_2,30) addr_line_2,&lt;br /&gt;
left(replace(addr_city,',',''),16) CITY,&lt;br /&gt;
replace(LEFT(rtrim(ltrim(ADDR_STATE)),2),'M0','MO') STATE,&lt;br /&gt;
PHONE_NUM_1,PHONE_NUM_2,PHONE_NUM_3,&lt;br /&gt;
LTRIM(RTRIM(ADDR_POSTCD)) ZIP,cust.tax_code &amp;quot;TAX_AUTHORITY&amp;quot;,&lt;br /&gt;
--cast(cust.tax_code as integer) txcd_int,&lt;br /&gt;
--left(LTRIM(RTRIM(taxj.tax_loc)),3) TAX_AUTHORITY,&lt;br /&gt;
LTRIM(RTRIM(CC_TERMS_CODE)) TERMS,&lt;br /&gt;
LTRIM(RTRIM(UPPER(CC_SALES_ANL_CODE))) CUCLS,&lt;br /&gt;
rtrim(LTRIM(CC_SLSMN_EMPL_CODE)) SLS_EMP,&lt;br /&gt;
rtrim(LTRIM(CC_PRICE_CAT)) PRICE_GROUP,&lt;br /&gt;
rtrim(LTRIM(CC_PRICE_PLANT_CODE) ) PRICE_PLANT,&lt;br /&gt;
CASE TAXBLE_CODE WHEN '1' then '' else CONCAT('TAX EXMPT RSN:', LTRIM(NON_TAX_RSN_CODE) ) END TAX_RSN,&lt;br /&gt;
case isnumeric(CC_SALES_ANL_CODE) &lt;br /&gt;
  WHEN 0 THEN LTRIM(CC_SALES_ANL_CODE)  ELSE RIGHT(CAST(100+CAST(CC_SALES_ANL_CODE AS INTEGER) AS CHAR(3)),2) END CUST_CLASS,&lt;br /&gt;
rtrim(LTRIM(INACTIVE_CODE)) INACTIVE_CODE,&lt;br /&gt;
CASE LTRIM(RTRIM(TAXBLE_CODE)) WHEN 1 THEN 'Y' ELSE 'N' END TAX_CODE,&lt;br /&gt;
CONCAT('Acct Cat Code: ',RTRIM(LTRIM(ACCT_CAT_CODE))) USER_2,&lt;br /&gt;
LEFT(CONTCT_NAME,30) CONTACT,&lt;br /&gt;
LEFT(SORT_NAME,30) SEQUENCE_CODE,&lt;br /&gt;
acct_cat_code,SETUP_DATE&lt;br /&gt;
from cust&lt;br /&gt;
--left outer join taxj on cast(taxj.tax_code as integer)=cast(cust.tax_code as integer)&lt;br /&gt;
order by cust_no&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO  artcust &lt;br /&gt;
( CUST_NO, SALESPERSON, CUST_CLASS, TERMS_CLASS, PRICE_GROUP, DIVISION_NO, PHONE_NO, FAX_NO, PAGER_NO, MOBILE_NO, EMAIL, URL, START_DATE, TAX_CODE, TAX_CODE_2, TAX_CODE_3, COD_FLAG, NAME, ADDRESS_1, ADDRESS_2, CITY, STATE, ZIP, USER_1, USER_2, NOTES_1,  TAX_AUTHORITY, CONTACT, SEQUENCE_CODE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{CUST_NO}', (SELECT CLASS_NO FROM ARTSLSPN WHERE EMPLOYEE_NO='{SLS_EMP}') , '{CUCLS}', '{TERMS}', '{PRICE_GROUP}' , NULL, '{PHONE_NUM_1}', NULL, NULL, '{PHONE_NUM_3}',  NULL, NULL, '{SETUP_DATE}', '{TAX_CODE}', 'Y', 'Y', 'N', '{NAME|STRLEN=30}', '{ADDR_LINE_1|STRLEN=30}', '{ADDR_LINE_2|STRLEN=30}', '{CITY}', '{STATE}', '{ZIP}', 'Sls Emp: {SLS_EMP|trim=0}',  '{USER_2}', '{TAX_RSN}',  '{TAX_AUTHORITY}', '{CONTACT}', '{SEQUENCE_CODE}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
=====&lt;br /&gt;
== LIST PRICE  ==&lt;br /&gt;
Price cat 1 as list price (54986 prices are cat 1)&lt;br /&gt;
&lt;br /&gt;
SELECT&lt;br /&gt;
concat(upper(rtrim(LTRIM(IPRC.ITEM_CODE))) , '.' , rtrim(ltrim(plnt.plant_code)))  &amp;quot;PRODUCT_CODE&amp;quot;,&lt;br /&gt;
upper(rtrim(LTRIM(IPRC.ITEM_CODE))) BASE_PRODUCT,&lt;br /&gt;
rtrim(ltrim(plnt.plant_code)) PLANT_NO,&lt;br /&gt;
PRICE UNIT_PRICE,1 CT,&lt;br /&gt;
IPRC.*&lt;br /&gt;
FROM IPRC&lt;br /&gt;
INNER JOIN PLNT ON plnt.LOC_CODE=iprc.LOC_CODE AND ISNUMERIC(PLNT.plant_code)&amp;gt;0&lt;br /&gt;
INNER JOIN ILOC ON ILOC.item_code=IPRC.item_code AND ILOC.loc_code=iprc.loc_code&lt;br /&gt;
INNER JOIN IMST ON IMST.item_code=ILOC.item_code &lt;br /&gt;
WHERE RTRIM(LTRIM(iprc.PRICE_CAT)) = '1' and price &amp;lt;&amp;gt; 0 &lt;br /&gt;
ORDER BY BASE_PRODUCT,PLANT_NO,PRICE_CAT,effect_date&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
UpdATE ARTPROD SET list_PRICE={PRICE} WHERE product_code='{BASE_PRODUCT}.{PLANT_NO}';&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Local to make manageable chunks and update only mismatches...&lt;br /&gt;
LQ2: &lt;br /&gt;
select lq2.*,LQ1.* from lq1&lt;br /&gt;
LEFT OUTER JOIN LQ2 ON LQ2.PRODUCT_CODE = LQ1.PRODUCT_CODE&lt;br /&gt;
WHERE LQ2.LIST_PRICE  &amp;lt;&amp;gt; LQ1.PRICE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
select lq2.*,LQ1.* from lq1&lt;br /&gt;
LEFT OUTER JOIN LQ2 ON LQ2.PRODUCT_CODE = LQ1.PRODUCT_CODE&lt;br /&gt;
WHERE LQ2.LIST_PRICE  &amp;lt;&amp;gt; LQ1.PRICE&lt;br /&gt;
limt 10000 offset 20000  -- 20000- 29999&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
========&lt;br /&gt;
=== artprice - group prices plant specific&lt;br /&gt;
&lt;br /&gt;
SELECT&lt;br /&gt;
concat(upper(rtrim(LTRIM(IPRC.ITEM_CODE))) , '.' , rtrim(ltrim(plnt.plant_code)))  &amp;quot;PRODUCT_CODE&amp;quot;,&lt;br /&gt;
upper(rtrim(LTRIM(IPRC.ITEM_CODE))) BASE_PRODUCT,&lt;br /&gt;
rtrim(ltrim(plnt.plant_code)) PLANT_NO,&lt;br /&gt;
rtrim(ltrim(iprc.price_cat)) GROUP_NO,&lt;br /&gt;
UPPER(PU.ABBR) UNIT_OF_MEASURE,&lt;br /&gt;
PRICE UNIT_PRICE,1 CT,&lt;br /&gt;
IPRC.*&lt;br /&gt;
FROM IPRC&lt;br /&gt;
INNER JOIN PLNT ON plnt.LOC_CODE=iprc.LOC_CODE AND ISNUMERIC(PLNT.plant_code)&amp;gt;0&lt;br /&gt;
INNER JOIN ILOC ON ILOC.item_code=IPRC.item_code AND ILOC.loc_code=iprc.loc_code&lt;br /&gt;
INNER JOIN IMST ON IMST.item_code=ILOC.item_code &lt;br /&gt;
LEFT OUTER JOIN UOMS PU ON PU.UOM=IMST.PRICE_UOM&lt;br /&gt;
WHERE RTRIM(LTRIM(iprc.PRICE_CAT)) &amp;gt; '1' and price &amp;lt;&amp;gt; 0 &lt;br /&gt;
ORDER BY BASE_PRODUCT,PLANT_NO,PRICE_CAT,effect_date&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTPRICE&lt;br /&gt;
( SESSION_NO, TRANS_NO, PRICE_TYPE, CUST_NO, GROUP_NO, PRICE_CODE, PRODUCT_CODE, UNIT_OF_MEASURE, UNIT_PRICE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( 1, {GROUP_NO|INC=1}, 'G', NULL,'{GROUP_NO}',  'P', '{BASE_PRODUCT}.{PLANT_NO}', '{UNIT_OF_MEASURE}', {UNIT_PRICE}, 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'   );&lt;br /&gt;
&lt;br /&gt;
-- 13 records &lt;br /&gt;
========&lt;br /&gt;
&lt;br /&gt;
No Customer Price (CPRD)&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
========&lt;br /&gt;
ARTSTR WIP&lt;br /&gt;
&lt;br /&gt;
select -- TOP (100)&lt;br /&gt;
1 SESSION_NO,1 TRANS_NO,SORT_LINE_NUM SEQUENCE_CODE,&lt;br /&gt;
PLNT.LOC_CODE &amp;quot;LOC_CODE&amp;quot;,&lt;br /&gt;
(PLNT.PLANT_CODE) PLANT_NO,&lt;br /&gt;
LTRIM(RTRIM(ICST.ITEM_CODE)) ASSY_PRODUCT_CODE,&lt;br /&gt;
LTRIM(RTRIM(CONST_ITEM_CODE)) COMP_PRODUCT_CODE,&lt;br /&gt;
UPPER(LTRIM(CU.ABBR)) COMP_UMS,&lt;br /&gt;
QTY QTY_ASSEMBLY, ILC.ITEM_CODE INGITEMLOC ,IMC.ITEM_CODE INGITEM&lt;br /&gt;
 from icst&lt;br /&gt;
LEFT OUTER JOIN UOMS CU ON CU.UOM=ICST.QTY_UOM&lt;br /&gt;
INNER JOIN PLNT ON ICST.LOC_CODE=PLNT.LOC_CODE AND ISNUMERIC(PLNT.PLANT_CODE)&amp;gt;0&lt;br /&gt;
INNER join iloc on iloc.item_code=icst.item_code AND ILOC.LOC_CODE=ICST.LOC_CODE&lt;br /&gt;
inner join imst on imst.item_code=iloc.item_code&lt;br /&gt;
LEFT OUTER JOIN ILOC ILC ON ILC.ITEM_CODE=ICST.CONST_ITEM_CODE AND ILC.LOC_CODE=ICST.LOC_CODE&lt;br /&gt;
LEFT OUTER JOIN IMST IMC ON IMC.ITEM_CODE=ICST.CONST_ITEM_CODE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTPRSTR&lt;br /&gt;
( SESSION_NO, TRANS_NO, SEQUENCE_CODE, ASSY_PRODUCT_CODE, COMP_PRODUCT_CODE, COMP_UMS, QTY_ASSEMBLY, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( {SESSION_NO}, {TRANS_NO|INC=1}, {SEQUENCE_CODE}, '{ASSY_PRODUCT_CODE}.{PLANT_NO}', '{COMP_PRODUCT_CODE}.{PLANT_NO}', '{COMP_UMS}', {QTY_ASSEMBLY}, 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
note: left outer allows missing items to go through - 5 components for plant 314 added.&lt;br /&gt;
(CMD does not have integrity - so structure for invalid products permitted)&lt;br /&gt;
&lt;br /&gt;
======================================================&lt;br /&gt;
jobs jobs jobs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Mismatch Items - no ILOC:&lt;br /&gt;
&lt;br /&gt;
select &lt;br /&gt;
proj.cust_code&lt;br /&gt;
,prjp.proj_code,CUST.NAME &amp;quot;CustName&amp;quot;,plnt.plant_code plant,(prjp.prod_code) ProjectProduct&lt;br /&gt;
,prjp.price&lt;br /&gt;
from prjp&lt;br /&gt;
INNER JOIN CUST ON CUST.CUST_CODE=PRjp.CUST_CODE&lt;br /&gt;
INNER JOIN PROJ ON PROJ.PROJ_CODE=PRJP.PROJ_CODE AND    PROJ.CUST_CODE=PRJP.CUST_CODE&lt;br /&gt;
inner join plnt on  plnt.plant_code = PROJ.Cc_PRICE_PLANT_CODE &lt;br /&gt;
left outer JOIN ILOC ON ILOC.ITEM_CODE=PRJP.PROD_CODE and    PLNT.LOC_CODE=ILOC.LOC_CODE&lt;br /&gt;
WHERE proj.INACTIVE_CODE=0&lt;br /&gt;
AND COALESCE(proj.EXPIR_DATE,'12/31/2099' ) &amp;gt;'1/1/23'&lt;br /&gt;
and iloc.item_code is null and price_plant_code &amp;lt;&amp;gt;'#'&lt;br /&gt;
order by proj.cust_code,prjp.proj_code,cust.name,proj.expir_date,plnt.plant_code,prjp.prod_code&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
0== job header query  ==&lt;br /&gt;
&lt;br /&gt;
with pj as(&lt;br /&gt;
select &lt;br /&gt;
proj.cust_code&lt;br /&gt;
,prjp.proj_code,CUST.NAME &amp;quot;CustName&amp;quot;&lt;br /&gt;
from prjp&lt;br /&gt;
INNER JOIN CUST ON CUST.CUST_CODE=PRjp.CUST_CODE&lt;br /&gt;
INNER JOIN PROJ ON PROJ.PROJ_CODE=PRJP.PROJ_CODE AND    PROJ.CUST_CODE=PRJP.CUST_CODE&lt;br /&gt;
--inner join plnt on  plnt.plant_code = PROJ.Cc_PRICE_PLANT_CODE &lt;br /&gt;
--INNER JOIN ILOC ON ILOC.ITEM_CODE=PRJP.PROD_CODE and    PLNT.LOC_CODE=ILOC.LOC_CODE&lt;br /&gt;
inner join plnt on  plnt.plant_code = PROJ.Cc_PRICE_PLANT_CODE &lt;br /&gt;
left outer JOIN ILOC ON ILOC.ITEM_CODE=PRJP.PROD_CODE and    PLNT.LOC_CODE=ILOC.LOC_CODE&lt;br /&gt;
--left outer join imst on imst.item_cat=prjp.prod_code and price_plant_code='#'&lt;br /&gt;
WHERE proj.INACTIVE_CODE=0&lt;br /&gt;
AND COALESCE(proj.EXPIR_DATE,'12/31/2099' ) &amp;gt;'1/1/23'&lt;br /&gt;
group by prjp.proj_code,proj.cust_code,cust.name,proj.expir_date&lt;br /&gt;
)&lt;br /&gt;
SELECT &lt;br /&gt;
rtrim(LTRIM(PROJ.CUST_CODE)) CUST_NO,PROJ.EXPIR_DATE,&lt;br /&gt;
Left(rtrim(LTRIM(PROJ.PROJ_code)),18) JOB_PO_LOC,&lt;br /&gt;
PROJ_NAME,PO,&lt;br /&gt;
Left(rtrim(LTRIM(PROJ_name)),18) batch_job_code,&lt;br /&gt;
rtrim(LTRIM(PROJ_NAME)) DELV_INST_1,&lt;br /&gt;
Left(LTRIM(proj.tax_code),3) TAX_code,&lt;br /&gt;
--'IMP' TAX_AUTHORITY,&lt;br /&gt;
CA_TERMS_CODE,PROJ.CA_PRICE_PLANT_CODE,&lt;br /&gt;
LTRIM(CA_TERMS_CODE) TERMS_CLASS,&lt;br /&gt;
--LTRIM(CA_PRICE_PLANT_CODE) PLANT_NO,&lt;br /&gt;
Left(rtrim(LTRIM(PO)) ,20) CUSTOMER_PO,&lt;br /&gt;
LTRIM(UPPER(PROJ.CA_SALES_ANL_CODE)) CUCLS,&lt;br /&gt;
'' SHIP_TO_1,&lt;br /&gt;
--Left(RTRIM(LTRIM(ship_name)),30) SHIP_TO_1 ,&lt;br /&gt;
Left(RTRIM(LTRIM(PROJ.ship_addr_line_1)),30) SHIP_TO_2 ,&lt;br /&gt;
Left(RTRIM(LTRIM(ship_addr_line_2)),30) SHIP_TO_3 ,&lt;br /&gt;
CASE LTRIM(TAXBLE_CODE) WHEN 1 THEN 'Y' ELSE 'N' END JOB_TAX_CODE,&lt;br /&gt;
Left(concat(SHIP_CITY,' ',SHIP_STATE,' ',SHIP_POSTCD),30) SHIP_TO_4,&lt;br /&gt;
 Taxj.tax_loc &amp;quot;NOTES_1&amp;quot;,&lt;br /&gt;
PROJ.EXPIR_DATE &amp;quot;NOTES_2&amp;quot;,&lt;br /&gt;
--USE_FOR_PROD_LINE_CODE &amp;quot;NOTES_2&amp;quot;,&lt;br /&gt;
LTRIM(NON_TAX_RSN_CODE) &amp;quot;CUSTOM_1&amp;quot;,&lt;br /&gt;
LTRIM(PROJ.CA_SLSMN_EMPL_CODE) &amp;quot;CUSTOM_2&amp;quot;,&lt;br /&gt;
Left(RTRIM(LTRIM(CONTCT_NAME)),30) &amp;quot;CONTACT&amp;quot;,&lt;br /&gt;
Left(RTRIM(LTRIM(PHONE_NUM_1)),30) PHONE_NO,&lt;br /&gt;
Left(RTRIM(LTRIM(PROJ_NAME)),30) &amp;quot;INVOICE_DESC&amp;quot;&lt;br /&gt;
,ship_addr_line_1,ship_addr_line_2,&lt;br /&gt;
PHONE_NUM_1,PHONE_NUM_2,PHONE_NUM_3,CONTct_NAME,custname&lt;br /&gt;
FROM proj &lt;br /&gt;
inner join pj on pj.proj_code=proj.proj_code and pj.cust_code=proj.cust_code&lt;br /&gt;
INNER JOIN TAXJ ON TAXJ.TAX_CODE=proj.TAX_CODE and taxj.tax_auth=1&lt;br /&gt;
where inactive_code = 0&lt;br /&gt;
and coalesce (PROJ.expir_date,'12/31/2099')&amp;gt;'1/1/2023'&lt;br /&gt;
ORDER BY CUST_NO,PROJ_NAME&lt;br /&gt;
&lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTJOBHD &lt;br /&gt;
( SESSION_NO, TRANS_NO, CUST_NO, JOB_PO_LOC, BATCH_JOB_CODE , TERMS_CLASS, TAX_AUTHORITY,  INVOICE_DESC, NOTES_1, NOTES_2, JOB_TAX_CODE, JOB_TAX_CODE_2, JOB_TAX_CODE_3, PLANT_NO, SHIP_TO_1, SHIP_TO_2, SHIP_TO_3, SHIP_TO_4, PHONE_NO, CONTACT, CUSTOMER_PO, CUSTOM_1, CUSTOM_2,  COD_FLAG, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG, MEMO )  VALUES &lt;br /&gt;
( 1, {CUST_NO|INC=1}, '{CUST_NO}', '{JOB_PO_LOC}', '{batch_job_code}',  NULL, '{TAX_AUTHORITY}', '{INVOICE_DESC}', '{NOTES_1}', '{NOTES_2}', '{JOB_TAX_CODE}', 'Y', 'Y', NULL, '{SHIP_TO_1}', '{SHIP_TO_2}', '{SHIP_TO_3}', '{SHIP_TO_4}', '{PHONE_NO}', '{CONTACT}', '{CUSTOMER_PO}', '{CUSTOM_1}', '{CUSTOM_2}', 'N', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y' , &lt;br /&gt;
'***Import Notes Jan 2023***&lt;br /&gt;
PROJ NAME: {PROJ_NAME}&lt;br /&gt;
PO: {PO}&lt;br /&gt;
CONTACT: {CONTct_NAME}&lt;br /&gt;
PHONE1: {phone_num_1}&lt;br /&gt;
PHONE2: {phone_num_2}&lt;br /&gt;
PHONE3: {phone_num_3}&lt;br /&gt;
ship_addr_line_1 {ship_addr_line_1}&lt;br /&gt;
ship_addr_line_2 {ship_addr_line_2}&lt;br /&gt;
expir_date: {expir_date}&lt;br /&gt;
*****************************************&lt;br /&gt;
'   );  -- {custname}&lt;br /&gt;
&lt;br /&gt;
NOTE: plant ok?&lt;br /&gt;
Uses numeric job code as JOB ID -- this should be updated on ib side.&lt;br /&gt;
&lt;br /&gt;
== job detail query  ==&lt;br /&gt;
&lt;br /&gt;
WITH JDT AS &lt;br /&gt;
(&lt;br /&gt;
select --top 100  &lt;br /&gt;
proj.cust_code,&lt;br /&gt;
RTRIM(LTRIM(PRJP.PROJ_CODE)) JOB_PO_LOC,&lt;br /&gt;
RTRIM(LTRIM(PRJP.CUST_CODE)) CUST_NO,&lt;br /&gt;
RTRIM(LTRIM(PRJP.PROD_CODE)) PRODUCT_CODE,&lt;br /&gt;
RTRIM(LTRIM(Cc_PRICE_PLANT_CODE)) PLANT_code,&lt;br /&gt;
PRJP.INTRNL_LINE_NUM LINE_NO,&lt;br /&gt;
(SELECT UPPER(ABBR) FROM UOMS WHERE UOMS.UOM = PRJP.PRICE_UOM) UNIT_OF_MEASURE,&lt;br /&gt;
left(RTRIM(LTRIM(PROD_DESCR)),35) DESCRIPTION,&lt;br /&gt;
PRICE UNIT_PRICE,prjp.effect_date&lt;br /&gt;
  ,PRJP.PROD_CODE&lt;br /&gt;
  ,LAG(PROD_CODE,1,'__') OVER (partition by PRJP.CUST_CODE,PRJP.PROJ_CODE,Cc_PRICE_PLANT_CODE&lt;br /&gt;
      order by PRJP.CUST_CODE,PRJP.PROJ_CODE,PRJP.PROD_CODE,Cc_PRICE_PLANT_CODE,PRJP.EFFECT_DATE DESC) PREVPROD&lt;br /&gt;
,iif(iloc.loc_code is null,(select min(loc_code) from iloc where iloc.item_code=imst.item_code and iloc.inactive_code=0),iloc.loc_code) altclocode&lt;br /&gt;
from prjp&lt;br /&gt;
INNER JOIN PROJ ON PROJ.PROJ_CODE=PRJP.PROJ_CODE AND PROJ.CUST_CODE=PRJP.CUST_CODE&lt;br /&gt;
inner join plnt on  plnt.plant_code = Cc_PRICE_PLANT_CODE&lt;br /&gt;
left outer JOIN ILOC ON ILOC.ITEM_CODE=PRJP.PROD_CODE and    PLNT.LOC_CODE=ILOC.LOC_CODE&lt;br /&gt;
inner join imst on imst.item_code=prjp.prod_code&lt;br /&gt;
WHERE proj.INACTIVE_CODE=0&lt;br /&gt;
AND COALESCE(proj.EXPIR_DATE,'12/31/2099' ) &amp;gt;'1/1/23'&lt;br /&gt;
)&lt;br /&gt;
SELECT JDT.*,plnt.plant_code &amp;quot;PLANT_NO&amp;quot;&lt;br /&gt;
FROM JDT&lt;br /&gt;
inner join cust on cust.cust_code=jdt.cust_code&lt;br /&gt;
inner join plnt on plnt.loc_code=jdt.altclocode AND ISNUMERIC(PLNT.PLANT_CODE)=1&lt;br /&gt;
WHERE PREVPROD&amp;lt;&amp;gt;PROD_CODE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTJOBDT &lt;br /&gt;
 ( SESSION_NO, TRANS_NO, JOB_PO_LOC, CUST_NO, PRODUCT_CODE, LINE_NO, UNIT_OF_MEASURE, DESCRIPTION, UNIT_PRICE, TAX_CODE, TAX_CODE_2, TAX_CODE_3, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER )  VALUES &lt;br /&gt;
  ( 1, (SELECT TRANS_NO  FROM ARTJOBHD WHERE JOB_PO_LOC='{JOB_PO_LOC}' AND CUST_NO='{CUST_NO}' )&lt;br /&gt;
  , '{JOB_PO_LOC}', '{CUST_NO}', '{PRODUCT_CODE}.{PLANT_NO}', {LINE_NO}, '{UNIT_OF_MEASURE}', '{DESCRIPTION}', {UNIT_PRICE}, 'Y', 'Y', 'Y', 'Y', CAST('TODAY' AS TIMESTAMP), 'Y'    );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTES:  Not loving the plant mismatches on detail&lt;br /&gt;
If primary plant not specified - takes the lowest value. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
------&lt;br /&gt;
ZONE&lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
SELECT * FROM ZONE&lt;br /&gt;
&lt;br /&gt;
INSERT INTO artzone&lt;br /&gt;
   ( ZONE, DESCRIPTION, PLANT_NO, ZONE_REGION, DEF_TAX_AUTHORITY, IMPORTED_FLAG, MEMO, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
   ( '{ZONE_CODE|TRIM=0}', '{DESCR|STRLEN=35}', NULL, NULL, '{TAX_CODE}', 'Y', 'Imported 01/17/2023', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
--------------&lt;br /&gt;
CONTACT&lt;br /&gt;
------&lt;br /&gt;
SELECT &lt;br /&gt;
LTRIM(RTRIM(CCON.CUST_CODE)) ENTITY_ID,&lt;br /&gt;
LTRIM(RTRIM(NAME)) NAME,&lt;br /&gt;
LTRIM(RTRIM(PHONE_NUM_1)) PHONE_NO,&lt;br /&gt;
LTRIM(RTRIM(PHONE_NUM_2)) CELL_NO,&lt;br /&gt;
LTRIM(RTRIM(PHONE_NUM_2)) FAX_NO,&lt;br /&gt;
LTRIM(RTRIM(JOB_TITLE)) TITLE,&lt;br /&gt;
ltrim(rtrim(email_addr)) EMAIL,&lt;br /&gt;
* FROM CCON&lt;br /&gt;
INNER JOIN CTCT ON CTCT.CONTCT_CODE=CCON.CONTCT_CODE&lt;br /&gt;
---&lt;br /&gt;
INSERT INTO cctcont&lt;br /&gt;
  ( RECKEY, ENTITY_TYPE, ENTITY_ID, NAME, PHONE_NO, CELL_NO, FAX_NO, TITLE,EMAIL, EMAIL_OPT_1, EMAIL_OPT_2, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
  ( GEN_ID(GEN_CCCONTKEY,1), 'C', '{ENTITY_ID}', '{NAME|STRLEN=30}', '{PHONE_NO|STRLEN=30}', '{CELL_NO|STRLEN=30}', '{FAX_NO|STRLEN=30}', '{TITLE}', '{EMAIL|STRLEN=80}', 'Y', 'Y', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
---------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
contacts from ONBASE...&lt;br /&gt;
&lt;br /&gt;
Lq3:&lt;br /&gt;
SELECT &lt;br /&gt;
--RTRIM(rd.distprocessnum) dist_proc_num, &lt;br /&gt;
--RTRIM(dp.distprocessname) dist_proc_name,&lt;br /&gt;
--rd.recipientnum OBRecipientNO,&lt;br /&gt;
--RTRIM(rd.distributionflags) dist_flags, &lt;br /&gt;
RTRIM(replace(rd.idkeywords,'!','')) 'CustomerNO', &lt;br /&gt;
RTRIM(sr.recipientname) 'CustomerName', &lt;br /&gt;
RTRIM(sr.email) 'Email', &lt;br /&gt;
RTRIM(sr.faxnum) 'FaxNO' &lt;br /&gt;
FROM hsi.recipientxdist rd &lt;br /&gt;
INNER JOIN hsi.stmtrecipient sr ON rd.recipientnum = sr.recipientnum LEFT OUTER JOIN hsi.distprocess dp ON rd.distprocessnum = dp.distprocessnum&lt;br /&gt;
ORDER BY rd.distprocessnum, sr.recipientname, rd.distributionflags&lt;br /&gt;
lq2:&lt;br /&gt;
select cust_no,name from artcust c&lt;br /&gt;
&lt;br /&gt;
Primary:&lt;br /&gt;
select * from lq3&lt;br /&gt;
left outer join lq2 on lq2.cust_no=lq3.CustomerNO&lt;br /&gt;
where lq2.cust_no is not null&lt;br /&gt;
order by cust_no&lt;br /&gt;
&lt;br /&gt;
INSERT INTO cctcont&lt;br /&gt;
  ( RECKEY, ENTITY_TYPE, ENTITY_ID, NAME, PHONE_NO, CELL_NO, FAX_NO, TITLE,EMAIL, EMAIL_OPT_1, EMAIL_OPT_2, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
  ( GEN_ID(GEN_CCCONTKEY,1), 'C', '{CUST_NO}', 'Accounts Payable', null, null, '{FAXNO|STRLEN=30}', null, '{EMAIL|STRLEN=80}', 'Y', 'Y', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
--------&lt;br /&gt;
Contacts Merge (If email from cmd and ob - use the cmd)&lt;br /&gt;
&lt;br /&gt;
SELECT ENTITY_ID,UPPER( EMAIL) EMAIL ,COUNT(*),MIN(NAME),MAX(NAME),MIN(RECKEY) ORIGKEY,MAX(RECKEY) NEWKEY FROM CCTCONT &lt;br /&gt;
WHERE EMAIL IS NOT NULL&lt;br /&gt;
GROUP BY 1,2&lt;br /&gt;
HAVING COUNT(*)&amp;gt;1&lt;br /&gt;
&lt;br /&gt;
(export a csv)&lt;br /&gt;
&lt;br /&gt;
update cctcont set email_opt_1='Y' ,email_opt_2='Y' WHERE RECKEY = {ORIGKEY};  /* {EMAIL}  */&lt;br /&gt;
DELETE FROM CCTCONT WHERE RECKEY={NEWKEY};&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
contacts deleted all where email null and cell_no null&lt;br /&gt;
&lt;br /&gt;
------------ Even MOre Onbase contacts&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
select lq1.*,lq2.*,1 ct,lq3.contemail from lq2&lt;br /&gt;
left outer join lq1 on lq1.cname=lq2.rname&lt;br /&gt;
left outer join lq3 on lq3.cust_no=lq1.cust_code and  lq2.email=lq3.contemail &lt;br /&gt;
where not (cust_code is  null);&lt;br /&gt;
&lt;br /&gt;
select ltrim(rtrim(cust_code)) cust_code,upper(name) cname from cust;&lt;br /&gt;
&lt;br /&gt;
select upper(recipientname) rname,upper(ltrim(rtrim(email))) email,1 rcpct from hsi.stmtrecipient&lt;br /&gt;
where coalesce(email,'')&amp;lt;&amp;gt;'';&lt;br /&gt;
&lt;br /&gt;
SELECT CUST_NO,c.NAME &amp;quot;CustomerName&amp;quot;,&lt;br /&gt;
c.CONTACT &amp;quot;CustomerContact&amp;quot;,cc.cell_no,cc.phone_no&lt;br /&gt;
,CC.NAME &amp;quot;ContName&amp;quot;,upper(cc.email) &amp;quot;ContEmail&amp;quot;,&lt;br /&gt;
email_opt_1 &amp;quot;EmailInv&amp;quot;,email_opt_2 &amp;quot;EmailStmt&amp;quot;&lt;br /&gt;
 FROM ARTCUST C&lt;br /&gt;
INNER JOIN CCTCONT CC ON CC.ENTITY_ID=C.CUST_NO&lt;br /&gt;
where cc.email is not null&lt;br /&gt;
order by c.cust_no,cc.reckey&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO cctcont&lt;br /&gt;
  ( RECKEY, ENTITY_TYPE, ENTITY_ID, NAME, PHONE_NO, CELL_NO, FAX_NO, TITLE,EMAIL, EMAIL_OPT_1, EMAIL_OPT_2, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
  ( GEN_ID(GEN_CCCONTKEY,1), 'C', '{CUST_code}', 'Accounts Payable', null, null, null, null, '{EMAIL|STRLEN=80}', 'Y', 'Y', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Update  Prods From Class:&lt;br /&gt;
&lt;br /&gt;
SELECT product_code,PRODUCT_CLASS,SELLABLE_FLAG,PRODUCT_TYPE,INGREDIENT_TYPE, (SELECT PC.STD_SELLABLE_FLAG FROM ARTPRCLS PC WHERE PC.CLASS_NO=P.PRODUCT_CLASS) STD_SELLABLE_FLAG,&lt;br /&gt;
(SELECT PC.STD_PRODUCT_TYPE FROM ARTPRCLS PC WHERE PC.CLASS_NO=P.PRODUCT_CLASS) STD_PRODUCT_TYPE,&lt;br /&gt;
(SELECT PC.STD_ingredient_TYPE FROM ARTPRCLS PC WHERE PC.CLASS_NO=P.PRODUCT_CLASS) STD_ingredient_TYPE&lt;br /&gt;
FROM ARTPROD P&lt;br /&gt;
&lt;br /&gt;
update artprod p&lt;br /&gt;
  SET SELLABLE_FLAG='{STD_SELLABLE_FLAG}',&lt;br /&gt;
  INGREDIENT_TYPE='{STD_INGREDIENT_TYPE}',&lt;br /&gt;
  PRODUCT_TYPE='{STD_PRODUCT_TYPE}'&lt;br /&gt;
  where product_code='{PRODUCT_CODE}';&lt;br /&gt;
&lt;br /&gt;
------&lt;br /&gt;
in mssql:  {set cust inactive}&lt;br /&gt;
&lt;br /&gt;
select &lt;br /&gt;
CONCAT( 'UPDATE ARTCUST C SET ACTIVE_FLAG=''N'' WHERE CUST_NO = ''',RTRIM(LTRIM(CUST_CODE)),''';')&lt;br /&gt;
from cust&lt;br /&gt;
where inactive_code &amp;lt;&amp;gt; 00&lt;br /&gt;
&lt;br /&gt;
===&lt;br /&gt;
Update sales g/l accounts by plant&lt;br /&gt;
(Setup Plants with default g/l!!!!)&lt;br /&gt;
&lt;br /&gt;
with ga (act,s1,s2,s3,s4,actnm) as&lt;br /&gt;
(select  gl_account,segment_1,segment_2,segment_3,segment_4,max(description)&lt;br /&gt;
from gltacct a&lt;br /&gt;
where segment_4 between '300' and '998'&lt;br /&gt;
group by gl_account,segment_1,segment_2,segment_3,segment_4&lt;br /&gt;
)&lt;br /&gt;
,pr (pact,ps1,ps2,ps3,ps4,plt) as&lt;br /&gt;
(select GL_ACCOUNT ,segment_1,segment_2,segment_3,segment_4,p.plant_no from artprod p&lt;br /&gt;
inner join gltacct a on a.gl_account=p.sales_gl&lt;br /&gt;
group by gl_account,segment_1,segment_2,segment_3,segment_4,plant_no)&lt;br /&gt;
select * from ga &lt;br /&gt;
inner join pr on pr.ps1=ga.s1 and  pr.ps2=ga.s2 and pr.plt=ga.s4&lt;br /&gt;
order by s1,s4&lt;br /&gt;
&lt;br /&gt;
update artprod p set sales_gl = '{act}' WHERE sales_gl='{pact}' and plant_no = '{plt}';&lt;br /&gt;
&lt;br /&gt;
NOTE: This could be done more generically by taking part of acct from artprcls and some from the g/l pattern&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Command_Import:_Hedger_Work_Notes&amp;diff=956</id>
		<title>Command Import: Hedger Work Notes</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Command_Import:_Hedger_Work_Notes&amp;diff=956"/>
		<updated>2024-02-27T15:45:18Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
2022DEC19&lt;br /&gt;
===Customer Class===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
select  &lt;br /&gt;
ltrim(rtrim(sales_anl_code)) class_no,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sanl&lt;br /&gt;
&lt;br /&gt;
==&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{CLASS_NO}', '{DESCRIPTION|LEN=35}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
==&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Price Groups==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SELECT &lt;br /&gt;
RTRIM(LTRIM(replace(PRICE_CAT,'.',''))) GROUP_NO,&lt;br /&gt;
RTRIM(LTRIM(DESCR)) DESCRIPTION,&lt;br /&gt;
PRCC.* FROM  prcc&lt;br /&gt;
==&lt;br /&gt;
INSERT INTO ARTPRGRP &lt;br /&gt;
( GROUP_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG, MEMO )  VALUES &lt;br /&gt;
( '{GROUP_NO}', '{DESCRIPTION}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y' , 'CMD PRICE CAT:{PRICE_CAT|TRIM=0}'   );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===GL=== &lt;br /&gt;
&lt;br /&gt;
===Plants===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
LQ1: (LIST OF NUMERIC PLANTS IN CMD)&lt;br /&gt;
SELECT &lt;br /&gt;
ISNUMERIC(plant_code),p.*&lt;br /&gt;
FROM plnt p&lt;br /&gt;
where isnumeric (plant_code)=1&lt;br /&gt;
&lt;br /&gt;
LQ2: (MODEL G/L)&lt;br /&gt;
select * from gltacct&lt;br /&gt;
where segment_4 like '150'&lt;br /&gt;
&lt;br /&gt;
PRIMARY:&lt;br /&gt;
select lq1.plant_code,lq2.* from lq2&lt;br /&gt;
inner join lq1 on 1=1&lt;br /&gt;
ORDER BY 1,2&lt;br /&gt;
&lt;br /&gt;
INSERT INTO &lt;br /&gt;
gltacct&lt;br /&gt;
( GL_ACCOUNT, DESCRIPTION, GL_GROUP, SEQUENCE, ACCOUNT_CLASS, COMPANY_NO, DIVISION_NO, ALLOC_RULE_ID, NRMCA_ACCOUNT, ACCOUNT_TYPE, DR_CR_FLAG, INTRA_COMPANY, JC_REQUIRED, SECURITY_CLASS, IMPORTED_FLAG, VALID_FROM_DATE, VALID_TO_DATE, NOTES_1, NOTES_2, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{segment_1}-00-9999{PLANT_CODE}-{PLANT_CODE}', '{DESCRIPTION}', '{GL_GROUP}', {SEQUENCE}, '{ACCOUNT_CLASS}', '{COMPANY_NO}', '{DIVISION_NO}', '{ALLOC_RULE_ID}', '{NRMCA_ACCOUNT}', '{ACCOUNT_TYPE}', '{DR_CR_FLAG}', '{INTRA_COMPANY}', '{JC_REQUIRED}', '{SECURITY_CLASS}', '{IMPORTED_FLAG}', '{VALID_FROM_DATE}', '{VALID_TO_DATE}', '{NOTES_1}', '{NOTES_2}', CAST('TODAY' AS TIMESTAMP), 'HIT', '{ACTIVE_FLAG}'    );&lt;br /&gt;
&lt;br /&gt;
= gl 000 =&lt;br /&gt;
&lt;br /&gt;
select  * from gltacct&lt;br /&gt;
where segment_4=000&lt;br /&gt;
&lt;br /&gt;
INSERT INTO GLTACCT&lt;br /&gt;
( GL_ACCOUNT, DESCRIPTION, GL_GROUP, SEQUENCE, ACCOUNT_CLASS, COMPANY_NO, DIVISION_NO, ALLOC_RULE_ID, NRMCA_ACCOUNT, ACCOUNT_TYPE, DR_CR_FLAG, INTRA_COMPANY, JC_REQUIRED, SECURITY_CLASS, IMPORTED_FLAG, VALID_FROM_DATE, VALID_TO_DATE, NOTES_1, NOTES_2, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{SEGMENT_1}-00-9999{SEGMENT_4}-{SEGMENT_4}', '{DESCRIPTION}', '{GL_GROUP}', {SEQUENCE}, '{ACCOUNT_CLASS}', '{COMPANY_NO}', '{DIVISION_NO}', '{ALLOC_RULE_ID}', '{NRMCA_ACCOUNT}', '{ACCOUNT_TYPE}', '{DR_CR_FLAG}', '{INTRA_COMPANY}', '{JC_REQUIRED}', '{SECURITY_CLASS}', '{IMPORTED_FLAG}', '{VALID_FROM_DATE}', '{VALID_TO_DATE}', '{NOTES_1}', '{NOTES_2}', CAST('TODAY' AS TIMESTAMP), 'HIT', '{ACTIVE_FLAG}'    );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
TODO - MAP SEGMENT 3 BY PLANT FROM 9999###&lt;br /&gt;
==========&lt;br /&gt;
=== ARTPLANT&lt;br /&gt;
SELECT &lt;br /&gt;
p.*&lt;br /&gt;
FROM plnt p&lt;br /&gt;
where isnumeric (plant_code)=1&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTPLANT ( PLANT_NO, SYS_LOC, PLANT_NAME, ADDRESS_1, ADDRESS_2, PHONE_NO, PLANT_TYPE, PLANT_SCREEN_ID, DIVISION_NO,PLANT_WASH_MINLD, JOB_WASH_MINLD,&lt;br /&gt;
BATCH_CAPACITY,&lt;br /&gt;
MEMO, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{plant_code|trim=0}', 0, '{name}', '{addr_line_1}', '{addr_line_2}', '{PHONE_Num}', 'D', '{short_name}', null, {PLANT_WASHDOWN_TIME}, {JOB_WASHDOWN_TIME},&lt;br /&gt;
{MAX_BATCH_SIZE},&lt;br /&gt;
'{LOC_CODE|trim=0}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
TODO: GL MASK - DEFAULT G/L ACCOUNTS&lt;br /&gt;
&lt;br /&gt;
===TAX  (when Flat in Keystone and MultiLevel in CMD)&lt;br /&gt;
&lt;br /&gt;
Tax Research&lt;br /&gt;
&lt;br /&gt;
select j.tax_code,a.descr,sum(prim_rate_curr_pct), sum(1) ct&lt;br /&gt;
from taxj j&lt;br /&gt;
inner join taxc a on a.tax_code=j.tax_code&lt;br /&gt;
inner join taxl l on j.tax_loc=l.tax_loc and l.tax_auth=j.tax_auth&lt;br /&gt;
group by j.tax_code,a.descr;&lt;br /&gt;
&lt;br /&gt;
select *&lt;br /&gt;
from taxj j&lt;br /&gt;
inner join taxc a on a.tax_code=j.tax_code&lt;br /&gt;
inner join taxl l on j.tax_loc=l.tax_loc and l.tax_auth=j.tax_auth&lt;br /&gt;
order by j.tax_code,a.descr;&lt;br /&gt;
&lt;br /&gt;
select * from taxj order by tax_code,tax_auth,tax_loc;&lt;br /&gt;
select * from taxc;&lt;br /&gt;
select * from taxl;&lt;br /&gt;
&lt;br /&gt;
Confirmed FLAT OK&lt;br /&gt;
&lt;br /&gt;
==ARTTXLOC/AUT/STR&lt;br /&gt;
select j.tax_code,a.descr,sum(prim_rate_curr_pct) TAX_RATE, sum(1)  ct&lt;br /&gt;
from taxj j&lt;br /&gt;
inner join taxc a on a.tax_code=j.tax_code&lt;br /&gt;
inner join taxl l on j.tax_loc=l.tax_loc and l.tax_auth=j.tax_auth&lt;br /&gt;
group by j.tax_code,a.descr;&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTTXLOC&lt;br /&gt;
( TAX_LOCALITY, LINE_NO, DESCRIPTION, TAX_COL, LOC_LEVEL, TAX_RATE, CALC_METHOD, EFFECT_DATE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{TAX_CODE}', 1, '{DESCR}', 1, 1, {TAX_RATE}, 1, '01/01/1900', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTTXAUT&lt;br /&gt;
( TAX_AUTHORITY, DESCRIPTION, INCREASE_DISC_FLAG, DISC_INCLUDES_TAX, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{TAX_CODE}', '{DESCR}', 'N', 'Y', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO &lt;br /&gt;
ARTTXSTR&lt;br /&gt;
( SESSION_NO, TRANS_NO, TAX_AUTHORITY, TAX_LOCALITY, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( 0, {TAX_RATE|INC=1}, '{TAX_CODE}', '{TAX_CODE}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
==ARTUMS (This finds CMD U/M that are actually used but not in Keystone)&lt;br /&gt;
&lt;br /&gt;
LQ1:&lt;br /&gt;
SELECT * FROM aRTUMS&lt;br /&gt;
&lt;br /&gt;
LQ2:&lt;br /&gt;
SELECT &lt;br /&gt;
LTRIM(UPPER(ABBR)) UM,&lt;br /&gt;
UOMS,* FROM UOMS&lt;br /&gt;
&lt;br /&gt;
LQ3: -- This finds the uoms used for importable items (no need to import baggage)&lt;br /&gt;
SELECT DISTINCT (order_uom) UMX FROM IMST UNION &lt;br /&gt;
SELECT DISTINCT (price_uom) FROM IMST UNION &lt;br /&gt;
SELECT DISTINCT (invy_uom) FROM IMST UNION &lt;br /&gt;
SELECT DISTINCT (purch_uom) FROM IMST UNION &lt;br /&gt;
SELECT DISTINCT (batch_uom) FROM IMST UNION &lt;br /&gt;
SELECT DISTINCT (rpt_uom) FROM IMST UNION &lt;br /&gt;
SELECT DISTINCT (order_dosage_qty_uom) FROM IMST&lt;br /&gt;
&lt;br /&gt;
SELECT:&lt;br /&gt;
SELECT lq2.* FROM LQ2&lt;br /&gt;
INNER JOIN LQ3 ON LQ2.UOM=LQ3.UMX&lt;br /&gt;
LEFT OUTER JOIN LQ1&lt;br /&gt;
 ON LQ2.UM=LQ1.UNIT_OF_MEASURE&lt;br /&gt;
WHERE UNIT_OF_MEASURE IS  NULL&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTUMS&lt;br /&gt;
( UNIT_OF_MEASURE, EXPANDED_UMS, DESCRIPTION, UMS_TYPE, UMS_SYSTEM,  SUBTOTAL, SYSTEM_FLAG, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{UM}', '{UOM}', '{DESCR}', 'U', 'E',   'N', 'N', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Set UofM Expanded &lt;br /&gt;
SELECT lq1.*,lq2.* FROM LQ2&lt;br /&gt;
INNER JOIN LQ3 ON LQ2.UOM=LQ3.UMX&lt;br /&gt;
LEFT OUTER JOIN LQ1&lt;br /&gt;
 ON cast(LQ2.UM as text)=cast(LQ1.UNIT_OF_MEASURE as text)&lt;br /&gt;
WHERE  (UNIT_OF_MEASURE IS not  NULL)&lt;br /&gt;
&lt;br /&gt;
update ARTUMS set EXPANDED_UMS={uom} where unit_of_measure='{UM}';&lt;br /&gt;
&lt;br /&gt;
Note - the expanded UofM stored for potential linking on imports.  &lt;br /&gt;
&lt;br /&gt;
TODO: Clear expanded at roll out - it will print on reports.&lt;br /&gt;
&lt;br /&gt;
=== artprcls&lt;br /&gt;
Straight rip from Alt Company&lt;br /&gt;
&lt;br /&gt;
===artslspn&lt;br /&gt;
&lt;br /&gt;
SELECT &lt;br /&gt;
ltrim(empl_code) CLASS_NO,&lt;br /&gt;
ltrim(empl_code) USER_1,&lt;br /&gt;
rtrim(LTRIM(NAME)) DESCRIPTION,&lt;br /&gt;
LTRIM(PHONE_NUM) PHONE_NO,&lt;br /&gt;
LTRIM(ASSGN_PLANT_CODE) USER_2&lt;br /&gt;
 FROM empl&lt;br /&gt;
where slsmn_flag='True'&lt;br /&gt;
&lt;br /&gt;
INSERT INTO artslspn &lt;br /&gt;
( CLASS_NO, EMPLOYEE_NO, DESCRIPTION, PHONE_NO, USER_2 )  VALUES &lt;br /&gt;
( SUBSTR(100+{CLASS_NO|INC=1},2,3), '{USER_1}', '{DESCRIPTION}', '{PHONE_NO}', '{USER_2}'    );&lt;br /&gt;
========&lt;br /&gt;
=== arttruck&lt;br /&gt;
select  &lt;br /&gt;
rtrim(ltrim(truck_code)) &amp;quot;TRUCK_NO&amp;quot;,&lt;br /&gt;
rtrim(ltrim(DESCR)) &amp;quot;DESCR&amp;quot;,&lt;br /&gt;
truc.* from truc&lt;br /&gt;
ORDER BY UPDATE_DATE DESC&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTTRUCK &lt;br /&gt;
( TRUCK_NO, TARE_WEIGHT, LAST_TARE_DATE, HOME_PLANT_NO, PLATE_NUMBER, EXPIRATION_DATE,  ACTIVE_FLAG, memo )  VALUES &lt;br /&gt;
( '{TRUCK_CODE|TRIM=0}', {TARE_WGT|null=0}, '{TARE_DATE}', '{FROM_PLANT_CODE|TRIM=0}', '{LIC_NUM}',  '{expir_date_1}',  'Y' ,&lt;br /&gt;
'Cmd Import mm/yy/dddd &lt;br /&gt;
Description: {DESCR}&lt;br /&gt;
Owner: {OWNER_NAME}&lt;br /&gt;
Trk Type: {truck_TYPE}&lt;br /&gt;
Inactive: {INACTIVE_FLAG}&lt;br /&gt;
Max Ld Sz: {MAX_LOAD_SIZE}&lt;br /&gt;
Driver Emp: {assgn_driv_empl_code|TRIM=0}'&lt;br /&gt;
   );  /* ------------------------------------ */&lt;br /&gt;
========&lt;br /&gt;
=== ARTDRIV&lt;br /&gt;
SELECT  &lt;br /&gt;
rtrim(ltrim(empl_code)) &amp;quot;DRIVER_CODE&amp;quot;, -- 12/11&lt;br /&gt;
rtrim(ltrim(NAME)) &amp;quot;DRIVER_NAME&amp;quot;,&lt;br /&gt;
EMPL.* from empl&lt;br /&gt;
where driv_flag = 1&lt;br /&gt;
order by update_date desc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO  artdriv&lt;br /&gt;
( DRIVER_CODE, DRIVER_NAME, PHONE_NO, HOME_PLANT_NO, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG,memo )  VALUES &lt;br /&gt;
( '{empl_CODE|trim=0}', '{NAME}', '{PHONE_Num}', '{assgn_plant_code}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y',&lt;br /&gt;
'Imported mm/dd/yyyy&lt;br /&gt;
 Inactive Date: {Inactive_date} &lt;br /&gt;
 Inactive code: {inactive_code}&lt;br /&gt;
 ' );&lt;br /&gt;
========&lt;br /&gt;
=== ARTPROD &lt;br /&gt;
&lt;br /&gt;
--t22&lt;br /&gt;
(01/05/22 simplified and cleaned up)&lt;br /&gt;
SELECT &lt;br /&gt;
CONCAT(RTRIM(LTRIM(IMST.ITEM_CODE)),'.',&lt;br /&gt;
PLNT.PLANT_CODE)  PRODUCT_CODE_ORIG,&lt;br /&gt;
UPPER(CONCAT(  RTRIM(LTRIM(IMST.ITEM_CODE))    ,'.',PLNT.PLANT_CODE))  &amp;quot;PRODUCT_CODE&amp;quot;, &lt;br /&gt;
UPPER(RTRIM(LTRIM(IMST.ITEM_CODE))) &amp;quot;BASE_PRODUCT&amp;quot;, -- 12/15 ADJ . TO -&lt;br /&gt;
RTRIM(lTRIM(ILOC.LOC_CODE)) LOC_CODE,&lt;br /&gt;
rtrim(LTRIM(PLNT.PLANT_CODE)) PLANT_NO,&lt;br /&gt;
coalesce(max_load_size,0) mxldsz,&lt;br /&gt;
RTRIM(LTRIM(IMST.ITEM_CODE)) ITEM_CODE,UPPER(IU.ABBR) INVUM,UPPER(PU.ABBR) PRICEUM,UPPER(PU.ABBR) BATCH_UMS,&lt;br /&gt;
CASE INVY_FLAG WHEN 'True' then 'Y' else 'N' END STOCKED,&lt;br /&gt;
CASE imst.TAXBLE_CODE WHEN '1' then 'Y' else 'N' END TAX_CODE_1,&lt;br /&gt;
LTRIM(imst.ITEM_CAT) ITEM_CAT,&lt;br /&gt;
case RTRIM(Ltrim(imst.item_cat))  -- icat to product class translation&lt;br /&gt;
   WHEN '1' THEN 'C5'&lt;br /&gt;
   WHEN '3' THEN 'X2'&lt;br /&gt;
   WHEN '4' THEN 'X3'&lt;br /&gt;
   WHEN '5' THEN 'X5'&lt;br /&gt;
   WHEN '6' THEN 'Y1'&lt;br /&gt;
   WHEN '7' THEN 'Y5'&lt;br /&gt;
   WHEN '8' THEN 'Y4'&lt;br /&gt;
   WHEN '9' THEN 'A4'&lt;br /&gt;
   WHEN '10' THEN '23'&lt;br /&gt;
   WHEN '11' THEN 'Y3'&lt;br /&gt;
   WHEN '12' THEN 'Y6'&lt;br /&gt;
   WHEN '15' THEN 'P1'&lt;br /&gt;
   WHEN '18' THEN 'P2'&lt;br /&gt;
   WHEN '21' THEN 'X1'&lt;br /&gt;
   WHEN '23' THEN '23'&lt;br /&gt;
   WHEN '24' THEN 'X4'&lt;br /&gt;
   WHEN '1.1' THEN 'C5'&lt;br /&gt;
   WHEN '1.2' THEN 'C5'&lt;br /&gt;
   WHEN '1.3' THEN 'C5'&lt;br /&gt;
   WHEN '1.4' THEN 'C5'&lt;br /&gt;
   WHEN '1.5' THEN 'C5'&lt;br /&gt;
   WHEN '1.6' THEN 'C5'&lt;br /&gt;
   WHEN '1.7' THEN 'C5'&lt;br /&gt;
   WHEN '1.8' THEN 'C5'&lt;br /&gt;
   WHEN '1.9' THEN 'C5'&lt;br /&gt;
   WHEN '13.1' THEN 'R1'&lt;br /&gt;
   WHEN '13.2' THEN 'R2'&lt;br /&gt;
   WHEN '13.6' THEN 'T1'&lt;br /&gt;
   WHEN '13.8' THEN 'D1'&lt;br /&gt;
   WHEN '20.1' THEN 'P1'&lt;br /&gt;
   WHEN '1.10' THEN 'C5'&lt;br /&gt;
elSe 'Z1' END PRODUCT_CLASS,&lt;br /&gt;
COALESCE (IMST.PCT_AIR,0) PCT_AIR,&lt;br /&gt;
COALESCE (IMST.WATER_CEM_RATIO,0) WATER_CEM_RATIO,&lt;br /&gt;
--IIF( LEN(REPLACE(imst.DESCR, '''', '~' ))&amp;lt;=35, REPLACE(imst.DESCR, '''', '~' ),REPLACE(imst.SHORT_DESCR, '''', '~' )) DESCRIPTION,&lt;br /&gt;
replace(replace(replace(REPLACE(imst.DESCR, '''', '~' ),'    ',' '),'  ',' '),'  ',' ') DESCR2,&lt;br /&gt;
iif(resale_flag=1,'Y','N')  &amp;quot;SELLABLE_FLAG&amp;quot;,&lt;br /&gt;
COALESCE(iloc.curr_std_cost,0) CURR_STD_COST,&lt;br /&gt;
prev_std_cost,&lt;br /&gt;
cost_ext_code,&lt;br /&gt;
prev_cost_ext_code,&lt;br /&gt;
std_cost_effect_date,&lt;br /&gt;
curr_opt_cost,&lt;br /&gt;
prev_opt_cost,&lt;br /&gt;
opt_cost_effect_date&lt;br /&gt;
,imst.short_descr&lt;br /&gt;
,iloc.inactive_code&lt;br /&gt;
,imst.tax_rate_code&lt;br /&gt;
,imst.NON_TAX_RSN_CODE&lt;br /&gt;
,imst.descr&lt;br /&gt;
--,IMST.* &lt;br /&gt;
FROM IMST&lt;br /&gt;
INNER JOIN ILOC ON ILOC.ITEM_CODE=IMST.ITEM_CODE&lt;br /&gt;
INNER JOIN PLNT ON PLNT.LOC_CODE=ILOC.LOC_CODE&lt;br /&gt;
LEFT OUTER JOIN DBO.UOMS IU ON IU.UOM=IMST.INVY_UOM&lt;br /&gt;
LEFT OUTER JOIN DBO.UOMS PU ON PU.UOM=IMST.PRICE_UOM&lt;br /&gt;
LEFT OUTER JOIN DBO.UOMS BU ON BU.UOM=IMST.BATCH_UOM&lt;br /&gt;
where isnumeric (plnt.plant_code)=1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO &lt;br /&gt;
ARTPROD &lt;br /&gt;
( PRODUCT_CODE, UNIT_OF_MEASURE, DESCRIPTION_1, DESCRIPTION_2, LOCATION, STOCKED, TAX_CODE, TAX_CODE_2, TAX_CODE_3, BASE_PRODUCT, PRODUCT_CLASS, PLANT_NO, PRODUCT_TYPE, INGREDIENT_TYPE, EXPORT_FLAG, ROLLUP_FLAG, SELLABLE_FLAG, SEND_TO_BATCH, UPC_CODE, VENDOR_NO, VENDOR_PART_NO, LIST_PRICE, SPECIFIC_GRAVITY, PERCENT_AIR, MIX_WC_RATIO, MIX_YIELD, MIXER_TIME_SEC, MAX_LOAD_SIZE, STD_PCT_DISC, AUTO_QTY, DEFAULT_SLUMP, PURCHASE_UMS, ENTRY_UMS, MIX_UMS, BATCH_UMS, NOTES_1, NOTES_2, NOTES_3, NOTES_4, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG, MEMO )  VALUES &lt;br /&gt;
( '{PRODUCT_CODE}', '{PRICEUM}', '{DESCR2|STRLEN=35}', '{SHORT_DESCR}', NULL, '{STOCKED}', '{TAX_CODE_1}', 'Y', 'Y', '{ITEM_CODE}', '{PRODUCT_CLASS}', '{PLANT_NO}', 'X', NULL, 'N', 'N', 'Y', 'N', NULL, NULL, NULL, 0, 0, {PCT_AIR}, {WATER_CEM_RATIO}, 0 , 0, {MXLDSZ}, NULL, 'N', 0, NULL, NULL, NULL, '{BATCH_UMS}', '{ITEM_CAT}', 'LOC: {LOC_CODE} / INACTIVE: {INACTIVE_CODE}', '{TAX_RATE_CODE}/{NON_TAX_RSN_CODE}', '{DESCR}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y' &lt;br /&gt;
, '***Import Notes  01/03/2023 ***' );&lt;br /&gt;
&lt;br /&gt;
todo:&lt;br /&gt;
Prices&lt;br /&gt;
Apply Product Class Updates&lt;br /&gt;
Update Product, Ingredient Types / G/L from product classes.&lt;br /&gt;
&lt;br /&gt;
To update missing products do main query in LQ1 and use:&lt;br /&gt;
&lt;br /&gt;
select LQ1.* from lq1&lt;br /&gt;
LEFT OUTER JOIN LQ2 ON LQ2.PRODUCT_CODE = LQ1.PRODUCT_CODE&lt;br /&gt;
WHERE LQ2.PRODUCT_CODE IS NULL&lt;br /&gt;
LIMIT 5000;&lt;br /&gt;
(5000 at a time for processing efficiency)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- FIX (01/04/2023  - unneeded since  reprocessed products)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ALTER TRIGGER argprod_bupdate INACTIVE;&lt;br /&gt;
ALTER TRIGGER argprod_Aupdate INACTIVE;&lt;br /&gt;
&lt;br /&gt;
select PRODUCT_CODE,upper(BASE_PRODUCT) BASE_PRODUCT,PLANT_NO from artPROD&lt;br /&gt;
WHERE PRODUCT_CODE &amp;lt;&amp;gt; upper(BASE_PRODUCT)||'.'||PLANT_NO&lt;br /&gt;
ORDER BY PLANT_NO,PRODUCT_CODE&lt;br /&gt;
&lt;br /&gt;
UPDATE ARTPROD SET PRODUCT_CODE='{BASE_PRODUCT}.{PLANT_NO}' WHERE upper(BASE_PRODUCT) =  '{BASE_PRODUCT}' AND PLANT_NO='{PLANT_NO}';&lt;br /&gt;
&lt;br /&gt;
ALTER TRIGGER argprod_bupdate ACTIVE;&lt;br /&gt;
ALTER TRIGGER argprod_Aupdate ACTIVE;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=======&lt;br /&gt;
=== ARTCTCLS&lt;br /&gt;
&lt;br /&gt;
SELECT ltrim(rtrim(terms_code)) terms_code&lt;br /&gt;
      ,descry&lt;br /&gt;
      ,disc_amt_1&lt;br /&gt;
      ,disc_amt_2&lt;br /&gt;
      ,disc_day_1&lt;br /&gt;
      ,disc_day_2&lt;br /&gt;
      ,due_day_1&lt;br /&gt;
      ,due_day_2&lt;br /&gt;
      ,short_descr&lt;br /&gt;
      ,terms_type&lt;br /&gt;
      ,per_uom&lt;br /&gt;
      ,update_date&lt;br /&gt;
  FROM CMDPROD_ARK.dbo.trms&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTCTCLS&lt;br /&gt;
( CLASS_NO, DESCRIPTION, DUE_BY, DUE_BY_PIVOT, DUE_IN, DISC_PCT, DISC_BY, DISC_BY_PIVOT, DISC_IN, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{TERMS_CODE}', '{DESCR}', NULL, NULL, NULL, {DISC_AMT_1}, NULL, NULL, {DISC_DAY_1}, 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTE: Not 100% clear on how to match days -manually edit.&lt;br /&gt;
========&lt;br /&gt;
=== ARTALCLS (FROM alt company)&lt;br /&gt;
select aa.* ,&lt;br /&gt;
a.segment_1,a.segment_2,a.segment_3,a.segment_4&lt;br /&gt;
from artalcls aa&lt;br /&gt;
left outer join gltacct a  on a.gl_account = aa.allow_gl&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTALCLS&lt;br /&gt;
( CLASS_NO, DESCRIPTION, ALLOW_GL, ALLOW_INCLUDES_TAX, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{CLASS_NO}', '{DESCRIPTION}',  '{SEGMENT_1}-00-9999{SEGMENT_4}-{SEGMENT_4}', '{ALLOW_INCLUDES_TAX}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', '{ACTIVE_FLAG}'    );&lt;br /&gt;
&lt;br /&gt;
========&lt;br /&gt;
=== ARTCUST&lt;br /&gt;
&lt;br /&gt;
select &lt;br /&gt;
LTRIM(RTRIM(cust.CUST_CODE)) CUST_NO,&lt;br /&gt;
left(ltrim(rtrim(CUST.NAME)),30) name,&lt;br /&gt;
left(CUST.ADDR_LINE_1,30) addr_line_1,&lt;br /&gt;
left(CUST.ADDR_LINE_2,30) addr_line_2,&lt;br /&gt;
left(replace(addr_city,',',''),16) CITY,&lt;br /&gt;
replace(LEFT(rtrim(ltrim(ADDR_STATE)),2),'M0','MO') STATE,&lt;br /&gt;
PHONE_NUM_1,PHONE_NUM_2,PHONE_NUM_3,&lt;br /&gt;
LTRIM(RTRIM(ADDR_POSTCD)) ZIP,cust.tax_code &amp;quot;TAX_AUTHORITY&amp;quot;,&lt;br /&gt;
--cast(cust.tax_code as integer) txcd_int,&lt;br /&gt;
--left(LTRIM(RTRIM(taxj.tax_loc)),3) TAX_AUTHORITY,&lt;br /&gt;
LTRIM(RTRIM(CC_TERMS_CODE)) TERMS,&lt;br /&gt;
LTRIM(RTRIM(UPPER(CC_SALES_ANL_CODE))) CUCLS,&lt;br /&gt;
rtrim(LTRIM(CC_SLSMN_EMPL_CODE)) SLS_EMP,&lt;br /&gt;
rtrim(LTRIM(CC_PRICE_CAT)) PRICE_GROUP,&lt;br /&gt;
rtrim(LTRIM(CC_PRICE_PLANT_CODE) ) PRICE_PLANT,&lt;br /&gt;
CASE TAXBLE_CODE WHEN '1' then '' else CONCAT('TAX EXMPT RSN:', LTRIM(NON_TAX_RSN_CODE) ) END TAX_RSN,&lt;br /&gt;
case isnumeric(CC_SALES_ANL_CODE) &lt;br /&gt;
  WHEN 0 THEN LTRIM(CC_SALES_ANL_CODE)  ELSE RIGHT(CAST(100+CAST(CC_SALES_ANL_CODE AS INTEGER) AS CHAR(3)),2) END CUST_CLASS,&lt;br /&gt;
rtrim(LTRIM(INACTIVE_CODE)) INACTIVE_CODE,&lt;br /&gt;
CASE LTRIM(RTRIM(TAXBLE_CODE)) WHEN 1 THEN 'Y' ELSE 'N' END TAX_CODE,&lt;br /&gt;
CONCAT('Acct Cat Code: ',RTRIM(LTRIM(ACCT_CAT_CODE))) USER_2,&lt;br /&gt;
LEFT(CONTCT_NAME,30) CONTACT,&lt;br /&gt;
LEFT(SORT_NAME,30) SEQUENCE_CODE,&lt;br /&gt;
acct_cat_code,SETUP_DATE&lt;br /&gt;
from cust&lt;br /&gt;
--left outer join taxj on cast(taxj.tax_code as integer)=cast(cust.tax_code as integer)&lt;br /&gt;
order by cust_no&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO  artcust &lt;br /&gt;
( CUST_NO, SALESPERSON, CUST_CLASS, TERMS_CLASS, PRICE_GROUP, DIVISION_NO, PHONE_NO, FAX_NO, PAGER_NO, MOBILE_NO, EMAIL, URL, START_DATE, TAX_CODE, TAX_CODE_2, TAX_CODE_3, COD_FLAG, NAME, ADDRESS_1, ADDRESS_2, CITY, STATE, ZIP, USER_1, USER_2, NOTES_1,  TAX_AUTHORITY, CONTACT, SEQUENCE_CODE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( '{CUST_NO}', (SELECT CLASS_NO FROM ARTSLSPN WHERE EMPLOYEE_NO='{SLS_EMP}') , '{CUCLS}', '{TERMS}', '{PRICE_GROUP}' , NULL, '{PHONE_NUM_1}', NULL, NULL, '{PHONE_NUM_3}',  NULL, NULL, '{SETUP_DATE}', '{TAX_CODE}', 'Y', 'Y', 'N', '{NAME|STRLEN=30}', '{ADDR_LINE_1|STRLEN=30}', '{ADDR_LINE_2|STRLEN=30}', '{CITY}', '{STATE}', '{ZIP}', 'Sls Emp: {SLS_EMP|trim=0}',  '{USER_2}', '{TAX_RSN}',  '{TAX_AUTHORITY}', '{CONTACT}', '{SEQUENCE_CODE}', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
=====&lt;br /&gt;
== LIST PRICE  ==&lt;br /&gt;
Price cat 1 as list price (54986 prices are cat 1)&lt;br /&gt;
&lt;br /&gt;
SELECT&lt;br /&gt;
concat(upper(rtrim(LTRIM(IPRC.ITEM_CODE))) , '.' , rtrim(ltrim(plnt.plant_code)))  &amp;quot;PRODUCT_CODE&amp;quot;,&lt;br /&gt;
upper(rtrim(LTRIM(IPRC.ITEM_CODE))) BASE_PRODUCT,&lt;br /&gt;
rtrim(ltrim(plnt.plant_code)) PLANT_NO,&lt;br /&gt;
PRICE UNIT_PRICE,1 CT,&lt;br /&gt;
IPRC.*&lt;br /&gt;
FROM IPRC&lt;br /&gt;
INNER JOIN PLNT ON plnt.LOC_CODE=iprc.LOC_CODE AND ISNUMERIC(PLNT.plant_code)&amp;gt;0&lt;br /&gt;
INNER JOIN ILOC ON ILOC.item_code=IPRC.item_code AND ILOC.loc_code=iprc.loc_code&lt;br /&gt;
INNER JOIN IMST ON IMST.item_code=ILOC.item_code &lt;br /&gt;
WHERE RTRIM(LTRIM(iprc.PRICE_CAT)) = '1' and price &amp;lt;&amp;gt; 0 &lt;br /&gt;
ORDER BY BASE_PRODUCT,PLANT_NO,PRICE_CAT,effect_date&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
UpdATE ARTPROD SET list_PRICE={PRICE} WHERE product_code='{BASE_PRODUCT}.{PLANT_NO}';&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Local to make manageable chunks and update only mismatches...&lt;br /&gt;
LQ2: &lt;br /&gt;
select lq2.*,LQ1.* from lq1&lt;br /&gt;
LEFT OUTER JOIN LQ2 ON LQ2.PRODUCT_CODE = LQ1.PRODUCT_CODE&lt;br /&gt;
WHERE LQ2.LIST_PRICE  &amp;lt;&amp;gt; LQ1.PRICE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
select lq2.*,LQ1.* from lq1&lt;br /&gt;
LEFT OUTER JOIN LQ2 ON LQ2.PRODUCT_CODE = LQ1.PRODUCT_CODE&lt;br /&gt;
WHERE LQ2.LIST_PRICE  &amp;lt;&amp;gt; LQ1.PRICE&lt;br /&gt;
limt 10000 offset 20000  -- 20000- 29999&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
========&lt;br /&gt;
=== artprice - group prices plant specific&lt;br /&gt;
&lt;br /&gt;
SELECT&lt;br /&gt;
concat(upper(rtrim(LTRIM(IPRC.ITEM_CODE))) , '.' , rtrim(ltrim(plnt.plant_code)))  &amp;quot;PRODUCT_CODE&amp;quot;,&lt;br /&gt;
upper(rtrim(LTRIM(IPRC.ITEM_CODE))) BASE_PRODUCT,&lt;br /&gt;
rtrim(ltrim(plnt.plant_code)) PLANT_NO,&lt;br /&gt;
rtrim(ltrim(iprc.price_cat)) GROUP_NO,&lt;br /&gt;
UPPER(PU.ABBR) UNIT_OF_MEASURE,&lt;br /&gt;
PRICE UNIT_PRICE,1 CT,&lt;br /&gt;
IPRC.*&lt;br /&gt;
FROM IPRC&lt;br /&gt;
INNER JOIN PLNT ON plnt.LOC_CODE=iprc.LOC_CODE AND ISNUMERIC(PLNT.plant_code)&amp;gt;0&lt;br /&gt;
INNER JOIN ILOC ON ILOC.item_code=IPRC.item_code AND ILOC.loc_code=iprc.loc_code&lt;br /&gt;
INNER JOIN IMST ON IMST.item_code=ILOC.item_code &lt;br /&gt;
LEFT OUTER JOIN UOMS PU ON PU.UOM=IMST.PRICE_UOM&lt;br /&gt;
WHERE RTRIM(LTRIM(iprc.PRICE_CAT)) &amp;gt; '1' and price &amp;lt;&amp;gt; 0 &lt;br /&gt;
ORDER BY BASE_PRODUCT,PLANT_NO,PRICE_CAT,effect_date&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTPRICE&lt;br /&gt;
( SESSION_NO, TRANS_NO, PRICE_TYPE, CUST_NO, GROUP_NO, PRICE_CODE, PRODUCT_CODE, UNIT_OF_MEASURE, UNIT_PRICE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( 1, {GROUP_NO|INC=1}, 'G', NULL,'{GROUP_NO}',  'P', '{BASE_PRODUCT}.{PLANT_NO}', '{UNIT_OF_MEASURE}', {UNIT_PRICE}, 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'   );&lt;br /&gt;
&lt;br /&gt;
-- 13 records &lt;br /&gt;
========&lt;br /&gt;
&lt;br /&gt;
No Customer Price (CPRD)&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
========&lt;br /&gt;
ARTSTR WIP&lt;br /&gt;
&lt;br /&gt;
select -- TOP (100)&lt;br /&gt;
1 SESSION_NO,1 TRANS_NO,SORT_LINE_NUM SEQUENCE_CODE,&lt;br /&gt;
PLNT.LOC_CODE &amp;quot;LOC_CODE&amp;quot;,&lt;br /&gt;
(PLNT.PLANT_CODE) PLANT_NO,&lt;br /&gt;
LTRIM(RTRIM(ICST.ITEM_CODE)) ASSY_PRODUCT_CODE,&lt;br /&gt;
LTRIM(RTRIM(CONST_ITEM_CODE)) COMP_PRODUCT_CODE,&lt;br /&gt;
UPPER(LTRIM(CU.ABBR)) COMP_UMS,&lt;br /&gt;
QTY QTY_ASSEMBLY, ILC.ITEM_CODE INGITEMLOC ,IMC.ITEM_CODE INGITEM&lt;br /&gt;
 from icst&lt;br /&gt;
LEFT OUTER JOIN UOMS CU ON CU.UOM=ICST.QTY_UOM&lt;br /&gt;
INNER JOIN PLNT ON ICST.LOC_CODE=PLNT.LOC_CODE AND ISNUMERIC(PLNT.PLANT_CODE)&amp;gt;0&lt;br /&gt;
INNER join iloc on iloc.item_code=icst.item_code AND ILOC.LOC_CODE=ICST.LOC_CODE&lt;br /&gt;
inner join imst on imst.item_code=iloc.item_code&lt;br /&gt;
LEFT OUTER JOIN ILOC ILC ON ILC.ITEM_CODE=ICST.CONST_ITEM_CODE AND ILC.LOC_CODE=ICST.LOC_CODE&lt;br /&gt;
LEFT OUTER JOIN IMST IMC ON IMC.ITEM_CODE=ICST.CONST_ITEM_CODE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTPRSTR&lt;br /&gt;
( SESSION_NO, TRANS_NO, SEQUENCE_CODE, ASSY_PRODUCT_CODE, COMP_PRODUCT_CODE, COMP_UMS, QTY_ASSEMBLY, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( {SESSION_NO}, {TRANS_NO|INC=1}, {SEQUENCE_CODE}, '{ASSY_PRODUCT_CODE}.{PLANT_NO}', '{COMP_PRODUCT_CODE}.{PLANT_NO}', '{COMP_UMS}', {QTY_ASSEMBLY}, 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
note: left outer allows missing items to go through - 5 components for plant 314 added.&lt;br /&gt;
(CMD does not have integrity - so structure for invalid products permitted)&lt;br /&gt;
&lt;br /&gt;
======================================================&lt;br /&gt;
jobs jobs jobs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Mismatch Items - no ILOC:&lt;br /&gt;
&lt;br /&gt;
select &lt;br /&gt;
proj.cust_code&lt;br /&gt;
,prjp.proj_code,CUST.NAME &amp;quot;CustName&amp;quot;,plnt.plant_code plant,(prjp.prod_code) ProjectProduct&lt;br /&gt;
,prjp.price&lt;br /&gt;
from prjp&lt;br /&gt;
INNER JOIN CUST ON CUST.CUST_CODE=PRjp.CUST_CODE&lt;br /&gt;
INNER JOIN PROJ ON PROJ.PROJ_CODE=PRJP.PROJ_CODE AND    PROJ.CUST_CODE=PRJP.CUST_CODE&lt;br /&gt;
inner join plnt on  plnt.plant_code = PROJ.Cc_PRICE_PLANT_CODE &lt;br /&gt;
left outer JOIN ILOC ON ILOC.ITEM_CODE=PRJP.PROD_CODE and    PLNT.LOC_CODE=ILOC.LOC_CODE&lt;br /&gt;
WHERE proj.INACTIVE_CODE=0&lt;br /&gt;
AND COALESCE(proj.EXPIR_DATE,'12/31/2099' ) &amp;gt;'1/1/23'&lt;br /&gt;
and iloc.item_code is null and price_plant_code &amp;lt;&amp;gt;'#'&lt;br /&gt;
order by proj.cust_code,prjp.proj_code,cust.name,proj.expir_date,plnt.plant_code,prjp.prod_code&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
0== job header query  ==&lt;br /&gt;
&lt;br /&gt;
with pj as(&lt;br /&gt;
select &lt;br /&gt;
proj.cust_code&lt;br /&gt;
,prjp.proj_code,CUST.NAME &amp;quot;CustName&amp;quot;&lt;br /&gt;
from prjp&lt;br /&gt;
INNER JOIN CUST ON CUST.CUST_CODE=PRjp.CUST_CODE&lt;br /&gt;
INNER JOIN PROJ ON PROJ.PROJ_CODE=PRJP.PROJ_CODE AND    PROJ.CUST_CODE=PRJP.CUST_CODE&lt;br /&gt;
--inner join plnt on  plnt.plant_code = PROJ.Cc_PRICE_PLANT_CODE &lt;br /&gt;
--INNER JOIN ILOC ON ILOC.ITEM_CODE=PRJP.PROD_CODE and    PLNT.LOC_CODE=ILOC.LOC_CODE&lt;br /&gt;
inner join plnt on  plnt.plant_code = PROJ.Cc_PRICE_PLANT_CODE &lt;br /&gt;
left outer JOIN ILOC ON ILOC.ITEM_CODE=PRJP.PROD_CODE and    PLNT.LOC_CODE=ILOC.LOC_CODE&lt;br /&gt;
--left outer join imst on imst.item_cat=prjp.prod_code and price_plant_code='#'&lt;br /&gt;
WHERE proj.INACTIVE_CODE=0&lt;br /&gt;
AND COALESCE(proj.EXPIR_DATE,'12/31/2099' ) &amp;gt;'1/1/23'&lt;br /&gt;
group by prjp.proj_code,proj.cust_code,cust.name,proj.expir_date&lt;br /&gt;
)&lt;br /&gt;
SELECT &lt;br /&gt;
rtrim(LTRIM(PROJ.CUST_CODE)) CUST_NO,PROJ.EXPIR_DATE,&lt;br /&gt;
Left(rtrim(LTRIM(PROJ.PROJ_code)),18) JOB_PO_LOC,&lt;br /&gt;
PROJ_NAME,PO,&lt;br /&gt;
Left(rtrim(LTRIM(PROJ_name)),18) batch_job_code,&lt;br /&gt;
rtrim(LTRIM(PROJ_NAME)) DELV_INST_1,&lt;br /&gt;
Left(LTRIM(proj.tax_code),3) TAX_code,&lt;br /&gt;
--'IMP' TAX_AUTHORITY,&lt;br /&gt;
CA_TERMS_CODE,PROJ.CA_PRICE_PLANT_CODE,&lt;br /&gt;
LTRIM(CA_TERMS_CODE) TERMS_CLASS,&lt;br /&gt;
--LTRIM(CA_PRICE_PLANT_CODE) PLANT_NO,&lt;br /&gt;
Left(rtrim(LTRIM(PO)) ,20) CUSTOMER_PO,&lt;br /&gt;
LTRIM(UPPER(PROJ.CA_SALES_ANL_CODE)) CUCLS,&lt;br /&gt;
'' SHIP_TO_1,&lt;br /&gt;
--Left(RTRIM(LTRIM(ship_name)),30) SHIP_TO_1 ,&lt;br /&gt;
Left(RTRIM(LTRIM(PROJ.ship_addr_line_1)),30) SHIP_TO_2 ,&lt;br /&gt;
Left(RTRIM(LTRIM(ship_addr_line_2)),30) SHIP_TO_3 ,&lt;br /&gt;
CASE LTRIM(TAXBLE_CODE) WHEN 1 THEN 'Y' ELSE 'N' END JOB_TAX_CODE,&lt;br /&gt;
Left(concat(SHIP_CITY,' ',SHIP_STATE,' ',SHIP_POSTCD),30) SHIP_TO_4,&lt;br /&gt;
 Taxj.tax_loc &amp;quot;NOTES_1&amp;quot;,&lt;br /&gt;
PROJ.EXPIR_DATE &amp;quot;NOTES_2&amp;quot;,&lt;br /&gt;
--USE_FOR_PROD_LINE_CODE &amp;quot;NOTES_2&amp;quot;,&lt;br /&gt;
LTRIM(NON_TAX_RSN_CODE) &amp;quot;CUSTOM_1&amp;quot;,&lt;br /&gt;
LTRIM(PROJ.CA_SLSMN_EMPL_CODE) &amp;quot;CUSTOM_2&amp;quot;,&lt;br /&gt;
Left(RTRIM(LTRIM(CONTCT_NAME)),30) &amp;quot;CONTACT&amp;quot;,&lt;br /&gt;
Left(RTRIM(LTRIM(PHONE_NUM_1)),30) PHONE_NO,&lt;br /&gt;
Left(RTRIM(LTRIM(PROJ_NAME)),30) &amp;quot;INVOICE_DESC&amp;quot;&lt;br /&gt;
,ship_addr_line_1,ship_addr_line_2,&lt;br /&gt;
PHONE_NUM_1,PHONE_NUM_2,PHONE_NUM_3,CONTct_NAME,custname&lt;br /&gt;
FROM proj &lt;br /&gt;
inner join pj on pj.proj_code=proj.proj_code and pj.cust_code=proj.cust_code&lt;br /&gt;
INNER JOIN TAXJ ON TAXJ.TAX_CODE=proj.TAX_CODE and taxj.tax_auth=1&lt;br /&gt;
where inactive_code = 0&lt;br /&gt;
and coalesce (PROJ.expir_date,'12/31/2099')&amp;gt;'1/1/2023'&lt;br /&gt;
ORDER BY CUST_NO,PROJ_NAME&lt;br /&gt;
&lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTJOBHD &lt;br /&gt;
( SESSION_NO, TRANS_NO, CUST_NO, JOB_PO_LOC, BATCH_JOB_CODE , TERMS_CLASS, TAX_AUTHORITY,  INVOICE_DESC, NOTES_1, NOTES_2, JOB_TAX_CODE, JOB_TAX_CODE_2, JOB_TAX_CODE_3, PLANT_NO, SHIP_TO_1, SHIP_TO_2, SHIP_TO_3, SHIP_TO_4, PHONE_NO, CONTACT, CUSTOMER_PO, CUSTOM_1, CUSTOM_2,  COD_FLAG, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG, MEMO )  VALUES &lt;br /&gt;
( 1, {CUST_NO|INC=1}, '{CUST_NO}', '{JOB_PO_LOC}', '{batch_job_code}',  NULL, '{TAX_AUTHORITY}', '{INVOICE_DESC}', '{NOTES_1}', '{NOTES_2}', '{JOB_TAX_CODE}', 'Y', 'Y', NULL, '{SHIP_TO_1}', '{SHIP_TO_2}', '{SHIP_TO_3}', '{SHIP_TO_4}', '{PHONE_NO}', '{CONTACT}', '{CUSTOMER_PO}', '{CUSTOM_1}', '{CUSTOM_2}', 'N', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y' , &lt;br /&gt;
'***Import Notes Jan 2023***&lt;br /&gt;
PROJ NAME: {PROJ_NAME}&lt;br /&gt;
PO: {PO}&lt;br /&gt;
CONTACT: {CONTct_NAME}&lt;br /&gt;
PHONE1: {phone_num_1}&lt;br /&gt;
PHONE2: {phone_num_2}&lt;br /&gt;
PHONE3: {phone_num_3}&lt;br /&gt;
ship_addr_line_1 {ship_addr_line_1}&lt;br /&gt;
ship_addr_line_2 {ship_addr_line_2}&lt;br /&gt;
expir_date: {expir_date}&lt;br /&gt;
*****************************************&lt;br /&gt;
'   );  -- {custname}&lt;br /&gt;
&lt;br /&gt;
NOTE: plant ok?&lt;br /&gt;
Uses numeric job code as JOB ID -- this should be updated on ib side.&lt;br /&gt;
&lt;br /&gt;
== job detail query  ==&lt;br /&gt;
&lt;br /&gt;
WITH JDT AS &lt;br /&gt;
(&lt;br /&gt;
select --top 100  &lt;br /&gt;
proj.cust_code,&lt;br /&gt;
RTRIM(LTRIM(PRJP.PROJ_CODE)) JOB_PO_LOC,&lt;br /&gt;
RTRIM(LTRIM(PRJP.CUST_CODE)) CUST_NO,&lt;br /&gt;
RTRIM(LTRIM(PRJP.PROD_CODE)) PRODUCT_CODE,&lt;br /&gt;
RTRIM(LTRIM(Cc_PRICE_PLANT_CODE)) PLANT_code,&lt;br /&gt;
PRJP.INTRNL_LINE_NUM LINE_NO,&lt;br /&gt;
(SELECT UPPER(ABBR) FROM UOMS WHERE UOMS.UOM = PRJP.PRICE_UOM) UNIT_OF_MEASURE,&lt;br /&gt;
left(RTRIM(LTRIM(PROD_DESCR)),35) DESCRIPTION,&lt;br /&gt;
PRICE UNIT_PRICE,prjp.effect_date&lt;br /&gt;
  ,PRJP.PROD_CODE&lt;br /&gt;
  ,LAG(PROD_CODE,1,'__') OVER (partition by PRJP.CUST_CODE,PRJP.PROJ_CODE,Cc_PRICE_PLANT_CODE&lt;br /&gt;
      order by PRJP.CUST_CODE,PRJP.PROJ_CODE,PRJP.PROD_CODE,Cc_PRICE_PLANT_CODE,PRJP.EFFECT_DATE DESC) PREVPROD&lt;br /&gt;
,iif(iloc.loc_code is null,(select min(loc_code) from iloc where iloc.item_code=imst.item_code and iloc.inactive_code=0),iloc.loc_code) altclocode&lt;br /&gt;
from prjp&lt;br /&gt;
INNER JOIN PROJ ON PROJ.PROJ_CODE=PRJP.PROJ_CODE AND PROJ.CUST_CODE=PRJP.CUST_CODE&lt;br /&gt;
inner join plnt on  plnt.plant_code = Cc_PRICE_PLANT_CODE&lt;br /&gt;
left outer JOIN ILOC ON ILOC.ITEM_CODE=PRJP.PROD_CODE and    PLNT.LOC_CODE=ILOC.LOC_CODE&lt;br /&gt;
inner join imst on imst.item_code=prjp.prod_code&lt;br /&gt;
WHERE proj.INACTIVE_CODE=0&lt;br /&gt;
AND COALESCE(proj.EXPIR_DATE,'12/31/2099' ) &amp;gt;'1/1/23'&lt;br /&gt;
)&lt;br /&gt;
SELECT JDT.*,plnt.plant_code &amp;quot;PLANT_NO&amp;quot;&lt;br /&gt;
FROM JDT&lt;br /&gt;
inner join cust on cust.cust_code=jdt.cust_code&lt;br /&gt;
inner join plnt on plnt.loc_code=jdt.altclocode AND ISNUMERIC(PLNT.PLANT_CODE)=1&lt;br /&gt;
WHERE PREVPROD&amp;lt;&amp;gt;PROD_CODE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO ARTJOBDT &lt;br /&gt;
 ( SESSION_NO, TRANS_NO, JOB_PO_LOC, CUST_NO, PRODUCT_CODE, LINE_NO, UNIT_OF_MEASURE, DESCRIPTION, UNIT_PRICE, TAX_CODE, TAX_CODE_2, TAX_CODE_3, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER )  VALUES &lt;br /&gt;
  ( 1, (SELECT TRANS_NO  FROM ARTJOBHD WHERE JOB_PO_LOC='{JOB_PO_LOC}' AND CUST_NO='{CUST_NO}' )&lt;br /&gt;
  , '{JOB_PO_LOC}', '{CUST_NO}', '{PRODUCT_CODE}.{PLANT_NO}', {LINE_NO}, '{UNIT_OF_MEASURE}', '{DESCRIPTION}', {UNIT_PRICE}, 'Y', 'Y', 'Y', 'Y', CAST('TODAY' AS TIMESTAMP), 'Y'    );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTES:  Not loving the plant mismatches on detail&lt;br /&gt;
If primary plant not specified - takes the lowest value. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
------&lt;br /&gt;
ZONE&lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
SELECT * FROM ZONE&lt;br /&gt;
&lt;br /&gt;
INSERT INTO artzone&lt;br /&gt;
   ( ZONE, DESCRIPTION, PLANT_NO, ZONE_REGION, DEF_TAX_AUTHORITY, IMPORTED_FLAG, MEMO, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
   ( '{ZONE_CODE|TRIM=0}', '{DESCR|STRLEN=35}', NULL, NULL, '{TAX_CODE}', 'Y', 'Imported 01/17/2023', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
--------------&lt;br /&gt;
CONTACT&lt;br /&gt;
------&lt;br /&gt;
SELECT &lt;br /&gt;
LTRIM(RTRIM(CCON.CUST_CODE)) ENTITY_ID,&lt;br /&gt;
LTRIM(RTRIM(NAME)) NAME,&lt;br /&gt;
LTRIM(RTRIM(PHONE_NUM_1)) PHONE_NO,&lt;br /&gt;
LTRIM(RTRIM(PHONE_NUM_2)) CELL_NO,&lt;br /&gt;
LTRIM(RTRIM(PHONE_NUM_2)) FAX_NO,&lt;br /&gt;
LTRIM(RTRIM(JOB_TITLE)) TITLE,&lt;br /&gt;
ltrim(rtrim(email_addr)) EMAIL,&lt;br /&gt;
* FROM CCON&lt;br /&gt;
INNER JOIN CTCT ON CTCT.CONTCT_CODE=CCON.CONTCT_CODE&lt;br /&gt;
---&lt;br /&gt;
INSERT INTO cctcont&lt;br /&gt;
  ( RECKEY, ENTITY_TYPE, ENTITY_ID, NAME, PHONE_NO, CELL_NO, FAX_NO, TITLE,EMAIL, EMAIL_OPT_1, EMAIL_OPT_2, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
  ( GEN_ID(GEN_CCCONTKEY,1), 'C', '{ENTITY_ID}', '{NAME|STRLEN=30}', '{PHONE_NO|STRLEN=30}', '{CELL_NO|STRLEN=30}', '{FAX_NO|STRLEN=30}', '{TITLE}', '{EMAIL|STRLEN=80}', 'Y', 'Y', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
---------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
contacts from ONBASE...&lt;br /&gt;
&lt;br /&gt;
Lq3:&lt;br /&gt;
SELECT &lt;br /&gt;
--RTRIM(rd.distprocessnum) dist_proc_num, &lt;br /&gt;
--RTRIM(dp.distprocessname) dist_proc_name,&lt;br /&gt;
--rd.recipientnum OBRecipientNO,&lt;br /&gt;
--RTRIM(rd.distributionflags) dist_flags, &lt;br /&gt;
RTRIM(replace(rd.idkeywords,'!','')) 'CustomerNO', &lt;br /&gt;
RTRIM(sr.recipientname) 'CustomerName', &lt;br /&gt;
RTRIM(sr.email) 'Email', &lt;br /&gt;
RTRIM(sr.faxnum) 'FaxNO' &lt;br /&gt;
FROM hsi.recipientxdist rd &lt;br /&gt;
INNER JOIN hsi.stmtrecipient sr ON rd.recipientnum = sr.recipientnum LEFT OUTER JOIN hsi.distprocess dp ON rd.distprocessnum = dp.distprocessnum&lt;br /&gt;
ORDER BY rd.distprocessnum, sr.recipientname, rd.distributionflags&lt;br /&gt;
lq2:&lt;br /&gt;
select cust_no,name from artcust c&lt;br /&gt;
&lt;br /&gt;
Primary:&lt;br /&gt;
select * from lq3&lt;br /&gt;
left outer join lq2 on lq2.cust_no=lq3.CustomerNO&lt;br /&gt;
where lq2.cust_no is not null&lt;br /&gt;
order by cust_no&lt;br /&gt;
&lt;br /&gt;
INSERT INTO cctcont&lt;br /&gt;
  ( RECKEY, ENTITY_TYPE, ENTITY_ID, NAME, PHONE_NO, CELL_NO, FAX_NO, TITLE,EMAIL, EMAIL_OPT_1, EMAIL_OPT_2, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
  ( GEN_ID(GEN_CCCONTKEY,1), 'C', '{CUST_NO}', 'Accounts Payable', null, null, '{FAXNO|STRLEN=30}', null, '{EMAIL|STRLEN=80}', 'Y', 'Y', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
--------&lt;br /&gt;
Contacts Merge (If email from cmd and ob - use the cmd)&lt;br /&gt;
&lt;br /&gt;
SELECT ENTITY_ID,UPPER( EMAIL) EMAIL ,COUNT(*),MIN(NAME),MAX(NAME),MIN(RECKEY) ORIGKEY,MAX(RECKEY) NEWKEY FROM CCTCONT &lt;br /&gt;
WHERE EMAIL IS NOT NULL&lt;br /&gt;
GROUP BY 1,2&lt;br /&gt;
HAVING COUNT(*)&amp;gt;1&lt;br /&gt;
&lt;br /&gt;
(export a csv)&lt;br /&gt;
&lt;br /&gt;
update cctcont set email_opt_1='Y' ,email_opt_2='Y' WHERE RECKEY = {ORIGKEY};  /* {EMAIL}  */&lt;br /&gt;
DELETE FROM CCTCONT WHERE RECKEY={NEWKEY};&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
contacts deleted all where email null and cell_no null&lt;br /&gt;
&lt;br /&gt;
------------ Even MOre Onbase contacts&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
select lq1.*,lq2.*,1 ct,lq3.contemail from lq2&lt;br /&gt;
left outer join lq1 on lq1.cname=lq2.rname&lt;br /&gt;
left outer join lq3 on lq3.cust_no=lq1.cust_code and  lq2.email=lq3.contemail &lt;br /&gt;
where not (cust_code is  null);&lt;br /&gt;
&lt;br /&gt;
select ltrim(rtrim(cust_code)) cust_code,upper(name) cname from cust;&lt;br /&gt;
&lt;br /&gt;
select upper(recipientname) rname,upper(ltrim(rtrim(email))) email,1 rcpct from hsi.stmtrecipient&lt;br /&gt;
where coalesce(email,'')&amp;lt;&amp;gt;'';&lt;br /&gt;
&lt;br /&gt;
SELECT CUST_NO,c.NAME &amp;quot;CustomerName&amp;quot;,&lt;br /&gt;
c.CONTACT &amp;quot;CustomerContact&amp;quot;,cc.cell_no,cc.phone_no&lt;br /&gt;
,CC.NAME &amp;quot;ContName&amp;quot;,upper(cc.email) &amp;quot;ContEmail&amp;quot;,&lt;br /&gt;
email_opt_1 &amp;quot;EmailInv&amp;quot;,email_opt_2 &amp;quot;EmailStmt&amp;quot;&lt;br /&gt;
 FROM ARTCUST C&lt;br /&gt;
INNER JOIN CCTCONT CC ON CC.ENTITY_ID=C.CUST_NO&lt;br /&gt;
where cc.email is not null&lt;br /&gt;
order by c.cust_no,cc.reckey&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
INSERT INTO cctcont&lt;br /&gt;
  ( RECKEY, ENTITY_TYPE, ENTITY_ID, NAME, PHONE_NO, CELL_NO, FAX_NO, TITLE,EMAIL, EMAIL_OPT_1, EMAIL_OPT_2, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
  ( GEN_ID(GEN_CCCONTKEY,1), 'C', '{CUST_code}', 'Accounts Payable', null, null, null, null, '{EMAIL|STRLEN=80}', 'Y', 'Y', 'Y', CAST('TODAY' AS TIMESTAMP), 'HIT', 'Y'    );&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Update  Prods From Class:&lt;br /&gt;
&lt;br /&gt;
SELECT product_code,PRODUCT_CLASS,SELLABLE_FLAG,PRODUCT_TYPE,INGREDIENT_TYPE, (SELECT PC.STD_SELLABLE_FLAG FROM ARTPRCLS PC WHERE PC.CLASS_NO=P.PRODUCT_CLASS) STD_SELLABLE_FLAG,&lt;br /&gt;
(SELECT PC.STD_PRODUCT_TYPE FROM ARTPRCLS PC WHERE PC.CLASS_NO=P.PRODUCT_CLASS) STD_PRODUCT_TYPE,&lt;br /&gt;
(SELECT PC.STD_ingredient_TYPE FROM ARTPRCLS PC WHERE PC.CLASS_NO=P.PRODUCT_CLASS) STD_ingredient_TYPE&lt;br /&gt;
FROM ARTPROD P&lt;br /&gt;
&lt;br /&gt;
update artprod p&lt;br /&gt;
  SET SELLABLE_FLAG='{STD_SELLABLE_FLAG}',&lt;br /&gt;
  INGREDIENT_TYPE='{STD_INGREDIENT_TYPE}',&lt;br /&gt;
  PRODUCT_TYPE='{STD_PRODUCT_TYPE}'&lt;br /&gt;
  where product_code='{PRODUCT_CODE}';&lt;br /&gt;
&lt;br /&gt;
------&lt;br /&gt;
in mssql:  {set cust inactive}&lt;br /&gt;
&lt;br /&gt;
select &lt;br /&gt;
CONCAT( 'UPDATE ARTCUST C SET ACTIVE_FLAG=''N'' WHERE CUST_NO = ''',RTRIM(LTRIM(CUST_CODE)),''';')&lt;br /&gt;
from cust&lt;br /&gt;
where inactive_code &amp;lt;&amp;gt; 00&lt;br /&gt;
&lt;br /&gt;
===&lt;br /&gt;
Update sales g/l accounts by plant&lt;br /&gt;
(Setup Plants with default g/l!!!!)&lt;br /&gt;
&lt;br /&gt;
with ga (act,s1,s2,s3,s4,actnm) as&lt;br /&gt;
(select  gl_account,segment_1,segment_2,segment_3,segment_4,max(description)&lt;br /&gt;
from gltacct a&lt;br /&gt;
where segment_4 between '300' and '998'&lt;br /&gt;
group by gl_account,segment_1,segment_2,segment_3,segment_4&lt;br /&gt;
)&lt;br /&gt;
,pr (pact,ps1,ps2,ps3,ps4,plt) as&lt;br /&gt;
(select GL_ACCOUNT ,segment_1,segment_2,segment_3,segment_4,p.plant_no from artprod p&lt;br /&gt;
inner join gltacct a on a.gl_account=p.sales_gl&lt;br /&gt;
group by gl_account,segment_1,segment_2,segment_3,segment_4,plant_no)&lt;br /&gt;
select * from ga &lt;br /&gt;
inner join pr on pr.ps1=ga.s1 and  pr.ps2=ga.s2 and pr.plt=ga.s4&lt;br /&gt;
order by s1,s4&lt;br /&gt;
&lt;br /&gt;
update artprod p set sales_gl = '{act}' WHERE sales_gl='{pact}' and plant_no = '{plt}';&lt;br /&gt;
&lt;br /&gt;
NOTE: This could be done more generically by taking part of acct from artprcls and some from the g/l pattern&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Command_Import&amp;diff=955</id>
		<title>Command Import</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Command_Import&amp;diff=955"/>
		<updated>2024-02-27T13:25:27Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* MS SQL to know */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There is not ONE way to import Command Data - each situation is unique.&lt;br /&gt;
&lt;br /&gt;
===Know This First===&lt;br /&gt;
What you need to know before importing Command's Data&lt;br /&gt;
*There is NO data integrity.&lt;br /&gt;
:*Expect sub tables, prices etc. to have records that do have matching main tables.  (e.g. prices for customers that don't exist).&lt;br /&gt;
*Alpha fields must be trimmed - especially key fields.  Expect both left and right padding on Customer and product codes.&lt;br /&gt;
:MS SQL hasn't had the &amp;quot;TRIM&amp;quot; statement for long, so most often you must select as:&lt;br /&gt;
:&amp;lt;code&amp;gt;LTRIM(RTRIM((PRJP.PROJ_CODE)) JOB_PO_LOC,&amp;lt;/code&amp;gt;&lt;br /&gt;
:in some cases, such as Oracle you only have trim and must select as:&lt;br /&gt;
:&amp;lt;code&amp;gt;TRIM(PRJP.PROJ_CODE) JOB_PO_LOC,&amp;lt;/code&amp;gt;&lt;br /&gt;
*Numeric Fields may be null.  Use coalesce... &amp;lt;code&amp;gt;COALESCE(Finc_Chrg_amt,0) Finc_chrg_amt&amp;lt;/code&amp;gt;&lt;br /&gt;
*Field IDs are longer - especially Tax Authorities, sales people and classes.&lt;br /&gt;
*Keep a list of mappings when setting up the class type fields to use in case statements...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
case TERMS&lt;br /&gt;
WHEN '15N' THEN '15' &lt;br /&gt;
WHEN 'N20' THEN '20' &lt;br /&gt;
   ...&lt;br /&gt;
WHEN 'CAS' THEN 'CA' ELSE '' END CUST_TERMS&amp;lt;/pre&amp;gt;&lt;br /&gt;
*Some records, especially prices, have what appear to be duplicates.  You need special queries that pull just the latest version of the record.&lt;br /&gt;
*Start with Small Tables and Build up (Like any Import)&lt;br /&gt;
&lt;br /&gt;
===MS SQL to know===&lt;br /&gt;
[[Microsoft SQL Server Query Features]]&lt;br /&gt;
*ltrim,rtrim&lt;br /&gt;
*replace&lt;br /&gt;
*left, right&lt;br /&gt;
*case&lt;br /&gt;
*iif&lt;br /&gt;
*rank&lt;br /&gt;
*with (derived queries)&lt;br /&gt;
&lt;br /&gt;
===Import Examples===&lt;br /&gt;
&lt;br /&gt;
Here are some samples used in the past...&lt;br /&gt;
:[[Examples by Table]]&lt;br /&gt;
:[[Command Import: Hedger Work Notes]]&lt;br /&gt;
:[[Command Import: Rain MO Work Notes]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Command Tables===&lt;br /&gt;
&lt;br /&gt;
*'''ACCT:''' GL  Accounts&lt;br /&gt;
*'''ARTB:''' Aging&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''COMP:''' Company&lt;br /&gt;
*'''CPRD:''' Customer Prices&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
*'''CUST:''' Customer Prices&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
*'''ILOC:''' Product by Location (Similar to Plant)&lt;br /&gt;
*'''IMST:''' Products&lt;br /&gt;
*'''IPRC:''' Prices - by Level (Group)&lt;br /&gt;
*'''LOCN:''' Locations (Similar to Plant)&lt;br /&gt;
*'''PLNT:''' Plant&lt;br /&gt;
*'''PRCC:''' Price Group&lt;br /&gt;
*'''PRJP:''' Project Prices&lt;br /&gt;
*'''PROJ:''' Project&lt;br /&gt;
*'''SANL:''' Customer Class&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
*'''TRMS:''' Terms&lt;br /&gt;
*'''TRUC:''' Trucks&lt;br /&gt;
*'''UOMS:''' Unit of Meausure&lt;br /&gt;
*'''USGE:''' Useage&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Command_Import&amp;diff=954</id>
		<title>Command Import</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Command_Import&amp;diff=954"/>
		<updated>2024-02-27T13:23:13Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* MS SQL to know */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There is not ONE way to import Command Data - each situation is unique.&lt;br /&gt;
&lt;br /&gt;
===Know This First===&lt;br /&gt;
What you need to know before importing Command's Data&lt;br /&gt;
*There is NO data integrity.&lt;br /&gt;
:*Expect sub tables, prices etc. to have records that do have matching main tables.  (e.g. prices for customers that don't exist).&lt;br /&gt;
*Alpha fields must be trimmed - especially key fields.  Expect both left and right padding on Customer and product codes.&lt;br /&gt;
:MS SQL hasn't had the &amp;quot;TRIM&amp;quot; statement for long, so most often you must select as:&lt;br /&gt;
:&amp;lt;code&amp;gt;LTRIM(RTRIM((PRJP.PROJ_CODE)) JOB_PO_LOC,&amp;lt;/code&amp;gt;&lt;br /&gt;
:in some cases, such as Oracle you only have trim and must select as:&lt;br /&gt;
:&amp;lt;code&amp;gt;TRIM(PRJP.PROJ_CODE) JOB_PO_LOC,&amp;lt;/code&amp;gt;&lt;br /&gt;
*Numeric Fields may be null.  Use coalesce... &amp;lt;code&amp;gt;COALESCE(Finc_Chrg_amt,0) Finc_chrg_amt&amp;lt;/code&amp;gt;&lt;br /&gt;
*Field IDs are longer - especially Tax Authorities, sales people and classes.&lt;br /&gt;
*Keep a list of mappings when setting up the class type fields to use in case statements...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
case TERMS&lt;br /&gt;
WHEN '15N' THEN '15' &lt;br /&gt;
WHEN 'N20' THEN '20' &lt;br /&gt;
   ...&lt;br /&gt;
WHEN 'CAS' THEN 'CA' ELSE '' END CUST_TERMS&amp;lt;/pre&amp;gt;&lt;br /&gt;
*Some records, especially prices, have what appear to be duplicates.  You need special queries that pull just the latest version of the record.&lt;br /&gt;
*Start with Small Tables and Build up (Like any Import)&lt;br /&gt;
&lt;br /&gt;
===MS SQL to know===&lt;br /&gt;
*ltrim,rtrim&lt;br /&gt;
*replace&lt;br /&gt;
*left, right&lt;br /&gt;
*case&lt;br /&gt;
*iif&lt;br /&gt;
*rank&lt;br /&gt;
*with (derived queries)&lt;br /&gt;
&lt;br /&gt;
===Import Examples===&lt;br /&gt;
&lt;br /&gt;
Here are some samples used in the past...&lt;br /&gt;
:[[Examples by Table]]&lt;br /&gt;
:[[Command Import: Hedger Work Notes]]&lt;br /&gt;
:[[Command Import: Rain MO Work Notes]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Command Tables===&lt;br /&gt;
&lt;br /&gt;
*'''ACCT:''' GL  Accounts&lt;br /&gt;
*'''ARTB:''' Aging&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''COMP:''' Company&lt;br /&gt;
*'''CPRD:''' Customer Prices&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
*'''CUST:''' Customer Prices&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
*'''ILOC:''' Product by Location (Similar to Plant)&lt;br /&gt;
*'''IMST:''' Products&lt;br /&gt;
*'''IPRC:''' Prices - by Level (Group)&lt;br /&gt;
*'''LOCN:''' Locations (Similar to Plant)&lt;br /&gt;
*'''PLNT:''' Plant&lt;br /&gt;
*'''PRCC:''' Price Group&lt;br /&gt;
*'''PRJP:''' Project Prices&lt;br /&gt;
*'''PROJ:''' Project&lt;br /&gt;
*'''SANL:''' Customer Class&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
*'''TRMS:''' Terms&lt;br /&gt;
*'''TRUC:''' Trucks&lt;br /&gt;
*'''UOMS:''' Unit of Meausure&lt;br /&gt;
*'''USGE:''' Useage&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=953</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=953"/>
		<updated>2024-02-26T16:54:02Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Job (proj) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants (Locn/Plnt)===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  &lt;br /&gt;
&lt;br /&gt;
*LOCN: Locations&lt;br /&gt;
*PLNT: Plant&lt;br /&gt;
&lt;br /&gt;
Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
===Drivers (empl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with driv as (&lt;br /&gt;
	SELECT  --the core query &lt;br /&gt;
	rtrim(ltrim(empl_code)) &amp;quot;DRIVER_CODE&amp;quot;,&lt;br /&gt;
	replace(rtrim(ltrim(NAME)),'''','''''') &amp;quot;DRIVER_NAME&amp;quot;,&lt;br /&gt;
	rtrim(ltrim(empl.phone_num)) Phone_no,&lt;br /&gt;
	rtrim(ltrim(empl.assgn_plant_code)) Home_plant_no,&lt;br /&gt;
	--EMPL.*,&lt;br /&gt;
	''',''' QCQ,''',' q1,'=''' q2 -- these are helpers for the concat query&lt;br /&gt;
	from empl&lt;br /&gt;
	where driv_flag = 1&lt;br /&gt;
	and inactive_code='00'&lt;br /&gt;
)&lt;br /&gt;
select -- this creates insert from the core query&lt;br /&gt;
concat('INSERT INTO  artdriv ( DRIVER_CODE, DRIVER_NAME, PHONE_NO, HOME_PLANT_NO, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG,memo )  VALUES &lt;br /&gt;
( ''',driver_code,qcq,DRIVER_NAME,qcq,Phone_no,qcq,Home_plant_no,qcq ,'Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y',qcq,'Imported from Cmd'');'   ),&lt;br /&gt;
driv.* from driv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Salespeople (empl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with cs as &lt;br /&gt;
	( select distinct(ltrim(rtrim(cust.cc_slsmn_empl_code))) custslsmn from cust where inactive_code='00' ), -- LIst of slsmn in active customers&lt;br /&gt;
slsemp as -- all sls employees&lt;br /&gt;
	(SELECT &lt;br /&gt;
	rtrim(ltrim(empl.empl_code)) empno,&lt;br /&gt;
	rtrim(ltrim(empl.empl_code)) USER_1,&lt;br /&gt;
	rtrim(LTRIM(empl.NAME)) DESCRIPTION,&lt;br /&gt;
	rtrim(LTRIM(empl.PHONE_NUM)) PHONE_NO,&lt;br /&gt;
	rtrim(LTRIM(empl.ASSGN_PLANT_CODE)) USER_2&lt;br /&gt;
	 FROM empl&lt;br /&gt;
	where slsmn_flag='True') &lt;br /&gt;
,slpn as&lt;br /&gt;
	(&lt;br /&gt;
	select cs.*,slsemp.*,&lt;br /&gt;
	case custslsmn&lt;br /&gt;
	WHEN '182' THEN 'NJ'&lt;br /&gt;
	WHEN '322' THEN 'RM'&lt;br /&gt;
	WHEN 'S15' THEN '15'&lt;br /&gt;
	---...&lt;br /&gt;
	WHEN 'SALES' THEN 'SA'&lt;br /&gt;
	else custslsmn&lt;br /&gt;
	end class_no,''',''' qcq &lt;br /&gt;
	from cs&lt;br /&gt;
	INNER join slsemp on slsemp.empno=cs.custslsmn --only include slspn that are in active customers&lt;br /&gt;
	) select &lt;br /&gt;
concat ( 'INSERT INTO artslspn ( CLASS_NO, EMPLOYEE_NO, DESCRIPTION, PHONE_NO, USER_2 )  VALUES (''',class_no,qcq,empno,qcq,DESCRIPTION,qcq,PHONE_NO,qcq,USER_2,''');'),&lt;br /&gt;
slpn.* from slpn&lt;br /&gt;
order by custslsmn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
====Tax Locality====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with ttl (tax_loc,tax_auth,descr,rate) as&lt;br /&gt;
  (select -- Core query (can be used with QG)&lt;br /&gt;
  cast(tl.tax_loc as integer),cast(tl.tax_auth as integer),&lt;br /&gt;
  replace(replace(ltrim(rtrim(descr)),'(City of','('),'( ','('),&lt;br /&gt;
  max(prim_rate_curr_pct) from taxl tl&lt;br /&gt;
  inner join taxj tj on tl.tax_loc=tj.tax_loc and tl.tax_auth=tj.tax_auth&lt;br /&gt;
  group by tl.tax_loc,tl.tax_auth,descr&lt;br /&gt;
  )&lt;br /&gt;
select &lt;br /&gt;
concat('INSERT INTO ARTTXLOC&lt;br /&gt;
( TAX_LOCALITY, LINE_NO, DESCRIPTION, TAX_COL, LOC_LEVEL, TAX_RATE, CALC_METHOD, EFFECT_DATE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',100*tax_auth + tax_loc,''', ',tax_auth,',''',left(descr,35),''',1 ,',tax_auth,',',rate,', 1, ''01/01/1900'', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );'),&lt;br /&gt;
ttl.* from ttl&lt;br /&gt;
order by tax_auth,tax_loc;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tax Authority====&lt;br /&gt;
For the tax authority, we just need the code and the description...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with tc as&lt;br /&gt;
	(select ltrim(rtrim(tax_code)) &amp;quot;tax_code&amp;quot;,&lt;br /&gt;
	replace(replace(ltrim(rtrim(descr)),'(City of','('),'( ','(') &amp;quot;descr&amp;quot;&lt;br /&gt;
	from taxc)&lt;br /&gt;
select &lt;br /&gt;
concat('INSERT INTO ARTTXAUT ( TAX_AUTHORITY, DESCRIPTION, INCREASE_DISC_FLAG, DISC_INCLUDES_TAX, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',tax_code,''' , ''',left(descr,35),''', ''N'', ''Y'', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y'' );',''),&lt;br /&gt;
tc.* from tc;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  Import the actual group prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
Sample query:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select -- core query that can be used with qg&lt;br /&gt;
	ltrim(rtrim(price_cat)),&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from prcc&lt;br /&gt;
	)&lt;br /&gt;
select -- outer query &lt;br /&gt;
concat('INSERT INTO ARTPRGRP ( GROUP_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG)  VALUES &lt;br /&gt;
  ( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''  );')&lt;br /&gt;
,clsno &amp;quot;group&amp;quot;, descry description&lt;br /&gt;
from aaa&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Price Cat codes tend to be short and do not need to be mapped coming into Keystone.&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Class (sanl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
select top (10000) &lt;br /&gt;
LTRIM(RTRIM(cust.CUST_CODE)) CUST_NO,&lt;br /&gt;
RTRIM(replace(left(ltrim(rtrim(CUST.NAME)),30),'''','''''')) name,&lt;br /&gt;
replace(left(LTRIM(RTRIM(CUST.ADDR_LINE_1)),30),'''','''''') address_1,&lt;br /&gt;
replace(left(LTRIM(RTRIM(CUST.ADDR_LINE_2)),30),'''','''''') address_2,&lt;br /&gt;
left(replace(ltrim(rtrim(addr_city)),',',''),16) CITY,&lt;br /&gt;
replace(LEFT(rtrim(ltrim(ADDR_STATE)),2),'M0','MO') STATE,&lt;br /&gt;
addr_state,&lt;br /&gt;
ltrim(rtrim(PHONE_NUM_1)) phone_no,PHONE_NUM_2,PHONE_NUM_3,&lt;br /&gt;
LTRIM(RTRIM(ADDR_POSTCD)) ZIP,ltrim(rtrim(cust.tax_code)) &amp;quot;TAX_AUTHORITY&amp;quot;,&lt;br /&gt;
--cast(cust.tax_code as integer) txcd_int,&lt;br /&gt;
--left(LTRIM(RTRIM(taxj.tax_loc)),3) TAX_AUTHORITY,&lt;br /&gt;
case ltrim(rtrim(cc_terms_code)) &lt;br /&gt;
  when '10N' THEN '1N'&lt;br /&gt;
  WHEN '15T' THEN '5T'&lt;br /&gt;
  WHEN '2.5' THEN '25'&lt;br /&gt;
  ELSE LTRIM(RTRIM(cc_TERMS_CODE)) END terms_class, --folsom mapping&lt;br /&gt;
LTRIM(RTRIM(CC_TERMS_CODE)) TERMS,&lt;br /&gt;
LTRIM(RTRIM(UPPER(CC_SALES_ANL_CODE))) CUCLS, -- unmapped&lt;br /&gt;
case ltrim(rtrim(cc_sales_anl_code)) --use cust class import mapping&lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	-- ... &lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(cc_sales_anl_code))  end &amp;quot;cust_class&amp;quot;,  &lt;br /&gt;
rtrim(LTRIM(CC_SLSMN_EMPL_CODE)) SLS_EMP,&lt;br /&gt;
case rtrim(LTRIM(CC_SLSMN_EMPL_CODE)) &lt;br /&gt;
	WHEN '182' THEN 'NJ' -- same mapping as slspn import&lt;br /&gt;
	--... &lt;br /&gt;
	WHEN 'SALES' THEN 'SA'&lt;br /&gt;
	else rtrim(LTRIM(CC_SLSMN_EMPL_CODE))  end salesperson,&lt;br /&gt;
rtrim(LTRIM(CC_PRICE_CAT)) PRICE_GROUP,&lt;br /&gt;
rtrim(LTRIM(CC_PRICE_PLANT_CODE) ) PRICE_PLANT,&lt;br /&gt;
CASE TAXBLE_CODE WHEN '1' then '' else CONCAT('TAX EXMPT RSN:', LTRIM(NON_TAX_RSN_CODE) ) END TAX_RSN,&lt;br /&gt;
rtrim(LTRIM(INACTIVE_CODE)) INACTIVE_CODE,&lt;br /&gt;
iif(rtrim(LTRIM(INACTIVE_CODE))='00','Y','N') active_flag,&lt;br /&gt;
CASE LTRIM(RTRIM(TAXBLE_CODE)) WHEN 1 THEN 'Y' ELSE 'N' END TAX_CODE,&lt;br /&gt;
CONCAT('Acct Cat Code: ',RTRIM(LTRIM(ACCT_CAT_CODE))) USER_2,&lt;br /&gt;
replace(LEFT(rtrim(ltrim(CONTCT_NAME)),30),'''','''''')CONTACT,&lt;br /&gt;
LEFT(replace(LTRIM(RTRIM(SORT_NAME)),'''',''),30) SEQUENCE_CODE,&lt;br /&gt;
acct_cat_code&lt;br /&gt;
--,cast(coalesce(SETUP_DATE,'1/1/1900') as date) start_date&lt;br /&gt;
,convert(varchar(10), setup_date, 101) start_date,&lt;br /&gt;
ltrim(rtrim(cust.tax_id_code)) Tax_id&lt;br /&gt;
from cust&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Product Class (icat)===&lt;br /&gt;
&lt;br /&gt;
A good product class table is essential for a Command conversion.&lt;br /&gt;
&lt;br /&gt;
You will mostly likely need to map long item cat codes to product class codes.  Instead of making them like the CMD item cat codes, so focus on making a well organized Keystone list and then have the customer help you mapping CMD item categories to Keystone classes.&lt;br /&gt;
&lt;br /&gt;
Separate the sellable ingredient items for admixes, colors etc. from the non-sellable ingredient codes.&lt;br /&gt;
When creating product classes, set the defaults for sellable, product type and ingredient type.  Then use the following script to update:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
update artprod p set  sellable_flag =(select std_sellable_flag from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  product_type =(select std_product_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  ingredient_type =(select std_ingredient_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup default sales G/L and make sure the plants are properly masked.  You can use a variant of this script to update yoru sales g/l accounts...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
UPDATE ARTPROD P&lt;br /&gt;
SET p.SALES_GL=&lt;br /&gt;
(select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class)||&lt;br /&gt;
(select substr(sales_gl_plant_mask,9,19) from artplant pl where pl.plant_no=p.plant_no)&lt;br /&gt;
where (select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class) is not null&lt;br /&gt;
and p.product_class IN ('AA','BB','CC')  -- Optionally only do this for select classes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Products===&lt;br /&gt;
Products are stored in 2 tables, imst and iloc.&lt;br /&gt;
*'''IMST:''' Product &amp;quot;Base&amp;quot;.  One record for base product that stores the category (class) description etc.&lt;br /&gt;
*'''ILOC:''' Product by Location&lt;br /&gt;
&lt;br /&gt;
These need to be combined to create keystone products.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Component Structure (icst)===&lt;br /&gt;
CMD dispatch mixes rarely are worth importing.  Verify with customer, but expect to import directly from batch controls.&lt;br /&gt;
&lt;br /&gt;
===Credit Terms (TRMS)===&lt;br /&gt;
You can import term codes and descriptions, but the meaning does not map from system to system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WITH T AS (&lt;br /&gt;
	SELECT &lt;br /&gt;
	case ltrim(rtrim(terms_code)) -- setup mapping for terms longer than 2 char.  Save for customer import etc.&lt;br /&gt;
		when '10N' THEN '1N'&lt;br /&gt;
		WHEN '15T' THEN '5T'&lt;br /&gt;
		WHEN '2.5' THEN '25'&lt;br /&gt;
		ELSE LTRIM(RTRIM(TERMS_CODE)) END CLASS_NO&lt;br /&gt;
	,LEFT(LTRIM(RTRIM(descr)),30) DESCRIPTION&lt;br /&gt;
	FROM dbo.trms&lt;br /&gt;
  )&lt;br /&gt;
  SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTCTCLS (CLASS_NO,DESCRIPTION) VALUES (''',CLASS_NO,''',''',DESCRIPTION,''');'),&lt;br /&gt;
  * FROM T&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trucks===&lt;br /&gt;
Trucks&lt;br /&gt;
&lt;br /&gt;
===Unit of Meausure (uoms)===&lt;br /&gt;
The key field for Unit of Measure is typically a long integer.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Prices (CPRD)===&lt;br /&gt;
&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List and Group Prices (IPRC)===&lt;br /&gt;
The table IPRC stores Category (cmd)/Group Prices and the equivelent of List prices.  Category &amp;quot;#&amp;quot; is represents &amp;quot;List&amp;quot; in Keystone.&lt;br /&gt;
*Many times, what appears to be a Group(cat) is in fact used as a list price.  You can preview the iprc data to the customer to determine this before the install.   You can also import into Keystone and then convert a group to list prices.&lt;br /&gt;
*Often, a large amount of junk pricing is in this table.  Preview to customer to determine if large amounts of pricing should be omitted.&lt;br /&gt;
*Where in Keystone, we often base pricing on X$ off list for a group or customer, in Command each price ends up as a record.  If possible, find groups (price cats) that can be skipped and replaced with a price off list.  (this may only apply to the mix items in a group/price cat)&lt;br /&gt;
*Expect redundant records that tneed to be processed by effect date.  (Use of RANK or similar SQL tricks can correct for this)&lt;br /&gt;
*Expect Prices for items that may or may not exist.&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Job (proj)====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Base selection on Expir_date, Setup_date and the inactive_code of projects, customers, iloc and imst.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SELECT -- PROJ HEAD&lt;br /&gt;
	rtrim(LTRIM(PROJ.CUST_CODE)) CUST_NO,&lt;br /&gt;
	proj.setup_date,&lt;br /&gt;
	PROJ.EXPIR_DATE,&lt;br /&gt;
	Left(rtrim(LTRIM(PROJ.PROJ_code)),18) JOB_PO_LOC,&lt;br /&gt;
	PROJ_NAME,PO,&lt;br /&gt;
	Left(rtrim(LTRIM(PROJ_name)),18) batch_job_code,&lt;br /&gt;
	rtrim(LTRIM(PROJ_NAME)) DELV_INST_1,&lt;br /&gt;
	Left(LTRIM(proj.tax_code),3) TAX_authority,&lt;br /&gt;
	proj.Cc_TERMS_CODE,PROJ.Cc_PRICE_PLANT_CODE,&lt;br /&gt;
	LTRIM(proj.Cc_TERMS_CODE) TERMS_CLASS,&lt;br /&gt;
	rtrim(LTRIM(proj.Cc_PRICE_PLANT_CODE)) PLANT_NO,&lt;br /&gt;
	Left(rtrim(LTRIM(PO)) ,20) CUSTOMER_PO,&lt;br /&gt;
	LTRIM(UPPER(PROJ.Cc_SALES_ANL_CODE)) CUCLS,&lt;br /&gt;
	--  ship_name or ship addr 2 in proj -- if ship_name avail. shift ship to addrs&lt;br /&gt;
	--Left(RTRIM(LTRIM(ship_name)),30) SHIP_TO_1 ,&lt;br /&gt;
	Left(RTRIM(LTRIM(PROJ.ship_addr_line_1)),30) SHIP_TO_1 ,&lt;br /&gt;
	--Left(RTRIM(LTRIM(ship_addr_line_2)),30) SHIP_TO_3 , &lt;br /&gt;
	Left(concat(SHIP_CITY,' ',SHIP_STATE,' ',SHIP_POSTCD),30) SHIP_TO_2,&lt;br /&gt;
	'' ship_to_3,''ship_to_4,&lt;br /&gt;
	CASE LTRIM(proj.TAXBLE_CODE) WHEN 1 THEN 'Y' ELSE 'N' END JOB_TAX_CODE,&lt;br /&gt;
	Left(concat(SHIP_CITY,' ',SHIP_STATE,' ',SHIP_POSTCD),30) SHIP_TO_4,&lt;br /&gt;
	Taxj.tax_loc &amp;quot;NOTES_1&amp;quot;,&lt;br /&gt;
	PROJ.EXPIR_DATE &amp;quot;NOTES_2&amp;quot;,&lt;br /&gt;
	LTRIM(PROJ.Cc_SLSMN_EMPL_CODE) &amp;quot;CUSTOM_2&amp;quot;,&lt;br /&gt;
	case proj.cc_slsmn_empl_code --slspn mapping&lt;br /&gt;
	WHEN '182' THEN 'NJ'&lt;br /&gt;
	-- ... &lt;br /&gt;
	WHEN 'S16' THEN '16'&lt;br /&gt;
	WHEN 'SALES' THEN 'SA'&lt;br /&gt;
	else null&lt;br /&gt;
	end salesperson,&lt;br /&gt;
	case proj.inactive_code when '00' then 'Y' ELSE 'N' END &amp;quot;JOB_ACTIVE_FLAG&amp;quot;,&lt;br /&gt;
	Left(RTRIM(LTRIM(proj.CONTCT_NAME)),30) &amp;quot;CONTACT&amp;quot;,&lt;br /&gt;
	Left(RTRIM(LTRIM(proj.PHONE_NUM_1)),30) PHONE_NO,&lt;br /&gt;
	Left(RTRIM(LTRIM(PROJ_NAME)),30) &amp;quot;INVOICE_DESC&amp;quot;&lt;br /&gt;
	,ship_name,ship_addr_line_1,ship_addr_line_2,&lt;br /&gt;
	proj.PHONE_NUM_1,proj.PHONE_NUM_2,proj.PHONE_NUM_3,proj.Contct_NAME&lt;br /&gt;
	,Ltrim(rtrim(PRJo.state_job_code)) state_job_code -- special case e.g. California AB219&lt;br /&gt;
FROM proj &lt;br /&gt;
inner join cust on cust.cust_code=proj.cust_code&lt;br /&gt;
INNER JOIN TAXJ ON TAXJ.TAX_CODE=proj.TAX_CODE and taxj.tax_auth=1&lt;br /&gt;
INNER JOIN PRJO ON PRJO.PROJ_CODE=PROJ.proj_code&lt;br /&gt;
where proj.inactive_code = '00' -- only active projects&lt;br /&gt;
and  cust.inactive_code='00' -- only active custs&lt;br /&gt;
--and coalesce (PROJ.expir_date,'12/31/2099')&amp;gt;'1/1/2024'  --(This would include jobs with no expir_date)&lt;br /&gt;
and (proj.expir_date &amp;gt; '1/1/2024'&lt;br /&gt;
or proj.setup_date &amp;gt; '5/1/23') -- includes all jobs starting after specified date&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Job Detail (prjp)====&lt;br /&gt;
*Tie this selection to the core query used for PROJ&lt;br /&gt;
*Plant # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
===Zone===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTzone (zone,DESCRIPTION,def_tax_authority) VALUES (''',rtrim(ltrim(zone_code)),&lt;br /&gt;
  ''',''',left(rtrim(ltrim(DESCR)),35),&lt;br /&gt;
  ''',''',rtrim(ltrim(tax_code)),''');'),&lt;br /&gt;
  zone.* &lt;br /&gt;
 FROM ZONE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=952</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=952"/>
		<updated>2024-02-26T14:44:07Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Customer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants (Locn/Plnt)===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  &lt;br /&gt;
&lt;br /&gt;
*LOCN: Locations&lt;br /&gt;
*PLNT: Plant&lt;br /&gt;
&lt;br /&gt;
Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
===Drivers (empl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with driv as (&lt;br /&gt;
	SELECT  --the core query &lt;br /&gt;
	rtrim(ltrim(empl_code)) &amp;quot;DRIVER_CODE&amp;quot;,&lt;br /&gt;
	replace(rtrim(ltrim(NAME)),'''','''''') &amp;quot;DRIVER_NAME&amp;quot;,&lt;br /&gt;
	rtrim(ltrim(empl.phone_num)) Phone_no,&lt;br /&gt;
	rtrim(ltrim(empl.assgn_plant_code)) Home_plant_no,&lt;br /&gt;
	--EMPL.*,&lt;br /&gt;
	''',''' QCQ,''',' q1,'=''' q2 -- these are helpers for the concat query&lt;br /&gt;
	from empl&lt;br /&gt;
	where driv_flag = 1&lt;br /&gt;
	and inactive_code='00'&lt;br /&gt;
)&lt;br /&gt;
select -- this creates insert from the core query&lt;br /&gt;
concat('INSERT INTO  artdriv ( DRIVER_CODE, DRIVER_NAME, PHONE_NO, HOME_PLANT_NO, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG,memo )  VALUES &lt;br /&gt;
( ''',driver_code,qcq,DRIVER_NAME,qcq,Phone_no,qcq,Home_plant_no,qcq ,'Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y',qcq,'Imported from Cmd'');'   ),&lt;br /&gt;
driv.* from driv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Salespeople (empl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with cs as &lt;br /&gt;
	( select distinct(ltrim(rtrim(cust.cc_slsmn_empl_code))) custslsmn from cust where inactive_code='00' ), -- LIst of slsmn in active customers&lt;br /&gt;
slsemp as -- all sls employees&lt;br /&gt;
	(SELECT &lt;br /&gt;
	rtrim(ltrim(empl.empl_code)) empno,&lt;br /&gt;
	rtrim(ltrim(empl.empl_code)) USER_1,&lt;br /&gt;
	rtrim(LTRIM(empl.NAME)) DESCRIPTION,&lt;br /&gt;
	rtrim(LTRIM(empl.PHONE_NUM)) PHONE_NO,&lt;br /&gt;
	rtrim(LTRIM(empl.ASSGN_PLANT_CODE)) USER_2&lt;br /&gt;
	 FROM empl&lt;br /&gt;
	where slsmn_flag='True') &lt;br /&gt;
,slpn as&lt;br /&gt;
	(&lt;br /&gt;
	select cs.*,slsemp.*,&lt;br /&gt;
	case custslsmn&lt;br /&gt;
	WHEN '182' THEN 'NJ'&lt;br /&gt;
	WHEN '322' THEN 'RM'&lt;br /&gt;
	WHEN 'S15' THEN '15'&lt;br /&gt;
	---...&lt;br /&gt;
	WHEN 'SALES' THEN 'SA'&lt;br /&gt;
	else custslsmn&lt;br /&gt;
	end class_no,''',''' qcq &lt;br /&gt;
	from cs&lt;br /&gt;
	INNER join slsemp on slsemp.empno=cs.custslsmn --only include slspn that are in active customers&lt;br /&gt;
	) select &lt;br /&gt;
concat ( 'INSERT INTO artslspn ( CLASS_NO, EMPLOYEE_NO, DESCRIPTION, PHONE_NO, USER_2 )  VALUES (''',class_no,qcq,empno,qcq,DESCRIPTION,qcq,PHONE_NO,qcq,USER_2,''');'),&lt;br /&gt;
slpn.* from slpn&lt;br /&gt;
order by custslsmn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
====Tax Locality====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with ttl (tax_loc,tax_auth,descr,rate) as&lt;br /&gt;
  (select -- Core query (can be used with QG)&lt;br /&gt;
  cast(tl.tax_loc as integer),cast(tl.tax_auth as integer),&lt;br /&gt;
  replace(replace(ltrim(rtrim(descr)),'(City of','('),'( ','('),&lt;br /&gt;
  max(prim_rate_curr_pct) from taxl tl&lt;br /&gt;
  inner join taxj tj on tl.tax_loc=tj.tax_loc and tl.tax_auth=tj.tax_auth&lt;br /&gt;
  group by tl.tax_loc,tl.tax_auth,descr&lt;br /&gt;
  )&lt;br /&gt;
select &lt;br /&gt;
concat('INSERT INTO ARTTXLOC&lt;br /&gt;
( TAX_LOCALITY, LINE_NO, DESCRIPTION, TAX_COL, LOC_LEVEL, TAX_RATE, CALC_METHOD, EFFECT_DATE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',100*tax_auth + tax_loc,''', ',tax_auth,',''',left(descr,35),''',1 ,',tax_auth,',',rate,', 1, ''01/01/1900'', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );'),&lt;br /&gt;
ttl.* from ttl&lt;br /&gt;
order by tax_auth,tax_loc;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tax Authority====&lt;br /&gt;
For the tax authority, we just need the code and the description...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with tc as&lt;br /&gt;
	(select ltrim(rtrim(tax_code)) &amp;quot;tax_code&amp;quot;,&lt;br /&gt;
	replace(replace(ltrim(rtrim(descr)),'(City of','('),'( ','(') &amp;quot;descr&amp;quot;&lt;br /&gt;
	from taxc)&lt;br /&gt;
select &lt;br /&gt;
concat('INSERT INTO ARTTXAUT ( TAX_AUTHORITY, DESCRIPTION, INCREASE_DISC_FLAG, DISC_INCLUDES_TAX, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',tax_code,''' , ''',left(descr,35),''', ''N'', ''Y'', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y'' );',''),&lt;br /&gt;
tc.* from tc;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  Import the actual group prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
Sample query:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select -- core query that can be used with qg&lt;br /&gt;
	ltrim(rtrim(price_cat)),&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from prcc&lt;br /&gt;
	)&lt;br /&gt;
select -- outer query &lt;br /&gt;
concat('INSERT INTO ARTPRGRP ( GROUP_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG)  VALUES &lt;br /&gt;
  ( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''  );')&lt;br /&gt;
,clsno &amp;quot;group&amp;quot;, descry description&lt;br /&gt;
from aaa&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Price Cat codes tend to be short and do not need to be mapped coming into Keystone.&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Class (sanl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
select top (10000) &lt;br /&gt;
LTRIM(RTRIM(cust.CUST_CODE)) CUST_NO,&lt;br /&gt;
RTRIM(replace(left(ltrim(rtrim(CUST.NAME)),30),'''','''''')) name,&lt;br /&gt;
replace(left(LTRIM(RTRIM(CUST.ADDR_LINE_1)),30),'''','''''') address_1,&lt;br /&gt;
replace(left(LTRIM(RTRIM(CUST.ADDR_LINE_2)),30),'''','''''') address_2,&lt;br /&gt;
left(replace(ltrim(rtrim(addr_city)),',',''),16) CITY,&lt;br /&gt;
replace(LEFT(rtrim(ltrim(ADDR_STATE)),2),'M0','MO') STATE,&lt;br /&gt;
addr_state,&lt;br /&gt;
ltrim(rtrim(PHONE_NUM_1)) phone_no,PHONE_NUM_2,PHONE_NUM_3,&lt;br /&gt;
LTRIM(RTRIM(ADDR_POSTCD)) ZIP,ltrim(rtrim(cust.tax_code)) &amp;quot;TAX_AUTHORITY&amp;quot;,&lt;br /&gt;
--cast(cust.tax_code as integer) txcd_int,&lt;br /&gt;
--left(LTRIM(RTRIM(taxj.tax_loc)),3) TAX_AUTHORITY,&lt;br /&gt;
case ltrim(rtrim(cc_terms_code)) &lt;br /&gt;
  when '10N' THEN '1N'&lt;br /&gt;
  WHEN '15T' THEN '5T'&lt;br /&gt;
  WHEN '2.5' THEN '25'&lt;br /&gt;
  ELSE LTRIM(RTRIM(cc_TERMS_CODE)) END terms_class, --folsom mapping&lt;br /&gt;
LTRIM(RTRIM(CC_TERMS_CODE)) TERMS,&lt;br /&gt;
LTRIM(RTRIM(UPPER(CC_SALES_ANL_CODE))) CUCLS, -- unmapped&lt;br /&gt;
case ltrim(rtrim(cc_sales_anl_code)) --use cust class import mapping&lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	-- ... &lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(cc_sales_anl_code))  end &amp;quot;cust_class&amp;quot;,  &lt;br /&gt;
rtrim(LTRIM(CC_SLSMN_EMPL_CODE)) SLS_EMP,&lt;br /&gt;
case rtrim(LTRIM(CC_SLSMN_EMPL_CODE)) &lt;br /&gt;
	WHEN '182' THEN 'NJ' -- same mapping as slspn import&lt;br /&gt;
	--... &lt;br /&gt;
	WHEN 'SALES' THEN 'SA'&lt;br /&gt;
	else rtrim(LTRIM(CC_SLSMN_EMPL_CODE))  end salesperson,&lt;br /&gt;
rtrim(LTRIM(CC_PRICE_CAT)) PRICE_GROUP,&lt;br /&gt;
rtrim(LTRIM(CC_PRICE_PLANT_CODE) ) PRICE_PLANT,&lt;br /&gt;
CASE TAXBLE_CODE WHEN '1' then '' else CONCAT('TAX EXMPT RSN:', LTRIM(NON_TAX_RSN_CODE) ) END TAX_RSN,&lt;br /&gt;
rtrim(LTRIM(INACTIVE_CODE)) INACTIVE_CODE,&lt;br /&gt;
iif(rtrim(LTRIM(INACTIVE_CODE))='00','Y','N') active_flag,&lt;br /&gt;
CASE LTRIM(RTRIM(TAXBLE_CODE)) WHEN 1 THEN 'Y' ELSE 'N' END TAX_CODE,&lt;br /&gt;
CONCAT('Acct Cat Code: ',RTRIM(LTRIM(ACCT_CAT_CODE))) USER_2,&lt;br /&gt;
replace(LEFT(rtrim(ltrim(CONTCT_NAME)),30),'''','''''')CONTACT,&lt;br /&gt;
LEFT(replace(LTRIM(RTRIM(SORT_NAME)),'''',''),30) SEQUENCE_CODE,&lt;br /&gt;
acct_cat_code&lt;br /&gt;
--,cast(coalesce(SETUP_DATE,'1/1/1900') as date) start_date&lt;br /&gt;
,convert(varchar(10), setup_date, 101) start_date,&lt;br /&gt;
ltrim(rtrim(cust.tax_id_code)) Tax_id&lt;br /&gt;
from cust&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Product Class (icat)===&lt;br /&gt;
&lt;br /&gt;
A good product class table is essential for a Command conversion.&lt;br /&gt;
&lt;br /&gt;
You will mostly likely need to map long item cat codes to product class codes.  Instead of making them like the CMD item cat codes, so focus on making a well organized Keystone list and then have the customer help you mapping CMD item categories to Keystone classes.&lt;br /&gt;
&lt;br /&gt;
Separate the sellable ingredient items for admixes, colors etc. from the non-sellable ingredient codes.&lt;br /&gt;
When creating product classes, set the defaults for sellable, product type and ingredient type.  Then use the following script to update:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
update artprod p set  sellable_flag =(select std_sellable_flag from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  product_type =(select std_product_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  ingredient_type =(select std_ingredient_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup default sales G/L and make sure the plants are properly masked.  You can use a variant of this script to update yoru sales g/l accounts...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
UPDATE ARTPROD P&lt;br /&gt;
SET p.SALES_GL=&lt;br /&gt;
(select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class)||&lt;br /&gt;
(select substr(sales_gl_plant_mask,9,19) from artplant pl where pl.plant_no=p.plant_no)&lt;br /&gt;
where (select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class) is not null&lt;br /&gt;
and p.product_class IN ('AA','BB','CC')  -- Optionally only do this for select classes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Products===&lt;br /&gt;
Products are stored in 2 tables, imst and iloc.&lt;br /&gt;
*'''IMST:''' Product &amp;quot;Base&amp;quot;.  One record for base product that stores the category (class) description etc.&lt;br /&gt;
*'''ILOC:''' Product by Location&lt;br /&gt;
&lt;br /&gt;
These need to be combined to create keystone products.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Component Structure (icst)===&lt;br /&gt;
CMD dispatch mixes rarely are worth importing.  Verify with customer, but expect to import directly from batch controls.&lt;br /&gt;
&lt;br /&gt;
===Credit Terms (TRMS)===&lt;br /&gt;
You can import term codes and descriptions, but the meaning does not map from system to system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WITH T AS (&lt;br /&gt;
	SELECT &lt;br /&gt;
	case ltrim(rtrim(terms_code)) -- setup mapping for terms longer than 2 char.  Save for customer import etc.&lt;br /&gt;
		when '10N' THEN '1N'&lt;br /&gt;
		WHEN '15T' THEN '5T'&lt;br /&gt;
		WHEN '2.5' THEN '25'&lt;br /&gt;
		ELSE LTRIM(RTRIM(TERMS_CODE)) END CLASS_NO&lt;br /&gt;
	,LEFT(LTRIM(RTRIM(descr)),30) DESCRIPTION&lt;br /&gt;
	FROM dbo.trms&lt;br /&gt;
  )&lt;br /&gt;
  SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTCTCLS (CLASS_NO,DESCRIPTION) VALUES (''',CLASS_NO,''',''',DESCRIPTION,''');'),&lt;br /&gt;
  * FROM T&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trucks===&lt;br /&gt;
Trucks&lt;br /&gt;
&lt;br /&gt;
===Unit of Meausure (uoms)===&lt;br /&gt;
The key field for Unit of Measure is typically a long integer.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Prices (CPRD)===&lt;br /&gt;
&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List and Group Prices (IPRC)===&lt;br /&gt;
The table IPRC stores Category (cmd)/Group Prices and the equivelent of List prices.  Category &amp;quot;#&amp;quot; is represents &amp;quot;List&amp;quot; in Keystone.&lt;br /&gt;
*Many times, what appears to be a Group(cat) is in fact used as a list price.  You can preview the iprc data to the customer to determine this before the install.   You can also import into Keystone and then convert a group to list prices.&lt;br /&gt;
*Often, a large amount of junk pricing is in this table.  Preview to customer to determine if large amounts of pricing should be omitted.&lt;br /&gt;
*Where in Keystone, we often base pricing on X$ off list for a group or customer, in Command each price ends up as a record.  If possible, find groups (price cats) that can be skipped and replaced with a price off list.  (this may only apply to the mix items in a group/price cat)&lt;br /&gt;
*Expect redundant records that tneed to be processed by effect date.  (Use of RANK or similar SQL tricks can correct for this)&lt;br /&gt;
*Expect Prices for items that may or may not exist.&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Job (proj)====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Base selection on Expir_date, Setup_date and the inactive_code of projects, customers, iloc and imst.&lt;br /&gt;
&lt;br /&gt;
====Job Detail (prjp)====&lt;br /&gt;
*Tie this selection to the core query used for PROJ&lt;br /&gt;
*Plant # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
===Zone===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTzone (zone,DESCRIPTION,def_tax_authority) VALUES (''',rtrim(ltrim(zone_code)),&lt;br /&gt;
  ''',''',left(rtrim(ltrim(DESCR)),35),&lt;br /&gt;
  ''',''',rtrim(ltrim(tax_code)),''');'),&lt;br /&gt;
  zone.* &lt;br /&gt;
 FROM ZONE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=951</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=951"/>
		<updated>2024-02-26T13:58:24Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Customer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants (Locn/Plnt)===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  &lt;br /&gt;
&lt;br /&gt;
*LOCN: Locations&lt;br /&gt;
*PLNT: Plant&lt;br /&gt;
&lt;br /&gt;
Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
===Drivers (empl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with driv as (&lt;br /&gt;
	SELECT  --the core query &lt;br /&gt;
	rtrim(ltrim(empl_code)) &amp;quot;DRIVER_CODE&amp;quot;,&lt;br /&gt;
	replace(rtrim(ltrim(NAME)),'''','''''') &amp;quot;DRIVER_NAME&amp;quot;,&lt;br /&gt;
	rtrim(ltrim(empl.phone_num)) Phone_no,&lt;br /&gt;
	rtrim(ltrim(empl.assgn_plant_code)) Home_plant_no,&lt;br /&gt;
	--EMPL.*,&lt;br /&gt;
	''',''' QCQ,''',' q1,'=''' q2 -- these are helpers for the concat query&lt;br /&gt;
	from empl&lt;br /&gt;
	where driv_flag = 1&lt;br /&gt;
	and inactive_code='00'&lt;br /&gt;
)&lt;br /&gt;
select -- this creates insert from the core query&lt;br /&gt;
concat('INSERT INTO  artdriv ( DRIVER_CODE, DRIVER_NAME, PHONE_NO, HOME_PLANT_NO, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG,memo )  VALUES &lt;br /&gt;
( ''',driver_code,qcq,DRIVER_NAME,qcq,Phone_no,qcq,Home_plant_no,qcq ,'Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y',qcq,'Imported from Cmd'');'   ),&lt;br /&gt;
driv.* from driv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Salespeople (empl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with cs as &lt;br /&gt;
	( select distinct(ltrim(rtrim(cust.cc_slsmn_empl_code))) custslsmn from cust where inactive_code='00' ), -- LIst of slsmn in active customers&lt;br /&gt;
slsemp as -- all sls employees&lt;br /&gt;
	(SELECT &lt;br /&gt;
	rtrim(ltrim(empl.empl_code)) empno,&lt;br /&gt;
	rtrim(ltrim(empl.empl_code)) USER_1,&lt;br /&gt;
	rtrim(LTRIM(empl.NAME)) DESCRIPTION,&lt;br /&gt;
	rtrim(LTRIM(empl.PHONE_NUM)) PHONE_NO,&lt;br /&gt;
	rtrim(LTRIM(empl.ASSGN_PLANT_CODE)) USER_2&lt;br /&gt;
	 FROM empl&lt;br /&gt;
	where slsmn_flag='True') &lt;br /&gt;
,slpn as&lt;br /&gt;
	(&lt;br /&gt;
	select cs.*,slsemp.*,&lt;br /&gt;
	case custslsmn&lt;br /&gt;
	WHEN '182' THEN 'NJ'&lt;br /&gt;
	WHEN '322' THEN 'RM'&lt;br /&gt;
	WHEN 'S15' THEN '15'&lt;br /&gt;
	---...&lt;br /&gt;
	WHEN 'SALES' THEN 'SA'&lt;br /&gt;
	else custslsmn&lt;br /&gt;
	end class_no,''',''' qcq &lt;br /&gt;
	from cs&lt;br /&gt;
	INNER join slsemp on slsemp.empno=cs.custslsmn --only include slspn that are in active customers&lt;br /&gt;
	) select &lt;br /&gt;
concat ( 'INSERT INTO artslspn ( CLASS_NO, EMPLOYEE_NO, DESCRIPTION, PHONE_NO, USER_2 )  VALUES (''',class_no,qcq,empno,qcq,DESCRIPTION,qcq,PHONE_NO,qcq,USER_2,''');'),&lt;br /&gt;
slpn.* from slpn&lt;br /&gt;
order by custslsmn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
====Tax Locality====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with ttl (tax_loc,tax_auth,descr,rate) as&lt;br /&gt;
  (select -- Core query (can be used with QG)&lt;br /&gt;
  cast(tl.tax_loc as integer),cast(tl.tax_auth as integer),&lt;br /&gt;
  replace(replace(ltrim(rtrim(descr)),'(City of','('),'( ','('),&lt;br /&gt;
  max(prim_rate_curr_pct) from taxl tl&lt;br /&gt;
  inner join taxj tj on tl.tax_loc=tj.tax_loc and tl.tax_auth=tj.tax_auth&lt;br /&gt;
  group by tl.tax_loc,tl.tax_auth,descr&lt;br /&gt;
  )&lt;br /&gt;
select &lt;br /&gt;
concat('INSERT INTO ARTTXLOC&lt;br /&gt;
( TAX_LOCALITY, LINE_NO, DESCRIPTION, TAX_COL, LOC_LEVEL, TAX_RATE, CALC_METHOD, EFFECT_DATE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',100*tax_auth + tax_loc,''', ',tax_auth,',''',left(descr,35),''',1 ,',tax_auth,',',rate,', 1, ''01/01/1900'', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );'),&lt;br /&gt;
ttl.* from ttl&lt;br /&gt;
order by tax_auth,tax_loc;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tax Authority====&lt;br /&gt;
For the tax authority, we just need the code and the description...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with tc as&lt;br /&gt;
	(select ltrim(rtrim(tax_code)) &amp;quot;tax_code&amp;quot;,&lt;br /&gt;
	replace(replace(ltrim(rtrim(descr)),'(City of','('),'( ','(') &amp;quot;descr&amp;quot;&lt;br /&gt;
	from taxc)&lt;br /&gt;
select &lt;br /&gt;
concat('INSERT INTO ARTTXAUT ( TAX_AUTHORITY, DESCRIPTION, INCREASE_DISC_FLAG, DISC_INCLUDES_TAX, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',tax_code,''' , ''',left(descr,35),''', ''N'', ''Y'', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y'' );',''),&lt;br /&gt;
tc.* from tc;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  Import the actual group prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
Sample query:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select -- core query that can be used with qg&lt;br /&gt;
	ltrim(rtrim(price_cat)),&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from prcc&lt;br /&gt;
	)&lt;br /&gt;
select -- outer query &lt;br /&gt;
concat('INSERT INTO ARTPRGRP ( GROUP_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG)  VALUES &lt;br /&gt;
  ( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''  );')&lt;br /&gt;
,clsno &amp;quot;group&amp;quot;, descry description&lt;br /&gt;
from aaa&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Price Cat codes tend to be short and do not need to be mapped coming into Keystone.&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Class (sanl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Product Class (icat)===&lt;br /&gt;
&lt;br /&gt;
A good product class table is essential for a Command conversion.&lt;br /&gt;
&lt;br /&gt;
You will mostly likely need to map long item cat codes to product class codes.  Instead of making them like the CMD item cat codes, so focus on making a well organized Keystone list and then have the customer help you mapping CMD item categories to Keystone classes.&lt;br /&gt;
&lt;br /&gt;
Separate the sellable ingredient items for admixes, colors etc. from the non-sellable ingredient codes.&lt;br /&gt;
When creating product classes, set the defaults for sellable, product type and ingredient type.  Then use the following script to update:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
update artprod p set  sellable_flag =(select std_sellable_flag from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  product_type =(select std_product_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  ingredient_type =(select std_ingredient_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup default sales G/L and make sure the plants are properly masked.  You can use a variant of this script to update yoru sales g/l accounts...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
UPDATE ARTPROD P&lt;br /&gt;
SET p.SALES_GL=&lt;br /&gt;
(select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class)||&lt;br /&gt;
(select substr(sales_gl_plant_mask,9,19) from artplant pl where pl.plant_no=p.plant_no)&lt;br /&gt;
where (select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class) is not null&lt;br /&gt;
and p.product_class IN ('AA','BB','CC')  -- Optionally only do this for select classes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Products===&lt;br /&gt;
Products are stored in 2 tables, imst and iloc.&lt;br /&gt;
*'''IMST:''' Product &amp;quot;Base&amp;quot;.  One record for base product that stores the category (class) description etc.&lt;br /&gt;
*'''ILOC:''' Product by Location&lt;br /&gt;
&lt;br /&gt;
These need to be combined to create keystone products.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Component Structure (icst)===&lt;br /&gt;
CMD dispatch mixes rarely are worth importing.  Verify with customer, but expect to import directly from batch controls.&lt;br /&gt;
&lt;br /&gt;
===Credit Terms (TRMS)===&lt;br /&gt;
You can import term codes and descriptions, but the meaning does not map from system to system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WITH T AS (&lt;br /&gt;
	SELECT &lt;br /&gt;
	case ltrim(rtrim(terms_code)) -- setup mapping for terms longer than 2 char.  Save for customer import etc.&lt;br /&gt;
		when '10N' THEN '1N'&lt;br /&gt;
		WHEN '15T' THEN '5T'&lt;br /&gt;
		WHEN '2.5' THEN '25'&lt;br /&gt;
		ELSE LTRIM(RTRIM(TERMS_CODE)) END CLASS_NO&lt;br /&gt;
	,LEFT(LTRIM(RTRIM(descr)),30) DESCRIPTION&lt;br /&gt;
	FROM dbo.trms&lt;br /&gt;
  )&lt;br /&gt;
  SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTCTCLS (CLASS_NO,DESCRIPTION) VALUES (''',CLASS_NO,''',''',DESCRIPTION,''');'),&lt;br /&gt;
  * FROM T&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trucks===&lt;br /&gt;
Trucks&lt;br /&gt;
&lt;br /&gt;
===Unit of Meausure (uoms)===&lt;br /&gt;
The key field for Unit of Measure is typically a long integer.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Prices (CPRD)===&lt;br /&gt;
&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List and Group Prices (IPRC)===&lt;br /&gt;
The table IPRC stores Category (cmd)/Group Prices and the equivelent of List prices.  Category &amp;quot;#&amp;quot; is represents &amp;quot;List&amp;quot; in Keystone.&lt;br /&gt;
*Many times, what appears to be a Group(cat) is in fact used as a list price.  You can preview the iprc data to the customer to determine this before the install.   You can also import into Keystone and then convert a group to list prices.&lt;br /&gt;
*Often, a large amount of junk pricing is in this table.  Preview to customer to determine if large amounts of pricing should be omitted.&lt;br /&gt;
*Where in Keystone, we often base pricing on X$ off list for a group or customer, in Command each price ends up as a record.  If possible, find groups (price cats) that can be skipped and replaced with a price off list.  (this may only apply to the mix items in a group/price cat)&lt;br /&gt;
*Expect redundant records that tneed to be processed by effect date.  (Use of RANK or similar SQL tricks can correct for this)&lt;br /&gt;
*Expect Prices for items that may or may not exist.&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Job (proj)====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Base selection on Expir_date, Setup_date and the inactive_code of projects, customers, iloc and imst.&lt;br /&gt;
&lt;br /&gt;
====Job Detail (prjp)====&lt;br /&gt;
*Tie this selection to the core query used for PROJ&lt;br /&gt;
*Plant # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
===Zone===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTzone (zone,DESCRIPTION,def_tax_authority) VALUES (''',rtrim(ltrim(zone_code)),&lt;br /&gt;
  ''',''',left(rtrim(ltrim(DESCR)),35),&lt;br /&gt;
  ''',''',rtrim(ltrim(tax_code)),''');'),&lt;br /&gt;
  zone.* &lt;br /&gt;
 FROM ZONE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=950</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=950"/>
		<updated>2024-02-26T13:57:54Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Salespeople (empl) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants (Locn/Plnt)===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  &lt;br /&gt;
&lt;br /&gt;
*LOCN: Locations&lt;br /&gt;
*PLNT: Plant&lt;br /&gt;
&lt;br /&gt;
Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
===Drivers (empl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with driv as (&lt;br /&gt;
	SELECT  --the core query &lt;br /&gt;
	rtrim(ltrim(empl_code)) &amp;quot;DRIVER_CODE&amp;quot;,&lt;br /&gt;
	replace(rtrim(ltrim(NAME)),'''','''''') &amp;quot;DRIVER_NAME&amp;quot;,&lt;br /&gt;
	rtrim(ltrim(empl.phone_num)) Phone_no,&lt;br /&gt;
	rtrim(ltrim(empl.assgn_plant_code)) Home_plant_no,&lt;br /&gt;
	--EMPL.*,&lt;br /&gt;
	''',''' QCQ,''',' q1,'=''' q2 -- these are helpers for the concat query&lt;br /&gt;
	from empl&lt;br /&gt;
	where driv_flag = 1&lt;br /&gt;
	and inactive_code='00'&lt;br /&gt;
)&lt;br /&gt;
select -- this creates insert from the core query&lt;br /&gt;
concat('INSERT INTO  artdriv ( DRIVER_CODE, DRIVER_NAME, PHONE_NO, HOME_PLANT_NO, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG,memo )  VALUES &lt;br /&gt;
( ''',driver_code,qcq,DRIVER_NAME,qcq,Phone_no,qcq,Home_plant_no,qcq ,'Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y',qcq,'Imported from Cmd'');'   ),&lt;br /&gt;
driv.* from driv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Salespeople (empl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with cs as &lt;br /&gt;
	( select distinct(ltrim(rtrim(cust.cc_slsmn_empl_code))) custslsmn from cust where inactive_code='00' ), -- LIst of slsmn in active customers&lt;br /&gt;
slsemp as -- all sls employees&lt;br /&gt;
	(SELECT &lt;br /&gt;
	rtrim(ltrim(empl.empl_code)) empno,&lt;br /&gt;
	rtrim(ltrim(empl.empl_code)) USER_1,&lt;br /&gt;
	rtrim(LTRIM(empl.NAME)) DESCRIPTION,&lt;br /&gt;
	rtrim(LTRIM(empl.PHONE_NUM)) PHONE_NO,&lt;br /&gt;
	rtrim(LTRIM(empl.ASSGN_PLANT_CODE)) USER_2&lt;br /&gt;
	 FROM empl&lt;br /&gt;
	where slsmn_flag='True') &lt;br /&gt;
,slpn as&lt;br /&gt;
	(&lt;br /&gt;
	select cs.*,slsemp.*,&lt;br /&gt;
	case custslsmn&lt;br /&gt;
	WHEN '182' THEN 'NJ'&lt;br /&gt;
	WHEN '322' THEN 'RM'&lt;br /&gt;
	WHEN 'S15' THEN '15'&lt;br /&gt;
	---...&lt;br /&gt;
	WHEN 'SALES' THEN 'SA'&lt;br /&gt;
	else custslsmn&lt;br /&gt;
	end class_no,''',''' qcq &lt;br /&gt;
	from cs&lt;br /&gt;
	INNER join slsemp on slsemp.empno=cs.custslsmn --only include slspn that are in active customers&lt;br /&gt;
	) select &lt;br /&gt;
concat ( 'INSERT INTO artslspn ( CLASS_NO, EMPLOYEE_NO, DESCRIPTION, PHONE_NO, USER_2 )  VALUES (''',class_no,qcq,empno,qcq,DESCRIPTION,qcq,PHONE_NO,qcq,USER_2,''');'),&lt;br /&gt;
slpn.* from slpn&lt;br /&gt;
order by custslsmn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
====Tax Locality====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with ttl (tax_loc,tax_auth,descr,rate) as&lt;br /&gt;
  (select -- Core query (can be used with QG)&lt;br /&gt;
  cast(tl.tax_loc as integer),cast(tl.tax_auth as integer),&lt;br /&gt;
  replace(replace(ltrim(rtrim(descr)),'(City of','('),'( ','('),&lt;br /&gt;
  max(prim_rate_curr_pct) from taxl tl&lt;br /&gt;
  inner join taxj tj on tl.tax_loc=tj.tax_loc and tl.tax_auth=tj.tax_auth&lt;br /&gt;
  group by tl.tax_loc,tl.tax_auth,descr&lt;br /&gt;
  )&lt;br /&gt;
select &lt;br /&gt;
concat('INSERT INTO ARTTXLOC&lt;br /&gt;
( TAX_LOCALITY, LINE_NO, DESCRIPTION, TAX_COL, LOC_LEVEL, TAX_RATE, CALC_METHOD, EFFECT_DATE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',100*tax_auth + tax_loc,''', ',tax_auth,',''',left(descr,35),''',1 ,',tax_auth,',',rate,', 1, ''01/01/1900'', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );'),&lt;br /&gt;
ttl.* from ttl&lt;br /&gt;
order by tax_auth,tax_loc;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tax Authority====&lt;br /&gt;
For the tax authority, we just need the code and the description...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with tc as&lt;br /&gt;
	(select ltrim(rtrim(tax_code)) &amp;quot;tax_code&amp;quot;,&lt;br /&gt;
	replace(replace(ltrim(rtrim(descr)),'(City of','('),'( ','(') &amp;quot;descr&amp;quot;&lt;br /&gt;
	from taxc)&lt;br /&gt;
select &lt;br /&gt;
concat('INSERT INTO ARTTXAUT ( TAX_AUTHORITY, DESCRIPTION, INCREASE_DISC_FLAG, DISC_INCLUDES_TAX, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',tax_code,''' , ''',left(descr,35),''', ''N'', ''Y'', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y'' );',''),&lt;br /&gt;
tc.* from tc;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  Import the actual group prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
Sample query:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select -- core query that can be used with qg&lt;br /&gt;
	ltrim(rtrim(price_cat)),&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from prcc&lt;br /&gt;
	)&lt;br /&gt;
select -- outer query &lt;br /&gt;
concat('INSERT INTO ARTPRGRP ( GROUP_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG)  VALUES &lt;br /&gt;
  ( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''  );')&lt;br /&gt;
,clsno &amp;quot;group&amp;quot;, descry description&lt;br /&gt;
from aaa&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Price Cat codes tend to be short and do not need to be mapped coming into Keystone.&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Class (sanl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Product Class (icat)===&lt;br /&gt;
&lt;br /&gt;
A good product class table is essential for a Command conversion.&lt;br /&gt;
&lt;br /&gt;
You will mostly likely need to map long item cat codes to product class codes.  Instead of making them like the CMD item cat codes, so focus on making a well organized Keystone list and then have the customer help you mapping CMD item categories to Keystone classes.&lt;br /&gt;
&lt;br /&gt;
Separate the sellable ingredient items for admixes, colors etc. from the non-sellable ingredient codes.&lt;br /&gt;
When creating product classes, set the defaults for sellable, product type and ingredient type.  Then use the following script to update:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
update artprod p set  sellable_flag =(select std_sellable_flag from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  product_type =(select std_product_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  ingredient_type =(select std_ingredient_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup default sales G/L and make sure the plants are properly masked.  You can use a variant of this script to update yoru sales g/l accounts...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
UPDATE ARTPROD P&lt;br /&gt;
SET p.SALES_GL=&lt;br /&gt;
(select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class)||&lt;br /&gt;
(select substr(sales_gl_plant_mask,9,19) from artplant pl where pl.plant_no=p.plant_no)&lt;br /&gt;
where (select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class) is not null&lt;br /&gt;
and p.product_class IN ('AA','BB','CC')  -- Optionally only do this for select classes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Products===&lt;br /&gt;
Products are stored in 2 tables, imst and iloc.&lt;br /&gt;
*'''IMST:''' Product &amp;quot;Base&amp;quot;.  One record for base product that stores the category (class) description etc.&lt;br /&gt;
*'''ILOC:''' Product by Location&lt;br /&gt;
&lt;br /&gt;
These need to be combined to create keystone products.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Component Structure (icst)===&lt;br /&gt;
CMD dispatch mixes rarely are worth importing.  Verify with customer, but expect to import directly from batch controls.&lt;br /&gt;
&lt;br /&gt;
===Credit Terms (TRMS)===&lt;br /&gt;
You can import term codes and descriptions, but the meaning does not map from system to system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WITH T AS (&lt;br /&gt;
	SELECT &lt;br /&gt;
	case ltrim(rtrim(terms_code)) -- setup mapping for terms longer than 2 char.  Save for customer import etc.&lt;br /&gt;
		when '10N' THEN '1N'&lt;br /&gt;
		WHEN '15T' THEN '5T'&lt;br /&gt;
		WHEN '2.5' THEN '25'&lt;br /&gt;
		ELSE LTRIM(RTRIM(TERMS_CODE)) END CLASS_NO&lt;br /&gt;
	,LEFT(LTRIM(RTRIM(descr)),30) DESCRIPTION&lt;br /&gt;
	FROM dbo.trms&lt;br /&gt;
  )&lt;br /&gt;
  SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTCTCLS (CLASS_NO,DESCRIPTION) VALUES (''',CLASS_NO,''',''',DESCRIPTION,''');'),&lt;br /&gt;
  * FROM T&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trucks===&lt;br /&gt;
Trucks&lt;br /&gt;
&lt;br /&gt;
===Unit of Meausure (uoms)===&lt;br /&gt;
The key field for Unit of Measure is typically a long integer.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Prices (CPRD)===&lt;br /&gt;
&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List and Group Prices (IPRC)===&lt;br /&gt;
The table IPRC stores Category (cmd)/Group Prices and the equivelent of List prices.  Category &amp;quot;#&amp;quot; is represents &amp;quot;List&amp;quot; in Keystone.&lt;br /&gt;
*Many times, what appears to be a Group(cat) is in fact used as a list price.  You can preview the iprc data to the customer to determine this before the install.   You can also import into Keystone and then convert a group to list prices.&lt;br /&gt;
*Often, a large amount of junk pricing is in this table.  Preview to customer to determine if large amounts of pricing should be omitted.&lt;br /&gt;
*Where in Keystone, we often base pricing on X$ off list for a group or customer, in Command each price ends up as a record.  If possible, find groups (price cats) that can be skipped and replaced with a price off list.  (this may only apply to the mix items in a group/price cat)&lt;br /&gt;
*Expect redundant records that tneed to be processed by effect date.  (Use of RANK or similar SQL tricks can correct for this)&lt;br /&gt;
*Expect Prices for items that may or may not exist.&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Job (proj)====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Base selection on Expir_date, Setup_date and the inactive_code of projects, customers, iloc and imst.&lt;br /&gt;
&lt;br /&gt;
====Job Detail (prjp)====&lt;br /&gt;
*Tie this selection to the core query used for PROJ&lt;br /&gt;
*Plant # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
===Zone===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTzone (zone,DESCRIPTION,def_tax_authority) VALUES (''',rtrim(ltrim(zone_code)),&lt;br /&gt;
  ''',''',left(rtrim(ltrim(DESCR)),35),&lt;br /&gt;
  ''',''',rtrim(ltrim(tax_code)),''');'),&lt;br /&gt;
  zone.* &lt;br /&gt;
 FROM ZONE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=949</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=949"/>
		<updated>2024-02-26T13:25:25Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants (Locn/Plnt)===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  &lt;br /&gt;
&lt;br /&gt;
*LOCN: Locations&lt;br /&gt;
*PLNT: Plant&lt;br /&gt;
&lt;br /&gt;
Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
===Drivers (empl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with driv as (&lt;br /&gt;
	SELECT  --the core query &lt;br /&gt;
	rtrim(ltrim(empl_code)) &amp;quot;DRIVER_CODE&amp;quot;,&lt;br /&gt;
	replace(rtrim(ltrim(NAME)),'''','''''') &amp;quot;DRIVER_NAME&amp;quot;,&lt;br /&gt;
	rtrim(ltrim(empl.phone_num)) Phone_no,&lt;br /&gt;
	rtrim(ltrim(empl.assgn_plant_code)) Home_plant_no,&lt;br /&gt;
	--EMPL.*,&lt;br /&gt;
	''',''' QCQ,''',' q1,'=''' q2 -- these are helpers for the concat query&lt;br /&gt;
	from empl&lt;br /&gt;
	where driv_flag = 1&lt;br /&gt;
	and inactive_code='00'&lt;br /&gt;
)&lt;br /&gt;
select -- this creates insert from the core query&lt;br /&gt;
concat('INSERT INTO  artdriv ( DRIVER_CODE, DRIVER_NAME, PHONE_NO, HOME_PLANT_NO, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG,memo )  VALUES &lt;br /&gt;
( ''',driver_code,qcq,DRIVER_NAME,qcq,Phone_no,qcq,Home_plant_no,qcq ,'Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y',qcq,'Imported from Cmd'');'   ),&lt;br /&gt;
driv.* from driv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Salespeople (empl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with cs as &lt;br /&gt;
( select distinct(ltrim(rtrim(cust.cc_slsmn_empl_code))) custslsmn from cust where inactive_code='00' ),&lt;br /&gt;
slsemp as&lt;br /&gt;
(SELECT &lt;br /&gt;
rtrim(ltrim(empl.empl_code)) empno,&lt;br /&gt;
rtrim(ltrim(empl.empl_code)) USER_1,&lt;br /&gt;
rtrim(LTRIM(empl.NAME)) DESCRIPTION,&lt;br /&gt;
rtrim(LTRIM(empl.PHONE_NUM)) PHONE_NO,&lt;br /&gt;
rtrim(LTRIM(empl.ASSGN_PLANT_CODE)) USER_2&lt;br /&gt;
 FROM empl&lt;br /&gt;
where slsmn_flag='True')&lt;br /&gt;
,slpn as&lt;br /&gt;
(&lt;br /&gt;
select cs.*,slsemp.*,&lt;br /&gt;
case custslsmn&lt;br /&gt;
WHEN '182' THEN 'NJ'&lt;br /&gt;
WHEN '322' THEN 'RM'&lt;br /&gt;
...&lt;br /&gt;
WHEN 'SALES' THEN 'SA'&lt;br /&gt;
else custslsmn&lt;br /&gt;
end class_no,''',''' qcq&lt;br /&gt;
from cs&lt;br /&gt;
left outer join slsemp on slsemp.empno=cs.custslsmn&lt;br /&gt;
) select &lt;br /&gt;
concat ( 'INSERT INTO artslspn ( CLASS_NO, EMPLOYEE_NO, DESCRIPTION, PHONE_NO, USER_2 )  VALUES (''',class_no,qcq,empno,qcq,DESCRIPTION,qcq,PHONE_NO,qcq,USER_2,''');'),&lt;br /&gt;
slpn.* from slpn&lt;br /&gt;
order by custslsmn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
====Tax Locality====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with ttl (tax_loc,tax_auth,descr,rate) as&lt;br /&gt;
  (select -- Core query (can be used with QG)&lt;br /&gt;
  cast(tl.tax_loc as integer),cast(tl.tax_auth as integer),&lt;br /&gt;
  replace(replace(ltrim(rtrim(descr)),'(City of','('),'( ','('),&lt;br /&gt;
  max(prim_rate_curr_pct) from taxl tl&lt;br /&gt;
  inner join taxj tj on tl.tax_loc=tj.tax_loc and tl.tax_auth=tj.tax_auth&lt;br /&gt;
  group by tl.tax_loc,tl.tax_auth,descr&lt;br /&gt;
  )&lt;br /&gt;
select &lt;br /&gt;
concat('INSERT INTO ARTTXLOC&lt;br /&gt;
( TAX_LOCALITY, LINE_NO, DESCRIPTION, TAX_COL, LOC_LEVEL, TAX_RATE, CALC_METHOD, EFFECT_DATE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',100*tax_auth + tax_loc,''', ',tax_auth,',''',left(descr,35),''',1 ,',tax_auth,',',rate,', 1, ''01/01/1900'', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );'),&lt;br /&gt;
ttl.* from ttl&lt;br /&gt;
order by tax_auth,tax_loc;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tax Authority====&lt;br /&gt;
For the tax authority, we just need the code and the description...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with tc as&lt;br /&gt;
	(select ltrim(rtrim(tax_code)) &amp;quot;tax_code&amp;quot;,&lt;br /&gt;
	replace(replace(ltrim(rtrim(descr)),'(City of','('),'( ','(') &amp;quot;descr&amp;quot;&lt;br /&gt;
	from taxc)&lt;br /&gt;
select &lt;br /&gt;
concat('INSERT INTO ARTTXAUT ( TAX_AUTHORITY, DESCRIPTION, INCREASE_DISC_FLAG, DISC_INCLUDES_TAX, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',tax_code,''' , ''',left(descr,35),''', ''N'', ''Y'', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y'' );',''),&lt;br /&gt;
tc.* from tc;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  Import the actual group prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
Sample query:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select -- core query that can be used with qg&lt;br /&gt;
	ltrim(rtrim(price_cat)),&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from prcc&lt;br /&gt;
	)&lt;br /&gt;
select -- outer query &lt;br /&gt;
concat('INSERT INTO ARTPRGRP ( GROUP_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG)  VALUES &lt;br /&gt;
  ( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''  );')&lt;br /&gt;
,clsno &amp;quot;group&amp;quot;, descry description&lt;br /&gt;
from aaa&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Price Cat codes tend to be short and do not need to be mapped coming into Keystone.&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Class (sanl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Product Class (icat)===&lt;br /&gt;
&lt;br /&gt;
A good product class table is essential for a Command conversion.&lt;br /&gt;
&lt;br /&gt;
You will mostly likely need to map long item cat codes to product class codes.  Instead of making them like the CMD item cat codes, so focus on making a well organized Keystone list and then have the customer help you mapping CMD item categories to Keystone classes.&lt;br /&gt;
&lt;br /&gt;
Separate the sellable ingredient items for admixes, colors etc. from the non-sellable ingredient codes.&lt;br /&gt;
When creating product classes, set the defaults for sellable, product type and ingredient type.  Then use the following script to update:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
update artprod p set  sellable_flag =(select std_sellable_flag from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  product_type =(select std_product_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  ingredient_type =(select std_ingredient_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup default sales G/L and make sure the plants are properly masked.  You can use a variant of this script to update yoru sales g/l accounts...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
UPDATE ARTPROD P&lt;br /&gt;
SET p.SALES_GL=&lt;br /&gt;
(select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class)||&lt;br /&gt;
(select substr(sales_gl_plant_mask,9,19) from artplant pl where pl.plant_no=p.plant_no)&lt;br /&gt;
where (select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class) is not null&lt;br /&gt;
and p.product_class IN ('AA','BB','CC')  -- Optionally only do this for select classes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Products===&lt;br /&gt;
Products are stored in 2 tables, imst and iloc.&lt;br /&gt;
*'''IMST:''' Product &amp;quot;Base&amp;quot;.  One record for base product that stores the category (class) description etc.&lt;br /&gt;
*'''ILOC:''' Product by Location&lt;br /&gt;
&lt;br /&gt;
These need to be combined to create keystone products.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Component Structure (icst)===&lt;br /&gt;
CMD dispatch mixes rarely are worth importing.  Verify with customer, but expect to import directly from batch controls.&lt;br /&gt;
&lt;br /&gt;
===Credit Terms (TRMS)===&lt;br /&gt;
You can import term codes and descriptions, but the meaning does not map from system to system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WITH T AS (&lt;br /&gt;
	SELECT &lt;br /&gt;
	case ltrim(rtrim(terms_code)) -- setup mapping for terms longer than 2 char.  Save for customer import etc.&lt;br /&gt;
		when '10N' THEN '1N'&lt;br /&gt;
		WHEN '15T' THEN '5T'&lt;br /&gt;
		WHEN '2.5' THEN '25'&lt;br /&gt;
		ELSE LTRIM(RTRIM(TERMS_CODE)) END CLASS_NO&lt;br /&gt;
	,LEFT(LTRIM(RTRIM(descr)),30) DESCRIPTION&lt;br /&gt;
	FROM dbo.trms&lt;br /&gt;
  )&lt;br /&gt;
  SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTCTCLS (CLASS_NO,DESCRIPTION) VALUES (''',CLASS_NO,''',''',DESCRIPTION,''');'),&lt;br /&gt;
  * FROM T&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trucks===&lt;br /&gt;
Trucks&lt;br /&gt;
&lt;br /&gt;
===Unit of Meausure (uoms)===&lt;br /&gt;
The key field for Unit of Measure is typically a long integer.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Prices (CPRD)===&lt;br /&gt;
&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List and Group Prices (IPRC)===&lt;br /&gt;
The table IPRC stores Category (cmd)/Group Prices and the equivelent of List prices.  Category &amp;quot;#&amp;quot; is represents &amp;quot;List&amp;quot; in Keystone.&lt;br /&gt;
*Many times, what appears to be a Group(cat) is in fact used as a list price.  You can preview the iprc data to the customer to determine this before the install.   You can also import into Keystone and then convert a group to list prices.&lt;br /&gt;
*Often, a large amount of junk pricing is in this table.  Preview to customer to determine if large amounts of pricing should be omitted.&lt;br /&gt;
*Where in Keystone, we often base pricing on X$ off list for a group or customer, in Command each price ends up as a record.  If possible, find groups (price cats) that can be skipped and replaced with a price off list.  (this may only apply to the mix items in a group/price cat)&lt;br /&gt;
*Expect redundant records that tneed to be processed by effect date.  (Use of RANK or similar SQL tricks can correct for this)&lt;br /&gt;
*Expect Prices for items that may or may not exist.&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Job (proj)====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Base selection on Expir_date, Setup_date and the inactive_code of projects, customers, iloc and imst.&lt;br /&gt;
&lt;br /&gt;
====Job Detail (prjp)====&lt;br /&gt;
*Tie this selection to the core query used for PROJ&lt;br /&gt;
*Plant # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
===Zone===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTzone (zone,DESCRIPTION,def_tax_authority) VALUES (''',rtrim(ltrim(zone_code)),&lt;br /&gt;
  ''',''',left(rtrim(ltrim(DESCR)),35),&lt;br /&gt;
  ''',''',rtrim(ltrim(tax_code)),''');'),&lt;br /&gt;
  zone.* &lt;br /&gt;
 FROM ZONE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=948</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=948"/>
		<updated>2024-02-26T13:20:56Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants (Locn/Plnt)===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  &lt;br /&gt;
&lt;br /&gt;
*LOCN: Locations&lt;br /&gt;
*PLNT: Plant&lt;br /&gt;
&lt;br /&gt;
Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
===Salespeople and Drivers===&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
&lt;br /&gt;
===Salespeople (empl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with cs as &lt;br /&gt;
( select distinct(ltrim(rtrim(cust.cc_slsmn_empl_code))) custslsmn from cust where inactive_code='00' ),&lt;br /&gt;
slsemp as&lt;br /&gt;
(SELECT &lt;br /&gt;
rtrim(ltrim(empl.empl_code)) empno,&lt;br /&gt;
rtrim(ltrim(empl.empl_code)) USER_1,&lt;br /&gt;
rtrim(LTRIM(empl.NAME)) DESCRIPTION,&lt;br /&gt;
rtrim(LTRIM(empl.PHONE_NUM)) PHONE_NO,&lt;br /&gt;
rtrim(LTRIM(empl.ASSGN_PLANT_CODE)) USER_2&lt;br /&gt;
 FROM empl&lt;br /&gt;
where slsmn_flag='True')&lt;br /&gt;
,slpn as&lt;br /&gt;
(&lt;br /&gt;
select cs.*,slsemp.*,&lt;br /&gt;
case custslsmn&lt;br /&gt;
WHEN '182' THEN 'NJ'&lt;br /&gt;
WHEN '322' THEN 'RM'&lt;br /&gt;
...&lt;br /&gt;
WHEN 'SALES' THEN 'SA'&lt;br /&gt;
else custslsmn&lt;br /&gt;
end class_no,''',''' qcq&lt;br /&gt;
from cs&lt;br /&gt;
left outer join slsemp on slsemp.empno=cs.custslsmn&lt;br /&gt;
) select &lt;br /&gt;
concat ( 'INSERT INTO artslspn ( CLASS_NO, EMPLOYEE_NO, DESCRIPTION, PHONE_NO, USER_2 )  VALUES (''',class_no,qcq,empno,qcq,DESCRIPTION,qcq,PHONE_NO,qcq,USER_2,''');'),&lt;br /&gt;
slpn.* from slpn&lt;br /&gt;
order by custslsmn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
====Tax Locality====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with ttl (tax_loc,tax_auth,descr,rate) as&lt;br /&gt;
  (select -- Core query (can be used with QG)&lt;br /&gt;
  cast(tl.tax_loc as integer),cast(tl.tax_auth as integer),&lt;br /&gt;
  replace(replace(ltrim(rtrim(descr)),'(City of','('),'( ','('),&lt;br /&gt;
  max(prim_rate_curr_pct) from taxl tl&lt;br /&gt;
  inner join taxj tj on tl.tax_loc=tj.tax_loc and tl.tax_auth=tj.tax_auth&lt;br /&gt;
  group by tl.tax_loc,tl.tax_auth,descr&lt;br /&gt;
  )&lt;br /&gt;
select &lt;br /&gt;
concat('INSERT INTO ARTTXLOC&lt;br /&gt;
( TAX_LOCALITY, LINE_NO, DESCRIPTION, TAX_COL, LOC_LEVEL, TAX_RATE, CALC_METHOD, EFFECT_DATE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',100*tax_auth + tax_loc,''', ',tax_auth,',''',left(descr,35),''',1 ,',tax_auth,',',rate,', 1, ''01/01/1900'', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );'),&lt;br /&gt;
ttl.* from ttl&lt;br /&gt;
order by tax_auth,tax_loc;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tax Authority====&lt;br /&gt;
For the tax authority, we just need the code and the description...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with tc as&lt;br /&gt;
	(select ltrim(rtrim(tax_code)) &amp;quot;tax_code&amp;quot;,&lt;br /&gt;
	replace(replace(ltrim(rtrim(descr)),'(City of','('),'( ','(') &amp;quot;descr&amp;quot;&lt;br /&gt;
	from taxc)&lt;br /&gt;
select &lt;br /&gt;
concat('INSERT INTO ARTTXAUT ( TAX_AUTHORITY, DESCRIPTION, INCREASE_DISC_FLAG, DISC_INCLUDES_TAX, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',tax_code,''' , ''',left(descr,35),''', ''N'', ''Y'', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y'' );',''),&lt;br /&gt;
tc.* from tc;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  Import the actual group prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
Sample query:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select -- core query that can be used with qg&lt;br /&gt;
	ltrim(rtrim(price_cat)),&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from prcc&lt;br /&gt;
	)&lt;br /&gt;
select -- outer query &lt;br /&gt;
concat('INSERT INTO ARTPRGRP ( GROUP_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG)  VALUES &lt;br /&gt;
  ( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''  );')&lt;br /&gt;
,clsno &amp;quot;group&amp;quot;, descry description&lt;br /&gt;
from aaa&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Price Cat codes tend to be short and do not need to be mapped coming into Keystone.&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Class (sanl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Product Class (icat)===&lt;br /&gt;
&lt;br /&gt;
A good product class table is essential for a Command conversion.&lt;br /&gt;
&lt;br /&gt;
You will mostly likely need to map long item cat codes to product class codes.  Instead of making them like the CMD item cat codes, so focus on making a well organized Keystone list and then have the customer help you mapping CMD item categories to Keystone classes.&lt;br /&gt;
&lt;br /&gt;
Separate the sellable ingredient items for admixes, colors etc. from the non-sellable ingredient codes.&lt;br /&gt;
When creating product classes, set the defaults for sellable, product type and ingredient type.  Then use the following script to update:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
update artprod p set  sellable_flag =(select std_sellable_flag from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  product_type =(select std_product_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  ingredient_type =(select std_ingredient_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup default sales G/L and make sure the plants are properly masked.  You can use a variant of this script to update yoru sales g/l accounts...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
UPDATE ARTPROD P&lt;br /&gt;
SET p.SALES_GL=&lt;br /&gt;
(select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class)||&lt;br /&gt;
(select substr(sales_gl_plant_mask,9,19) from artplant pl where pl.plant_no=p.plant_no)&lt;br /&gt;
where (select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class) is not null&lt;br /&gt;
and p.product_class IN ('AA','BB','CC')  -- Optionally only do this for select classes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Products===&lt;br /&gt;
Products are stored in 2 tables, imst and iloc.&lt;br /&gt;
*'''IMST:''' Product &amp;quot;Base&amp;quot;.  One record for base product that stores the category (class) description etc.&lt;br /&gt;
*'''ILOC:''' Product by Location&lt;br /&gt;
&lt;br /&gt;
These need to be combined to create keystone products.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Component Structure (icst)===&lt;br /&gt;
CMD dispatch mixes rarely are worth importing.  Verify with customer, but expect to import directly from batch controls.&lt;br /&gt;
&lt;br /&gt;
===Credit Terms (TRMS)===&lt;br /&gt;
You can import term codes and descriptions, but the meaning does not map from system to system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WITH T AS (&lt;br /&gt;
	SELECT &lt;br /&gt;
	case ltrim(rtrim(terms_code)) -- setup mapping for terms longer than 2 char.  Save for customer import etc.&lt;br /&gt;
		when '10N' THEN '1N'&lt;br /&gt;
		WHEN '15T' THEN '5T'&lt;br /&gt;
		WHEN '2.5' THEN '25'&lt;br /&gt;
		ELSE LTRIM(RTRIM(TERMS_CODE)) END CLASS_NO&lt;br /&gt;
	,LEFT(LTRIM(RTRIM(descr)),30) DESCRIPTION&lt;br /&gt;
	FROM dbo.trms&lt;br /&gt;
  )&lt;br /&gt;
  SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTCTCLS (CLASS_NO,DESCRIPTION) VALUES (''',CLASS_NO,''',''',DESCRIPTION,''');'),&lt;br /&gt;
  * FROM T&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trucks===&lt;br /&gt;
Trucks&lt;br /&gt;
&lt;br /&gt;
===Unit of Meausure (uoms)===&lt;br /&gt;
The key field for Unit of Measure is typically a long integer.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Prices (CPRD)===&lt;br /&gt;
&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List and Group Prices (IPRC)===&lt;br /&gt;
The table IPRC stores Category (cmd)/Group Prices and the equivelent of List prices.  Category &amp;quot;#&amp;quot; is represents &amp;quot;List&amp;quot; in Keystone.&lt;br /&gt;
*Many times, what appears to be a Group(cat) is in fact used as a list price.  You can preview the iprc data to the customer to determine this before the install.   You can also import into Keystone and then convert a group to list prices.&lt;br /&gt;
*Often, a large amount of junk pricing is in this table.  Preview to customer to determine if large amounts of pricing should be omitted.&lt;br /&gt;
*Where in Keystone, we often base pricing on X$ off list for a group or customer, in Command each price ends up as a record.  If possible, find groups (price cats) that can be skipped and replaced with a price off list.  (this may only apply to the mix items in a group/price cat)&lt;br /&gt;
*Expect redundant records that tneed to be processed by effect date.  (Use of RANK or similar SQL tricks can correct for this)&lt;br /&gt;
*Expect Prices for items that may or may not exist.&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Job (proj)====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Base selection on Expir_date, Setup_date and the inactive_code of projects, customers, iloc and imst.&lt;br /&gt;
&lt;br /&gt;
====Job Detail (prjp)====&lt;br /&gt;
*Tie this selection to the core query used for PROJ&lt;br /&gt;
*Plant # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
===Zone===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTzone (zone,DESCRIPTION,def_tax_authority) VALUES (''',rtrim(ltrim(zone_code)),&lt;br /&gt;
  ''',''',left(rtrim(ltrim(DESCR)),35),&lt;br /&gt;
  ''',''',rtrim(ltrim(tax_code)),''');'),&lt;br /&gt;
  zone.* &lt;br /&gt;
 FROM ZONE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=947</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=947"/>
		<updated>2024-02-23T19:34:06Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Component Stucture */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants (Locn/Plnt)===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  &lt;br /&gt;
&lt;br /&gt;
*LOCN: Locations&lt;br /&gt;
*PLNT: Plant&lt;br /&gt;
&lt;br /&gt;
Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
===Customer Class===&lt;br /&gt;
*'''SANL:'''&lt;br /&gt;
&lt;br /&gt;
===Salespeople and Drivers===&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with ttl (tax_loc,tax_auth,descr,rate) as&lt;br /&gt;
  (select -- Core query (can be used with QG)&lt;br /&gt;
  cast(tl.tax_loc as integer),cast(tl.tax_auth as integer),&lt;br /&gt;
  replace(replace(ltrim(rtrim(descr)),'(City of','('),'( ','('),&lt;br /&gt;
  max(prim_rate_curr_pct) from taxl tl&lt;br /&gt;
  inner join taxj tj on tl.tax_loc=tj.tax_loc and tl.tax_auth=tj.tax_auth&lt;br /&gt;
  group by tl.tax_loc,tl.tax_auth,descr&lt;br /&gt;
  )&lt;br /&gt;
select &lt;br /&gt;
concat('INSERT INTO ARTTXLOC&lt;br /&gt;
( TAX_LOCALITY, LINE_NO, DESCRIPTION, TAX_COL, LOC_LEVEL, TAX_RATE, CALC_METHOD, EFFECT_DATE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',100*tax_auth + tax_loc,''', ',tax_auth,',''',left(descr,35),''',1 ,',tax_auth,',',rate,', 1, ''01/01/1900'', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );'),&lt;br /&gt;
ttl.* from ttl&lt;br /&gt;
order by tax_auth,tax_loc;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  Import the actual group prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
Sample query:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select -- core query that can be used with qg&lt;br /&gt;
	ltrim(rtrim(price_cat)),&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from prcc&lt;br /&gt;
	)&lt;br /&gt;
select -- outer query &lt;br /&gt;
concat('INSERT INTO ARTPRGRP ( GROUP_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG)  VALUES &lt;br /&gt;
  ( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''  );')&lt;br /&gt;
,clsno &amp;quot;group&amp;quot;, descry description&lt;br /&gt;
from aaa&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Price Cat codes tend to be short and do not need to be mapped coming into Keystone.&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Class (sanl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Product Class (icat)===&lt;br /&gt;
&lt;br /&gt;
A good product class table is essential for a Command conversion.&lt;br /&gt;
&lt;br /&gt;
You will mostly likely need to map long item cat codes to product class codes.  Instead of making them like the CMD item cat codes, so focus on making a well organized Keystone list and then have the customer help you mapping CMD item categories to Keystone classes.&lt;br /&gt;
&lt;br /&gt;
Separate the sellable ingredient items for admixes, colors etc. from the non-sellable ingredient codes.&lt;br /&gt;
When creating product classes, set the defaults for sellable, product type and ingredient type.  Then use the following script to update:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
update artprod p set  sellable_flag =(select std_sellable_flag from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  product_type =(select std_product_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  ingredient_type =(select std_ingredient_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup default sales G/L and make sure the plants are properly masked.  You can use a variant of this script to update yoru sales g/l accounts...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
UPDATE ARTPROD P&lt;br /&gt;
SET p.SALES_GL=&lt;br /&gt;
(select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class)||&lt;br /&gt;
(select substr(sales_gl_plant_mask,9,19) from artplant pl where pl.plant_no=p.plant_no)&lt;br /&gt;
where (select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class) is not null&lt;br /&gt;
and p.product_class IN ('AA','BB','CC')  -- Optionally only do this for select classes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Products===&lt;br /&gt;
Products are stored in 2 tables, imst and iloc.&lt;br /&gt;
*'''IMST:''' Product &amp;quot;Base&amp;quot;.  One record for base product that stores the category (class) description etc.&lt;br /&gt;
*'''ILOC:''' Product by Location&lt;br /&gt;
&lt;br /&gt;
These need to be combined to create keystone products.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Component Structure (icst)===&lt;br /&gt;
CMD dispatch mixes rarely are worth importing.  Verify with customer, but expect to import directly from batch controls.&lt;br /&gt;
&lt;br /&gt;
===Credit Terms (TRMS)===&lt;br /&gt;
You can import term codes and descriptions, but the meaning does not map from system to system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WITH T AS (&lt;br /&gt;
	SELECT &lt;br /&gt;
	case ltrim(rtrim(terms_code)) -- setup mapping for terms longer than 2 char.  Save for customer import etc.&lt;br /&gt;
		when '10N' THEN '1N'&lt;br /&gt;
		WHEN '15T' THEN '5T'&lt;br /&gt;
		WHEN '2.5' THEN '25'&lt;br /&gt;
		ELSE LTRIM(RTRIM(TERMS_CODE)) END CLASS_NO&lt;br /&gt;
	,LEFT(LTRIM(RTRIM(descr)),30) DESCRIPTION&lt;br /&gt;
	FROM dbo.trms&lt;br /&gt;
  )&lt;br /&gt;
  SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTCTCLS (CLASS_NO,DESCRIPTION) VALUES (''',CLASS_NO,''',''',DESCRIPTION,''');'),&lt;br /&gt;
  * FROM T&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trucks===&lt;br /&gt;
Trucks&lt;br /&gt;
&lt;br /&gt;
===Unit of Meausure (uoms)===&lt;br /&gt;
The key field for Unit of Measure is typically a long integer.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Prices (CPRD)===&lt;br /&gt;
&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List and Group Prices (IPRC)===&lt;br /&gt;
The table IPRC stores Category (cmd)/Group Prices and the equivelent of List prices.  Category &amp;quot;#&amp;quot; is represents &amp;quot;List&amp;quot; in Keystone.&lt;br /&gt;
*Many times, what appears to be a Group(cat) is in fact used as a list price.  You can preview the iprc data to the customer to determine this before the install.   You can also import into Keystone and then convert a group to list prices.&lt;br /&gt;
*Often, a large amount of junk pricing is in this table.  Preview to customer to determine if large amounts of pricing should be omitted.&lt;br /&gt;
*Where in Keystone, we often base pricing on X$ off list for a group or customer, in Command each price ends up as a record.  If possible, find groups (price cats) that can be skipped and replaced with a price off list.  (this may only apply to the mix items in a group/price cat)&lt;br /&gt;
*Expect redundant records that tneed to be processed by effect date.  (Use of RANK or similar SQL tricks can correct for this)&lt;br /&gt;
*Expect Prices for items that may or may not exist.&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Job (proj)====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Base selection on Expir_date, Setup_date and the inactive_code of projects, customers, iloc and imst.&lt;br /&gt;
&lt;br /&gt;
====Job Detail (prjp)====&lt;br /&gt;
*Tie this selection to the core query used for PROJ&lt;br /&gt;
*Plant # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=946</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=946"/>
		<updated>2024-02-23T18:25:37Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Taxes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants (Locn/Plnt)===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  &lt;br /&gt;
&lt;br /&gt;
*LOCN: Locations&lt;br /&gt;
*PLNT: Plant&lt;br /&gt;
&lt;br /&gt;
Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
===Customer Class===&lt;br /&gt;
*'''SANL:'''&lt;br /&gt;
&lt;br /&gt;
===Salespeople and Drivers===&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with ttl (tax_loc,tax_auth,descr,rate) as&lt;br /&gt;
  (select -- Core query (can be used with QG)&lt;br /&gt;
  cast(tl.tax_loc as integer),cast(tl.tax_auth as integer),&lt;br /&gt;
  replace(replace(ltrim(rtrim(descr)),'(City of','('),'( ','('),&lt;br /&gt;
  max(prim_rate_curr_pct) from taxl tl&lt;br /&gt;
  inner join taxj tj on tl.tax_loc=tj.tax_loc and tl.tax_auth=tj.tax_auth&lt;br /&gt;
  group by tl.tax_loc,tl.tax_auth,descr&lt;br /&gt;
  )&lt;br /&gt;
select &lt;br /&gt;
concat('INSERT INTO ARTTXLOC&lt;br /&gt;
( TAX_LOCALITY, LINE_NO, DESCRIPTION, TAX_COL, LOC_LEVEL, TAX_RATE, CALC_METHOD, EFFECT_DATE, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',100*tax_auth + tax_loc,''', ',tax_auth,',''',left(descr,35),''',1 ,',tax_auth,',',rate,', 1, ''01/01/1900'', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );'),&lt;br /&gt;
ttl.* from ttl&lt;br /&gt;
order by tax_auth,tax_loc;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  Import the actual group prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
Sample query:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select -- core query that can be used with qg&lt;br /&gt;
	ltrim(rtrim(price_cat)),&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from prcc&lt;br /&gt;
	)&lt;br /&gt;
select -- outer query &lt;br /&gt;
concat('INSERT INTO ARTPRGRP ( GROUP_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG)  VALUES &lt;br /&gt;
  ( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''  );')&lt;br /&gt;
,clsno &amp;quot;group&amp;quot;, descry description&lt;br /&gt;
from aaa&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Price Cat codes tend to be short and do not need to be mapped coming into Keystone.&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Class (sanl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Product Class (icat)===&lt;br /&gt;
&lt;br /&gt;
A good product class table is essential for a Command conversion.&lt;br /&gt;
&lt;br /&gt;
You will mostly likely need to map long item cat codes to product class codes.  Instead of making them like the CMD item cat codes, so focus on making a well organized Keystone list and then have the customer help you mapping CMD item categories to Keystone classes.&lt;br /&gt;
&lt;br /&gt;
Separate the sellable ingredient items for admixes, colors etc. from the non-sellable ingredient codes.&lt;br /&gt;
When creating product classes, set the defaults for sellable, product type and ingredient type.  Then use the following script to update:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
update artprod p set  sellable_flag =(select std_sellable_flag from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  product_type =(select std_product_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  ingredient_type =(select std_ingredient_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup default sales G/L and make sure the plants are properly masked.  You can use a variant of this script to update yoru sales g/l accounts...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
UPDATE ARTPROD P&lt;br /&gt;
SET p.SALES_GL=&lt;br /&gt;
(select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class)||&lt;br /&gt;
(select substr(sales_gl_plant_mask,9,19) from artplant pl where pl.plant_no=p.plant_no)&lt;br /&gt;
where (select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class) is not null&lt;br /&gt;
and p.product_class IN ('AA','BB','CC')  -- Optionally only do this for select classes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Products===&lt;br /&gt;
Products are stored in 2 tables, imst and iloc.&lt;br /&gt;
*'''IMST:''' Product &amp;quot;Base&amp;quot;.  One record for base product that stores the category (class) description etc.&lt;br /&gt;
*'''ILOC:''' Product by Location&lt;br /&gt;
&lt;br /&gt;
These need to be combined to create keystone products.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Cost====&lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
&lt;br /&gt;
===Credit Terms (TRMS)===&lt;br /&gt;
You can import term codes and descriptions, but the meaning does not map from system to system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WITH T AS (&lt;br /&gt;
	SELECT &lt;br /&gt;
	case ltrim(rtrim(terms_code)) -- setup mapping for terms longer than 2 char.  Save for customer import etc.&lt;br /&gt;
		when '10N' THEN '1N'&lt;br /&gt;
		WHEN '15T' THEN '5T'&lt;br /&gt;
		WHEN '2.5' THEN '25'&lt;br /&gt;
		ELSE LTRIM(RTRIM(TERMS_CODE)) END CLASS_NO&lt;br /&gt;
	,LEFT(LTRIM(RTRIM(descr)),30) DESCRIPTION&lt;br /&gt;
	FROM dbo.trms&lt;br /&gt;
  )&lt;br /&gt;
  SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTCTCLS (CLASS_NO,DESCRIPTION) VALUES (''',CLASS_NO,''',''',DESCRIPTION,''');'),&lt;br /&gt;
  * FROM T&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trucks===&lt;br /&gt;
Trucks&lt;br /&gt;
&lt;br /&gt;
===Unit of Meausure (uoms)===&lt;br /&gt;
The key field for Unit of Measure is typically a long integer.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Prices (CPRD)===&lt;br /&gt;
&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List and Group Prices (IPRC)===&lt;br /&gt;
The table IPRC stores Category (cmd)/Group Prices and the equivelent of List prices.  Category &amp;quot;#&amp;quot; is represents &amp;quot;List&amp;quot; in Keystone.&lt;br /&gt;
*Many times, what appears to be a Group(cat) is in fact used as a list price.  You can preview the iprc data to the customer to determine this before the install.   You can also import into Keystone and then convert a group to list prices.&lt;br /&gt;
*Often, a large amount of junk pricing is in this table.  Preview to customer to determine if large amounts of pricing should be omitted.&lt;br /&gt;
*Where in Keystone, we often base pricing on X$ off list for a group or customer, in Command each price ends up as a record.  If possible, find groups (price cats) that can be skipped and replaced with a price off list.  (this may only apply to the mix items in a group/price cat)&lt;br /&gt;
*Expect redundant records that tneed to be processed by effect date.  (Use of RANK or similar SQL tricks can correct for this)&lt;br /&gt;
*Expect Prices for items that may or may not exist.&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Job (proj)====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Base selection on Expir_date, Setup_date and the inactive_code of projects, customers, iloc and imst.&lt;br /&gt;
&lt;br /&gt;
====Job Detail (prjp)====&lt;br /&gt;
*Tie this selection to the core query used for PROJ&lt;br /&gt;
*Plant # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=945</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=945"/>
		<updated>2024-02-22T21:11:51Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Product Class (icat) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants (Locn/Plnt)===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  &lt;br /&gt;
&lt;br /&gt;
*LOCN: Locations&lt;br /&gt;
*PLNT: Plant&lt;br /&gt;
&lt;br /&gt;
Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
===Customer Class===&lt;br /&gt;
*'''SANL:'''&lt;br /&gt;
&lt;br /&gt;
===Salespeople and Drivers===&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  Import the actual group prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
Sample query:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select -- core query that can be used with qg&lt;br /&gt;
	ltrim(rtrim(price_cat)),&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from prcc&lt;br /&gt;
	)&lt;br /&gt;
select -- outer query &lt;br /&gt;
concat('INSERT INTO ARTPRGRP ( GROUP_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG)  VALUES &lt;br /&gt;
  ( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''  );')&lt;br /&gt;
,clsno &amp;quot;group&amp;quot;, descry description&lt;br /&gt;
from aaa&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Price Cat codes tend to be short and do not need to be mapped coming into Keystone.&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Class (sanl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Product Class (icat)===&lt;br /&gt;
&lt;br /&gt;
A good product class table is essential for a Command conversion.&lt;br /&gt;
&lt;br /&gt;
You will mostly likely need to map long item cat codes to product class codes.  Instead of making them like the CMD item cat codes, so focus on making a well organized Keystone list and then have the customer help you mapping CMD item categories to Keystone classes.&lt;br /&gt;
&lt;br /&gt;
Separate the sellable ingredient items for admixes, colors etc. from the non-sellable ingredient codes.&lt;br /&gt;
When creating product classes, set the defaults for sellable, product type and ingredient type.  Then use the following script to update:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
update artprod p set  sellable_flag =(select std_sellable_flag from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  product_type =(select std_product_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
update artprod p set  ingredient_type =(select std_ingredient_type from artprcls c where c.class_no=p.product_class);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup default sales G/L and make sure the plants are properly masked.  You can use a variant of this script to update yoru sales g/l accounts...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
UPDATE ARTPROD P&lt;br /&gt;
SET p.SALES_GL=&lt;br /&gt;
(select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class)||&lt;br /&gt;
(select substr(sales_gl_plant_mask,9,19) from artplant pl where pl.plant_no=p.plant_no)&lt;br /&gt;
where (select substr(std_sales_gl,1,8) from artprcls pc where pc.class_no=p.product_class) is not null&lt;br /&gt;
and p.product_class IN ('AA','BB','CC')  -- Optionally only do this for select classes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Products===&lt;br /&gt;
Products are stored in 2 tables, imst and iloc.&lt;br /&gt;
*'''IMST:''' Product &amp;quot;Base&amp;quot;.  One record for base product that stores the category (class) description etc.&lt;br /&gt;
*'''ILOC:''' Product by Location&lt;br /&gt;
&lt;br /&gt;
These need to be combined to create keystone products.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Cost====&lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
&lt;br /&gt;
===Credit Terms (TRMS)===&lt;br /&gt;
You can import term codes and descriptions, but the meaning does not map from system to system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WITH T AS (&lt;br /&gt;
	SELECT &lt;br /&gt;
	case ltrim(rtrim(terms_code)) -- setup mapping for terms longer than 2 char.  Save for customer import etc.&lt;br /&gt;
		when '10N' THEN '1N'&lt;br /&gt;
		WHEN '15T' THEN '5T'&lt;br /&gt;
		WHEN '2.5' THEN '25'&lt;br /&gt;
		ELSE LTRIM(RTRIM(TERMS_CODE)) END CLASS_NO&lt;br /&gt;
	,LEFT(LTRIM(RTRIM(descr)),30) DESCRIPTION&lt;br /&gt;
	FROM dbo.trms&lt;br /&gt;
  )&lt;br /&gt;
  SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTCTCLS (CLASS_NO,DESCRIPTION) VALUES (''',CLASS_NO,''',''',DESCRIPTION,''');'),&lt;br /&gt;
  * FROM T&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trucks===&lt;br /&gt;
Trucks&lt;br /&gt;
&lt;br /&gt;
===Unit of Meausure (uoms)===&lt;br /&gt;
The key field for Unit of Measure is typically a long integer.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Prices (CPRD)===&lt;br /&gt;
&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List and Group Prices (IPRC)===&lt;br /&gt;
The table IPRC stores Category (cmd)/Group Prices and the equivelent of List prices.  Category &amp;quot;#&amp;quot; is represents &amp;quot;List&amp;quot; in Keystone.&lt;br /&gt;
*Many times, what appears to be a Group(cat) is in fact used as a list price.  You can preview the iprc data to the customer to determine this before the install.   You can also import into Keystone and then convert a group to list prices.&lt;br /&gt;
*Often, a large amount of junk pricing is in this table.  Preview to customer to determine if large amounts of pricing should be omitted.&lt;br /&gt;
*Where in Keystone, we often base pricing on X$ off list for a group or customer, in Command each price ends up as a record.  If possible, find groups (price cats) that can be skipped and replaced with a price off list.  (this may only apply to the mix items in a group/price cat)&lt;br /&gt;
*Expect redundant records that tneed to be processed by effect date.  (Use of RANK or similar SQL tricks can correct for this)&lt;br /&gt;
*Expect Prices for items that may or may not exist.&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Job (proj)====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Base selection on Expir_date, Setup_date and the inactive_code of projects, customers, iloc and imst.&lt;br /&gt;
&lt;br /&gt;
====Job Detail (prjp)====&lt;br /&gt;
*Tie this selection to the core query used for PROJ&lt;br /&gt;
*Plant # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Command_Import&amp;diff=944</id>
		<title>Command Import</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Command_Import&amp;diff=944"/>
		<updated>2024-02-22T15:12:22Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There is not ONE way to import Command Data - each situation is unique.&lt;br /&gt;
&lt;br /&gt;
===Know This First===&lt;br /&gt;
What you need to know before importing Command's Data&lt;br /&gt;
*There is NO data integrity.&lt;br /&gt;
:*Expect sub tables, prices etc. to have records that do have matching main tables.  (e.g. prices for customers that don't exist).&lt;br /&gt;
*Alpha fields must be trimmed - especially key fields.  Expect both left and right padding on Customer and product codes.&lt;br /&gt;
:MS SQL hasn't had the &amp;quot;TRIM&amp;quot; statement for long, so most often you must select as:&lt;br /&gt;
:&amp;lt;code&amp;gt;LTRIM(RTRIM((PRJP.PROJ_CODE)) JOB_PO_LOC,&amp;lt;/code&amp;gt;&lt;br /&gt;
:in some cases, such as Oracle you only have trim and must select as:&lt;br /&gt;
:&amp;lt;code&amp;gt;TRIM(PRJP.PROJ_CODE) JOB_PO_LOC,&amp;lt;/code&amp;gt;&lt;br /&gt;
*Numeric Fields may be null.  Use coalesce... &amp;lt;code&amp;gt;COALESCE(Finc_Chrg_amt,0) Finc_chrg_amt&amp;lt;/code&amp;gt;&lt;br /&gt;
*Field IDs are longer - especially Tax Authorities, sales people and classes.&lt;br /&gt;
*Keep a list of mappings when setting up the class type fields to use in case statements...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
case TERMS&lt;br /&gt;
WHEN '15N' THEN '15' &lt;br /&gt;
WHEN 'N20' THEN '20' &lt;br /&gt;
   ...&lt;br /&gt;
WHEN 'CAS' THEN 'CA' ELSE '' END CUST_TERMS&amp;lt;/pre&amp;gt;&lt;br /&gt;
*Some records, especially prices, have what appear to be duplicates.  You need special queries that pull just the latest version of the record.&lt;br /&gt;
*Start with Small Tables and Build up (Like any Import)&lt;br /&gt;
&lt;br /&gt;
===MS SQL to know===&lt;br /&gt;
*ltrim,rtrim&lt;br /&gt;
*replace&lt;br /&gt;
*left, right&lt;br /&gt;
*case&lt;br /&gt;
*iif&lt;br /&gt;
*rank&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Import Examples===&lt;br /&gt;
&lt;br /&gt;
Here are some samples used in the past...&lt;br /&gt;
:[[Examples by Table]]&lt;br /&gt;
:[[Command Import: Hedger Work Notes]]&lt;br /&gt;
:[[Command Import: Rain MO Work Notes]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Command Tables===&lt;br /&gt;
&lt;br /&gt;
*'''ACCT:''' GL  Accounts&lt;br /&gt;
*'''ARTB:''' Aging&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''COMP:''' Company&lt;br /&gt;
*'''CPRD:''' Customer Prices&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
*'''CUST:''' Customer Prices&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
*'''ILOC:''' Product by Location (Similar to Plant)&lt;br /&gt;
*'''IMST:''' Products&lt;br /&gt;
*'''IPRC:''' Prices - by Level (Group)&lt;br /&gt;
*'''LOCN:''' Locations (Similar to Plant)&lt;br /&gt;
*'''PLNT:''' Plant&lt;br /&gt;
*'''PRCC:''' Price Group&lt;br /&gt;
*'''PRJP:''' Project Prices&lt;br /&gt;
*'''PROJ:''' Project&lt;br /&gt;
*'''SANL:''' Customer Class&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
*'''TRMS:''' Terms&lt;br /&gt;
*'''TRUC:''' Trucks&lt;br /&gt;
*'''UOMS:''' Unit of Meausure&lt;br /&gt;
*'''USGE:''' Useage&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=943</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=943"/>
		<updated>2024-02-22T15:08:44Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Credit Terms (TRMS) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants (Locn/Plnt)===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  &lt;br /&gt;
&lt;br /&gt;
*LOCN: Locations&lt;br /&gt;
*PLNT: Plant&lt;br /&gt;
&lt;br /&gt;
Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
===Customer Class===&lt;br /&gt;
*'''SANL:'''&lt;br /&gt;
&lt;br /&gt;
===Salespeople and Drivers===&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  Import the actual group prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
Sample query:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select -- core query that can be used with qg&lt;br /&gt;
	ltrim(rtrim(price_cat)),&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from prcc&lt;br /&gt;
	)&lt;br /&gt;
select -- outer query &lt;br /&gt;
concat('INSERT INTO ARTPRGRP ( GROUP_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG)  VALUES &lt;br /&gt;
  ( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''  );')&lt;br /&gt;
,clsno &amp;quot;group&amp;quot;, descry description&lt;br /&gt;
from aaa&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Price Cat codes tend to be short and do not need to be mapped coming into Keystone.&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Class (sanl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Product Class (icat)===&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
&lt;br /&gt;
===Products===&lt;br /&gt;
Products are stored in 2 tables, imst and iloc.&lt;br /&gt;
*'''IMST:''' Product &amp;quot;Base&amp;quot;.  One record for base product that stores the category (class) description etc.&lt;br /&gt;
*'''ILOC:''' Product by Location&lt;br /&gt;
&lt;br /&gt;
These need to be combined to create keystone products.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Cost====&lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
&lt;br /&gt;
===Credit Terms (TRMS)===&lt;br /&gt;
You can import term codes and descriptions, but the meaning does not map from system to system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WITH T AS (&lt;br /&gt;
	SELECT &lt;br /&gt;
	case ltrim(rtrim(terms_code)) -- setup mapping for terms longer than 2 char.  Save for customer import etc.&lt;br /&gt;
		when '10N' THEN '1N'&lt;br /&gt;
		WHEN '15T' THEN '5T'&lt;br /&gt;
		WHEN '2.5' THEN '25'&lt;br /&gt;
		ELSE LTRIM(RTRIM(TERMS_CODE)) END CLASS_NO&lt;br /&gt;
	,LEFT(LTRIM(RTRIM(descr)),30) DESCRIPTION&lt;br /&gt;
	FROM dbo.trms&lt;br /&gt;
  )&lt;br /&gt;
  SELECT &lt;br /&gt;
  CONCAT('iNSERT INTO ARTCTCLS (CLASS_NO,DESCRIPTION) VALUES (''',CLASS_NO,''',''',DESCRIPTION,''');'),&lt;br /&gt;
  * FROM T&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trucks===&lt;br /&gt;
Trucks&lt;br /&gt;
&lt;br /&gt;
===Unit of Meausure (uoms)===&lt;br /&gt;
The key field for Unit of Measure is typically a long integer.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Prices (CPRD)===&lt;br /&gt;
&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List and Group Prices (IPRC)===&lt;br /&gt;
The table IPRC stores Category (cmd)/Group Prices and the equivelent of List prices.  Category &amp;quot;#&amp;quot; is represents &amp;quot;List&amp;quot; in Keystone.&lt;br /&gt;
*Many times, what appears to be a Group(cat) is in fact used as a list price.  You can preview the iprc data to the customer to determine this before the install.   You can also import into Keystone and then convert a group to list prices.&lt;br /&gt;
*Often, a large amount of junk pricing is in this table.  Preview to customer to determine if large amounts of pricing should be omitted.&lt;br /&gt;
*Where in Keystone, we often base pricing on X$ off list for a group or customer, in Command each price ends up as a record.  If possible, find groups (price cats) that can be skipped and replaced with a price off list.  (this may only apply to the mix items in a group/price cat)&lt;br /&gt;
*Expect redundant records that tneed to be processed by effect date.  (Use of RANK or similar SQL tricks can correct for this)&lt;br /&gt;
*Expect Prices for items that may or may not exist.&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Job (proj)====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Base selection on Expir_date, Setup_date and the inactive_code of projects, customers, iloc and imst.&lt;br /&gt;
&lt;br /&gt;
====Job Detail (prjp)====&lt;br /&gt;
*Tie this selection to the core query used for PROJ&lt;br /&gt;
*Plant # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=942</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=942"/>
		<updated>2024-02-22T15:03:41Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Price Group Headers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants (Locn/Plnt)===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  &lt;br /&gt;
&lt;br /&gt;
*LOCN: Locations&lt;br /&gt;
*PLNT: Plant&lt;br /&gt;
&lt;br /&gt;
Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
===Customer Class===&lt;br /&gt;
*'''SANL:'''&lt;br /&gt;
&lt;br /&gt;
===Salespeople and Drivers===&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  Import the actual group prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
Sample query:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with aaa (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select -- core query that can be used with qg&lt;br /&gt;
	ltrim(rtrim(price_cat)),&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from prcc&lt;br /&gt;
	)&lt;br /&gt;
select -- outer query &lt;br /&gt;
concat('INSERT INTO ARTPRGRP ( GROUP_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG)  VALUES &lt;br /&gt;
  ( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''  );')&lt;br /&gt;
,clsno &amp;quot;group&amp;quot;, descry description&lt;br /&gt;
from aaa&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Price Cat codes tend to be short and do not need to be mapped coming into Keystone.&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Class (sanl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Product Class (icat)===&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
&lt;br /&gt;
===Products===&lt;br /&gt;
Products are stored in 2 tables, imst and iloc.&lt;br /&gt;
*'''IMST:''' Product &amp;quot;Base&amp;quot;.  One record for base product that stores the category (class) description etc.&lt;br /&gt;
*'''ILOC:''' Product by Location&lt;br /&gt;
&lt;br /&gt;
These need to be combined to create keystone products.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Cost====&lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
&lt;br /&gt;
===Credit Terms (TRMS)===&lt;br /&gt;
You can import term codes and descriptions, but the meaning does not map from system to system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Trucks===&lt;br /&gt;
Trucks&lt;br /&gt;
&lt;br /&gt;
===Unit of Meausure (uoms)===&lt;br /&gt;
The key field for Unit of Measure is typically a long integer.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Prices (CPRD)===&lt;br /&gt;
&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List and Group Prices (IPRC)===&lt;br /&gt;
The table IPRC stores Category (cmd)/Group Prices and the equivelent of List prices.  Category &amp;quot;#&amp;quot; is represents &amp;quot;List&amp;quot; in Keystone.&lt;br /&gt;
*Many times, what appears to be a Group(cat) is in fact used as a list price.  You can preview the iprc data to the customer to determine this before the install.   You can also import into Keystone and then convert a group to list prices.&lt;br /&gt;
*Often, a large amount of junk pricing is in this table.  Preview to customer to determine if large amounts of pricing should be omitted.&lt;br /&gt;
*Where in Keystone, we often base pricing on X$ off list for a group or customer, in Command each price ends up as a record.  If possible, find groups (price cats) that can be skipped and replaced with a price off list.  (this may only apply to the mix items in a group/price cat)&lt;br /&gt;
*Expect redundant records that tneed to be processed by effect date.  (Use of RANK or similar SQL tricks can correct for this)&lt;br /&gt;
*Expect Prices for items that may or may not exist.&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Job (proj)====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Base selection on Expir_date, Setup_date and the inactive_code of projects, customers, iloc and imst.&lt;br /&gt;
&lt;br /&gt;
====Job Detail (prjp)====&lt;br /&gt;
*Tie this selection to the core query used for PROJ&lt;br /&gt;
*Plant # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=941</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=941"/>
		<updated>2024-02-22T14:57:14Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Customer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants (Locn/Plnt)===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  &lt;br /&gt;
&lt;br /&gt;
*LOCN: Locations&lt;br /&gt;
*PLNT: Plant&lt;br /&gt;
&lt;br /&gt;
Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
===Customer Class===&lt;br /&gt;
*'''SANL:'''&lt;br /&gt;
&lt;br /&gt;
===Salespeople and Drivers===&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  The actual prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Class (sanl)===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Product Class (icat)===&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
&lt;br /&gt;
===Products===&lt;br /&gt;
Products are stored in 2 tables, imst and iloc.&lt;br /&gt;
*'''IMST:''' Product &amp;quot;Base&amp;quot;.  One record for base product that stores the category (class) description etc.&lt;br /&gt;
*'''ILOC:''' Product by Location&lt;br /&gt;
&lt;br /&gt;
These need to be combined to create keystone products.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Cost====&lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
&lt;br /&gt;
===Credit Terms (TRMS)===&lt;br /&gt;
You can import term codes and descriptions, but the meaning does not map from system to system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Trucks===&lt;br /&gt;
Trucks&lt;br /&gt;
&lt;br /&gt;
===Unit of Meausure (uoms)===&lt;br /&gt;
The key field for Unit of Measure is typically a long integer.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Prices (CPRD)===&lt;br /&gt;
&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List and Group Prices (IPRC)===&lt;br /&gt;
The table IPRC stores Category (cmd)/Group Prices and the equivelent of List prices.  Category &amp;quot;#&amp;quot; is represents &amp;quot;List&amp;quot; in Keystone.&lt;br /&gt;
*Many times, what appears to be a Group(cat) is in fact used as a list price.  You can preview the iprc data to the customer to determine this before the install.   You can also import into Keystone and then convert a group to list prices.&lt;br /&gt;
*Often, a large amount of junk pricing is in this table.  Preview to customer to determine if large amounts of pricing should be omitted.&lt;br /&gt;
*Where in Keystone, we often base pricing on X$ off list for a group or customer, in Command each price ends up as a record.  If possible, find groups (price cats) that can be skipped and replaced with a price off list.  (this may only apply to the mix items in a group/price cat)&lt;br /&gt;
*Expect redundant records that tneed to be processed by effect date.  (Use of RANK or similar SQL tricks can correct for this)&lt;br /&gt;
*Expect Prices for items that may or may not exist.&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Job (proj)====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Base selection on Expir_date, Setup_date and the inactive_code of projects, customers, iloc and imst.&lt;br /&gt;
&lt;br /&gt;
====Job Detail (prjp)====&lt;br /&gt;
*Tie this selection to the core query used for PROJ&lt;br /&gt;
*Plant # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=940</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=940"/>
		<updated>2024-02-22T14:18:50Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants (Locn/Plnt)===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  &lt;br /&gt;
&lt;br /&gt;
*LOCN: Locations&lt;br /&gt;
*PLNT: Plant&lt;br /&gt;
&lt;br /&gt;
Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
===Customer Class===&lt;br /&gt;
*'''SANL:'''&lt;br /&gt;
&lt;br /&gt;
===Salespeople and Drivers===&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  The actual prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
*'''IMST:''' Products&lt;br /&gt;
*'''ILOC:''' Product by Location (Similar to Plant)&lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Credit Terms (TRMS)===&lt;br /&gt;
You can import term codes and descriptions, but the meaning does not map from system to system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Trucks===&lt;br /&gt;
Trucks&lt;br /&gt;
&lt;br /&gt;
===Unit of Meausure (uoms)===&lt;br /&gt;
The key field for Unit of Measure is typically a long integer.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer Prices (CPRD)===&lt;br /&gt;
&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List and Group Prices (IPRC)===&lt;br /&gt;
The table IPRC stores Category (cmd)/Group Prices and the equivelent of List prices.  Category &amp;quot;#&amp;quot; is represents &amp;quot;List&amp;quot; in Keystone.&lt;br /&gt;
*Many times, what appears to be a Group(cat) is in fact used as a list price.  You can preview the iprc data to the customer to determine this before the install.   You can also import into Keystone and then convert a group to list prices.&lt;br /&gt;
*Often, a large amount of junk pricing is in this table.  Preview to customer to determine if large amounts of pricing should be omitted.&lt;br /&gt;
*Where in Keystone, we often base pricing on X$ off list for a group or customer, in Command each price ends up as a record.  If possible, find groups (price cats) that can be skipped and replaced with a price off list.  (this may only apply to the mix items in a group/price cat)&lt;br /&gt;
*Expect redundant records that tneed to be processed by effect date.  (Use of RANK or similar SQL tricks can correct for this)&lt;br /&gt;
*Expect Prices for items that may or may not exist.&lt;br /&gt;
*A plant of # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Job (proj)====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Base selection on Expir_date, Setup_date and the inactive_code of projects, customers, iloc and imst.&lt;br /&gt;
&lt;br /&gt;
====Job Detail (prjp)====&lt;br /&gt;
*Tie this selection to the core query used for PROJ&lt;br /&gt;
*Plant # means all plants.  On import try to match this to a Keystone Base Price Plant.  (If all plants point to 01 - import price to 01 if possible)&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=939</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=939"/>
		<updated>2024-02-21T17:06:32Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Project (proj) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
*'''LOCN:''' Locations (Similar to Plant)&lt;br /&gt;
*'''PLNT:''' Plant&lt;br /&gt;
&lt;br /&gt;
===Customer Class===&lt;br /&gt;
*'''SANL:'''&lt;br /&gt;
&lt;br /&gt;
===Salespeople and Drivers===&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  The actual prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
*'''IMST:''' Products&lt;br /&gt;
*'''ILOC:''' Product by Location (Similar to Plant)&lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
*'''TRMS:''' Terms&lt;br /&gt;
*'''TRUC:''' Trucks&lt;br /&gt;
*'''UOMS:''' Unit of Meausure&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Prices===&lt;br /&gt;
*'''CPRD:''' Customer Prices&lt;br /&gt;
&lt;br /&gt;
*'''IPRC:''' Prices - by Category (Group)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
====Challenges with Job Import====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
====Project (proj)====&lt;br /&gt;
*Base selection on Expir_date, Setup_date and the inactive_code of projects, customers, iloc and imst.&lt;br /&gt;
&lt;br /&gt;
====Project Prices (prjp)====&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=938</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=938"/>
		<updated>2024-02-21T16:02:24Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Challenges with Job Import */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
*'''LOCN:''' Locations (Similar to Plant)&lt;br /&gt;
*'''PLNT:''' Plant&lt;br /&gt;
&lt;br /&gt;
===Customer Class===&lt;br /&gt;
*'''SANL:'''&lt;br /&gt;
&lt;br /&gt;
===Salespeople and Drivers===&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  The actual prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
*'''IMST:''' Products&lt;br /&gt;
*'''ILOC:''' Product by Location (Similar to Plant)&lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
*'''TRMS:''' Terms&lt;br /&gt;
*'''TRUC:''' Trucks&lt;br /&gt;
*'''UOMS:''' Unit of Meausure&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Prices===&lt;br /&gt;
*'''CPRD:''' Customer Prices&lt;br /&gt;
&lt;br /&gt;
*'''IPRC:''' Prices - by Category (Group)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
====Challenges with Job Import====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
====Project (proj)====&lt;br /&gt;
====Project Prices (prjp)====&lt;br /&gt;
====Price Escalation (ppre)====&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=937</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=937"/>
		<updated>2024-02-21T16:01:19Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Jobs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
*'''LOCN:''' Locations (Similar to Plant)&lt;br /&gt;
*'''PLNT:''' Plant&lt;br /&gt;
&lt;br /&gt;
===Customer Class===&lt;br /&gt;
*'''SANL:'''&lt;br /&gt;
&lt;br /&gt;
===Salespeople and Drivers===&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  The actual prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
*'''IMST:''' Products&lt;br /&gt;
*'''ILOC:''' Product by Location (Similar to Plant)&lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
*'''TRMS:''' Terms&lt;br /&gt;
*'''TRUC:''' Trucks&lt;br /&gt;
*'''UOMS:''' Unit of Meausure&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Prices===&lt;br /&gt;
*'''CPRD:''' Customer Prices&lt;br /&gt;
&lt;br /&gt;
*'''IPRC:''' Prices - by Category (Group)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
&lt;br /&gt;
====Challenges with Job Import====&lt;br /&gt;
*Project Code and Name vs JOB PO Loc.  Code is very cryptic. Name is very long.  Best solution: - BatchJobCode as ProjCode.  Import Proj Name into Invoice Desc..Import proj code into JobPoLoc but update with a cleaned up verion of the code.&lt;br /&gt;
*Plant number not cleanly in detail table.  You can attempt to use the plant info in the project table. But then the next problem...&lt;br /&gt;
*The products from job detail will have mismatches with imported products.  You will see prices for product (base) and plant combos that don't exist and thus are not imported into Keystone.  Either these get skipped or you need clever rerouting selection queries to find valid product.&lt;br /&gt;
*Multiple price records per Customer/Project/Product.  You need to use special query features such as rank to sort this out.&lt;br /&gt;
*Price Escalation - the price in prjp may not apply if the customer uses escalation.&lt;br /&gt;
&lt;br /&gt;
*'''PROJ:''' Project&lt;br /&gt;
*'''PRJP:''' Project Prices&lt;br /&gt;
*'''PPRE:''' Price Escalation&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Command_Import&amp;diff=936</id>
		<title>Command Import</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Command_Import&amp;diff=936"/>
		<updated>2024-02-20T16:21:18Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Know This First */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There is not ONE way to import Command Data - each situation is unique.&lt;br /&gt;
&lt;br /&gt;
===Know This First===&lt;br /&gt;
What you need to know before importing Command's Data&lt;br /&gt;
*There is NO data integrity.&lt;br /&gt;
:*Expect sub tables, prices etc. to have records that do have matching main tables.  (e.g. prices for customers that don't exist).&lt;br /&gt;
*Alpha fields must be trimmed - especially key fields.  Expect both left and right padding on Customer and product codes.&lt;br /&gt;
:MS SQL hasn't had the &amp;quot;TRIM&amp;quot; statement for long, so most often you must select as:&lt;br /&gt;
:&amp;lt;code&amp;gt;LTRIM(RTRIM((PRJP.PROJ_CODE)) JOB_PO_LOC,&amp;lt;/code&amp;gt;&lt;br /&gt;
:in some cases, such as Oracle you only have trim and must select as:&lt;br /&gt;
:&amp;lt;code&amp;gt;TRIM(PRJP.PROJ_CODE) JOB_PO_LOC,&amp;lt;/code&amp;gt;&lt;br /&gt;
*Numeric Fields may be null.  Use coalesce... &amp;lt;code&amp;gt;COALESCE(Finc_Chrg_amt,0) Finc_chrg_amt&amp;lt;/code&amp;gt;&lt;br /&gt;
*Field IDs are longer - especially Tax Authorities, sales people and classes.&lt;br /&gt;
*Keep a list of mappings when setting up the class type fields to use in case statements...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
case TERMS&lt;br /&gt;
WHEN '15N' THEN '15' &lt;br /&gt;
WHEN 'N20' THEN '20' &lt;br /&gt;
   ...&lt;br /&gt;
WHEN 'CAS' THEN 'CA' ELSE '' END CUST_TERMS&amp;lt;/pre&amp;gt;&lt;br /&gt;
*Some records, especially prices, have what appear to be duplicates.  You need special queries that pull just the latest version of the record.&lt;br /&gt;
*Start with Small Tables and Build up (Like any Import)&lt;br /&gt;
&lt;br /&gt;
===Import Examples===&lt;br /&gt;
&lt;br /&gt;
Here are some samples used in the past...&lt;br /&gt;
:[[Examples by Table]]&lt;br /&gt;
:[[Command Import: Hedger Work Notes]]&lt;br /&gt;
:[[Command Import: Rain MO Work Notes]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Command Tables===&lt;br /&gt;
&lt;br /&gt;
*'''ACCT:''' GL  Accounts&lt;br /&gt;
*'''ARTB:''' Aging&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''COMP:''' Company&lt;br /&gt;
*'''CPRD:''' Customer Prices&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
*'''CUST:''' Customer Prices&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
*'''ILOC:''' Product by Location (Similar to Plant)&lt;br /&gt;
*'''IMST:''' Products&lt;br /&gt;
*'''IPRC:''' Prices - by Level (Group)&lt;br /&gt;
*'''LOCN:''' Locations (Similar to Plant)&lt;br /&gt;
*'''PLNT:''' Plant&lt;br /&gt;
*'''PRCC:''' Price Group&lt;br /&gt;
*'''PRJP:''' Project Prices&lt;br /&gt;
*'''PROJ:''' Project&lt;br /&gt;
*'''SANL:''' Customer Class&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
*'''TRMS:''' Terms&lt;br /&gt;
*'''TRUC:''' Trucks&lt;br /&gt;
*'''UOMS:''' Unit of Meausure&lt;br /&gt;
*'''USGE:''' Useage&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Command_Import&amp;diff=935</id>
		<title>Command Import</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Command_Import&amp;diff=935"/>
		<updated>2024-02-20T16:18:01Z</updated>

		<summary type="html">&lt;p&gt;Chanson: /* Know This First */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There is not ONE way to import Command Data - each situation is unique.&lt;br /&gt;
&lt;br /&gt;
===Know This First===&lt;br /&gt;
What you need to know before importing Command's Data&lt;br /&gt;
*There is NO data integrity.&lt;br /&gt;
:*Expect sub tables, prices etc. to have records that do have matching main tables.  (e.g. prices for customers that don't exist).&lt;br /&gt;
*Alpha fields must be trimmed - especially key fields.  Expect both left and right padding on Customer and product codes.&lt;br /&gt;
:MS SQL hasn't had the &amp;quot;TRIM&amp;quot; statement for long, so most often you must select as:&lt;br /&gt;
:&amp;lt;code&amp;gt;LTRIM(RTRIM((PRJP.PROJ_CODE)) JOB_PO_LOC,&amp;lt;/code&amp;gt;&lt;br /&gt;
:in some cases, such as Oracle you only have trim and must select as:&lt;br /&gt;
:&amp;lt;code&amp;gt;TRIM(PRJP.PROJ_CODE) JOB_PO_LOC,&amp;lt;/code&amp;gt;&lt;br /&gt;
*Numeric Fields may be null.  Use coalesce... &amp;lt;code&amp;gt;COALESCE(Finc_Chrg_amt,0) Finc_chrg_amt&amp;lt;/code&amp;gt;&lt;br /&gt;
*Field IDs are longer - especially Tax Authorities, sales people and classes.&lt;br /&gt;
*Keep a list of mappings when setting up the class type fields to use in case statements...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
case TERMS&lt;br /&gt;
WHEN '15N' THEN '15' &lt;br /&gt;
WHEN 'N20' THEN '20' &lt;br /&gt;
   ...&lt;br /&gt;
WHEN 'CAS' THEN 'CA' ELSE '' END CUST_TERMS&amp;lt;/pre&amp;gt;&lt;br /&gt;
*Start with Small Tables and Build up (Like any Import)&lt;br /&gt;
&lt;br /&gt;
===Import Examples===&lt;br /&gt;
&lt;br /&gt;
Here are some samples used in the past...&lt;br /&gt;
:[[Examples by Table]]&lt;br /&gt;
:[[Command Import: Hedger Work Notes]]&lt;br /&gt;
:[[Command Import: Rain MO Work Notes]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Command Tables===&lt;br /&gt;
&lt;br /&gt;
*'''ACCT:''' GL  Accounts&lt;br /&gt;
*'''ARTB:''' Aging&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''COMP:''' Company&lt;br /&gt;
*'''CPRD:''' Customer Prices&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
*'''CUST:''' Customer Prices&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
*'''ILOC:''' Product by Location (Similar to Plant)&lt;br /&gt;
*'''IMST:''' Products&lt;br /&gt;
*'''IPRC:''' Prices - by Level (Group)&lt;br /&gt;
*'''LOCN:''' Locations (Similar to Plant)&lt;br /&gt;
*'''PLNT:''' Plant&lt;br /&gt;
*'''PRCC:''' Price Group&lt;br /&gt;
*'''PRJP:''' Project Prices&lt;br /&gt;
*'''PROJ:''' Project&lt;br /&gt;
*'''SANL:''' Customer Class&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
*'''TRMS:''' Terms&lt;br /&gt;
*'''TRUC:''' Trucks&lt;br /&gt;
*'''UOMS:''' Unit of Meausure&lt;br /&gt;
*'''USGE:''' Useage&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=934</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=934"/>
		<updated>2024-02-19T18:43:28Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===GL Accounts===&lt;br /&gt;
ACCT is the source in CMD but it's not high quality data.&lt;br /&gt;
&lt;br /&gt;
===Company (Divisions)===&lt;br /&gt;
COMP will provide company list.  This might be separate databases or separate divisions within a database.&lt;br /&gt;
&lt;br /&gt;
===Plants===&lt;br /&gt;
Locations and plants are similar but different.  Multiple plants may have on location.  Prices and items are normally setup by location.  For example you may have location 01 with plants 1A and 1B.  The product tables (IMST/ILOC) would only have a reference to location 01 where Keystone will have 1A and 1B.&lt;br /&gt;
&lt;br /&gt;
*'''LOCN:''' Locations (Similar to Plant)&lt;br /&gt;
*'''PLNT:''' Plant&lt;br /&gt;
&lt;br /&gt;
===Customer Class===&lt;br /&gt;
*'''SANL:'''&lt;br /&gt;
&lt;br /&gt;
===Salespeople and Drivers===&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
This is somewhat similar to Keystone setup, but not quite the same.  Terminlogy is quite different:&lt;br /&gt;
Command - Keystone&lt;br /&gt;
Tax Code - Tax Authority&lt;br /&gt;
Tax Authority - Tax Level (e.g. 1=state, 2=County, 3=City)&lt;br /&gt;
&lt;br /&gt;
CMD is always setup multi-level whereas Keystone customer often want to flatten the taxes to single level.  This is a key up-front question explaining the pros/cons of each direction.&lt;br /&gt;
&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
===Price Group Headers===&lt;br /&gt;
You need to import the Price Group (Category in CMD) before customers.  The actual prices after products are setup.&lt;br /&gt;
'''PRCC'''&lt;br /&gt;
&lt;br /&gt;
===Dispatch Useage Class===&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
*'''IMST:''' Products&lt;br /&gt;
*'''ILOC:''' Product by Location (Similar to Plant)&lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descry)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descry)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
*'''TRMS:''' Terms&lt;br /&gt;
*'''TRUC:''' Trucks&lt;br /&gt;
*'''UOMS:''' Unit of Meausure&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Prices===&lt;br /&gt;
*'''CPRD:''' Customer Prices&lt;br /&gt;
&lt;br /&gt;
*'''IPRC:''' Prices - by Category (Group)&lt;br /&gt;
&lt;br /&gt;
===Jobs===&lt;br /&gt;
The number one challenge is getting useful codes from CMD into Keystone.  CMD Proj codes tend to be short and cryptic to end customer.  Proj Names are very long.  the typical process is to import the code as job_po_loc (can also into batch_job_code) and invoice description comes from proj_name.  Then after import, we udpate job_po_loc from invoice desc the help of the customer.&lt;br /&gt;
&lt;br /&gt;
*'''PROJ:''' Project&lt;br /&gt;
*'''PRJP:''' Project Prices&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=933</id>
		<title>Examples by Table</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Examples_by_Table&amp;diff=933"/>
		<updated>2024-02-19T18:28:33Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*'''GL Accounts''' (ACCT)&lt;br /&gt;
*'''COMP:''' Company&lt;br /&gt;
*'''USGE:''' Useage&lt;br /&gt;
*'''SANL:''' Customer Class&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Taxes===&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Salespeople and Drivers===&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conctacts===&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
&lt;br /&gt;
===Customer===&lt;br /&gt;
*'''CUST:''' Customer&lt;br /&gt;
State needs to be mapped...&lt;br /&gt;
&amp;lt;pre)&lt;br /&gt;
CASE REPLACE(UPPER(TRIM(ADDR_STATE)),' ','')&lt;br /&gt;
   WHEN 'NEBRASK' THEN 'NE'&lt;br /&gt;
   WHEN 'NEWYORK' THEN 'NY'&lt;br /&gt;
   WHEN 'NEWJERSEY' THEN 'NJ'&lt;br /&gt;
   ...&lt;br /&gt;
   WHEN 'PENNSYLVAN' THEN 'PA'&lt;br /&gt;
   WHEN 'SOUTHCARO' THEN 'SC'&lt;br /&gt;
   WHEN 'TENNESSEE' THEN 'TN'&lt;br /&gt;
 ELSE SUBSTR(UPPER(TRIM(ADDR_STATE)),1,2) END STATE,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
*'''ILOC:''' Product by Location (Similar to Plant)&lt;br /&gt;
*'''IMST:''' Products&lt;br /&gt;
*'''LOCN:''' Locations (Similar to Plant)&lt;br /&gt;
*'''PLNT:''' Plant&lt;br /&gt;
*'''PRCC:''' Price Group&lt;br /&gt;
*'''PRJP:''' Project Prices&lt;br /&gt;
*'''PROJ:''' Project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
with sac (clsno,descr) as&lt;br /&gt;
	(&lt;br /&gt;
	select &lt;br /&gt;
	case ltrim(rtrim(sales_anl_code)) &lt;br /&gt;
	when 'NSF' THEN 'NS'&lt;br /&gt;
	when 'CNA' THEN 'CN'&lt;br /&gt;
	when 'C27' THEN '27'&lt;br /&gt;
	when 'C29' THEN '29'&lt;br /&gt;
	when 'C34' THEN '34'&lt;br /&gt;
	when 'C53' THEN '53'&lt;br /&gt;
	else ltrim(rtrim(sales_anl_code))  end&lt;br /&gt;
	&amp;quot;class_no&amp;quot;,&lt;br /&gt;
	ltrim(rtrim(descr)) description&lt;br /&gt;
	from sanl&lt;br /&gt;
	)&lt;br /&gt;
select  &lt;br /&gt;
concat('&lt;br /&gt;
INSERT INTO artcucls&lt;br /&gt;
( CLASS_NO, DESCRIPTION, IMPORTED_FLAG, LAST_CHANGE_DATETIME, LAST_CHANGE_USER, ACTIVE_FLAG )  VALUES &lt;br /&gt;
( ''',clsno,''',''',left(descr,35),''', ''Y'', CAST(''TODAY'' AS TIMESTAMP), ''HIT'', ''Y''    );&lt;br /&gt;
'),&lt;br /&gt;
ltrim(rtrim(clsno)) &amp;quot;class_no&amp;quot;,&lt;br /&gt;
ltrim(rtrim(descr)) description,  * &lt;br /&gt;
from sac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
*'''TRMS:''' Terms&lt;br /&gt;
*'''TRUC:''' Trucks&lt;br /&gt;
*'''UOMS:''' Unit of Meausure&lt;br /&gt;
===Prices===&lt;br /&gt;
*'''CPRD:''' Customer Prices&lt;br /&gt;
*'''IPRC:''' Prices - by Level (Group)&lt;br /&gt;
&lt;br /&gt;
===A/R Invoice===&lt;br /&gt;
AR may or may not come from Command system.  This needs to be researched.&lt;br /&gt;
*Invoice Numbers may be numeric or Alpha.  When Alpha - Invoice Number=0,   JobPoLoc = Alpha Inovice Number.&lt;br /&gt;
*Create Preview outputs - DataScopeX is good for this.&lt;br /&gt;
*Establish a Hard Cutoff Date&lt;br /&gt;
&lt;br /&gt;
*ARTB&lt;br /&gt;
:*Curr_Bal_amt key field&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=Command_Import&amp;diff=932</id>
		<title>Command Import</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=Command_Import&amp;diff=932"/>
		<updated>2024-02-19T12:57:10Z</updated>

		<summary type="html">&lt;p&gt;Chanson: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There is not ONE way to import Command Data - each situation is unique.&lt;br /&gt;
&lt;br /&gt;
===Know This First===&lt;br /&gt;
What you need to know before importing Command's Data&lt;br /&gt;
*There is NO data integrity.&lt;br /&gt;
:*Expect sub tables, prices etc. to have records that do have matching main tables.  (e.g. prices for customers that don't exist).&lt;br /&gt;
*All fields must be trimmed - especially key fields.  Expect both left and right padding on Customer and product codes.&lt;br /&gt;
:MS SQL hasn't had the &amp;quot;TRIM&amp;quot; statement for long, so most often you must select as:&lt;br /&gt;
:&amp;lt;code&amp;gt;LTRIM(RTRIM((PRJP.PROJ_CODE)) JOB_PO_LOC,&amp;lt;/code&amp;gt;&lt;br /&gt;
:in some cases, such as Oracle you only have trim and must select as:&lt;br /&gt;
:&amp;lt;code&amp;gt;TRIM(PRJP.PROJ_CODE) JOB_PO_LOC,&amp;lt;/code&amp;gt;&lt;br /&gt;
*Field IDs are longer - especially Tax Authorities, sales people and classes.&lt;br /&gt;
:*Keep a list of mappings when setting up the class type fields to use in case statements...&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
case TERMS&lt;br /&gt;
WHEN '15N' THEN '15' &lt;br /&gt;
WHEN 'N20' THEN '20' &lt;br /&gt;
   ...&lt;br /&gt;
WHEN 'CAS' THEN 'CA' ELSE '' END CUST_TERMS&amp;lt;/pre&amp;gt;&lt;br /&gt;
*Start with Small Tables and Build up (Like any Import)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Import Examples===&lt;br /&gt;
&lt;br /&gt;
Here are some samples used in the past...&lt;br /&gt;
:[[Examples by Table]]&lt;br /&gt;
:[[Command Import: Hedger Work Notes]]&lt;br /&gt;
:[[Command Import: Rain MO Work Notes]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Command Tables===&lt;br /&gt;
&lt;br /&gt;
*'''ACCT:''' GL  Accounts&lt;br /&gt;
*'''ARTB:''' Aging&lt;br /&gt;
*'''CCON:''' Contact Connection&lt;br /&gt;
*'''COMP:''' Company&lt;br /&gt;
*'''CPRD:''' Customer Prices&lt;br /&gt;
*'''CTCT:''' Contact&lt;br /&gt;
*'''CUST:''' Customer Prices&lt;br /&gt;
*'''EMPL:''' Employee - Sales and Drivers&lt;br /&gt;
*'''ICAT:''' Item (Product) &lt;br /&gt;
*'''ICST:''' Component Structure&lt;br /&gt;
*'''ILOC:''' Product by Location (Similar to Plant)&lt;br /&gt;
*'''IMST:''' Products&lt;br /&gt;
*'''IPRC:''' Prices - by Level (Group)&lt;br /&gt;
*'''LOCN:''' Locations (Similar to Plant)&lt;br /&gt;
*'''PLNT:''' Plant&lt;br /&gt;
*'''PRCC:''' Price Group&lt;br /&gt;
*'''PRJP:''' Project Prices&lt;br /&gt;
*'''PROJ:''' Project&lt;br /&gt;
*'''SANL:''' Customer Class&lt;br /&gt;
*'''TAXC:''' Tax (Similar to Keystone Tax Auth)&lt;br /&gt;
*'''TAXJ:''' Tax Structure&lt;br /&gt;
*'''TAXL:''' Tax Locality (not 1 to 1 with Keystone)&lt;br /&gt;
*'''TRMS:''' Terms&lt;br /&gt;
*'''TRUC:''' Trucks&lt;br /&gt;
*'''UOMS:''' Unit of Meausure&lt;br /&gt;
*'''USGE:''' Useage&lt;/div&gt;</summary>
		<author><name>Chanson</name></author>
	</entry>
</feed>