X12Writer Class
Properties Methods Events Config Settings Errors
The X12Writer class generates X12 documents with a clear, straightforward API.
Syntax
X12Writer
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:
- Call LoadSchema to load the necessary schemas for the transactions that will be used.
- Specify where to write the output document by setting the OutputFile, or check the OutputData property after writing.
- 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.
- 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.
- To start a transaction, call the StartTransactionSet method. Once all segments have been added, call EndTransactionSet to add a footer to the transaction.
- 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.
- To write a basic element to the current segment, call the WriteElement method.
- 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.
| Delimiters | Contains the delimiters for the EDI Document. |
| FileWriteMode | Determines how the output file is opened for writing. |
| FunctionalGroup | Contains the current functional group information for the EDI Document. |
| Interchange | Contains the current interchange information for the EDI Document. |
| OutputData | The output data that has been written so far. |
| OutputFile | The name of the output file to which the EDI data will be written. |
| SegmentSuffix | The suffix that is appended to the end of a segment. |
| TransactionSet | Contains the current transaction set information for the EDI Document. |
Method List
The following is the full list of the methods of the class with short descriptions. Click on the links for further details.
| Close | Closes the writer. |
| Config | Sets or retrieves a configuration setting. |
| EndCompositeElement | Closes the current composite element. |
| EndFunctionalGroup | Closes the current functional group. |
| EndInterchange | Closes the current interchange. |
| EndSegment | Finish writing the current segment. |
| EndTransactionSet | Closes the current transaction set. |
| Reset | Resets all properties to their default values. |
| StartCompositeElement | Starts a composite element within the current segment. |
| StartFunctionalGroup | Starts a new functional group in the EDI document. |
| StartInterchange | Starts a new interchange in the EDI document. |
| StartSegment | Starts a new segment with the specified tag. |
| StartTransactionSet | Starts a new transaction set in the EDI document. |
| WriteComponent | Writes a class element value to the current composite element. |
| WriteElement | Writes 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.
| Error | Fires when an error occurs during message processing. Normally, the class fails with an error. |
| Output | Fires 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.
Delimiters Property (X12Writer Class)
Contains the delimiters for the EDI Document.
Syntax
EDISDKX12Delimiters* GetDelimiters();
char* edisdk_x12writer_getdelimitercomponent(void* lpObj);
int edisdk_x12writer_setdelimitercomponent(void* lpObj, const char* lpszDelimiterComponent);
char* edisdk_x12writer_getdelimiterelement(void* lpObj);
int edisdk_x12writer_setdelimiterelement(void* lpObj, const char* lpszDelimiterElement);
char* edisdk_x12writer_getdelimiterrepetition(void* lpObj);
int edisdk_x12writer_setdelimiterrepetition(void* lpObj, const char* lpszDelimiterRepetition);
char* edisdk_x12writer_getdelimitersegment(void* lpObj);
int edisdk_x12writer_setdelimitersegment(void* lpObj, const char* lpszDelimiterSegment);
QString getDelimiterComponent();
int setDelimiterComponent(QString qsDelimiterComponent); QString getDelimiterElement();
int setDelimiterElement(QString qsDelimiterElement); QString getDelimiterRepetition();
int setDelimiterRepetition(QString qsDelimiterRepetition); QString getDelimiterSegment();
int setDelimiterSegment(QString qsDelimiterSegment);
Remarks
This property contains the delimiters that will be used when writing the EDIFACT document. If the document uses delimiters other than the default, change the properties of this object to write the document correctly.
This property is read-only and not available at design time.
Data Type
FileWriteMode Property (X12Writer Class)
Determines how the output file is opened for writing.
Syntax
ANSI (Cross Platform) int GetFileWriteMode();
int SetFileWriteMode(int iFileWriteMode); Unicode (Windows) INT GetFileWriteMode();
INT SetFileWriteMode(INT iFileWriteMode);
Possible Values
FWM_CREATE(0),
FWM_OVERWRITE(1),
FWM_APPEND(2)
int edisdk_x12writer_getfilewritemode(void* lpObj);
int edisdk_x12writer_setfilewritemode(void* lpObj, int iFileWriteMode);
int getFileWriteMode();
int setFileWriteMode(int iFileWriteMode);
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. |
| fwmOverwrite | Opens an existing file and overwrites its contents. If the file does not exist, a new file will be created. |
| fwmAppend | Opens 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
FunctionalGroup Property (X12Writer Class)
Contains the current functional group information for the EDI Document.
Syntax
EDISDKX12FunctionalGroup* GetFunctionalGroup();
char* edisdk_x12writer_getfgroupappreceivercode(void* lpObj);
int edisdk_x12writer_setfgroupappreceivercode(void* lpObj, const char* lpszFGroupAppReceiverCode);
char* edisdk_x12writer_getfgroupappsendercode(void* lpObj);
int edisdk_x12writer_setfgroupappsendercode(void* lpObj, const char* lpszFGroupAppSenderCode);
char* edisdk_x12writer_getfgroupdate(void* lpObj);
int edisdk_x12writer_setfgroupdate(void* lpObj, const char* lpszFGroupDate);
char* edisdk_x12writer_getfgroupfunctionalidentifiercode(void* lpObj);
int edisdk_x12writer_setfgroupfunctionalidentifiercode(void* lpObj, const char* lpszFGroupFunctionalIdentifierCode);
char* edisdk_x12writer_getfgroupgroupcontrolnum(void* lpObj);
int edisdk_x12writer_setfgroupgroupcontrolnum(void* lpObj, const char* lpszFGroupGroupControlNum);
char* edisdk_x12writer_getfgroupresponsibleagencycode(void* lpObj);
int edisdk_x12writer_setfgroupresponsibleagencycode(void* lpObj, const char* lpszFGroupResponsibleAgencyCode);
char* edisdk_x12writer_getfgrouptime(void* lpObj);
int edisdk_x12writer_setfgrouptime(void* lpObj, const char* lpszFGroupTime);
char* edisdk_x12writer_getfgroupversion(void* lpObj);
int edisdk_x12writer_setfgroupversion(void* lpObj, const char* lpszFGroupVersion);
QString getFGroupAppReceiverCode();
int setFGroupAppReceiverCode(QString qsFGroupAppReceiverCode); QString getFGroupAppSenderCode();
int setFGroupAppSenderCode(QString qsFGroupAppSenderCode); QString getFGroupDate();
int setFGroupDate(QString qsFGroupDate); QString getFGroupFunctionalIdentifierCode();
int setFGroupFunctionalIdentifierCode(QString qsFGroupFunctionalIdentifierCode); QString getFGroupGroupControlNum();
int setFGroupGroupControlNum(QString qsFGroupGroupControlNum); QString getFGroupResponsibleAgencyCode();
int setFGroupResponsibleAgencyCode(QString qsFGroupResponsibleAgencyCode); QString getFGroupTime();
int setFGroupTime(QString qsFGroupTime); QString getFGroupVersion();
int setFGroupVersion(QString qsFGroupVersion);
Remarks
The functional group information is used when writing the functional group header (GS) and trailer (GE) segments. The properties of this object must be changed before calling StartFunctionalGroup to write the functional group correctly. After calling StartFunctionalGroup changing the properties of this object will change the values for the next functional group only.
This property is read-only and not available at design time.
Data Type
Interchange Property (X12Writer Class)
Contains the current interchange information for the EDI Document.
Syntax
EDISDKX12Interchange* GetInterchange();
char* edisdk_x12writer_getinterchangeackrequest(void* lpObj);
int edisdk_x12writer_setinterchangeackrequest(void* lpObj, const char* lpszInterchangeAckRequest);
char* edisdk_x12writer_getinterchangeauthorizationinfo(void* lpObj);
int edisdk_x12writer_setinterchangeauthorizationinfo(void* lpObj, const char* lpszInterchangeAuthorizationInfo);
char* edisdk_x12writer_getinterchangeauthorizationinfoqualifier(void* lpObj);
int edisdk_x12writer_setinterchangeauthorizationinfoqualifier(void* lpObj, const char* lpszInterchangeAuthorizationInfoQualifier);
char* edisdk_x12writer_getinterchangedate(void* lpObj);
int edisdk_x12writer_setinterchangedate(void* lpObj, const char* lpszInterchangeDate);
char* edisdk_x12writer_getinterchangeinterchangecontrolnum(void* lpObj);
int edisdk_x12writer_setinterchangeinterchangecontrolnum(void* lpObj, const char* lpszInterchangeInterchangeControlNum);
char* edisdk_x12writer_getinterchangeinterchangecontrolversionnum(void* lpObj);
int edisdk_x12writer_setinterchangeinterchangecontrolversionnum(void* lpObj, const char* lpszInterchangeInterchangeControlVersionNum);
char* edisdk_x12writer_getinterchangereceiverid(void* lpObj);
int edisdk_x12writer_setinterchangereceiverid(void* lpObj, const char* lpszInterchangeReceiverID);
char* edisdk_x12writer_getinterchangereceiveridqualifier(void* lpObj);
int edisdk_x12writer_setinterchangereceiveridqualifier(void* lpObj, const char* lpszInterchangeReceiverIDQualifier);
char* edisdk_x12writer_getinterchangesecurityinfo(void* lpObj);
int edisdk_x12writer_setinterchangesecurityinfo(void* lpObj, const char* lpszInterchangeSecurityInfo);
char* edisdk_x12writer_getinterchangesecurityinfoqualifier(void* lpObj);
int edisdk_x12writer_setinterchangesecurityinfoqualifier(void* lpObj, const char* lpszInterchangeSecurityInfoQualifier);
char* edisdk_x12writer_getinterchangesenderid(void* lpObj);
int edisdk_x12writer_setinterchangesenderid(void* lpObj, const char* lpszInterchangeSenderID);
char* edisdk_x12writer_getinterchangesenderidqualifier(void* lpObj);
int edisdk_x12writer_setinterchangesenderidqualifier(void* lpObj, const char* lpszInterchangeSenderIDQualifier);
char* edisdk_x12writer_getinterchangetime(void* lpObj);
int edisdk_x12writer_setinterchangetime(void* lpObj, const char* lpszInterchangeTime);
char* edisdk_x12writer_getinterchangeusageindicator(void* lpObj);
int edisdk_x12writer_setinterchangeusageindicator(void* lpObj, const char* lpszInterchangeUsageIndicator);
QString getInterchangeAckRequest();
int setInterchangeAckRequest(QString qsInterchangeAckRequest); QString getInterchangeAuthorizationInfo();
int setInterchangeAuthorizationInfo(QString qsInterchangeAuthorizationInfo); QString getInterchangeAuthorizationInfoQualifier();
int setInterchangeAuthorizationInfoQualifier(QString qsInterchangeAuthorizationInfoQualifier); QString getInterchangeDate();
int setInterchangeDate(QString qsInterchangeDate); QString getInterchangeInterchangeControlNum();
int setInterchangeInterchangeControlNum(QString qsInterchangeInterchangeControlNum); QString getInterchangeInterchangeControlVersionNum();
int setInterchangeInterchangeControlVersionNum(QString qsInterchangeInterchangeControlVersionNum); QString getInterchangeReceiverID();
int setInterchangeReceiverID(QString qsInterchangeReceiverID); QString getInterchangeReceiverIDQualifier();
int setInterchangeReceiverIDQualifier(QString qsInterchangeReceiverIDQualifier); QString getInterchangeSecurityInfo();
int setInterchangeSecurityInfo(QString qsInterchangeSecurityInfo); QString getInterchangeSecurityInfoQualifier();
int setInterchangeSecurityInfoQualifier(QString qsInterchangeSecurityInfoQualifier); QString getInterchangeSenderID();
int setInterchangeSenderID(QString qsInterchangeSenderID); QString getInterchangeSenderIDQualifier();
int setInterchangeSenderIDQualifier(QString qsInterchangeSenderIDQualifier); QString getInterchangeTime();
int setInterchangeTime(QString qsInterchangeTime); QString getInterchangeUsageIndicator();
int setInterchangeUsageIndicator(QString qsInterchangeUsageIndicator);
Remarks
The interchange information is used when writing the interchange header (ISA) and trailer (IEA) segments. The properties of this object must be changed before calling StartInterchange to write the interchange correctly. After calling StartInterchange changing the properties of this object will change the values for the next interchange only.
This property is read-only and not available at design time.
Data Type
OutputData Property (X12Writer Class)
The output data that has been written so far.
Syntax
ANSI (Cross Platform) char* GetOutputData();
int SetOutputData(const char* lpszOutputData); Unicode (Windows) LPWSTR GetOutputData();
INT SetOutputData(LPCWSTR lpszOutputData);
char* edisdk_x12writer_getoutputdata(void* lpObj);
int edisdk_x12writer_setoutputdata(void* lpObj, const char* lpszOutputData);
QString getOutputData();
int setOutputData(QString qsOutputData);
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 (X12Writer Class)
The name of the output file to which the EDI data will be written.
Syntax
ANSI (Cross Platform) char* GetOutputFile();
int SetOutputFile(const char* lpszOutputFile); Unicode (Windows) LPWSTR GetOutputFile();
INT SetOutputFile(LPCWSTR lpszOutputFile);
char* edisdk_x12writer_getoutputfile(void* lpObj);
int edisdk_x12writer_setoutputfile(void* lpObj, const char* lpszOutputFile);
QString getOutputFile();
int setOutputFile(QString qsOutputFile);
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 (X12Writer Class)
The suffix that is appended to the end of a segment.
Syntax
ANSI (Cross Platform) int GetSegmentSuffix();
int SetSegmentSuffix(int iSegmentSuffix); Unicode (Windows) INT GetSegmentSuffix();
INT SetSegmentSuffix(INT iSegmentSuffix);
Possible Values
SS_NONE(0),
SS_CR(1),
SS_LF(2),
SS_CRLF(3)
int edisdk_x12writer_getsegmentsuffix(void* lpObj);
int edisdk_x12writer_setsegmentsuffix(void* lpObj, int iSegmentSuffix);
int getSegmentSuffix();
int setSegmentSuffix(int iSegmentSuffix);
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
TransactionSet Property (X12Writer Class)
Contains the current transaction set information for the EDI Document.
Syntax
EDISDKX12TransactionSet* GetTransactionSet();
char* edisdk_x12writer_gettranssetimpconventionreference(void* lpObj);
int edisdk_x12writer_settranssetimpconventionreference(void* lpObj, const char* lpszTransSetImpConventionReference);
char* edisdk_x12writer_gettranssettransactionsetcontrolnum(void* lpObj);
int edisdk_x12writer_settranssettransactionsetcontrolnum(void* lpObj, const char* lpszTransSetTransactionSetControlNum);
char* edisdk_x12writer_gettranssettransactionsetidcode(void* lpObj);
int edisdk_x12writer_settranssettransactionsetidcode(void* lpObj, const char* lpszTransSetTransactionSetIDCode);
QString getTransSetImpConventionReference();
int setTransSetImpConventionReference(QString qsTransSetImpConventionReference); QString getTransSetTransactionSetControlNum();
int setTransSetTransactionSetControlNum(QString qsTransSetTransactionSetControlNum); QString getTransSetTransactionSetIDCode();
int setTransSetTransactionSetIDCode(QString qsTransSetTransactionSetIDCode);
Remarks
This property holds the current transaction set information for the EDI document. It is used by the StartTransactionSet method to create a new transaction set header. The properties of this object must be changed before calling StartTransactionSet to write the transaction set correctly. After calling StartTransactionSet changing the properties of this object will change the values for the next transaction set only.
This property is read-only and not available at design time.
Data Type
Close Method (X12Writer Class)
Closes the writer.
Syntax
ANSI (Cross Platform) int Close(); Unicode (Windows) INT Close();
int edisdk_x12writer_close(void* lpObj);
int close();
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.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
Config Method (X12Writer Class)
Sets or retrieves a configuration setting.
Syntax
ANSI (Cross Platform) char* Config(const char* lpszConfigurationString); Unicode (Windows) LPWSTR Config(LPCWSTR lpszConfigurationString);
char* edisdk_x12writer_config(void* lpObj, const char* lpszConfigurationString);
QString config(const QString& qsConfigurationString);
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.
Error Handling (C++)
This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
EndCompositeElement Method (X12Writer Class)
Closes the current composite element.
Syntax
ANSI (Cross Platform) int EndCompositeElement(); Unicode (Windows) INT EndCompositeElement();
int edisdk_x12writer_endcompositeelement(void* lpObj);
int endCompositeElement();
Remarks
Calling EndCompositeElement will close the current composite element. If no composite element is open, an error will be raised.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
EndFunctionalGroup Method (X12Writer Class)
Closes the current functional group.
Syntax
ANSI (Cross Platform) int EndFunctionalGroup(); Unicode (Windows) INT EndFunctionalGroup();
int edisdk_x12writer_endfunctionalgroup(void* lpObj);
int endFunctionalGroup();
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.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
EndInterchange Method (X12Writer Class)
Closes the current interchange.
Syntax
ANSI (Cross Platform) int EndInterchange(); Unicode (Windows) INT EndInterchange();
int edisdk_x12writer_endinterchange(void* lpObj);
int endInterchange();
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.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
EndSegment Method (X12Writer Class)
Finish writing the current segment.
Syntax
ANSI (Cross Platform) int EndSegment(); Unicode (Windows) INT EndSegment();
int edisdk_x12writer_endsegment(void* lpObj);
int endSegment();
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.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
EndTransactionSet Method (X12Writer Class)
Closes the current transaction set.
Syntax
ANSI (Cross Platform) int EndTransactionSet(); Unicode (Windows) INT EndTransactionSet();
int edisdk_x12writer_endtransactionset(void* lpObj);
int endTransactionSet();
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.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
Reset Method (X12Writer Class)
Resets all properties to their default values.
Syntax
ANSI (Cross Platform) int Reset(); Unicode (Windows) INT Reset();
int edisdk_x12writer_reset(void* lpObj);
int reset();
Remarks
This method resets all properties of the component to their default values as specified in the property definitions.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
StartCompositeElement Method (X12Writer Class)
Starts a composite element within the current segment.
Syntax
ANSI (Cross Platform) int StartCompositeElement(); Unicode (Windows) INT StartCompositeElement();
int edisdk_x12writer_startcompositeelement(void* lpObj);
int startCompositeElement();
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.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
StartFunctionalGroup Method (X12Writer Class)
Starts a new functional group in the EDI document.
Syntax
ANSI (Cross Platform) int StartFunctionalGroup(); Unicode (Windows) INT StartFunctionalGroup();
int edisdk_x12writer_startfunctionalgroup(void* lpObj);
int startFunctionalGroup();
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.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
StartInterchange Method (X12Writer Class)
Starts a new interchange in the EDI document.
Syntax
ANSI (Cross Platform) int StartInterchange(); Unicode (Windows) INT StartInterchange();
int edisdk_x12writer_startinterchange(void* lpObj);
int startInterchange();
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.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
StartSegment Method (X12Writer Class)
Starts a new segment with the specified tag.
Syntax
ANSI (Cross Platform) int StartSegment(const char* lpsztag); Unicode (Windows) INT StartSegment(LPCWSTR lpsztag);
int edisdk_x12writer_startsegment(void* lpObj, const char* lpsztag);
int startSegment(const QString& qstag);
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.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
StartTransactionSet Method (X12Writer Class)
Starts a new transaction set in the EDI document.
Syntax
ANSI (Cross Platform) int StartTransactionSet(); Unicode (Windows) INT StartTransactionSet();
int edisdk_x12writer_starttransactionset(void* lpObj);
int startTransactionSet();
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.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
WriteComponent Method (X12Writer Class)
Writes a class element value to the current composite element.
Syntax
ANSI (Cross Platform) int WriteComponent(const char* lpszval); Unicode (Windows) INT WriteComponent(LPCWSTR lpszval);
int edisdk_x12writer_writecomponent(void* lpObj, const char* lpszval);
int writeComponent(const QString& qsval);
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.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
WriteElement Method (X12Writer Class)
Writes an element value to the current segment.
Syntax
ANSI (Cross Platform) int WriteElement(const char* lpszval); Unicode (Windows) INT WriteElement(LPCWSTR lpszval);
int edisdk_x12writer_writeelement(void* lpObj, const char* lpszval);
int writeElement(const QString& qsval);
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 Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
Error Event (X12Writer Class)
Fires when an error occurs during message processing. Normally, the class fails with an error.
Syntax
ANSI (Cross Platform) virtual int FireError(X12WriterErrorEventParams *e);
typedef struct {
int ErrorCode;
const char *Description; int reserved; } X12WriterErrorEventParams;
Unicode (Windows) virtual INT FireError(X12WriterErrorEventParams *e);
typedef struct {
INT ErrorCode;
LPCWSTR Description; INT reserved; } X12WriterErrorEventParams;
#define EID_X12WRITER_ERROR 1 virtual INT EDISDK_CALL FireError(INT &iErrorCode, LPSTR &lpszDescription);
class X12WriterErrorEventParams {
public:
int errorCode();
const QString &description();
int eventRetVal();
void setEventRetVal(int iRetVal);
};
// To handle, subclass X12Writer and override this emitter function.
virtual int fireError(X12WriterErrorEventParams *e) {...}
// Or, connect one or more slots to this signal.
void error(X12WriterErrorEventParams *e);
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 (X12Writer Class)
Fires when output data is written.
Syntax
ANSI (Cross Platform) virtual int FireOutput(X12WriterOutputEventParams *e);
typedef struct {
const char *Data; int lenData; int reserved; } X12WriterOutputEventParams;
Unicode (Windows) virtual INT FireOutput(X12WriterOutputEventParams *e);
typedef struct {
LPCSTR Data; INT lenData; INT reserved; } X12WriterOutputEventParams;
#define EID_X12WRITER_OUTPUT 2 virtual INT EDISDK_CALL FireOutput(LPSTR &lpData, INT &lenData);
class X12WriterOutputEventParams {
public:
const QByteArray &data();
int eventRetVal();
void setEventRetVal(int iRetVal);
};
// To handle, subclass X12Writer and override this emitter function.
virtual int fireOutput(X12WriterOutputEventParams *e) {...}
// Or, connect one or more slots to this signal.
void output(X12WriterOutputEventParams *e);
Remarks
This event is fired when output data is written. The Data parameter contains the segment that was written.
X12Delimiters Type
The delimiters used in the X12 document.
Syntax
EDISDKX12Delimiters (declared in edisdk.h)
Remarks
This type contains fields specifying the various delimiters used within the X12 document.
Fields
Component
char*
Default Value: ":"
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
Element
char*
Default Value: "*"
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
Repetition
char*
Default Value: "^"
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
Segment
char*
Default Value: "~"
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
Constructors
X12Delimiters()
X12FunctionalGroup Type
A functional group of messages.
Syntax
EDISDKX12FunctionalGroup (declared in edisdk.h)
Remarks
This type represents a functional group of messages, with fields describing the values from the GS segment.
- AppReceiverCode
- AppSenderCode
- Date
- FunctionalIdentifierCode
- GroupControlNum
- ResponsibleAgencyCode
- Time
- Version
Fields
AppReceiverCode
char*
Default Value: ""
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.
AppSenderCode
char*
Default Value: ""
Code identifying the sender of FunctionalGroup
This is an alphanumeric field with a value between 2 and 15 characters long.
Date
char*
Default Value: ""
The date that the group of transaction sets was prepared.
This is a numeric field with a value in the format YYMMDD.
FunctionalIdentifierCode
char*
Default Value: ""
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.
GroupControlNum
char*
Default Value: ""
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.
ResponsibleAgencyCode
char*
Default Value: ""
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.
Time
char*
Default Value: ""
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.
Version
char*
Default Value: ""
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.
Constructors
X12FunctionalGroup()
X12Interchange Type
An interchange containing functional groups and transaction sets.
Syntax
EDISDKX12Interchange (declared in edisdk.h)
Remarks
This type represents an X12 interchange, with fields describing the values from the ISA segment.
- AckRequest
- AuthorizationInfo
- AuthorizationInfoQualifier
- Date
- InterchangeControlNum
- InterchangeControlVersionNum
- ReceiverID
- ReceiverIDQualifier
- SecurityInfo
- SecurityInfoQualifier
- SenderID
- SenderIDQualifier
- Time
- UsageIndicator
Fields
AckRequest
char*
Default Value: ""
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).
AuthorizationInfo
char*
Default Value: ""
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.
AuthorizationInfoQualifier
char*
Default Value: ""
A code indicating the type of data supplied in Authorization Information field.
This is an alphanumeric field with a code value of 2 characters.
Date
char*
Default Value: ""
The date that the Interchange was prepared.
This is a numeric field with a value of 6 digits in the format YYMMDD.
InterchangeControlNum
char*
Default Value: ""
A control number assigned by the sender to uniquely identify the interchange.
This is a numeric field with a value of 9 digits.
InterchangeControlVersionNum
char*
Default Value: ""
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.
ReceiverID
char*
Default Value: ""
The identification code of the receiver of the transaction set.
This is an alphanumeric field with a value of 15 characters.
ReceiverIDQualifier
char*
Default Value: ""
A code that identifies the format of the receiver ID.
This is an alphanumeric field with a code value of 2 characters.
SecurityInfo
char*
Default Value: ""
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.
SecurityInfoQualifier
char*
Default Value: ""
A code indicating the type of data in the Security Information field.
This is an alphanumeric field with a code value of 2 characters.
SenderID
char*
Default Value: ""
The identification code of the sender of the transaction set.
This is an alphanumeric field with a value of 15 characters.
SenderIDQualifier
char*
Default Value: ""
A code that identifies the format of the sender ID.
This is an alphanumeric field with a code value of 2 characters.
Time
char*
Default Value: ""
The time that the Interchange sets was prepared.
This is a numeric field with a value in the format HHMM.
UsageIndicator
char*
Default Value: ""
Code to indicate whether the interchange is a test or production.
This is an alphanumeric field with a code value of 1 character.
Constructors
X12Interchange()
X12TransactionSet Type
An X12 transaction set.
Syntax
EDISDKX12TransactionSet (declared in edisdk.h)
Remarks
This type represents an X12 transaction set, with fields describing the values from the ST segment.
Fields
ImpConventionReference
char*
Default Value: ""
Reference used to identify the implementation convention.
This is an alphanumeric field with a value up to 35 characters long.
TransactionSetControlNum
char*
Default Value: ""
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.
TransactionSetIDCode
char*
Default Value: ""
The identifier code for the transaction set.
This is an alphanumeric field with a code value of 3 characters long.
Constructors
X12TransactionSet()
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)
Error Handling (C++)
Call the GetLastErrorCode() method to obtain the last called method's result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. Known error codes are listed below. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
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. |