<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://in.compucrete.com/index.php?action=history&amp;feed=atom&amp;title=QueryGen_Case%3A_Fix_Standard_Cost</id>
	<title>QueryGen Case: Fix Standard Cost - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://in.compucrete.com/index.php?action=history&amp;feed=atom&amp;title=QueryGen_Case%3A_Fix_Standard_Cost"/>
	<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=QueryGen_Case:_Fix_Standard_Cost&amp;action=history"/>
	<updated>2026-05-15T16:09:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>http://in.compucrete.com/index.php?title=QueryGen_Case:_Fix_Standard_Cost&amp;diff=530&amp;oldid=prev</id>
		<title>WikiAdmin: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=QueryGen_Case:_Fix_Standard_Cost&amp;diff=530&amp;oldid=prev"/>
		<updated>2023-07-14T13:00:35Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:00, 14 July 2023&lt;/td&gt;
				&lt;/tr&gt;
&lt;!-- diff cache key my_wiki:diff::1.12:old-529:rev-530 --&gt;
&lt;/table&gt;</summary>
		<author><name>WikiAdmin</name></author>
	</entry>
	<entry>
		<id>http://in.compucrete.com/index.php?title=QueryGen_Case:_Fix_Standard_Cost&amp;diff=529&amp;oldid=prev</id>
		<title>Intra&gt;Chanson: /* Standard Cost Mismatch */</title>
		<link rel="alternate" type="text/html" href="http://in.compucrete.com/index.php?title=QueryGen_Case:_Fix_Standard_Cost&amp;diff=529&amp;oldid=prev"/>
		<updated>2018-05-23T16:14:02Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Standard Cost Mismatch&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[CATEGORY: QueryGen]]&lt;br /&gt;
=Standard Cost Mismatch=&lt;br /&gt;
Case - Standard cost in products mismatches the current standard cost record in product transaction table.&lt;br /&gt;
&lt;br /&gt;
When Standard Cost for a product is updated through Product Maintenance a corresponding cost transaction is created into ARTPRTRX.  When costs are updated by other means these transactions need to be generated for proper function of Keystone.&lt;br /&gt;
&lt;br /&gt;
=Diagnostic query=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select P.PRODUCT_CODE,OH.STANDARD_COST &amp;quot;TRX STD COST&amp;quot;,P.STANDARD_COST &amp;quot;PRD STD COST&amp;quot;,OH.*,P.UNIT_OF_MEASURE,P.INVENTORY_GL,&lt;br /&gt;
(SELECT MAX(TRX_DATE) FROM artprtrx x where x.product_code=p.product_code and trx_type='C') LAST_COST&lt;br /&gt;
 FROM  ARTPROD P&lt;br /&gt;
LEFT OUTER JOIN ARPPRTRX_QTY_ON_HAND(P.PRODUCT_CODE,CAST('TODAY' AS DATE),2359,0,1) OH ON 1=1&lt;br /&gt;
where p.stocked='Y'&lt;br /&gt;
AND P.STANDARD_COST&amp;lt;&amp;gt;OH.STANDARD_COST&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=QueryGen Configuration=&lt;br /&gt;
&lt;br /&gt;
==Source Query==&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
select P.PRODUCT_CODE,OH.STANDARD_COST &amp;quot;TRX STD COST&amp;quot;,P.STANDARD_COST &amp;quot;PRD STD COST&amp;quot;,OH.*,P.UNIT_OF_MEASURE,P.INVENTORY_GL,&lt;br /&gt;
(SELECT MAX(TRX_DATE) FROM artprtrx x where x.product_code=p.product_code and trx_type='C') LAST_COST&lt;br /&gt;
 FROM  ARTPROD P&lt;br /&gt;
LEFT OUTER JOIN ARPPRTRX_QTY_ON_HAND(P.PRODUCT_CODE,CAST('TODAY' AS DATE),2359,0,1) OH ON 1=1&lt;br /&gt;
where p.stocked='Y'&lt;br /&gt;
AND P.STANDARD_COST&amp;lt;&amp;gt;OH.STANDARD_COST&lt;br /&gt;
and  ((&lt;br /&gt;
    (SELECT MAX(TRX_DATE) FROM artprtrx x where x.product_code=p.product_code and trx_type='C')  IS NULL)&lt;br /&gt;
OR ((SELECT MAX(TRX_DATE) FROM artprtrx x where x.product_code=p.product_code and trx_type='C')  &amp;lt;CAST('TODAY' AS DATE)));&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Header==&lt;br /&gt;
The purpose of the header text is to create a new session number and store it into the temporary table TMP_SNO.  If the Table TMP_SNO exists keep the &amp;quot;Create&amp;quot; portion in comments (/* ...  */). &lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
/* CREATE  TABLE TMP_SNO(SNO INTEGER); */ DELETE FROM TMP_SNO;&lt;br /&gt;
INSERT INTO TMP_SNO (SNO)  SELECT session_no FROM CCP_SESSION_BEGIN('ADMIN', 'Fix Std Cost artprtrx', '127.0.0.1', '3.X');&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Update Query:==&lt;br /&gt;
In the script below - set the default date you wish to use as the effective date for standard cost.&lt;br /&gt;
&amp;lt;PRE&amp;gt;&lt;br /&gt;
INSERT INTO &lt;br /&gt;
ARTPRTRX&lt;br /&gt;
( SESSION_NO, TRANS_NO, PRODUCT_CODE, UNIT_OF_MEASURE, QTY_CHANGE, COST, TRX_TYPE, TRX_DATE, TRX_TIME, INVENTORY_GL )  VALUES &lt;br /&gt;
( (SELECT MAX(SNO) FROM TMP_SNO), {PRODUCT_CODE|INC=1}, '{PRODUCT_CODE}', '{UNIT_OF_MEASURE}', 0 , {PRD STD COST}, 'C', '&amp;lt;as of date&amp;gt;', 0, '{INVENTORY_GL}'    );&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&lt;/div&gt;</summary>
		<author><name>Intra&gt;Chanson</name></author>
	</entry>
</feed>