EDI.Net icon indicating copy to clipboard operation
EDI.Net copied to clipboard

Avoid ambiguities between segments

Open dinmukhamed09 opened this issue 6 years ago • 7 comments

Hi,

I have structure: List<NUM> NUMs (Condition type: I, status: TOT)

NUM: Number - NUM/0/0 Type - NUM/0/1 Status - NUM/1/0 Additional - NUM segment with NUM/0/0 and NUM/0/1 DUM - segment to avoid ambiguities between NUM DEC - DEC/0/0 List<Info> Infos (Condition code: A,B,C,D)

Info: Code - PTS/0/0 InfoNumber - NUM segment with NUM/0/0 and NUM/0/1 (Condition type: R) DEC - DEC/0/0 and DEC/0/1 Text - TXF/0/0

SDI+TT'
		NUM+123456789:I+TOT'
		NUM+123454554:I'
		DUM+'
		DEC+2'
			PTS+A+'
			NUM+123456788:R'
			DEC+2:C'
			TXF+TEXT'
			PTS+C'
			NUM+123456777:R'
			DEC+1:C'
			TXF+TEXT'
                NUM+123456789:I+TOT'
		DUM+'
		DEC+2'
			PTS+A+'
			NUM+123456838:R'
			DEC+2:D'
			TXF+TEXT'
SPR+ETD'

But is not work, it is my code. It extract group from num to num. My code:

        [EdiCondition("I", Path = "NUM/0/1")]
	public List<NUM> NUMs  { get; set; }
	
	[EdiSegmentGroup("NUM", SequenceEnd = "SPR")]
	public class NUM
	{
		[EdiValue("X(35)", Path = "NUM/0", Mandatory = true)]
		public string Number { get; set; }

		[EdiValue("X(3)", Path = "NUM/0/1", Mandatory = true)]
		public string Type { get; set; }

		[EdiValue("X(3)", Path = "NUM/1", Mandatory = true)]
		public string Status { get; set; }

		public DUM DUM { get; set; }

		public DEC DEC { get; set; }

		[EdiCondition("A", Path = "PTS/1/0")]
		[EdiCondition("B", Path = "PTS/1/0")]
		[EdiCondition("C", Path = "PTS/1/0")]
		[EdiAny]
		public List<Info> Infos { get; set; }
	}
	
	[EdiSegmentGroup("PTS")]
	public class Info
	{
		[EdiValue("X(3)", Path = "PTS/1/0")]
		public string Code { get; set; }

		[EdiValue("X(3)", Path = "PTS/2/0")]
		public string CodeT { get; set; }

		[EdiCondition("J", Path = "NUM/0/1")]
		public NumberDetails Details { get; set; }

		public DEC DEC { get; set; }

		[EdiCondition("4", Path = "TXF/0/0")]
		public string Text { get; set; }
	}
	
	[EdiSegment, EdiPath("DEC")]
	public class DEC
	{
		[EdiValue("X(6)", Path = "DEC/0/0", Mandatory = true)]
		public string Number { get; set; }

		[EdiValue("X(3)", Path = "DEC/0/1")]
		public string Status { get; set; }
		
	}

dinmukhamed09 avatar Jan 31 '19 07:01 dinmukhamed09

How to parse it, i missed Details in Info. Because i cut data in List<NUM> SegmentGroup

dinmukhamed09 avatar Jan 31 '19 07:01 dinmukhamed09

I have to get list of NUM with 2 object. NUM[0].Infos with 2 object NUM[1].Infos with 1 object

dinmukhamed09 avatar Jan 31 '19 07:01 dinmukhamed09

Ok I cannot help without a complete class model and a sample. But if I had to guess by the structure indentation above you are better of defining your SegmentGroup explicitly by providing all direct possible children. For example instead of providing a sequence end you should define NUM and Info with something along the lines:

[EdiSegmentGroup("NUM", "DUM", "DEC", "PTS")]
public class NUM
{
     [EdiValue("X(35)", Path = "NUM/0", Mandatory = true)]
     public string Number { get; set; }

     [EdiValue("X(3)", Path = "NUM/0/1", Mandatory = true)]
     public string Type { get; set; }
    
     [EdiValue("X(3)", Path = "NUM/1", Mandatory = true)]
     public string Status { get; set; }

     public DUM DUM { get; set; }
     public DEC DEC { get; set; }
     public List<Info> Infos { get; set; }
}

[EdiSegmentGroup("PTS", "NUM", "TXF")]
public class Info
{
     [EdiValue("X(3)", Path = "PTS/1/0")]
     public string Code { get; set; }

     [EdiValue("X(3)", Path = "PTS/2/0")]
     public string CodeT { get; set; }

     public NUM Details { get; set; }

     [EdiValue("X(4)", Path = "TXF/0/0")]
     public string Text { get; set; }
}

This will help avoid any mixup for cyclic references.

If this does not help you have to provide me with more info as well as the transmission type.

cleftheris avatar Jan 31 '19 15:01 cleftheris

in class NUM, I can meet a segment twice, but I have to use into NUM other

dinmukhamed09 avatar Feb 01 '19 02:02 dinmukhamed09

Have you resolved this issue? If yes please tell me so I can mark it as closed.

cleftheris avatar Feb 04 '19 13:02 cleftheris

No,

Because in class NUM, i can meet again Segment NUM. And i get only last NUM 1st is mandatory 2nd is not mandatory, but when exist i have to get

dinmukhamed09 avatar Feb 14 '19 04:02 dinmukhamed09

There is a simple example of nested segments with the same name (issue #91). Checkout the sample and the models. Hope it helps.

cleftheris avatar Feb 14 '19 08:02 cleftheris