<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.commander4j.com/index.php?action=history&amp;feed=atom&amp;title=IDOC</id>
	<title>IDOC - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.commander4j.com/index.php?action=history&amp;feed=atom&amp;title=IDOC"/>
	<link rel="alternate" type="text/html" href="https://wiki.commander4j.com/index.php?title=IDOC&amp;action=history"/>
	<updated>2026-11-23T06:50:20Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.commander4j.com/index.php?title=IDOC&amp;diff=2014&amp;oldid=prev</id>
		<title>Dgarratt: Updated by push_wiki.py</title>
		<link rel="alternate" type="text/html" href="https://wiki.commander4j.com/index.php?title=IDOC&amp;diff=2014&amp;oldid=prev"/>
		<updated>2026-11-09T20:47:21Z</updated>

		<summary type="html">&lt;p&gt;Updated by push_wiki.py&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The IDOC [[Connectors|connector]] reads SAP IDOC flat files and converts them into XML, so that a stylesheet can turn them into another format. It is an &amp;#039;&amp;#039;&amp;#039;input&amp;#039;&amp;#039;&amp;#039; connector only: [[Middleware4j]] does not write IDOC files.&lt;br /&gt;
&lt;br /&gt;
== How it works ==&lt;br /&gt;
&lt;br /&gt;
An IDOC flat file is a long run of fixed length segments, each beginning with the segment name. The connector needs to be told which segments and fields you are interested in and where each field sits within its segment. That description is held in a &amp;#039;&amp;#039;&amp;#039;schema file&amp;#039;&amp;#039;&amp;#039;, and one for the SAP material master (MATMAS03) is supplied in &amp;lt;code&amp;gt;idoc/schema&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The sample map &amp;#039;&amp;#039;&amp;#039;Map11&amp;#039;&amp;#039;&amp;#039; reads a material master IDOC and writes a Commander4j material XML message.&lt;br /&gt;
&lt;br /&gt;
== Map configuration ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;config.xml&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;map&amp;gt;&lt;br /&gt;
   &amp;lt;id&amp;gt;Map11&amp;lt;/id&amp;gt;&lt;br /&gt;
   &amp;lt;enabled&amp;gt;true&amp;lt;/enabled&amp;gt;&lt;br /&gt;
   &amp;lt;description&amp;gt;Idoc Material to XML&amp;lt;/description&amp;gt;&lt;br /&gt;
   &amp;lt;enableEmailNotifications&amp;gt;true&amp;lt;/enableEmailNotifications&amp;gt;&lt;br /&gt;
   &amp;lt;connectors&amp;gt;&lt;br /&gt;
      &amp;lt;input&amp;gt;&lt;br /&gt;
         &amp;lt;id&amp;gt;in1&amp;lt;/id&amp;gt;&lt;br /&gt;
         &amp;lt;description&amp;gt;Read IDOC&amp;lt;/description&amp;gt;&lt;br /&gt;
         &amp;lt;type&amp;gt;IDOC&amp;lt;/type&amp;gt;&lt;br /&gt;
         &amp;lt;url&amp;gt;&lt;br /&gt;
            &amp;lt;path&amp;gt;./interface/input/Map11 IDOC to XML&amp;lt;/path&amp;gt;&lt;br /&gt;
            &amp;lt;mask/&amp;gt;&lt;br /&gt;
            &amp;lt;prefix/&amp;gt;&lt;br /&gt;
            &amp;lt;pollingInterval&amp;gt;1000&amp;lt;/pollingInterval&amp;gt;&lt;br /&gt;
         &amp;lt;/url&amp;gt;&lt;br /&gt;
         &amp;lt;xsl&amp;gt;&lt;br /&gt;
            &amp;lt;XSLTPath/&amp;gt;&lt;br /&gt;
            &amp;lt;XSLT&amp;gt;Map11_IDOC_to_XML.xsl&amp;lt;/XSLT&amp;gt;&lt;br /&gt;
         &amp;lt;/xsl&amp;gt;&lt;br /&gt;
         &amp;lt;idoc&amp;gt;&lt;br /&gt;
            &amp;lt;idocSchemaFilename&amp;gt;./idoc/schema/ZMATMAS03c.txt&amp;lt;/idocSchemaFilename&amp;gt;&lt;br /&gt;
         &amp;lt;/idoc&amp;gt;&lt;br /&gt;
      &amp;lt;/input&amp;gt;&lt;br /&gt;
      &amp;lt;output&amp;gt;&lt;br /&gt;
         &amp;lt;id&amp;gt;out1&amp;lt;/id&amp;gt;&lt;br /&gt;
         &amp;lt;enabled&amp;gt;true&amp;lt;/enabled&amp;gt;&lt;br /&gt;
         &amp;lt;description&amp;gt;Write XML File&amp;lt;/description&amp;gt;&lt;br /&gt;
         &amp;lt;type&amp;gt;XML&amp;lt;/type&amp;gt;&lt;br /&gt;
         &amp;lt;url&amp;gt;&lt;br /&gt;
            &amp;lt;path&amp;gt;./interface/output/Map11 IDOC to XML&amp;lt;/path&amp;gt;&lt;br /&gt;
            &amp;lt;prefix/&amp;gt;&lt;br /&gt;
            &amp;lt;fileExtension/&amp;gt;&lt;br /&gt;
            &amp;lt;use83GUID&amp;gt;false&amp;lt;/use83GUID&amp;gt;&lt;br /&gt;
            &amp;lt;retainOriginalFilename&amp;gt;false&amp;lt;/retainOriginalFilename&amp;gt;&lt;br /&gt;
         &amp;lt;/url&amp;gt;&lt;br /&gt;
      &amp;lt;/output&amp;gt;&lt;br /&gt;
   &amp;lt;/connectors&amp;gt;&lt;br /&gt;
