Humm, normally legstar does the appropriate offsetting so that the fields following a Choice are at a fixed position.
I just did a test with the sample you sent, adding a field after the REDEFINES like so:
01 COMMAREA.
20 BRANDS OCCURS 20 TIMES.
25 BRAND PIC X(40).
15 FOOTER PIC X.
Here is my testing code:
public void testApp() throws Exception {
Commarea c = new Commarea();
c.setFooter("Z");
Cars cars = new Cars();
for (int i = 0; i < 20; i++) {
Brands b = new Brands();
b.setBrand("AB" + i);
cars.getBrands().add(b);
}
c.setCars(cars);
CommareaTransformers tf = new CommareaTransformers();
byte hostData[] = tf.toHost(c);
assertEquals("c1c2f040404040404040404040404040404040404040404040404040404040404040404040404040c1c2f140404040404040404040404040404040404040404040404040404040404040404040404040c1c2f240404040404040404040404040404040404040404040404040404040404040404040404040c1c2f340404040404040404040404040404040404040404040404040404040404040404040404040c1c2f440404040404040404040404040404040404040404040404040404040404040404040404040c1c2f540404040404040404040404040404040404040404040404040404040404040404040404040c1c2f640404040404040404040404040404040404040404040404040404040404040404040404040c1c2f740404040404040404040404040404040404040404040404040404040404040404040404040c1c2f840404040404040404040404040404040404040404040404040404040404040404040404040c1c2f940404040404040404040404040404040404040404040404040404040404040404040404040c1c2f1f0404040404040404040404040404040404040404040404040404040404040404040404040c1c2f1f1404040404040404040404040404040404040404040404040404040404040404040404040c1c2f1f2404040404040404040404040404040404040404040404040404040404040404040404040c1c2f1f3404040404040404040404040404040404040404040404040404040404040404040404040c1c2f1f4404040404040404040404040404040404040404040404040404040404040404040404040c1c2f1f5404040404040404040404040404040404040404040404040404040404040404040404040c1c2f1f6404040404040404040404040404040404040404040404040404040404040404040404040c1c2f1f7404040404040404040404040404040404040404040404040404040404040404040404040c1c2f1f8404040404040404040404040404040404040404040404040404040404040404040404040c1c2f1f940404040404040404040404040404040404040404040404040404040404040404040404000000000000000000000000000000000000000000000000000000000000000000000000000000000e9", HostData.toHexString(hostData));
Commarea c1 = tf.toJava(hostData);
assertEquals("Z", c1.getFooter());
assertNotNull(c1.getCars());
assertNull(c1.getInput());
}
Seems to work fine. Are you sure the issue is right after the REDEFINES?