X12Writer Class

Properties   Methods   Events   Config Settings   Errors  

The X12Writer class generates X12 documents with a clear, straightforward API.

Class Name

EDISDK_X12Writer

Procedural Interface

 edisdk_x12writer_open();
 edisdk_x12writer_close($res);
 edisdk_x12writer_register_callback($res, $id, $function);
 edisdk_x12writer_get_last_error($res);
 edisdk_x12writer_get_last_error_code($res);
 edisdk_x12writer_set($res, $id, $index, $value);
 edisdk_x12writer_get($res, $id, $index);
 edisdk_x12writer_do_close($res);
 edisdk_x12writer_do_config($res, $configurationstring);
 edisdk_x12writer_do_endcompositeelement($res);
 edisdk_x12writer_do_endfunctionalgroup($res);
 edisdk_x12writer_do_endinterchange($res);
 edisdk_x12writer_do_endsegment($res);
 edisdk_x12writer_do_endtransactionset($res);
 edisdk_x12writer_do_reset($res);
 edisdk_x12writer_do_startcompositeelement($res);
 edisdk_x12writer_do_startfunctionalgroup($res);
 edisdk_x12writer_do_startinterchange($res);
 edisdk_x12writer_do_startsegment($res, $tag);
 edisdk_x12writer_do_starttransactionset($res);
 edisdk_x12writer_do_writecomponent($res, $val);
 edisdk_x12writer_do_writeelement($res, $val);

Remarks

The class allows you to create an EDI document from scratch, one segment at a time. Here's how a document would normally be created:

  1. Call LoadSchema to load the necessary schemas for the transactions that will be used.
  2. Specify where to write the output document by setting the OutputFile, or check the OutputData property after writing.
  3. Create a new interchange start segment by setting the fields of the Interchange property and call the StartInterchange method. Once the interchange is complete, call EndInterchange to add the interchange footer.
  4. If you want to create a functional group, set the fields of the FunctionalGroup property and then call the StartFunctionalGroup. Once all the transactions in the group have been created, call EndFunctionalGroup to add a footer for the group.
  5. To start a transaction, call the StartTransactionSet method. Once all segments have been added, call EndTransactionSet to add a footer to the transaction.
  6. To begin a segment, call the StartSegment method and pass in the tag for the segment. Once all the elements in the segment have been added, call EndSegment to add the segment terminator.
  7. To write a basic element to the current segment, call the WriteElement method.
  8. To write a composite element, call the StartCompositeElement method, then call the WriteComponent method for each component, and finally call EndCompositeElement to end the element.

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

DelimiterComponentThe delimiter separating classes.
DelimiterElementThe delimiter separating elements.
DelimiterRepetitionThe delimiter separating classes.
DelimiterSegmentThe delimiter separating segments.
FileWriteModeDetermines how the output file is opened for writing.
FGroupAppReceiverCodeThe name or code of the intended receiver of the transaction set group.
FGroupAppSenderCodeCode identifying the sender of FunctionalGroup This is an alphanumeric property with a value between 2 and 15 characters long.
FGroupDateThe date that the group of transaction sets was prepared.
FGroupFunctionalIdentifierCodeA code identifying the type of transaction sets included in the functional group.
FGroupGroupControlNumAn identification number assigned by the sender to uniquely identify the group of transaction sets.
FGroupResponsibleAgencyCodeA code identifying the issuer of the standard that the transaction set conforms to.
FGroupTimeThe time that the group of transaction sets was prepared.
FGroupVersionCode indicating the version of the X12 standard used to construct the transaction set.
InterchangeAckRequestCode indicating whether an interchange acknowledgment is requested.
InterchangeAuthorizationInfoInformation used for additional identification or authorization of the interchange sender or the data in the interchange.
InterchangeAuthorizationInfoQualifierA code indicating the type of data supplied in Authorization Information property.
InterchangeDateThe date that the Interchange was prepared.
InterchangeInterchangeControlNumA control number assigned by the sender to uniquely identify the interchange.
InterchangeInterchangeControlVersionNumA code specifying the version of the X12 standard used to construct the Interchange.
InterchangeReceiverIDThe identification code of the receiver of the transaction set.
InterchangeReceiverIDQualifierA code that identifies the format of the receiver ID.
InterchangeSecurityInfoCoded security information associated with the Interchange.
InterchangeSecurityInfoQualifierA code indicating the type of data in the Security Information property.
InterchangeSenderIDThe identification code of the sender of the transaction set.
InterchangeSenderIDQualifierA code that identifies the format of the sender ID.
InterchangeTimeThe time that the Interchange sets was prepared.
InterchangeUsageIndicatorCode to indicate whether the interchange is a test or production.
OutputDataThe output data that has been written so far.
OutputFileThe name of the output file to which the EDI data will be written.
SegmentSuffixThe suffix that is appended to the end of a segment.
TransSetImpConventionReferenceReference used to identify the implementation convention.
TransSetTransactionSetControlNumThe unique transaction set control number assigned for a transaction set.
TransSetTransactionSetIDCodeThe identifier code for the transaction set.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

CloseCloses the writer.
ConfigSets or retrieves a configuration setting.
EndCompositeElementCloses the current composite element.
EndFunctionalGroupCloses the current functional group.
EndInterchangeCloses the current interchange.
EndSegmentFinish writing the current segment.
EndTransactionSetCloses the current transaction set.
ResetResets all properties to their default values.
StartCompositeElementStarts a composite element within the current segment.
StartFunctionalGroupStarts a new functional group in the EDI document.
StartInterchangeStarts a new interchange in the EDI document.
StartSegmentStarts a new segment with the specified tag.
StartTransactionSetStarts a new transaction set in the EDI document.
WriteComponentWrites a class element value to the current composite element.
WriteElementWrites an element value to the current segment.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

ErrorFires when an error occurs during message processing. Normally, the class fails with an error.
OutputFires when output data is written.

Config Settings


The following is a list of config settings for the class with short descriptions. Click on the links for further details.

DelimiterComponent Property (EDISDK_X12Writer Class)

The delimiter separating classes.

Object Oriented Interface

public function getDelimiterComponent();
public function setDelimiterComponent($value);

Procedural Interface

edisdk_x12writer_get($res, 1 );
edisdk_x12writer_set($res, 1, $value );

Default Value

':'

Remarks

The delimiter separating components.

In X12Reader, this type is used to hold the delimiters found when parsing the component, while in X12Writer the fields can be set to choose the delimiters that will be used when writing

This property is not available at design time.

Data Type

String

DelimiterElement Property (EDISDK_X12Writer Class)

The delimiter separating elements.

Object Oriented Interface

public function getDelimiterElement();
public function setDelimiterElement($value);

Procedural Interface

edisdk_x12writer_get($res, 2 );
edisdk_x12writer_set($res, 2, $value );

Default Value

'*'

Remarks

The delimiter separating elements.

In X12Reader, this type is used to hold the delimiters found when parsing the element, while in X12Writer the fields can be set to choose the delimiters that will be used when writing

This property is not available at design time.

Data Type

String

DelimiterRepetition Property (EDISDK_X12Writer Class)

The delimiter separating classes.

Object Oriented Interface

public function getDelimiterRepetition();
public function setDelimiterRepetition($value);

Procedural Interface

edisdk_x12writer_get($res, 3 );
edisdk_x12writer_set($res, 3, $value );

Default Value

'^'

Remarks

The delimiter separating components.

In X12Reader, this type is used to hold the delimiters found when parsing the component, while in X12Writer the fields can be set to choose the delimiters that will be used when writing

This property is not available at design time.

Data Type

String

DelimiterSegment Property (EDISDK_X12Writer Class)

The delimiter separating segments.

Object Oriented Interface

public function getDelimiterSegment();
public function setDelimiterSegment($value);

Procedural Interface

edisdk_x12writer_get($res, 4 );
edisdk_x12writer_set($res, 4, $value );

Default Value

'~'

Remarks

The delimiter separating segments.

In X12Reader, this type is used to hold the delimiters found when parsing the segment, while in X12Writer the fields can be set to choose the delimiters that will be used when writing

This property is not available at design time.

Data Type

String

FileWriteMode Property (EDISDK_X12Writer Class)

Determines how the output file is opened for writing.

Object Oriented Interface

public function getFileWriteMode();
public function setFileWriteMode($value);

Procedural Interface

edisdk_x12writer_get($res, 5 );
edisdk_x12writer_set($res, 5, $value );

Possible Values

X12WRITER_FILEWRITEMODE_CREATE(0), 
X12WRITER_FILEWRITEMODE_OVERWRITE(1),
X12WRITER_FILEWRITEMODE_APPEND(2)

Default Value

0

Remarks

When OutputFile is set, this property determines how the file will be opened.

fwmCreate (Default)Creates a new file. If the file already exists, the translation will fail.
fwmOverwriteOpens an existing file and overwrites its contents. If the file does not exist, a new file will be created.
fwmAppendOpens an existing file and appends data to the end of the file. If the file does not exist, a new file will be created.

This property is not available at design time.

Data Type

Integer

FGroupAppReceiverCode Property (EDISDK_X12Writer Class)

The name or code of the intended receiver of the transaction set group.

Object Oriented Interface

public function getFGroupAppReceiverCode();
public function setFGroupAppReceiverCode($value);

Procedural Interface

edisdk_x12writer_get($res, 6 );
edisdk_x12writer_set($res, 6, $value );

Default Value

''

Remarks

The name or code of the intended receiver of the transaction set group.

This is an alphanumeric field with a value between 2 and 15 characters.

This property is not available at design time.

Data Type

String

FGroupAppSenderCode Property (EDISDK_X12Writer Class)

Code identifying the sender of FunctionalGroup This is an alphanumeric property with a value between 2 and 15 characters long.

Object Oriented Interface

public function getFGroupAppSenderCode();
public function setFGroupAppSenderCode($value);

Procedural Interface

edisdk_x12writer_get($res, 7 );
edisdk_x12writer_set($res, 7, $value );

Default Value

''

Remarks

Code identifying the sender of FunctionalGroup

This is an alphanumeric field with a value between 2 and 15 characters long.

This property is not available at design time.

Data Type

String

FGroupDate Property (EDISDK_X12Writer Class)

The date that the group of transaction sets was prepared.

Object Oriented Interface

public function getFGroupDate();
public function setFGroupDate($value);

Procedural Interface

edisdk_x12writer_get($res, 8 );
edisdk_x12writer_set($res, 8, $value );

Default Value

''

Remarks

The date that the group of transaction sets was prepared.

This is a numeric field with a value in the format YYMMDD.

This property is not available at design time.

Data Type

String

FGroupFunctionalIdentifierCode Property (EDISDK_X12Writer Class)

A code identifying the type of transaction sets included in the functional group.

Object Oriented Interface

public function getFGroupFunctionalIdentifierCode();
public function setFGroupFunctionalIdentifierCode($value);

Procedural Interface

edisdk_x12writer_get($res, 9 );
edisdk_x12writer_set($res, 9, $value );

Default Value

''

Remarks

A code identifying the type of transaction sets included in the functional group.

This is an alphanumeric field with a code value between of 2 characters.

This property is not available at design time.

Data Type

String

FGroupGroupControlNum Property (EDISDK_X12Writer Class)

An identification number assigned by the sender to uniquely identify the group of transaction sets.

Object Oriented Interface

public function getFGroupGroupControlNum();
public function setFGroupGroupControlNum($value);

Procedural Interface

edisdk_x12writer_get($res, 10 );
edisdk_x12writer_set($res, 10, $value );

Default Value

''

Remarks

An identification number assigned by the sender to uniquely identify the group of transaction sets.

This is a numeric field with a value between 1 and 9 digits.

This property is not available at design time.

Data Type

String

FGroupResponsibleAgencyCode Property (EDISDK_X12Writer Class)

A code identifying the issuer of the standard that the transaction set conforms to.

Object Oriented Interface

public function getFGroupResponsibleAgencyCode();
public function setFGroupResponsibleAgencyCode($value);

Procedural Interface

edisdk_x12writer_get($res, 11 );
edisdk_x12writer_set($res, 11, $value );

Default Value

''

Remarks

A code identifying the issuer of the standard that the transaction set conforms to.

This is an alphanumeric field with a code value of 1 to 2 characters.

This property is not available at design time.

Data Type

String

FGroupTime Property (EDISDK_X12Writer Class)

The time that the group of transaction sets was prepared.

Object Oriented Interface

public function getFGroupTime();
public function setFGroupTime($value);

Procedural Interface

edisdk_x12writer_get($res, 12 );
edisdk_x12writer_set($res, 12, $value );

Default Value

''

Remarks

The time that the group of transaction sets was prepared.

This is a numeric field with a value between 4 and 8 digits in the format HHMM, HHMMSS, or HHMMSSDD. Time should be in the 24-hour format.

This property is not available at design time.

Data Type

String

FGroupVersion Property (EDISDK_X12Writer Class)

Code indicating the version of the X12 standard used to construct the transaction set.

Object Oriented Interface

public function getFGroupVersion();
public function setFGroupVersion($value);

Procedural Interface

edisdk_x12writer_get($res, 13 );
edisdk_x12writer_set($res, 13, $value );

Default Value

''

Remarks

Code indicating the version of the X12 standard used to construct the transaction set.

This is an alphanumeric field with a code value between 1 and 12 characters.

This property is not available at design time.

Data Type

String

InterchangeAckRequest Property (EDISDK_X12Writer Class)

Code indicating whether an interchange acknowledgment is requested.

Object Oriented Interface

public function getInterchangeAckRequest();
public function setInterchangeAckRequest($value);

Procedural Interface

edisdk_x12writer_get($res, 14 );
edisdk_x12writer_set($res, 14, $value );

Default Value

''

Remarks

Code indicating whether an interchange acknowledgment is requested.

This is an alphanumeric field with a code value of 1 character, either "0" (no acknowledgment requested) or "1" (acknowledgment requested).

This property is not available at design time.

Data Type

String

InterchangeAuthorizationInfo Property (EDISDK_X12Writer Class)

Information used for additional identification or authorization of the interchange sender or the data in the interchange.

Object Oriented Interface

public function getInterchangeAuthorizationInfo();
public function setInterchangeAuthorizationInfo($value);

Procedural Interface

edisdk_x12writer_get($res, 15 );
edisdk_x12writer_set($res, 15, $value );

Default Value

''

Remarks

Information used for additional identification or authorization of the interchange sender or the data in the interchange.

The type of information is set by the AuthorizationInfoQual field.

This property is not available at design time.

Data Type

String

InterchangeAuthorizationInfoQualifier Property (EDISDK_X12Writer Class)

A code indicating the type of data supplied in Authorization Information property.

Object Oriented Interface

public function getInterchangeAuthorizationInfoQualifier();
public function setInterchangeAuthorizationInfoQualifier($value);

Procedural Interface

edisdk_x12writer_get($res, 16 );
edisdk_x12writer_set($res, 16, $value );

Default Value

''

Remarks

A code indicating the type of data supplied in Authorization Information field.

This is an alphanumeric field with a code value of 2 characters.

This property is not available at design time.

Data Type

String

InterchangeDate Property (EDISDK_X12Writer Class)

The date that the Interchange was prepared.

Object Oriented Interface

public function getInterchangeDate();
public function setInterchangeDate($value);

Procedural Interface

edisdk_x12writer_get($res, 17 );
edisdk_x12writer_set($res, 17, $value );

Default Value

''

Remarks

The date that the Interchange was prepared.

This is a numeric field with a value of 6 digits in the format YYMMDD.

This property is not available at design time.

Data Type

String

InterchangeInterchangeControlNum Property (EDISDK_X12Writer Class)

A control number assigned by the sender to uniquely identify the interchange.

Object Oriented Interface

public function getInterchangeInterchangeControlNum();
public function setInterchangeInterchangeControlNum($value);

Procedural Interface