&amp;lt;/map&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Setting !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;type&amp;#039;&amp;#039;&amp;#039; || &amp;lt;code&amp;gt;IDOC&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;mask&amp;#039;&amp;#039;&amp;#039; || Leave empty to pick up files ending in &amp;lt;code&amp;gt;.txt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;.idoc&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;idoc / idocSchemaFilename&amp;#039;&amp;#039;&amp;#039; || The schema file describing the segments and fields to read.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The settings shared by all connectors are described on the [[Maps]] page.&lt;br /&gt;
&lt;br /&gt;
== The XML produced ==&lt;br /&gt;
&lt;br /&gt;
Each group of fields becomes a &amp;lt;code&amp;gt;&amp;amp;lt;DATA&amp;amp;gt;&amp;lt;/code&amp;gt; element, and each field a &amp;lt;code&amp;gt;&amp;amp;lt;FIELD&amp;amp;gt;&amp;lt;/code&amp;gt; element with a &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; and a &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;. This is part of the XML produced from the sample IDOC:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;MESSAGE id=&amp;quot;150493303&amp;quot; number=&amp;quot;./interface/input/Map11 IDOC to XML/IDOC Sample.txt&amp;quot; type=&amp;quot;idoc&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;DATA type=&amp;quot;Basic&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;FIELD name=&amp;quot;Material&amp;quot; value=&amp;quot;000000000043066649&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;FIELD name=&amp;quot;MaterialType&amp;quot; value=&amp;quot;HALB&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;FIELD name=&amp;quot;BaseUOM&amp;quot; value=&amp;quot;EA&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;FIELD name=&amp;quot;GrossWeight&amp;quot; value=&amp;quot;90.000&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;FIELD name=&amp;quot;EANItemCode&amp;quot; value=&amp;quot;5000161030149&amp;quot;/&amp;gt;&lt;br /&gt;
      ...&lt;br /&gt;
   &amp;lt;/DATA&amp;gt;&lt;br /&gt;
   &amp;lt;DATA type=&amp;quot;Additional&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;FIELD name=&amp;quot;RecordType&amp;quot; value=&amp;quot;HUTYP&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;FIELD name=&amp;quot;Value&amp;quot; value=&amp;quot;P53&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/DATA&amp;gt;&lt;br /&gt;
   &amp;lt;DATA type=&amp;quot;Additional&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;FIELD name=&amp;quot;RecordType&amp;quot; value=&amp;quot;STACK&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;FIELD name=&amp;quot;Value&amp;quot; value=&amp;quot;Y&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/DATA&amp;gt;&lt;br /&gt;
   &amp;lt;DATA type=&amp;quot;Text&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;FIELD name=&amp;quot;Description&amp;quot; value=&amp;quot;SELF SEALING STEM BOLT&amp;quot;/&amp;gt;&lt;br /&gt;
      ...&lt;br /&gt;
   &amp;lt;/DATA&amp;gt;&lt;br /&gt;
