Skip to content

Make unparsed child loops available in ASN #140

Closed
@CodeSmell

Description

Got an interesting file where a loop (the Order) had a child loop that was unexpected. That loop and its segments were not available to the user of Gozer.

One example is an Order loop with another Order loop as a child

HL*1**S
...

HL*2*1*O
...
HL*3*2*O

Another example is an Pack loop with another unknown loop as a child (in this case a loop of type X)

HL*9*5*P
...
HL*10*9*X

When the ASN parser is processing the children loops of the pack and does not recognize the loop code of X it will now add it as an unparsed child loop for the pack

parentLoop.addLoop(unparsedLoop);

which will make the data available as follows:

Pack pack = ...
// the known segments of a pack loop
List<MANMarkNumber> manList = pack.getManList();
...

// Gozer was already doing this for segments it did not recognize
List<X12Segment> unparsedSegments = pack.getUnparsedSegments();
...

// This is how to access the Item and other known child loops
List<X12Loop> items = pack.getParsedChildrenLoops();
...
// example of an unexpected child loop 
// that was not handled in the parser
List<X12Loop> unparsedLoops = pack.getUnparsedChildrenLoops();
X12Loop unparsedLoop = unparsedLoops.get(0);
// the segments for this loop are also available
unparsedLoop.getSegments();

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions