<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Deft Flux &#187; JDEdwards</title>
	<atom:link href="http://deftflux.com/category/jdedwards/feed/" rel="self" type="application/rss+xml" />
	<link>http://deftflux.com</link>
	<description>recycling truckloads of electrons daily</description>
	<lastBuildDate>Mon, 24 May 2010 15:40:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>J. D. Edwards Unit of Measure Conversion</title>
		<link>http://deftflux.com/2008/10/09/jde-unit-of-measure-conversion/</link>
		<comments>http://deftflux.com/2008/10/09/jde-unit-of-measure-conversion/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 17:57:59 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[JDEdwards]]></category>

		<guid isPermaLink="false">http://deftflux.com/?p=6</guid>
		<description><![CDATA[As long as we are discussing JD Edwards running on DB/2. Here&#8217;s another potentially useful function.  This one converts a value from one unit of measure to another based on the F41002 table.  It does this by converting the FromUOM to the primary UOM and thence to the ToUOM. --#SET DELIMITER ! drop function myuser.JDEConvert! [...]]]></description>
			<content:encoded><![CDATA[<p>As long as we are discussing JD Edwards running on DB/2.  Here&#8217;s another potentially useful function.  This one converts a value from one unit of measure to another based on the F41002 table.  It does this by converting the FromUOM to the primary UOM and thence to the ToUOM.  </p>
<p><span id="more-6"></span></p>
<pre>--#SET DELIMITER !
drop function myuser.JDEConvert!

CREATE function myuser.JDEConvert(Item decimal(10,0), FromUOM varchar(3),
                                  ToUOM varchar(3), Units decimal(15,7))
   returns decimal(15,7)
   language sql
   not deterministic
   reads sql data
begin atomic

   declare PrimaryUnits decimal(15,7);
   declare ToUnits decimal(15,7);

   /*declare exit handler for sqlexception
      return null;*/

   /* This is for the sake of speed mainly */
   if Units = 0 then
      return 0;
   end if;
   if FromUOM = ToUOM then
      return Units;
   end if;

   /* -----------------------------------------------------------------
      we know we don't have any conversion directly between the from unit
      and the to unit, so what we do is look for a conversion like so...
      FromUOM to PrimaryUOM to ToUOM
      ----------------------------------------------------------------- */
   for cfF41002 as
      select f.umum fum, f.umrum frum, round(f.umconv/10000000,7) fconv, round(f.umcnv1/10000000,7) fcnv1,
             t.umum tum, t.umrum trum, round(t.umconv/10000000,7) tconv, round(t.umcnv1/10000000,7) tcnv1
        from f41002 f join F41002 t on t.umitm = f.umitm
       where f.umitm = Item
         and FromUOM in (f.umum, f.umrum)
         and ToUOM in (t.umum, t.umrum)
   do
       /* This could be slightly simplified, but this way is easier to read I think. */
       if fum = FromUOM then
          set PrimaryUnits = Units * fcnv1;
       else
          set PrimaryUnits = (Units / fconv) * fcnv1;
       end if;

       if tum = ToUOM then
          set ToUnits = PrimaryUnits / tcnv1;
       else
          set ToUnits = (PrimaryUnits * tconv) / tcnv1;
       end if;

       return ToUnits;

       /*return ToUnits;*/

   end for;

   return null;

end!

select imsrtx,
       '1' || imuom1 || ' =', JDEConvert(imitm, imuom1, 'LB', 1) || ' lbs.',
       '1' || imuom2 || ' =', JDEConvert(imitm, imuom2, 'LB', 1) || ' lbs.'
  from f4101</pre>
<p>(In the past, we had a function that found the requested conversion by recursively searching direct conversions till it found a path between the From UOM and the ToUOM.  We all know recursion is more fun and usually requires less code.  In this case the recursive method was less efficient and created more problems than it solved, so we sadly had to rewrite to this method, which we are just as proud of.)</p>
]]></content:encoded>
			<wfw:commentRss>http://deftflux.com/2008/10/09/jde-unit-of-measure-conversion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>J. D. Edwards Date to DB/2 Date</title>
		<link>http://deftflux.com/2008/10/08/j-d-edwards-date-to-db2-date/</link>
		<comments>http://deftflux.com/2008/10/08/j-d-edwards-date-to-db2-date/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 16:06:32 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[JDEdwards]]></category>

		<guid isPermaLink="false">http://deftflux.com/?p=5</guid>
		<description><![CDATA[During nine years of blackguarding the J. D. Edwards date format (also known as JDate, also misnamed Julian Date),  I have resisted learning to write DB/2 stored procedures because the need to use them while developing OneWorld applications is minimal and OneWorld is the only context in which I have encountered DB/2.  Well, I have [...]]]></description>
			<content:encoded><![CDATA[<p>During nine years of blackguarding the J. D. Edwards date format (also known as JDate, also misnamed Julian Date),  I have resisted learning to write DB/2 stored procedures because the need to use them while developing OneWorld applications is minimal and OneWorld is the only context in which I have encountered DB/2.  Well, I have finally encountered that special confluence of  necessity and available time that produces a tool &#8212; in this case a function. I broke down, I learned, and I wrote that JDate to DB/2 Date function. Here is that code, in case you should find it useful:</p>
<p><span id="more-5"></span></p>
<pre>
-- We have to set the delimiter to ! so we can use
-- ; inside our function.  This is an intelligent comment
-- just for DB/2, but don't forget to tell your SQL tool to use !.
--#SET DELIMITER !
drop function myuser.JToDate!

CREATE function myuser.JToDate (JDEDate decimal(8,0))
    returns date
    language sql
    deterministic
    no external action
begin atomic
   if JDEDate = 0 then
      return null;
   else
      return date(char(1900000 + Round(JDEDate, -3) + (JDEDate - Round(JDEDate, -3))));
   end if;
end!

select JToDate(108098), JToDate(0), JToDate(imupmj)
from F4101!</pre>
<p>I recommend the <a href="http://mysite.verizon.net/Graeme_Birchall/id1.html">DB/2 SQL Cookbook</a> as a pleasant mix of examples and syntax flows from which to learn.</p>
<p align="right">- Adam</p>
]]></content:encoded>
			<wfw:commentRss>http://deftflux.com/2008/10/08/j-d-edwards-date-to-db2-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JDEdwards Data Dictionary Where Used</title>
		<link>http://deftflux.com/2008/06/17/jdedwards-data-dictionary-where-used/</link>
		<comments>http://deftflux.com/2008/06/17/jdedwards-data-dictionary-where-used/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 02:09:59 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[JDEdwards]]></category>

		<guid isPermaLink="false">http://deftflux.com/?p=3</guid>
		<description><![CDATA[If you have ever used the JDEdwards cross-reference facility in an attempt to find where a certain table column is used, you understand that it can be difficult, especially when the alias for your column is common. Let&#8217;s say you have a custom table [F550001] that has a column [URRF], and you need to find [...]]]></description>
			<content:encoded><![CDATA[<p>If you have ever used the JDEdwards cross-reference facility in an attempt to find where a certain table column is used, you understand that it can be difficult, especially when the alias for your column is common.</p>
<p>Let&#8217;s say you have a custom table [F550001] that has a column [URRF], and you need to find all programs that use the F550001.URRF.  Well, you may have 50 custom programs that use F550001 and there may be 250 programs, native and custom, that use the alias URRF.  You can see the difficulty in searching through 50 programs to find 5 that reference F550001.URRF.</p>
<p>If, however, you take the 50 custom programs that reference F550001 and export them to the spreadsheet program of your choice and then export the 250 programs that reference the URRF to another spreadsheet, you can filter the 50 references to F550001 down to only those programs that also reference URRF.  Now, you still may have a few extra programs in your list &#8212; programs that don&#8217;t reference F550001.URRF &#8212; but you now have a much smaller list to work from.</p>
]]></content:encoded>
			<wfw:commentRss>http://deftflux.com/2008/06/17/jdedwards-data-dictionary-where-used/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
