Introduction:
This blog describes the configuration steps for converting the XML Data with nested hierarchies to FlatFile using custom Adapter Module
ContentConversionBean ( Direction -> Receiver ).
Pre-Requisites:
For novice users, Please read the link provided in help.sap.com related to File Content Conversion
Java Version:
This adapter module is written using JDK 1.5 API’s, so before deploying the Adapter Module (.ear file) make sure the JDK version 1.5 and above.
Problem:
Many Times, there are requirements where XML data in nested hierarchies needs to be converted into Flat File. Standard File Adapter or Standard Adapter Module supports only 3 nested levels of XML to Flat File. These requirements can be accomplished using Java Mapping. The Java Mapping is confined to that particular interface and it cannot be re-used for more than one interface, and hence it cannot be re-used for other scenarios.
Solution:
I have created a Generic Adapter Module to address the above problem for converting XML Data( with Nested Levels) to Flat File.
This module uses the most of the standard FCC parameters and the use of the those parameters are listed in the Table2.
Table 1:
The following properties should be configured only in the module configuration of the channel.
Property Name | Required/Optional | Description |
---|---|---|
Direction | Required | If the module used in sender channel provide the value as sender and if it is used in receiver channel specify receiver |
Configuration_Mode | Optional | Configuration_Mode contains either file or local as the value.
|
File_Path | Optional |
|
Table2 :
The following properties can be specified either in the file or in the Module Configuration of the channel depends on the value specified in the Configuration_Mode property specified in the Table1.
FCC Properties in the Receiver Side
Property Name | Required/Optional | Description |
---|---|---|
RecordSetName.recordSetStructure | Optional | Specify the recordset names and the cardinality of substructures as follows:<NameA,nA,NameB,nB,...> , where nA=1,2,3,... or* (for a variable, unlimited number, including 0)
Here NameA, NameB,… is the recordset Names nA specifies the cardinality |
RecordSetName.fieldNames | Optional | Specify the fieldNames separater by comma (,) which belongs to the corresponding recordSet structure |
RecordSetName.endSeparator | Optional | If you want to define an additional string as a separator after the last column in a row, specify it here. The system skips this separator when it processes the last column (otherwise the system would treat it as part of the last column). Note:if fieldNames property isdefined for a recordSet, then endSeparator is required for that corresponding recordSet. |
RecordSetName.fieldSeparator | Optional | If you make an entry here, the Module expects that the structure contains the specified character string (one or more characters) as a separator between the individual columns. If you have not made an entry for fieldFixedLengths , this is the only specification to identify the individual columns in a row. |
RecordSetName.fieldFixedLengths | Optional | If you make an entry here, the Module expects a character string that contains the lengths of the structure columns as arguments separated by commas. If you also specify a separator for the columns, you must not add its length to the length of the columns. This entry is mandatory if you have not made an entry for RecordSetName.fieldSeparator |
RecordSetName.fixedLengthTooShortHandling | Optional | Specify how you want the system to respond when column widths in the actual document exceed those defined in RecordSetName.fieldFixedLengths. The following values are permitted: Error -> Document processing is cancelled. Cut -> The value is cut to the maximum permitted length. Ignore -> The value is accepted even though its length exceeds the permitted value. Subsequent columns are moved accordingly. Note : This property will be used only RecordSetName.fieldFixedLengths is configured. |
How to create the Properties file:
- Open any text editor
- Save it with extension .properties
- Each and every property occurs in combination of key and value.
Eg: propertyname=propertyvalue
Scenario 1:
The below snapshot depicts the xsd which is created with 5 levels of depth
Module Configuration:
In the below configuration, Configuration_Mode is specified as file, we have specified all the FCC properties in the file and stored in the NFS path and specified the path of the file to File_Path property.
The advantage here is, user no need to modify/change the channels in order to change the FCC property.
If the Configuration_Mode is either not specified or configured as local, then all the FCC properties should be configured in the Module Configuration
Input XML Data with Nested Hierarchies:
FCC Configuration:
Output Flat File:
Scenario 2: This scenario explains how to use the RecordSetName.fixedLengthTooShortHandling
Input XML Data:
FCC Configuration:
Output Flat File:
Note : In the above FCC, fixedLengthTooShortHanding propery will be effective only if the fieldFixedLengths property is configured for the recordset
Use the below link which explains conversion of FlatFile to XML with Nested Structures,
File Content Conversion for Deeply Nested Structures - Sender
Disclaimer:
- This Module is optimized to process messages with an approximate payload size <= 5 MB.
- This Module will not work with messages having attachments.