&amp;lt;/MESSAGE&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Points to note when writing the stylesheet:&lt;br /&gt;
&lt;br /&gt;
* The values are in the &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; &amp;#039;&amp;#039;&amp;#039;attribute&amp;#039;&amp;#039;&amp;#039;, not in the text of the element.&lt;br /&gt;
* The fields within a &amp;lt;code&amp;gt;&amp;amp;lt;DATA&amp;amp;gt;&amp;lt;/code&amp;gt; element are in no particular order. Always select them by name.&lt;br /&gt;
* A segment that repeats in the IDOC, such as a unit of measure or a plant, gives one &amp;lt;code&amp;gt;&amp;amp;lt;DATA&amp;amp;gt;&amp;lt;/code&amp;gt; element for each occurrence.&lt;br /&gt;
&lt;br /&gt;
Selecting a single value:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;xsl:variable name=&amp;quot;BASE_UOM&amp;quot; select=&amp;quot;string(/MESSAGE/DATA[@type=&amp;#039;Basic&amp;#039;]/FIELD[@name=&amp;#039;BaseUOM&amp;#039;]/@value)&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selecting a value from the one repeated section that matches a key, here the plant section for a given plant:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;xsl:variable name=&amp;quot;PROCUREMENT&amp;quot; select=&amp;quot;string(/MESSAGE/DATA[@type=&amp;#039;Plant&amp;#039;]/FIELD[@name=&amp;#039;Plant&amp;#039;][@value=$PLANT]/parent::*/FIELD[@name=&amp;#039;SpecialProcessing&amp;#039;]/@value)&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Both lines are taken from &amp;lt;code&amp;gt;Map11_IDOC_to_XML.xsl&amp;lt;/code&amp;gt;, which is the best starting point for a stylesheet of your own.&lt;br /&gt;
&lt;br /&gt;
== The schema file ==&lt;br /&gt;
&lt;br /&gt;
The schema is a text file with one line for each field to be read. Lines beginning with a single quote are comments, and the list of fields starts after a line beginning &amp;lt;code&amp;gt;#START&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;#039; Segment Definition,  IDOC Field,  Field Offset,  Length,  FFMW Section,  New Section,  FFMW Field&lt;br /&gt;
&amp;#039;&lt;br /&gt;
#START MATMAS03 MM&lt;br /&gt;
EDI_DC40,                   ,20  ,9   ,          ,0  ,MessageId&lt;br /&gt;
E2MARAM005,     MATNR       ,66  ,18  ,Basic     ,1  ,Material[KEY]&lt;br /&gt;
E2MARAM005,     MTART       ,140 ,4   ,          ,0  ,MaterialType&lt;br /&gt;
E2MARAM005,     MEINS       ,172 ,3   ,          ,0  ,BaseUOM&lt;br /&gt;
E2MAKTM001,     MAKTX       ,66  ,1   ,Text      ,1  ,Language[SUBKEY]&lt;br /&gt;
E2MAKTM001,     SPRAS       ,67  ,40  ,          ,0  ,Description&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Column !! Description&lt;br /&gt;
|-&lt;br /&gt;
| Segment Definition || The SAP segment name as it appears in the IDOC file.&lt;br /&gt;
|-&lt;br /&gt;
| IDOC Field || The SAP field name. For reference only.&lt;br /&gt;
|-&lt;br /&gt;
| Field Offset || Position of the field within the segment.&lt;br /&gt;
|-&lt;br /&gt;
| Length || Length of the field in characters.&lt;br /&gt;
|-&lt;br /&gt;
| Section || The name given to the &amp;lt;code&amp;gt;&amp;amp;lt;DATA type=&amp;quot;...&amp;quot;&amp;amp;gt;&amp;lt;/code&amp;gt; element. Entered on the first field of each section.&lt;br /&gt;
|-&lt;br /&gt;
| New Section || 1 on the line that starts a new section, otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
| Field || The name given to the &amp;lt;code&amp;gt;&amp;amp;lt;FIELD name=&amp;quot;...&amp;quot;&amp;amp;gt;&amp;lt;/code&amp;gt; element. &amp;lt;code&amp;gt;[KEY]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;[SUBKEY]&amp;lt;/code&amp;gt; mark the fields that identify a section.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To read a different IDOC type, or extra fields, copy the supplied schema and edit the copy. The offsets and lengths come from the SAP documentation for the segment. The simplest way to check a change is to run a sample IDOC through a map with no stylesheet and read the XML that comes out.&lt;br /&gt;
&lt;br /&gt;
See also: [[Connectors]], [[Maps]], [[Creating a Map]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Middleware4j]]&lt;/div&gt;</summary>
		<author><name>Dgarratt</name></author>
	</entry>
</feed>