IPWorks EDI 2020 Node.js Edition

Questions / Feedback?

RepeatElement Method

Adds a new repetition to the current element.

Syntax

edifactwriter.repeatElement([callback])

Callback

The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).

The callback for this method is defined as:

function(err){ }

'err' is the error that occurred. If there was no error, then 'err' is 'null'.

'err' has 2 properties which hold detailed information:

err.code
err.message

Remarks

RepeatElement is used to write repeated data elements in supporting version of X12 or EDIFACT. To use it, first write the first repetition of the simple or composite data element and then call RepeatElement to repeat it, then write again.

Example: Repeating a simple data element:

  EDIWriter writer = new EDIWriter();
  ...
  writer.StartSegment("Tag");
  ...
  writer.WriteElementString("R1_1");
  writer.RepeatElement();
  writer.WriteElementString("R1_2");
  writer.RepeatElement();
  writer.WriteElementString("R1_3");
  ...
  writer.EndSegment();

Example: Repeating a composite data element:

  EDIWriter writer = new EDIWriter();
  ...
  writer.StartSegment("Tag");
  ...
  writer.StartElement();
  writer.WriteComponentString("C1_1");
  writer.WriteComponentString("C2_1");
  writer.RepeatElement();
  writer.WriteComponentString("C1_2");
  writer.WriteComponentString("C2_2");
  writer.RepeatElement();
  writer.WriteComponentString("C1_3");
  writer.EndElement();
  ...
  writer.EndSegment();

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks EDI 2020 Node.js Edition - Version 20.0 [Build 8203]