User Guide : Map Connectors : Source and Target Map Connectors : SAP IDoc
 
Share this page                  
SAP IDoc
The SAP(IDoc) connector can use either the relevant SAP IDoc definition file exported from the SAP applications or the XML IDoc schemas downloaded from SAP to parse and build SAP (IDoc) files. Using a sample SAP (IDoc) data instance is optional. For information about SAP, see https://www.sap.com/index.html.
SAP (DMI) with ODBC
The SAP Data Migration Interface (DMI) is a defined interface published by SAP; it defines how import files are to be laid out, so that the DMI can load them into the various SAP modules. The import files are flat files, with multiple structured schemas.
The Connect Premium for SAP ODBC driver and Connect ADO provider are designed to use the appropriate BAPIs and RFCs in a production SAP system. This provides full read/write transactional capabilities through standard open interfaces.
Map Editor supplies SAP DMI layout dictionaries that make mapping any Source into the SAP DMI easy. Look in the Common directory for the Connections folder, then open the SAP folder. Many .djd (dictionary files) are included in the SAP folder for your convenience.
To access a SAP DMI file with ODBC, see ODBC 3.5.
Using the SAP (IDoc) connector
SAP IDocs are proprietary layout definitions corresponding to common business transactions such as purchase orders, invoices, material master information and more. They are published as XML schemas and are used as templates in Document Schema Designer. SAP IDoc XML metadata schemas are available for download directly from the SAP Interface Repository. For more information, see https://www.sap.com/index.html.
SAP IDoc internal metadata definitions are exported from SAP applications as text files.
SAP Interface Repository and IDocs
SAP XML IDocs are available from the Interface Repository located at ifr.sap.com. The site is organized by Module and SAP release number. Navigate to the appropriate Module and select the relevant release number to scroll through a list of available IDocs. SAP employs a naming convention that relates the IDoc to its business function and its release version. Download links and documentation are accessed from this list.
IDocs are configured and linked to programs designed to process the application events associated with a specific document in an SAP system. Follow the steps below to transfer the downloaded IDoc to your local default installation directory for use with Integration product software.
Transferring an IDoc to Your Local Default Folder
SAP IDocs should be stored in the installation directory in a SAP subdirectory. The path is InstallDir\Common\LegacyMetadata\SAP.
After you download and unzip the IDoc, save it to this directory.
IDoc Schemas
IDocs consist of segments and fields within those segments. Each IDoc must include one control record (Header Record - EDI_DC40). The Header Record contains transmission and processing information. Based on a profile set up in the ALE (Application Linking and Embedding) interface, the control segment informs SAP how to treat an incoming IDoc and what routine to follow to produce the expected result. In the case of outbound IDocs, the control record is generally not needed by the receiving system unless it is also SAP.
Segments that follow the Control Record make up the body of the business document. Six fields, called Data Control Segments, are found at the beginning of each segment. These six fields retain segment identification information and are not defined in the SAP IDoc schema. When you load the Source/target connector, these fields are added to the beginning of the Data Control Segment. The following table gives a description of these fields.
Segment ID
Description
Value
SEGNAM
Segment (external name)
30
MANDT
Client
3
DOCNUM
IDoc number
16
SEGNUM
Segment number
6
PSGNUM
Number of superior parent segment
6
HLEVEL
Hierarchy level of SAP segment
2
The fields that follow each Data Control Segment hold information that pertains to the specific business transaction.
In Map Editor, each segment of the IDoc is treated as an individual record type. This enables you to exercise complete control of each segment and means that you can decide where, when and how a particular segment is read or written.
"Complete control" also means that you can decide if a record is read or written at all. Many IDocs contain looping or repeatable segments. A looping segment may be hierarchically dependent on preceding segments or distinguished by a qualifier value, a common feature in many EDI (Electronic Data Interchange) formats. The Partner Information segment, for example, might be the vendor, customer, sold-to-party, ship-to-party, or some other partner. An IDoc may configure the Partner Information segment to repeat several times. The partner type qualifier value for Customer is "KU", so if the partner is a Customer, the "KU" value can be used to control the segment looping to write only one iteration.
Mapping IDocs
 
