EDIWriter Class
Properties Methods Events Configuration Settings Errors
The EDIWriter component is used to create new EDI documents.
Class Name
InEDI_EDIWriter
Procedural Interface
inedi_ediwriter_open(); inedi_ediwriter_close($res); inedi_ediwriter_register_callback($res, $id, $function); inedi_ediwriter_get_last_error($res); inedi_ediwriter_get_last_error_code($res); inedi_ediwriter_set($res, $id, $index, $value); inedi_ediwriter_get($res, $id, $index); inedi_ediwriter_do_compileschema($res, $xsdschema, $binschema); inedi_ediwriter_do_config($res, $configurationstring); inedi_ediwriter_do_createfunctionalgroupfooter($res); inedi_ediwriter_do_createinterchangefooter($res); inedi_ediwriter_do_createtransactionfooter($res); inedi_ediwriter_do_displayschemainfo($res); inedi_ediwriter_do_endelement($res); inedi_ediwriter_do_endsegment($res); inedi_ediwriter_do_flush($res); inedi_ediwriter_do_loadschema($res, $filename); inedi_ediwriter_do_repeatelement($res); inedi_ediwriter_do_reset($res); inedi_ediwriter_do_skipcomponent($res); inedi_ediwriter_do_skipelement($res); inedi_ediwriter_do_startelement($res); inedi_ediwriter_do_startfunctionalgroupheader($res); inedi_ediwriter_do_startinterchangeheader($res, $version); inedi_ediwriter_do_startsegment($res, $segmenttype); inedi_ediwriter_do_starttransactionheader($res, $code); inedi_ediwriter_do_writecomponentstring($res, $value); inedi_ediwriter_do_writeelementstring($res, $value); inedi_ediwriter_do_writetransaction($res, $value);
Remarks
The EDIWriter component allows you to create a document from scratch. The class allows you to create an EDI document 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 property or SetOutputStream method, or set neither and check the OutputData property.
- Create a new interchange start segment using the StartInterchangeHeader method and set its properties using WriteElementString and WriteComponentString.
- To write a basic element value to the current location, call the WriteElementString method. For complex element values, there are two possibilities, elements which are split into components, and elements which repeat. To write these complex element values, use the StartElement and EndElement methods, with WriteComponentString and RepeatElement methods for writing the values. (Examples available below).
- Create a new functional group using StartFunctionalGroupHeader and set its properties using WriteElementString and WriteComponentString.
- Create a new transaction using StartTransactionHeader and set the properties for the header segment.
- Write all the data for the transaction by creating new data segments using StartSegment and providing the path of the segment to create using the schema names of the loops and segments, like /N1Loop1/N1.
- Once you are done with the segment, call EndSegment.
- Once you are done with the transaction, call CreateTransactionFooter.
- Once you are done with the functional group, call CreateFunctionalGroupFooter.
- Once the interchange is complete, call CreateInterchangeFooter.
Example EDIWriter Code:
EDIWriter1.StartInterchangeHeader("D98B"); //Complex Element, two components EDIWriter1.StartElement(); EDIWriter1.WriteComponentString("UNOB"); EDIWriter1.WriteComponentString("1"); EDIWriter1.EndElement(); //Skip a value for this element EDIWriter1.SkipElement(); //Basic element EDIWriter1.WriteElementString("7654323"); ... EDIWriter1.StartFunctionalGroupHeader(); ... EDIWriter1.StartTransactionHeader("APERAK"); //Complex Element, repeated element EDIWriter1.StartElement(); EDIWriter1.WriteComponentString("UNH1"); EDIWriter1.RepeatElement(); EDIWriter1.WriteComponentString("UNH2"); EDIWriter1.EndElement(); ... //Segment and its data EDIWriter1.StartSegment("BGM"); EDIWriter1.StartElement(); EDIWriter1.WriteComponentString("C00"); EDIWriter1.EndElement(); EDIWriter1.StartElement(); EDIWriter1.WriteComponentString("C10601"); EDIWriter1.EndElement(); EDIWriter1.EndSegment(); ... CreateTransactionFooter(); CreateFunctionalGroupFooter(); CreateInterchangeFooter();
Property List
The following is the full list of the properties of the class with short descriptions. Click on the links for further details.
EDIStandard | The document format. |
FileWriteMode | Controls how the output file is opened. |
OutputData | Contains the output data. |
OutputFile | Specifies the name of the EDI file to write to. |
SchemaFormat | The format of the schema file. |
Suffix | What to append after each segment delimiter. |
Method List
The following is the full list of the methods of the class with short descriptions. Click on the links for further details.
CompileSchema | Compiles an existing XSD schema into an optimized binary representation. |
Config | Sets or retrieves a configuration setting . |
CreateFunctionalGroupFooter | Closes the current functional group by writing its footer segment. |
CreateInterchangeFooter | Closes the current interchange by writing its footer segment. |
CreateTransactionFooter | Closes the current transaction set by writing its footer segment. |
DisplaySchemaInfo | Returns a string showing the structure of the schema defining the document. |
EndElement | Finishes the current composite data element. |
EndSegment | Ends writing the current segment. |
Flush | Forces any pending segments to be written to the output stream without closing it. |
LoadSchema | Loads a schema file describing a Transaction Set. |
RepeatElement | Adds a new repetition to the current element. |
Reset | Resets the state of the control. |
SkipComponent | Moves to the next sub-element in the current composite element in the current segment. |
SkipElement | Moves to the next data element in the current segment. |
StartElement | Starts a new EDI composite data element on the current segment. |
StartFunctionalGroupHeader | Creates a new EDI functional group header segment on the current document. |
StartInterchangeHeader | Creates a new EDI Interchange header segment on the current document. |
StartSegment | Creates a new EDI data segment on the current document. |
StartTransactionHeader | Creates a new EDI transaction set header on the current document. |
WriteComponentString | Sets the value of the next component within the current element in the current segment. |
WriteElementString | Sets a value of the next element in the current segment to a simple value. |
WriteTransaction | Writes an entire transaction to the output. |
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 | Information about errors during data delivery. |
Output | Fires whenever a segment is complete. |
Warning | Fires whenever a validation warning is encountered. |
Configuration Settings
The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.
IncludeUNA | Whether to include the UNA segment in the output. |
EdifactSyntaxVersion | Changes the syntax version used for EDIFACT control segments. |
Encoding | The character encoding to be applied when reading and writing data. |
ComponentDelimiter | The delimiter character to use to separate components. |
ElementDelimiter | The delimiter character to use to separate data elements. |
ReleaseChar | The character to use to escape delimiters within values. |
RepetitionChar | The repetition character. |
SegmentDelimiter | The delimiter character to use to separate segments. |
TransactionOnly | Ignores interchange and functional group validation, allowing you to build the transaction body. |
StrictSchemaValidation | Specifies the behavior during schema validation. |
SelectWaitMillis | The length of time in milliseconds the component will wait when DoEvents is called if there are no events to process. |
CodePage | The system code page used for Unicode to Multibyte translations. |
UseInternalSecurityAPI | Tells the component whether or not to use the system security libraries or an internal implementation. |