edisdk_x12writer_get($res, 18 );
edisdk_x12writer_set($res, 18, $value );

Default Value

''

Remarks

A control number assigned by the sender to uniquely identify the interchange.

This is a numeric field with a value of 9 digits.

This property is not available at design time.

Data Type

String

InterchangeInterchangeControlVersionNum Property (EDISDK_X12Writer Class)

A code specifying the version of the X12 standard used to construct the Interchange.

Object Oriented Interface

public function getInterchangeInterchangeControlVersionNum();
public function setInterchangeInterchangeControlVersionNum($value);

Procedural Interface

edisdk_x12writer_get($res, 19 );
edisdk_x12writer_set($res, 19, $value );

Default Value

''

Remarks

A code specifying the version of the X12 standard used to construct the Interchange.

This is an alphanumeric field with a code value 5 characters.

This property is not available at design time.

Data Type

String

InterchangeReceiverID Property (EDISDK_X12Writer Class)

The identification code of the receiver of the transaction set.

Object Oriented Interface

public function getInterchangeReceiverID();
public function setInterchangeReceiverID($value);

Procedural Interface

edisdk_x12writer_get($res, 20 );
edisdk_x12writer_set($res, 20, $value );

Default Value

''

Remarks

The identification code of the receiver of the transaction set.

This is an alphanumeric field with a value of 15 characters.

This property is not available at design time.

Data Type

String

InterchangeReceiverIDQualifier Property (EDISDK_X12Writer Class)

A code that identifies the format of the receiver ID.

Object Oriented Interface

public function getInterchangeReceiverIDQualifier();
public function setInterchangeReceiverIDQualifier($value);

Procedural Interface

edisdk_x12writer_get($res, 21 );
edisdk_x12writer_set($res, 21, $value );

Default Value

''

Remarks

A code that identifies the format of the receiver ID.

This is an alphanumeric field with a code value of 2 characters.

This property is not available at design time.

Data Type

String

InterchangeSecurityInfo Property (EDISDK_X12Writer Class)

Coded security information associated with the Interchange.

Object Oriented Interface

public function getInterchangeSecurityInfo();
public function setInterchangeSecurityInfo($value);

Procedural Interface

edisdk_x12writer_get($res, 22 );
edisdk_x12writer_set($res, 22, $value );

Default Value

''

Remarks

Coded security information associated with the Interchange.

The type of information is set by the SecurityInfoQualifier.

This is an alphanumeric field with a value between of 10 characters.

This property is not available at design time.

Data Type

String

InterchangeSecurityInfoQualifier Property (EDISDK_X12Writer Class)

A code indicating the type of data in the Security Information property.

Object Oriented Interface

public function getInterchangeSecurityInfoQualifier();
public function setInterchangeSecurityInfoQualifier($value);

Procedural Interface

edisdk_x12writer_get($res, 23 );
edisdk_x12writer_set($res, 23, $value );

Default Value

''

Remarks

A code indicating the type of data in the Security Information field.

This is an alphanumeric field with a code value of 2 characters.

This property is not available at design time.

Data Type

String

InterchangeSenderID Property (EDISDK_X12Writer Class)

The identification code of the sender of the transaction set.

Object Oriented Interface

public function getInterchangeSenderID();
public function setInterchangeSenderID($value);

Procedural Interface

edisdk_x12writer_get($res, 24 );
edisdk_x12writer_set($res, 24, $value );

Default Value

''

Remarks

The identification code of the sender of the transaction set.

This is an alphanumeric field with a value of 15 characters.

This property is not available at design time.

Data Type

String

InterchangeSenderIDQualifier Property (EDISDK_X12Writer Class)

A code that identifies the format of the sender ID.

Object Oriented Interface

public function getInterchangeSenderIDQualifier();
public function setInterchangeSenderIDQualifier($value);

Procedural Interface

edisdk_x12writer_get($res, 25 );
edisdk_x12writer_set($res, 25, $value );

Default Value

''

Remarks

A code that identifies the format of the sender ID.

This is an alphanumeric field with a code value of 2 characters.

This property is not available at design time.

Data Type

String

