Writing Multiple Segments using BeanIO throws error as indeterminate size

1.2k views Asked by At

Please help as writing multiple Segment throws error "A segment of indeterminate size may not follow another component of indeterminate size"

Sample XML config is

        <field name="noOfShipmentContents" type="Integer" />
        <segment name="shipmentContentsPart2"
            class="com.ShipmentContentsPart2"
            collection="list" minOccurs="1" maxOccurs="unbounded">
            <field name="shipmentContents" type="String" nillable="true" />
        </segment>

        <field name="noOfSpecialServices" type="Integer" />
        <segment name="specialServicesPart3"
            class="com.SpecialServicePart3"
            collection="list" minOccurs="0" maxOccurs="unbounded">
            <field name="chrgServCode" type="String" nillable="true" />
            <field name="chrgAmt" type="String" nillable="true" />
        </segment>
    </record>

beanio.jar version 2.0.7 and 2.1.0 Both gives same error What JDK version? 1.6.0.35

1

There are 1 answers

0
Anand On

Got answer from developer of beanIO Kevin (Thanks) to use occursRef="[name of field]" on segments whose occurrences depend on a preceding field in the same record.

Trick is configuring

<field name="noOfSpecialServices" type="Integer" />
    <segment name="specialServicesPart3" class="com.SpecialServicePart3"
   collection="list" occursRef="noOfSpecialServices">

This feature is available in beanIO2.1.x