IPWorks EDI 2020 Python Edition

Questions / Feedback?

EDIFACTWriter Class

Properties   Methods   Events   Configuration Settings   Errors  

The EDIFACTWriter class is optimized for EDIFACT documents, providing a simple way to create EDIFACT documents.

Syntax

class ipworksedi.EDIFACTWriter

Remarks

The class 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:

  1. Call load_schema to load the necessary schemas for the transactions that will be used.
  2. Specify where to write the output document by setting the output_file property or set_output_stream method, or set neither and check the output_data property.
  3. Create a new interchange start segment using the start_interchange_header method and set its properties using write_element_string and write_component_string.
  4. To write a basic element value to the current location, call the write_element_string 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 start_element and end_element methods, with write_component_string and repeat_element methods for writing the values. (Examples available below).
  5. Create a new functional group using start_functional_group_header and set its properties using write_element_string and write_component_string.
  6. Create a new transaction using start_transaction_header and set the properties for the header segment.
  7. Write all the data for the transaction by creating new data segments using start_segment and providing the path of the segment to create using the schema names of the loops and segments, like /N1Loop1/N1.
  8. Once you are done with the segment, call end_segment.
  9. Once you are done with the transaction, call create_transaction_footer.
  10. Once you are done with the functional group, call create_functional_group_footer.
  11. Once the interchange is complete, call create_interchange_footer.

Example EDIFACTWriter 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.

file_write_modeControls how the output file is opened.
output_dataContains the output data.
output_fileSpecifies the name of the EDI file to write to.
schema_formatThe format of the schema file.
suffixWhat 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.

compile_schemaCompiles an existing XSD schema into an optimized binary representation.
configSets or retrieves a configuration setting.
create_functional_group_footerCloses the current functional group by writing its footer segment.
create_interchange_footerCloses the current interchange by writing its footer segment.
create_transaction_footerCloses the current transaction set by writing its footer segment.
display_schema_infoReturns a string showing the structure of the schema defining the document.
end_elementFinishes the current composite data element.
end_segmentEnds writing the current segment.
flushForces any pending segments to be written to the output stream without closing it.
load_schemaLoads a schema file describing a Transaction Set.
repeat_elementAdds a new repetition to the current element.
resetResets the state of the control.
skip_componentMoves to the next sub-element in the current composite element in the current segment.
skip_elementMoves to the next data element in the current segment.
start_elementStarts a new EDI composite data element on the current segment.
start_functional_group_headerCreates a new EDI functional group header segment on the current document.
start_interchange_headerCreates a new EDI Interchange header segment on the current document.
start_segmentCreates a new EDI data segment on the current document.
start_transaction_headerCreates a new EDI transaction set header on the current document.
write_component_stringSets the value of the next class within the current element in the current segment.
write_element_stringSets a value of the next element in the current segment to a simple value.
write_transactionWrites 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.

on_errorInformation about errors during data delivery.
on_outputFires whenever a segment is complete.
on_warningFires 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.

ComponentDelimiterThe delimiter character to use to separate classes.
EdifactSyntaxVersionChanges the syntax version used for EDIFACT control segments.
ElementDelimiterThe delimiter character to use to separate data elements.
EncodingThe character encoding to be applied when reading and writing data.
IncludeUNAWhether to include the UNA segment in the output.
ReleaseCharThe character to use to escape delimiters within values.
RepetitionCharThe repetition character.
SegmentDelimiterThe delimiter character to use to separate segments.
StrictSchemaValidationSpecifies the behavior during schema validation.
TransactionOnlyIgnores interchange and functional group validation, allowing you to build the transaction body.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
ProcessIdleEventsWhether the class uses its internal event loop to process events when the main thread is idle.
SelectWaitMillisThe length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.
UseInternalSecurityAPITells the class whether or not to use the system security libraries or an internal implementation.

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