Open Qtemp123 opened 2 years ago
I have debugged the EdiSerializer class and this is what I have found (reference documentation: https://www.stylusstudio.com/edifact/D01B/IFCSUM.htm):
When I enter the MEA SegmentGroup 29 (inside TPL SG28) in the outer CNI SegmentGroup 25 which is contained in the class with [EdiMessage] attribute it closed the CNI SG25 on one of the conditions inside TryCreateContainer method,
else if (level.GroupMembers.Length > 1 &&!level.GroupContains(readerSegment as string))
{
level.Close(); // Close this level
continue;
}
as CNI SG 25 didn't contain the possibility to have "MEA" segment inside it's SegmentGroup attribute parameters. After I changed it (added all possible segments from all the nested SegmentGroups inside CNI) it seems to work perfectly fine now, but my question is, is this actually a proper solution? Based on all issue suggestions that I have read, I should only be including Segments and SegmentsGroups that may exist on the same level, but it works with all nested Segments and SegmentGroups also added to the attribute in CNI.
The definition of CNI currently looks like this:
[EdiSegmentGroup("CNI", "TPL", "DTM", "TSR", "CUX", "MOA", "FTX", "GDS", "TOD", "RFF", "TDT", "NAD", "GID", "MEA", "CTA", "HAN", "LOC", "MOA", "PIA", "DIM", "PCI", "SGP", "DGS")]
public class D01B_CNI_SEGMENTGROUP25
{
// 010/1490
[EdiValue(Path = "CNI/0")]
public string CNI_ConsolidationItemNumber { get; set; }
// C503/1004
[EdiValue(Path = "CNI/1")]
public string CNI_DocumentIdentifier { get; set; }
public D01B_TPL_SEGMENTGROUP28[] TPL { get; set; }
public D01B_DTM_SEGMENT[] DTM { get; set; }
public D01B_TSR_SEGMENT[] TSR { get; set; }
public D01B_CUX_SEGMENT[] CUX { get; set; }
public D01B_MOA_SEGMENT[] MOA { get; set; }
public D01B_FTX_SEGMENT[] FTX { get; set; }
public D01B_GDS_SEGMENT[] GDS { get; set; }
public D01B_TOD_SEGMENTGROUP31[] TOD { get; set; }
public D01B_RFF_SEGMENTGROUP32[] RFF { get; set; }
public D01B_TDT_SEGMENTGROUP38[] TDT { get; set; }
public D01B_NAD_SEGMENTGROUP43[] NAD { get; set; }
public D01B_GID_SEGMENTGROUP50[] GID { get; set; }
}
Compared to previous:
[EdiSegmentGroup("CNI", "TPL", "DTM", "TSR", "CUX", "MOA", "FTX", "GDS", "TOD", "RFF", "TDT", "NAD", "GID")]
public class D01B_CNI_SEGMENTGROUP25
{
// 010/1490
[EdiValue(Path = "CNI/0")]
public string CNI_ConsolidationItemNumber { get; set; }
// C503/1004
[EdiValue(Path = "CNI/1")]
public string CNI_DocumentIdentifier { get; set; }
public D01B_TPL_SEGMENTGROUP28[] TPL { get; set; }
public D01B_DTM_SEGMENT[] DTM { get; set; }
public D01B_TSR_SEGMENT[] TSR { get; set; }
public D01B_CUX_SEGMENT[] CUX { get; set; }
public D01B_MOA_SEGMENT[] MOA { get; set; }
public D01B_FTX_SEGMENT[] FTX { get; set; }
public D01B_GDS_SEGMENT[] GDS { get; set; }
public D01B_TOD_SEGMENTGROUP31[] TOD { get; set; }
public D01B_RFF_SEGMENTGROUP32[] RFF { get; set; }
public D01B_TDT_SEGMENTGROUP38[] TDT { get; set; }
public D01B_NAD_SEGMENTGROUP43[] NAD { get; set; }
public D01B_GID_SEGMENTGROUP50[] GID { get; set; }
}
Hi @Qtemp123 and thank you for your interest in EDI.Net
question is, is this actually a proper solution? Based on all issue suggestions that I have read, I should only be including Segments and SegmentsGroups that may exist on the same level, but it works with all nested Segments and SegmentGroups also added to the attribute in CNI.
Usually this (mapping everything contained and not only same level) is useful only when developing or when some nested GegmentGroups are not present in the CLR classes (Mapped at all). I have not yet found the time to debug your case but if you would like it would be helpful to make a pull request with a failing test so that I can take a look.
Also generally speaking the sequenceEnd is discouraged and only works in the simplest of scenarios.
Hello :),
I am currently developing a solution for deserialization of IFCSUM D01B message using EDI.Net. The problem that I am facing has to do with the way that the library is handling SegmentGroups, which I probably just don't understand.
Given this sample D01B IFCSUM message:
Everything is working fine when I use SequenceEnd in the SegmentGroup attribute, and segment defined as the SequenceEnd acutally exists. Below are a few examples of my implementation of the message as of right now (passing child segments in the SegmentGroup attribute constructor):
I don't want to paste the whole code base for this because it would be massive, but I hope the picture of the situation is clear enough. Every other EdiSegment is nested like BGM in this example, and every other SegmentGroup is also nested like in this example, according to the structure of the EDI file above. When I assume that, for example, RFF SG1's SequenceEnd is "NAD" (NAD SG4), or NAD SG4's SequenceEnd is TDT SG9 etc. (even in far more nested SG's like CNI or GID it works perfectly fine) it's all good.
So after all this, what's the actual problem? I am in a situation when I can't be always sure what my EDI file will include, and there are some SegmentGroups that will not always be present, let's look at the example:
The only difference between two provided EDIFACT's is the EQD SegmentGroup, after TDT SG9, it's there sometimes, sometimes it is not ;). So when I (wrongly) assume that TDT SG9's SequenceEnd is CNI, it fails when there is EQD segment present in the file, or when I assign EQD as SequenceEnd of TDT, and EQD is not present (ok otherwise). That's it, the only problem. I have looked at a lot of issues posted here, where providing child segments and SegmentGroups in the constructor of SegmentGroups would be the way to go, but then Deserialization fails, for example, the RFF SG1 which is defined in the EdiMessage attributed class collects all 10 RFF segments from the whole file, instead of 3 which are actually there in the main message context of EDIFACT.
I suspect that the solution for this problem is there, but I just can't quite find it, so I would very much appreciate some help with this examples. If needed, I will provide more implementation examples from the D01BIFCSUM class, and thanks in advance :).