Hi Team,
The input file has 4 records (Header, item, itemextn and trailer). Each record has initiator and fields are of fixed length. There are few optional fields in these records.
When we pass the exact length for all fields the DFDL parses successfully.
There is a special case, some source systems can send the data less than defined length for optional field. Then parser fails with below error. Can we handle variable lengths for the optional fields by assuming the following optional fields are also does not have data?
Error:
"CTDP3058E: Separator '%LF;' not found at offset '174' for sequence within element '/BatchFile_Message[1]'.
ParsedDataRegion[SimpleContent, startOffset = 173, length = 1, scd = #xscd(/schemaElement::BatchFile_Message/type::0/model::sequence/schemaElement::body/type::0/model::sequence/schemaElement::ItemExtention/type::0/model::sequence/sch"
Sample Message:
00Journalaaa20240606GL
20Journalaaa20240606AccCGLOL 123X
21Journalaaa20240606OrderNum 001A
20Journalaaa20240606AccCGLOL2 123X
21Journalaaa20240606OrderNum2
20Journalaaa20240606AccCGLOL3 123X
21Journalaaa20240606OrNum3
99Filler2
DFDL Schema:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:ibmDfdlExtn="http://www.ibm.com/dfdl/extensions" xmlns:ibmSchExtn="http://www.ibm.com/schema/extensions" xmlns:recFixLengthFieldsFmt="http://www.ibm.com/dfdl/RecordFixLengthFieldFormat" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.ibm.com/dfdl/RecordFixLengthFieldFormat" schemaLocation="IBMdefined/RecordFixLengthFieldFormat.xsd"/>
<xsd:annotation>
<xsd:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:format encoding="{$dfdl:encoding}" escapeSchemeRef="" occursCountKind="fixed" ref="recFixLengthFieldsFmt:RecordFixLengthFieldsFormat"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:element dfdl:lengthKind="delimited" ibmSchExtn:docRoot="true" name="BatchFile_Message">
<xsd:complexType>
<xsd:sequence dfdl:separator="%LF;" dfdl:separatorPosition="postfix" dfdl:separatorSuppressionPolicy="anyEmpty">
<xsd:element dfdl:initiator="00" dfdl:lengthKind="delimited" name="header">
<xsd:complexType>
<xsd:sequence>
<xsd:element dfdl:length="10" ibmDfdlExtn:sampleValue="a" name="Journal" type="xsd:string"/>
<xsd:element dfdl:length="8" ibmDfdlExtn:sampleValue="a" name="Date" type="xsd:string"/>
<xsd:element dfdl:length="2" dfdl:occursCountKind="implicit" ibmDfdlExtn:sampleValue="a" minOccurs="0" name="Application" type="xsd:string"/>
<xsd:element dfdl:length="12" dfdl:occursCountKind="implicit" ibmDfdlExtn:sampleValue="a" minOccurs="0" name="Filler1" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element dfdl:initiator="20" dfdl:lengthKind="delimited" dfdl:occursCountKind="implicit" maxOccurs="unbounded" name="body">
<xsd:complexType>
<xsd:sequence dfdl:separator="%LF;" dfdl:separatorPosition="infix" dfdl:separatorSuppressionPolicy="anyEmpty">
<xsd:element dfdl:lengthKind="delimited" ibmDfdlExtn:sampleValue="body_valu1" name="Item">
<xsd:complexType>
<xsd:sequence>
<xsd:element dfdl:length="10" ibmDfdlExtn:sampleValue="head_valu2" name="Journal" type="xsd:string"/>
<xsd:element dfdl:length="8" ibmDfdlExtn:sampleValue="head_valu3" name="Date" type="xsd:string"/>
<xsd:element dfdl:length="10" dfdl:occursCountKind="implicit" minOccurs="0" name="Account" type="xsd:string"/>
<xsd:element dfdl:length="3" dfdl:occursCountKind="implicit" minOccurs="0" name="Amount" type="xsd:string"/>
<xsd:element dfdl:length="1" dfdl:occursCountKind="implicit" minOccurs="0" name="Indicator" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element dfdl:initiator="21" dfdl:lengthKind="delimited" dfdl:lengthPattern=".*" ibmDfdlExtn:sampleValue="body_valu2" name="ItemExtention">
<xsd:complexType>
<xsd:sequence>
<xsd:element dfdl:length="10" ibmDfdlExtn:sampleValue="a" name="Journal" type="xsd:string"/>
<xsd:element dfdl:length="8" ibmDfdlExtn:sampleValue="a" name="Date" type="xsd:string"/>
<xsd:element dfdl:length="10" dfdl:occursCountKind="implicit" minOccurs="0" name="Order" type="xsd:string"/>
<xsd:element dfdl:length="3" dfdl:occursCountKind="implicit" minOccurs="0" name="Quantity" type="xsd:string"/>
<xsd:element dfdl:length="1" dfdl:occursCountKind="implicit" minOccurs="0" name="Department" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element dfdl:initiator="99" dfdl:lengthKind="delimited" dfdl:occursCountKind="implicit" minOccurs="0" name="trailer">
<xsd:complexType>
<xsd:sequence>
<xsd:element dfdl:length="10" dfdl:occursCountKind="implicit" ibmDfdlExtn:sampleValue="a" minOccurs="0" name="Filler2" type="xsd:string"/>
<xsd:element dfdl:length="22" dfdl:occursCountKind="implicit" ibmDfdlExtn:sampleValue="a" minOccurs="0" name="Filler3" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>