InterchangeTime Property (EDISDK_X12Writer Class)

The time that the Interchange sets was prepared.

Object Oriented Interface

public function getInterchangeTime();
public function setInterchangeTime($value);

Procedural Interface

edisdk_x12writer_get($res, 26 );
edisdk_x12writer_set($res, 26, $value );

Default Value

''

Remarks

The time that the Interchange sets was prepared.

This is a numeric field with a value in the format HHMM.

This property is not available at design time.

Data Type

String

InterchangeUsageIndicator Property (EDISDK_X12Writer Class)

Code to indicate whether the interchange is a test or production.

Object Oriented Interface

public function getInterchangeUsageIndicator();
public function setInterchangeUsageIndicator($value);

Procedural Interface

edisdk_x12writer_get($res, 27 );
edisdk_x12writer_set($res, 27, $value );

Default Value

''

Remarks

Code to indicate whether the interchange is a test or production.

This is an alphanumeric field with a code value of 1 character.

This property is not available at design time.

Data Type

String

OutputData Property (EDISDK_X12Writer Class)

The output data that has been written so far.

Object Oriented Interface

public function getOutputData();
public function setOutputData($value);

Procedural Interface

edisdk_x12writer_get($res, 28 );
edisdk_x12writer_set($res, 28, $value );

Default Value

''

Remarks

OutputData contains the entire EDI document that has been written so far. If writing to a file or stream, this property will be empty.

This property is not available at design time.

Data Type

String

OutputFile Property (EDISDK_X12Writer Class)

The name of the output file to which the EDI data will be written.

Object Oriented Interface

public function getOutputFile();
public function setOutputFile($value);

Procedural Interface

edisdk_x12writer_get($res, 29 );
edisdk_x12writer_set($res, 29, $value );

Default Value

''

Remarks

FileWriteMode property determines how the file is opened for writing. If OutputFile is empty, no file will be written and the OutputData property will contain the EDI data instead.

This property is not available at design time.

Data Type

String

SegmentSuffix Property (EDISDK_X12Writer Class)

The suffix that is appended to the end of a segment.

Object Oriented Interface

public function getSegmentSuffix();
public function setSegmentSuffix($value);

Procedural Interface

edisdk_x12writer_get($res, 30 );
edisdk_x12writer_set($res, 30, $value );

Possible Values

X12WRITER_SEGMENTSUFFIX_NONE(0), 
X12WRITER_SEGMENTSUFFIX_CR(1),
X12WRITER_SEGMENTSUFFIX_LF(2),
X12WRITER_SEGMENTSUFFIX_CRLF(3)

Default Value

0

Remarks

Possible values are:

ssNone (0)No suffix is appended to the segment.
ssCR (1)A carriage return (ASCII 13) is appended to the segment.
ssLF (2)A line feed (ASCII 10) is appended to the segment.
ssCRLF (3)A carriage return followed by a line feed (ASCII 13 and 10) is appended to the segment. This is the default value.

This property is not available at design time.

Data Type

Integer

TransSetImpConventionReference Property (EDISDK_X12Writer Class)

Reference used to identify the implementation convention.

Object Oriented Interface

public function getTransSetImpConventionReference();
public function setTransSetImpConventionReference($value);

Procedural Interface

edisdk_x12writer_get($res, 31 );
edisdk_x12writer_set($res, 31, $value );

Default Value

''

Remarks

Reference used to identify the implementation convention.

This is an alphanumeric field with a value up to 35 characters long.

This property is not available at design time.

Data Type

String

TransSetTransactionSetControlNum Property (EDISDK_X12Writer Class)

The unique transaction set control number assigned for a transaction set.

Object Oriented Interface

public function getTransSetTransactionSetControlNum();
public function setTransSetTransactionSetControlNum($value);

Procedural Interface

edisdk_x12writer_get($res, 32 );
edisdk_x12writer_set($res, 32, $value );

Default Value

''

Remarks

The unique transaction set control number assigned for a transaction set.

This is an alphanumeric field with a value between 4 and 9 characters long.

This property is not available at design time.

Data Type

String

