<?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>Jimmy&#039;s Blog &#187; Programming</title>
	<atom:link href="http://jimmod.com/blog/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://jimmod.com/blog</link>
	<description>My name is Jimmy, and this is my story... ;)</description>
	<lastBuildDate>Fri, 14 Oct 2011 17:26:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library</title>
		<link>http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/</link>
		<comments>http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 12:42:27 +0000</pubDate>
		<dc:creator>jimmy</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[8583]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[iso]]></category>
		<category><![CDATA[iso 8583]]></category>
		<category><![CDATA[jimmy]]></category>
		<category><![CDATA[jpos]]></category>
		<category><![CDATA[pack]]></category>
		<category><![CDATA[packager]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[unpack]]></category>

		<guid isPermaLink="false">http://jimmod.com/blog/?p=225</guid>
		<description><![CDATA[ 
				
			 
				
			 
				Tweet 
			
		ISO 8583 Tutorial article

Introduction for Beginners
Build and Parse ISO Message using JPOS library
????

In the beginning
OK after my article about ISO 8583 let&#8217;s go deeper into programming using Java + JPOS library.
Quote from JPOS website:
jPOS is a Java® platform-based, mission-critical, ISO-8583 based financial transaction library/framework that can be customized and extended in [...]


Related posts:<ol><li><a href='http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Introduction for Beginners'>Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Introduction for Beginners</a></li><li><a href='http://jimmod.com/blog/2007/11/simple-log4j-implementation/' rel='bookmark' title='Permanent Link: Simple Log4J implementation'>Simple Log4J implementation</a></li><li><a href='http://jimmod.com/blog/2010/03/java-me-j2me-json-implementation-tutorialsample/' rel='bookmark' title='Permanent Link: Java ME (J2ME) JSON Implementation Tutorial/Sample'>Java ME (J2ME) JSON Implementation Tutorial/Sample</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div style="height:33px; padding-top:2px; padding-bottom:2px; clear:both;" class="really_simple_share"><div style="float:left; width:100px; " class="really_simple_share_facebook_like"> 
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjimmod.com%2Fblog%2F2011%2F07%2Fjimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library%2F&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=27" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"></iframe>
			</div><div style="float:left; width:90px; padding-left:10px;" class="really_simple_share_google1"> 
				<g:plusone size="medium" href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/" ></g:plusone>
			</div><div style="float:left; width:110px; padding-left:10px;" class="really_simple_share_twitter"> 
				<a href="http://twitter.com/share" class="twitter-share-button" data-count="none" 
					data-text="Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library" data-url="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/">Tweet</a> 
			</div></div>
		<div style="clear:both;"></div><h2 style="font-size: 1.5em;"><strong>ISO 8583 Tutorial article</strong></h2>
<ul>
<li><a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/">Introduction for Beginners</a></li>
<li><a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/">Build and Parse ISO Message using JPOS library</a></li>
<li>????</li>
</ul>
<h2><strong>In the beginning</strong></h2>
<p>OK after <a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/">my article about ISO 8583</a> let&#8217;s go deeper into programming using Java + JPOS library.</p>
<p>Quote from <a href="http://www.jpos.org/" target="_blank">JPOS website</a>:</p>
<blockquote><p>jPOS is a Java® platform-based, mission-critical, ISO-8583 based financial transaction library/framework that can be customized and extended in order to implement financial interchanges.</p></blockquote>
<p>So first thing to do is download JPOS from it website.</p>
<p>Then we setup our development environment by creating Java Project using your favorites IDE. Add to the project all jar in JPOS library.<br />
Here&#8217;s my Eclipse  package explorer looks like.<br />
<span id="more-225"></span></p>
<div id="attachment_226" class="wp-caption aligncenter" style="width: 306px"><a href="http://jimmod.com/blog/wp-content/uploads/2011/07/package-explorer.png"><img class="size-medium wp-image-226" title="package explorer" src="http://jimmod.com/blog/wp-content/uploads/2011/07/package-explorer-296x300.png" alt="package explorer" width="296" height="300" /></a><p class="wp-caption-text">package explorer</p></div>
<h2><strong>Create Data Elements (DE) types XML</strong></h2>
<p>Like I said that ISO 8583 is a &#8217;standard&#8217; which mean can be different between one implementation and another <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
To put it simple, although there&#8217;s a (some) standard for DE list sometime we need to change it.<br />
Either way, we need to tell JPOS how our DE will be formatted or packaged.</p>
<p>Since in the complete XML there&#8217;s 128 DE, I&#8217;ll quote only the DE # we used. Full xml can be <a href="http://jimmod.com/blog/wp-content/uploads/2011/07/basic.xml">downloaded here (basic.xml)</a></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span> <span style="color: #000066;">standalone</span>=<span style="color: #ff0000;">&quot;no&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE isopackager SYSTEM &quot;genericpackager.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isopackager<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;4&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;MESSAGE TYPE INDICATOR&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_NUMERIC&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;1&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;64&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;BIT MAP&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_BITMAP&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;3&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;6&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;PROCESSING CODE&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_NUMERIC&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;4&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;12&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;AMOUNT, TRANSACTION&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_NUMERIC&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;7&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;10&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;TRANSMISSION DATE AND TIME&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_NUMERIC&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;11&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;6&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SYSTEM TRACE AUDIT NUMBER&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_NUMERIC&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;44&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;25&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ADITIONAL RESPONSE DATA&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_LLCHAR&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;105&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;999&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;RESERVED ISO USE&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFA_LLLCHAR&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/isopackager<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The XML should easily understand in each isofield tag we define:</p>
<ul>
<li>id : the DE number</li>
<li>length : the max/fixed length of the DE</li>
<li>name : yes, it&#8217;s the name or description</li>
<li>class : this define the type of the DE, which in this case represent by the JPOS class. You can see the whole <a href="http://www.jpos.org/doc/javadoc/org/jpos/iso/package-summary.html" target="_blank">class list here</a>. I only list some of it.
<ul>
<li>IFA_NUMERIC : Numeric &#8211; Left padder with zeros.</li>
<li>IFA_BITMAP : For ISO Bitmap</li>
<li>IFA_LLCHAR : ASCII variable len CHAR &#8211; 2 digit length info</li>
<li>IFA_LLLCHAR : ASCII variable len CHAR &#8211; 3 digit length info</li>
</ul>
</li>
</ul>
<p>So this XML will be used for build (pack) ISO Message or parse (unpack) ISO Message.</p>
<p>You will need the <a href="http://jimmod.com/blog/wp-content/uploads/2011/07/genericpackager.dtd">XML data schema (genericpackager.dtd)</a> to be put on same directory with basic.xml</p>
<h2 style="font-size: 1.5em;">Build (pack) ISO Message</h2>
<p>Below is the code. The code is quite straight forward, review it first and I&#8217;ll discuss a bit afterward.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">gnu.jimmod.iso8583.utility</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISOMsg</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.packager.GenericPackager</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BuildISOMessage <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span>, ISOException <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Create Packager based on XML that contain DE type</span>
		GenericPackager packager <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GenericPackager<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;basic.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Create ISO Message</span>
		ISOMsg isoMsg <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ISOMsg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">setPackager</span><span style="color: #009900;">&#40;</span>packager<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">setMTI</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;0200&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span>, <span style="color: #0000ff;">&quot;201234&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">4</span>, <span style="color: #0000ff;">&quot;10000&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">7</span>, <span style="color: #0000ff;">&quot;110722180&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">11</span>, <span style="color: #0000ff;">&quot;123456&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">44</span>, <span style="color: #0000ff;">&quot;A5DFGR&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">105</span>, <span style="color: #0000ff;">&quot;ABCDEFGHIJ 1234567890&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// print the DE list</span>
		logISOMsg<span style="color: #009900;">&#40;</span>isoMsg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Get and print the output result</span>
		<span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> data <span style="color: #339933;">=</span> isoMsg.<span style="color: #006633;">pack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;RESULT : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> logISOMsg<span style="color: #009900;">&#40;</span>ISOMsg msg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;----ISO MESSAGE-----&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;  MTI : &quot;</span> <span style="color: #339933;">+</span> msg.<span style="color: #006633;">getMTI</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span>msg.<span style="color: #006633;">getMaxField</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>msg.<span style="color: #006633;">hasField</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;    Field-&quot;</span><span style="color: #339933;">+</span>i<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; : &quot;</span><span style="color: #339933;">+</span>msg.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>ISOException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;--------------------&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The output:</p>
<pre>----ISO MESSAGE-----
  MTI : 0200
    Field-3 : 201234
    Field-4 : 10000
    Field-7 : 110722180
    Field-11 : 123456
    Field-44 : A5DFGR
    Field-105 : ABCDEFGHIJ 1234567890
--------------------
RESULT : 0200B2200000001000000000000000800000201234000000010000011072218012345606A5DFGR021ABCDEFGHIJ 1234567890</pre>
<p>The program flow:</p>
<ol>
<li>Create ISO packager based on the xml file.</li>
<li>Set the DE values. I use <a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/" target="_blank">the previous article</a> examples.</li>
<li>Print the DE values set.</li>
<li>Pack the message.</li>
<li>Print the formatted ISO message. As you can see the result is the same with <a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/" target="_blank">the previous article</a> examples.</li>
</ol>
<h2 style="font-size: 1.5em;">Parse (unpack) ISO Message</h2>
<p>On this case it&#8217;s reversed. We have the ISO Message, and we need to see the DE values of it.<br />
Like the previous code this one also similar and should be easy to understand.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">gnu.jimmod.iso8583.utility</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISOMsg</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.packager.GenericPackager</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ParseISOMessage <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span>, ISOException <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Create Packager based on XML that contain DE type</span>
		GenericPackager packager <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GenericPackager<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;basic.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Print Input Data</span>
		<span style="color: #003399;">String</span> data <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;0200B2200000001000000000000000800000201234000000010000011072218012345606A5DFGR021ABCDEFGHIJ 1234567890&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DATA : &quot;</span> <span style="color: #339933;">+</span> data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Create ISO Message</span>
		ISOMsg isoMsg <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ISOMsg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">setPackager</span><span style="color: #009900;">&#40;</span>packager<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		isoMsg.<span style="color: #006633;">unpack</span><span style="color: #009900;">&#40;</span>data.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// print the DE list</span>
		logISOMsg<span style="color: #009900;">&#40;</span>isoMsg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> logISOMsg<span style="color: #009900;">&#40;</span>ISOMsg msg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;----ISO MESSAGE-----&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;  MTI : &quot;</span> <span style="color: #339933;">+</span> msg.<span style="color: #006633;">getMTI</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span>msg.<span style="color: #006633;">getMaxField</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>msg.<span style="color: #006633;">hasField</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;    Field-&quot;</span><span style="color: #339933;">+</span>i<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; : &quot;</span><span style="color: #339933;">+</span>msg.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>ISOException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;--------------------&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The output:</p>
<pre>DATA : 0200B2200000001000000000000000800000201234000000010000011072218012345606A5DFGR021ABCDEFGHIJ 1234567890
----ISO MESSAGE-----
  MTI : 0200
    Field-3 : 201234
    Field-4 : 000000010000
    Field-7 : 0110722180
    Field-11 : 123456
    Field-44 : A5DFGR
    Field-105 : ABCDEFGHIJ 1234567890
--------------------</pre>
<p>The program flow:</p>
<ol>
<li>Create ISO packager based on the xml file.</li>
<li>Set ISO Message.</li>
<li>Print the ISO Message.</li>
<li>Unpack the message.</li>
<li>Print the DE values. As you can see the result is correct, just like the DE set in first example.</li>
</ol>
<h2 style="font-size: 1.5em;"><strong>In the end</strong></h2>
<p>Ok, like always I hope I make it clear for you.<br />
This might not (yet) a tutorial to make you able the whole financial platform or a bank platform <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
But everyone need to start somewhere.</p>
<p>I see this code example as the implementation of <a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/">my previous article (ISO 8583 introduction)</a></p>
<p><a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/"></a>Just leave comment if you have questions.</p>


<p>Related posts:<ol><li><a href='http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Introduction for Beginners'>Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Introduction for Beginners</a></li><li><a href='http://jimmod.com/blog/2007/11/simple-log4j-implementation/' rel='bookmark' title='Permanent Link: Simple Log4J implementation'>Simple Log4J implementation</a></li><li><a href='http://jimmod.com/blog/2010/03/java-me-j2me-json-implementation-tutorialsample/' rel='bookmark' title='Permanent Link: Java ME (J2ME) JSON Implementation Tutorial/Sample'>Java ME (J2ME) JSON Implementation Tutorial/Sample</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Introduction for Beginners</title>
		<link>http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/</link>
		<comments>http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 09:46:23 +0000</pubDate>
		<dc:creator>jimmy</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[8583]]></category>
		<category><![CDATA[bank]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[financial]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[iso]]></category>
		<category><![CDATA[iso 8583]]></category>
		<category><![CDATA[jimmy]]></category>
		<category><![CDATA[message]]></category>
		<category><![CDATA[standard]]></category>
		<category><![CDATA[tcp]]></category>
		<category><![CDATA[transaction]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://jimmod.com/blog/?p=209</guid>
		<description><![CDATA[ 
				
			 
				
			 
				Tweet 
			
		ISO 8583 Tutorial article

Introduction for Beginners
Build and Parse ISO Message using JPOS library
????


Introduction
Lately I&#8217;ve handle several financial project that allow me to understand bank and financial transaction better.
All (or most?) financial transaction is using ISO 8583 standard, which at first I thought is a complicated standard. But after learn and see [...]


Related posts:<ol><li><a href='http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library'>Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library</a></li><li><a href='http://jimmod.com/blog/2010/04/basic-lwuit-tutorial-with-eclipse-pulsar/' rel='bookmark' title='Permanent Link: Basic LWUIT tutorial/sample with Eclipse Pulsar'>Basic LWUIT tutorial/sample with Eclipse Pulsar</a></li><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application'>Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div style="height:33px; padding-top:2px; padding-bottom:2px; clear:both;" class="really_simple_share"><div style="float:left; width:100px; " class="really_simple_share_facebook_like"> 
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjimmod.com%2Fblog%2F2011%2F07%2Fjimmys-blog-iso-8583-introduction-beginners-tutorial%2F&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=27" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"></iframe>
			</div><div style="float:left; width:90px; padding-left:10px;" class="really_simple_share_google1"> 
				<g:plusone size="medium" href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/" ></g:plusone>
			</div><div style="float:left; width:110px; padding-left:10px;" class="really_simple_share_twitter"> 
				<a href="http://twitter.com/share" class="twitter-share-button" data-count="none" 
					data-text="Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Introduction for Beginners" data-url="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/">Tweet</a> 
			</div></div>
		<div style="clear:both;"></div><h2 style="font-size: 1.5em;"><strong style="font-weight: bold;">ISO 8583 Tutorial article</strong></h2>
<ul>
<li><a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/">Introduction for Beginners</a></li>
<li><a href="http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/">Build and Parse ISO Message using JPOS library</a></li>
<li>????</li>
</ul>
<ul></ul>
<h2><strong>Introduction</strong></h2>
<p>Lately I&#8217;ve handle several financial project that allow me to understand bank and financial transaction better.<br />
All (or most?) financial transaction is using ISO 8583 standard, which at first I thought is a complicated standard. But after learn and see how it implemented it&#8217;s not as complex as I thought.<br />
In this post I will try to explain (based on my experience <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  before I go deeper on the programming side.<br />
<span id="more-209"></span><br />
Although it&#8217;s a &#8217;standard&#8217; I see that&#8217;s many variant for the detail implementation of ISO 8583.</p>
<p>Financial transaction is communication between 2 system through socket connection.<br />
After connection established, each system can send message in ISO 8583 format which commonly will be request and the other system will response.<br />
From my experience the communication will be start with sign on and then the financial transactions.<br />
Periodically an echo message is send to make sure the other system is still alive.</p>
<p>If I break down the flow:</p>
<ol>
<li>System A open connection to System B (through specific IP and Port).</li>
<li>Connection established.</li>
<li>System A send Sign-On request message.</li>
<li>System B send Sign-on response message.</li>
<li>System A will start send Echo request message periodically (e.g every 1 minute).</li>
<li>System B will send Echo response message when receive Echo request message.</li>
<li>When financial transaction happen, System A will send Transaction request message.</li>
<li>Then System B will send Transaction response message.</li>
<li>If something wrong happen (usually timeout so System A didn&#8217;t get the response), System A will send Reversal request message to cancel the previous transaction.</li>
<li>System B will send Reversal response message.</li>
</ol>
<p>I hope my explaination give clear basic understanding about the flow.<br />
Next the question will be what&#8217;s this ISO 8583 message looks like.<br />
We can separate the message into 3 parts:</p>
<ul>
<li>Message Type Identifier</li>
<li>Bitmaps</li>
<li>Data Elements</li>
</ul>
<p style="text-align: center; "><strong> </strong></p>
<div id="attachment_216" class="wp-caption aligncenter" style="width: 310px"><a href="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-structure.png"><img class="size-medium wp-image-216" title="ISO8583 - structure" src="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-structure-300x28.png" alt="ISO8583 - structure" width="300" height="28" /></a><p class="wp-caption-text">ISO8583 - structure</p></div>
<h2><strong>Message Type Identifier</strong></h2>
<p>Message Type Identifier or MTI is 4 digits numeric that describe the message type. It will explain the message function.<br />
Commonly used:<br />
- 02xx : Financial Message (e.g 0200 for request, 0210 for response)<br />
- 04xx : Reversal Message (e.g 0400 for request, 0410 for response)<br />
- 08xx : Network Management Message (e.g 0800 for request, 0810 for response)<br />
* I found more detail &amp; complete list at <a title="wikipedia" href="http://en.wikipedia.org/wiki/ISO_8583" target="_blank">wikipedia</a></p>
<h2><strong>Bitmaps</strong></h2>
<p>Bitmaps is field that contain information about which data element is presence or absence. Based on the variant it could be 16 hexadecimal characters.<br />
An example will make it clear.</p>
<p>The bitmap is:</p>
<p style="text-align: center;">B220000000100000</p>
<p>If we break down to binary (I hope you understand how to convert hexadecimal to binary:) :</p>
<p style="text-align: center;">1011001000100000000000000000000000000000000100000000000000000000</p>
<p>Since I&#8217;m nice <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  I create graphical illustration.</p>
<div id="attachment_211" class="wp-caption aligncenter" style="width: 310px"><a href="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-bitmaps.png"><img class="size-medium wp-image-211" title="ISO8583 - bitmaps" src="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-bitmaps-300x8.png" alt="Bitmap sample" width="300" height="8" /></a><p class="wp-caption-text">Bitmap sample</p></div>
<p>You can see that in this bitmap it explain that data element in the message is 1, 3, 4, 7, 11.<br />
There&#8217;s special meaning of first bit of bitmap, if it has value of 1 that mean there&#8217;s secondary bitmap.<br />
And what the hell is this secondary bitmap?<br />
Since 16 hexadecimal characters will can only contain info of 64 data element, some transactions contain data element number 64 &#8211; 128. That mean the 16 hexadecimal characters is not sufficient.<br />
With set the first bit to &#8216;1&#8242; that will inform there&#8217;s additional bitmap, which is another 16 hexadecimal characters.<br />
So in this case the full bitmap example should be:<br />
B220000000100000<strong>0000000000800000</strong><br />
Convert to binary:<br />
1011001000100000000000000000000000000000000100000000000000000000<strong>0000000000000000000000000000000000000000100000000000000000000000</strong><br />
From the bitmap, data element presence in the message : 3, 4, 7, 11, 105.</p>
<div id="attachment_212" class="wp-caption aligncenter" style="width: 310px"><a href="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-bitmaps-2.png"><img class="size-medium wp-image-212" title="ISO8583 - bitmaps - 2" src="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-bitmaps-2-300x20.png" alt="Sample Bitmap complete" width="300" height="20" /></a><p class="wp-caption-text">Sample Bitmap complete</p></div>
<h2>Data Elements</h2>
<p>Data Elements is the essense of the whole ISO message, contain information about the transaction (transaction type, amount, customer id, etc).<br />
Each data element have their on format, attribute and length.<br />
Each data element number also have standard purpose, for example DE #4 is transaction amount.<br />
I will explain based on the example above, since this is only introduction I don&#8217;t want to confuse beginner reader. In <a href="http://en.wikipedia.org/wiki/ISO_8583#Data_elements" target="_blank">wikipedia </a> there&#8217;s full list.<br />
For our examples, the data element list:</p>
<ul>
<li>#3 &#8211; Processing code &#8211; n 6</li>
<li>#4 &#8211; Transaction amount &#8211; n 12</li>
<li>#7 &#8211; Transmission date &amp; time &#8211; n 10</li>
<li>#11 &#8211; Systems trace audit number &#8211; n 6</li>
<li>#44 &#8211; Additional response data &#8211; an ..25</li>
<li>#105 &#8211; Reserved for ISO use &#8211; ans &#8230;999</li>
</ul>
<p>To make it practical let&#8217;s just use example.<br />
We want to send :</p>
<ul>
<li>DE #3 : 201234</li>
<li>DE #4 : 10000</li>
<li>DE #7 : 1107221830</li>
<li>DE #11 : 123456</li>
<li>DE #44 : A5DFGR</li>
<li>DE #105 : ABCDEFGHIJ 1234567890</li>
</ul>
<p>Using above value, the data in data elements :</p>
<div id="attachment_238" class="wp-caption aligncenter" style="width: 310px"><a href="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-de2.png"><img class="size-medium wp-image-238" title="ISO8583 - de" src="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-de2-300x77.png" alt="ISO8583 - de" width="300" height="77" /></a><p class="wp-caption-text">ISO8583 - de</p></div>
<p style="text-align: center;">
<p>Based on the type each value will be formatted.</p>
<ul>
<li>a : alpha (including blanks)</li>
<li>n : numeric value</li>
<li>s : special characters</li>
<li> x (no dot) : length is x (fixed)</li>
<li>.x (one dot) :  max length is x (1 digit in front as length info)</li>
<li>..xx (two dot) :  max length is xx (2 digit in front as length info)</li>
<li>&#8230;xxx (three dot) :  max length is xxx (3 digit in front as length info)</li>
</ul>
<h2><strong>ISO Message</strong></h2>
<p>From above examples the whole ISO message will be :</p>
<p style="text-align: center;">0200B2200000001000000000000000800000201234000000010000110722183012345606A5DFGR021ABCDEFGHIJ   1234567890</p>
<p style="text-align: center;"><a href="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-full1.png"><img class="aligncenter size-full wp-image-239" title="ISO8583 - full" src="http://jimmod.com/blog/wp-content/uploads/2011/07/ISO8583-full1.png" alt="ISO8583 - full" width="983" height="88" /></a></p>
<p style="text-align: center;">
<h2>Conclusion</h2>
<p>Ok. This article already long enough <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Actually I always prefer short article, but on this case it&#8217;s cannot be to short.<br />
Anyway, I hope this article is clear enough for you.</p>
<p>Like always, just drop question in the comment if you confused.</p>
<p>Next I will write article about implementing ISO 8583 using JPOS library.</p>


<p>Related posts:<ol><li><a href='http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-tutorial-build-and-parse-iso-message-using-jpos-library/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library'>Jimmy&#8217;s Blog &#8211; ISO 8583 Tutorial &#8211; Build and Parse ISO Message using JPOS library</a></li><li><a href='http://jimmod.com/blog/2010/04/basic-lwuit-tutorial-with-eclipse-pulsar/' rel='bookmark' title='Permanent Link: Basic LWUIT tutorial/sample with Eclipse Pulsar'>Basic LWUIT tutorial/sample with Eclipse Pulsar</a></li><li><a href='http://jimmod.com/blog/2011/02/jimmys-blog-send-receiving-on-specific-port-with-j2me-application/' rel='bookmark' title='Permanent Link: Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application'>Jimmy&#8217;s Blog &#8211; Send &#038; Receiving SMS on specific Port with J2ME Application</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://jimmod.com/blog/2011/07/jimmys-blog-iso-8583-introduction-beginners-tutorial/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using mock object with jmock 2</title>
		<link>http://jimmod.com/blog/2007/12/using-mock-object-with-jmock-2/</link>
		<comments>http://jimmod.com/blog/2007/12/using-mock-object-with-jmock-2/#comments</comments>
		<pubDate>Wed, 26 Dec 2007 11:33:25 +0000</pubDate>
		<dc:creator>jimmy</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[easymock]]></category>
		<category><![CDATA[jMock]]></category>
		<category><![CDATA[mock]]></category>
		<category><![CDATA[mock object]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[unit test]]></category>

		<guid isPermaLink="false">http://jimlife.wordpress.com/2007/12/26/using-mock-object-with-jmock-2/</guid>
		<description><![CDATA[ 
				
			 
				
			 
				Tweet 
			
		Okay, finally you decide it&#8217;s time to create a unit testing for your project (after a long ad hoc programming life :p).
When you create a sample unit testing, it&#8217;s all seem so simple.. you fascinate by the junit easiness, how it can do reflection and make it simple.
When you want to [...]


Related posts:<ol><li><a href='http://jimmod.com/blog/2011/09/java-me-j2me-json-implementation-for-array-object/' rel='bookmark' title='Permanent Link: Java ME (J2ME) JSON Implementation For Array Object'>Java ME (J2ME) JSON Implementation For Array Object</a></li><li><a href='http://jimmod.com/blog/2007/12/java-adding-new-classpath-at-runtime/' rel='bookmark' title='Permanent Link: Java &#8211; Adding new Classpath at Runtime'>Java &#8211; Adding new Classpath at Runtime</a></li><li><a href='http://jimmod.com/blog/2010/03/java-me-j2me-json-implementation-tutorialsample/' rel='bookmark' title='Permanent Link: Java ME (J2ME) JSON Implementation Tutorial/Sample'>Java ME (J2ME) JSON Implementation Tutorial/Sample</a></li></ol>]]></description>
			<content:encoded><![CDATA[<div style="height:33px; padding-top:2px; padding-bottom:2px; clear:both;" class="really_simple_share"><div style="float:left; width:100px; " class="really_simple_share_facebook_like"> 
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjimmod.com%2Fblog%2F2007%2F12%2Fusing-mock-object-with-jmock-2%2F&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=27" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"></iframe>
			</div><div style="float:left; width:90px; padding-left:10px;" class="really_simple_share_google1"> 
				<g:plusone size="medium" href="http://jimmod.com/blog/2007/12/using-mock-object-with-jmock-2/" ></g:plusone>
			</div><div style="float:left; width:110px; padding-left:10px;" class="really_simple_share_twitter"> 
				<a href="http://twitter.com/share" class="twitter-share-button" data-count="none" 
					data-text="Using mock object with jmock 2" data-url="http://jimmod.com/blog/2007/12/using-mock-object-with-jmock-2/">Tweet</a> 
			</div></div>
		<div style="clear:both;"></div><p>Okay, finally you decide it&#8217;s time to create a unit testing for your project (after a long ad hoc programming life :p).<br />
When you create a sample unit testing, it&#8217;s all seem so simple.. you fascinate by the junit easiness, how it can do reflection and make it simple.</p>
<p>When you want to create a real unit testing for your project, you realize that a &#8216;real&#8217; method is not like just adding 2 int argument and return a result. It&#8217;s more complex and using interface as parameter is common&#8230;<br />
Now a thought cross your mind &#8220;do I have to create all stupid classes to implement all the interface I need?&#8221;, you starting to think that creating unit testing is really waste of time &amp; you don&#8217;t want to do it anymore :p</p>
<p>It&#8217;s time mock object framework come to rescue&#8230; before you fall to the darkness of untested code <img src='http://jimmod.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
There&#8217;re several mock object framework like <a href="http://www.jmock.org/download.html" title="jMock">jMock</a>, <a href="http://www.easymock.org/" title="easymock">easymock</a>, etc</p>
<p>Here&#8217;s an example creatin HttpMethod mock-object with jMock 2 &amp; JUnit 3</p>
<p>[sourcecode language='java']<br />
public class sampleJMockTest extends MockObjectTestCase {<br />
  public void testCreateHTTPMethod() {<br />
    final HttpMethod httpMethod = mock(HttpMethod.class);<br />
    checking(new Expectations() {<br />
    {<br />
      allowing(httpMethod).getResponseBodyAsString();<br />
      will(returnValue(&#8221;sample response&#8221;));<br />
    }<br />
    });<br />
    SomeObject someObject = new SomeObject();<br />
    someObject.someMethod(httpMethod);<br />
  }<br />
}[/sourcecode]<br />
This sample will create an instance of HttpMethod (which is an interface) and when this mock object&#8217;s &#8216;getResponseBodyAsString&#8217; method called it&#8217;ll return &#8220;sample response&#8221;.<br />
So now we can easily create all interface implementation we need.Of course there&#8217;re more in jMock than just this simple feature, check it more at <a href="http://www.jmock.org/cookbook.html" title="jMock Cookbook">jMock Cookbook</a></p>


<p>Related posts:<ol><li><a href='http://jimmod.com/blog/2011/09/java-me-j2me-json-implementation-for-array-object/' rel='bookmark' title='Permanent Link: Java ME (J2ME) JSON Implementation For Array Object'>Java ME (J2ME) JSON Implementation For Array Object</a></li><li><a href='http://jimmod.com/blog/2007/12/java-adding-new-classpath-at-runtime/' rel='bookmark' title='Permanent Link: Java &#8211; Adding new Classpath at Runtime'>Java &#8211; Adding new Classpath at Runtime</a></li><li><a href='http://jimmod.com/blog/2010/03/java-me-j2me-json-implementation-tutorialsample/' rel='bookmark' title='Permanent Link: Java ME (J2ME) JSON Implementation Tutorial/Sample'>Java ME (J2ME) JSON Implementation Tutorial/Sample</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://jimmod.com/blog/2007/12/using-mock-object-with-jmock-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