Source/Target
Task
Source
If you are working with an IDoc as a source file, navigate to the Source Connection Window in Map Designer to choose the SAP (IDoc) adapter and the .ds.xml file, then just drag the fields from the Source segments to your target fields. In looping (repeatable) segments, you can use a conditional expression to examine the contents of the qualifier field and accept only those records or segments that contain the information you want in your target.
Target
If you are working with an IDoc as a target file, navigate to the Target Connection Window in Map Editor to choose the SAP (IDoc) adapter, the .ds.xml file and to name the target file.
The .ds.xml file provides part of the Control Record information; IDoc type, for example. Your Trading Partner, or the contact person who configured the ALE profile, can provide Message Type, Partner Profile names, port number and other information.
The .ds.xml file fills-in some of the information required in the Data Control segments. Some of the Control Field values are identical to the Control Record field values, but some are user-defined. Doc Num, for example, can be hard coded as "0000000000000000". You have to setup a counter to increment Segment Count and add multiple ClearMapPutRecord Actions to repeatable segments if you want to write those records to your target. Then navigate to the Map tab and drag each Source field to its counterpart in the IDoc Target layout.
Schema File Required
You can obtain an SAP IDoc schema file (in W3C XML format) from SAP that contains the structure for your SAP IDoc file connections. If your SAP IDoc file structure is different, you may need to modify the template.
To make changes to an SAP IDoc template file
1. Import the file into Project Explorer as a text artifact.
2. Open the file in Project Explorer using the Text Editor.
3. Make your changes.
4. Save the file with a different name.
To obtain a template file, contact your sales representative. These template files are standard schemas.
Property Options
You can set the following source (S) and target (T) properties.
Property
ST
Description
Encoding
ST
To set encoding for reading source and writing target data, select a code page translation table. Default is OEM. To use ANSI, select ISO8859-1. For Windows CodePage 1252, select CP1252.
SchemaFile
ST
Used for parsing data and generating a new schema during design time. Select a schema file that contains the schema you want to use.
RecordSeparator
ST
Sets the character used to mark the end of a record.
The default is CR-LF (carriage return-line feed). An HCFA1500-NSF file is expected to use this default between records. To use a different record separator, click the RecordSeparator property and select an option from the list. See Element Separator below for the list of options.
If the record separator is not one of the choices on the list and is a printable character, highlight CR-LF and then enter the correct character.
If the record separator is not a printable character, replace CR-LF with a backslash (), an X, and the hexadecimal value for the separator. For example, for a check mark, enter \XFB. For a list of the 256 standard and extended ASCII characters, search for "hex values."
Validation
ST
This setting determines whether or not the IDoc file is checked for validity. The default is false. If you want to validate the IDoc file, change this setting to true.
Version
ST
This connector supports SAP IDoc versions R/3 and R/4.
Element Separator
This connector supports the following element separators:
CR-LF
STX (0001)
SOT (0002)
ETX (0003)
EOT (0004)
ENQ (0005)
ACK (0006)
BEL (0007)
BS (0008)
HT (0009)
LF (000A)
VT (000B)
FF (000C)
CR (000D)
SO (000E)
S1 (000F)
DLE (0010)
DC1 (0011)
DC2 (0012)
DC3 (0013)
DC4 (0014)
NAK (0015)
SYN (0016)
ETB (0017)
CAN (0018)
EM (0019)
SUB (001A)
ESC (001B)
FS (001C)
GS (001D)
RS (001E)
US (001F)
SP (0020)
! (0021)
" (0022)
# (0023)
$ (0024)
% (0025)
& (0026)
' (0027)
( (0028)
) (0029)
* (002A)
+ (002B)
, (002C)
- (002D)
. (002E)
/ (002F)
: (003A)
; (003B)
< (003C)
= (003D)
> (003E)
? (003F)
@ (0040)
[ (005B)
\ (005C)
] (005D)
^ (005E)
_ (005F)
' (0060)
{ (007B)
| (007C)
} (007D)
~ (007E)
DEL (007F)
Data Type
These are the data types of the fields in your target data table:
boolean
date
decimal
double
float
record
string
time
If you are writing to a new file, you may use any of these available data types from the list that appears when you click the arrow in the Type cell of a field.
If you are appending data to an existing file, the data type of each field becomes the data type in the file.