TransSetTransactionSetIDCode Property (EDISDK_X12Writer Class)

The identifier code for the transaction set.

Object Oriented Interface

public function getTransSetTransactionSetIDCode();
public function setTransSetTransactionSetIDCode($value);

Procedural Interface

edisdk_x12writer_get($res, 33 );
edisdk_x12writer_set($res, 33, $value );

Default Value

''

Remarks

The identifier code for the transaction set.

This is an alphanumeric field with a code value of 3 characters long.

This property is not available at design time.

Data Type

String

Close Method (EDISDK_X12Writer Class)

Closes the writer.

Object Oriented Interface

public function doClose();

Procedural Interface

edisdk_x12writer_do_close($res);

Remarks

Calling Close will close the writer and release any resources associated with it. After calling Close, the writer cannot be used unless it is re-initialized.

Config Method (EDISDK_X12Writer Class)

Sets or retrieves a configuration setting.

Object Oriented Interface

public function doConfig($configurationstring);

Procedural Interface

edisdk_x12writer_do_config($res, $configurationstring);

Remarks

Config is a generic method available in every class. It is used to set and retrieve configuration settings for the class.

These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.

To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).

To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.

EndCompositeElement Method (EDISDK_X12Writer Class)

Closes the current composite element.

Object Oriented Interface

public function doEndCompositeElement();

Procedural Interface

edisdk_x12writer_do_endcompositeelement($res);

Remarks

Calling EndCompositeElement will close the current composite element. If no composite element is open, an error will be raised.

EndFunctionalGroup Method (EDISDK_X12Writer Class)

Closes the current functional group.

Object Oriented Interface

public function doEndFunctionalGroup();

Procedural Interface

edisdk_x12writer_do_endfunctionalgroup($res);

Remarks

Calling EndFunctionalGroup will close the current functional group. If no functional group is open, an error will be raised. This method will also write the required FunctionalGroup Trailer (GE) segment to the output.

EndInterchange Method (EDISDK_X12Writer Class)

Closes the current interchange.

Object Oriented Interface

public function doEndInterchange();

Procedural Interface

edisdk_x12writer_do_endinterchange($res);

Remarks

Calling EndInterchange will close the current interchange. If no interchange is open, an error will be raised. This method will also write the required Interchange Trailer (IEA) segment to the output.

EndSegment Method (EDISDK_X12Writer Class)

Finish writing the current segment.

Object Oriented Interface

public function doEndSegment();

Procedural Interface

edisdk_x12writer_do_endsegment($res);

Remarks

Calling EndSegment will finish writing the current segment. If no segment is open or if a composite element is still open an error will be raised. This method will also write the segment delimiter and segment suffix to the output.

EndTransactionSet Method (EDISDK_X12Writer Class)

Closes the current transaction set.

Object Oriented Interface

public function doEndTransactionSet();

Procedural Interface

edisdk_x12writer_do_endtransactionset($res);

Remarks

Calling this method will close the current transaction set. If no transaction set is open, an error will be raised. This method will also write the required Transaction Set Trailer (SE) segment to the output.

Reset Method (EDISDK_X12Writer Class)

Resets all properties to their default values.

Object Oriented Interface

public function doReset();

Procedural Interface

edisdk_x12writer_do_reset($res);

Remarks

This method resets all properties of the component to their default values as specified in the property definitions.

StartCompositeElement Method (EDISDK_X12Writer Class)

Starts a composite element within the current segment.

Object Oriented Interface

public function doStartCompositeElement();

Procedural Interface

edisdk_x12writer_do_startcompositeelement($res);

Remarks

This method starts a composite element within the current segment. The composite element can contain multiple component elements. The composite element is ended by calling the EndCompositeElement method. Component elements within the composite are added by calling the WriteComponent method.

StartFunctionalGroup Method (EDISDK_X12Writer Class)

Starts a new functional group in the EDI document.

Object Oriented Interface

public function doStartFunctionalGroup();

Procedural Interface

edisdk_x12writer_do_startfunctionalgroup($res);

Remarks

This method starts a new functional group in the EDI document. The functional group fields must be set using the appropriate properties before calling this method. The functional group is ended by calling the EndFunctionalGroup method. The functional group header segment (GS) is written to the output when this method is called.

StartInterchange Method (EDISDK_X12Writer Class)

Starts a new interchange in the EDI document.

Object Oriented Interface

public function doStartInterchange();

Procedural Interface

edisdk_x12writer_do_startinterchange($res);

Remarks

This method starts a new interchange in the EDI document. The interchange fields must be set using the appropriate properties before calling this method. The interchange is ended by calling the EndInterchange method. The interchange header segment (ISA) is written to the output when this method is called. If opening a new interchange would result in an invalid structure (for example, starting a new interchange before ending the previous one), an error will be raised.

StartSegment Method (EDISDK_X12Writer Class)

Starts a new segment with the specified tag.

Object Oriented Interface

public function doStartSegment($tag);

Procedural Interface

edisdk_x12writer_do_startsegment($res, $tag);

Remarks

This method starts a new segment with the specified tag. The segment is ended by calling the EndSegment method. Element values within the segment are added by calling the WriteElement method. Composite elements can be added to the segment by calling the StartCompositeElement method. If starting a new segment would result in an invalid structure (for example, starting a new segment before ending the previous one), an error will be raised.

StartTransactionSet Method (EDISDK_X12Writer Class)

Starts a new transaction set in the EDI document.

Object Oriented Interface

public function doStartTransactionSet();

Procedural Interface

edisdk_x12writer_do_starttransactionset($res);

Remarks

This method starts a new transaction set in the EDI document. The transaction set fields must be set using the appropriate properties before calling this method. The transaction set is ended by calling the EndTransactionSet method. The transaction set header segment (ST) is written to the output when this method is called. If opening a new transaction set would result in an invalid structure (for example, starting a new transaction set before ending the previous one), an error will be raised.

WriteComponent Method (EDISDK_X12Writer Class)

Writes a class element value to the current composite element.

Object Oriented Interface

public function doWriteComponent($val);

Procedural Interface

edisdk_x12writer_do_writecomponent($res, $val);

Remarks

This method writes a component element value to the current composite element. The composite element must be started by calling the StartCompositeElement method before calling this method. The composite element is ended by calling the EndCompositeElement method. If this method is called when not within a composite element, an error will be raised.

WriteElement Method (EDISDK_X12Writer Class)

Writes an element value to the current segment.

Object Oriented Interface

public function doWriteElement($val);

Procedural Interface

edisdk_x12writer_do_writeelement($res, $val);

Remarks

This method writes an element value to the current segment. The segment must be started by calling the StartSegment method before calling this method. The segment is ended by calling the EndSegment method. If this method is called when not within a segment, an error will be raised.

Error Event (EDISDK_X12Writer Class)

Fires when an error occurs during message processing. Normally, the class fails with an error.

Object Oriented Interface

public function fireError($param);

Procedural Interface

edisdk_x12writer_register_callback($res, 1, array($this, 'fireError'));

Parameter List

 'errorcode'
'description'

Remarks

The Error event is fired in case of exceptional conditions during message processing. Normally, the class fails with an error.

ConnectionId is the associated client Id, ErrorCode contains an error code, and Description contains a textual description of the error. For a list of valid error codes and their descriptions, please refer to the Error Codes section.

Output Event (EDISDK_X12Writer Class)

Fires when output data is written.

Object Oriented Interface

public function fireOutput($param);

Procedural Interface

edisdk_x12writer_register_callback($res, 2, array($this, 'fireOutput'));

Parameter List

 'data'

Remarks

This event is fired when output data is written. The Data parameter contains the segment that was written.

Config Settings (X12Writer Class)

The class accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.

Trappable Errors (X12Writer Class)

X12Writer Errors

202   Invalid argument.
304   Cannot write to file.
1099   Encountered an unexpected segment tag.
1100   Attempted to perform an action while the component was busy, or close an incomplete interchange.
1205   Tried to perform an operation in a bad state (such as ending an interchange before starting one).
1206   Tried to end an interchange with no contents.