EDIFACTWriter Class
Properties Methods Events Config Settings Errors
The EDIFACTWriter class generates EDIFACT documents with a clear, straightforward API.
Syntax
class edisdk.EDIFACTWriter
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 load_schema to load the necessary schemas for the transactions that will be used.
- Specify where to write the output document by setting the output_file, or check the output_data property after writing.
- Create a new interchange start segment by setting the fields of the interchange property and call the start_interchange method. Once the interchange is complete, call end_interchange to add the interchange footer.
- If you want to create a functional group, set the fields of the functional_group property and then call the start_functional_group. Once all the messages in the group have been created, call end_functional_group to add a footer for the group.
- To start a message, call the start_message method. Once all segments have been added, call end_message to add a footer to the message.
- To begin a segment, call the start_segment method and pass in the tag for the segment. Once all the elements in the segment have been added, call end_segment to add the segment terminator.
- To write a basic element to the current segment, call the write_element method.
- To write a composite element, call the start_composite_element method, then call the write_component method for each component, and finally call end_composite_element 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.
| delimiter_component | The character used to separate the classes in a composite element. |
| delimiter_decimal | The character used to separate the integer portion of a numeric value from the fractional portion. |
| delimiter_element | The delimiter used to separate elements within a segment. |
| delimiter_release | The character used to escape other characters within a property. |
| delimiter_repetition | The character used to indicate a repeating element or class. |
| delimiter_segment | The character used to terminate a segment. |
| file_write_mode | Determines how the output file is opened for writing. |
| f_group_app_password | The application password as specified in the functional group header. |
| f_group_app_recipient_identification | The name or code of the intended recipient of the message group. |
| f_group_app_recipient_id_qualifier | The qualifier for the recipient's identification (if it contains a code value). |
| f_group_app_sender_identification | The name or code of the message group's sender. |
| f_group_app_sender_id_qualifier | The qualifier for the sender's identification (if it contains a code value). |
| f_group_association_assigned_code | The assigned code for the message type. |
| f_group_controlling_agency | A code value that indicates the agency responsible for maintaining the message specifications. |
| f_group_date | The date that the group of messages was prepared. |
| f_group_group_identification | The identification value for the functional group. |
| f_group_message_release | The message release number for the message type appearing in the message group. |
| f_group_message_version | The message version number for message type appearing in the functional group. |
| f_group_reference_number | The reference number for the functional group. |
| f_group_time | The time that the group of messages was prepared. |
| interchange_ack_request | If this property is '1', an ACK was requested in response to this interchange. |
| interchange_agreement_identifier | The identifier for the communication agreement used by the interchange. |
| interchange_application_reference | If the interchange contains only one type of message, this can contain the identifier for the type of message. |
| interchange_character_encoding | The character encoding used by the interchange. |
| interchange_code_list_version_number | The identifier for the communication agreement used by the interchange. |
| interchange_date | The date that the interchange was prepared. |
| interchange_processing_priority_code | A 1-character code that requests a specific processing priority for the interchange. |
| interchange_recipient_identification | The identification for the interchange's recipient. |
| interchange_recipient_id_qualifier | The qualifier for the recipient identification code. |
| interchange_recipient_internal_identification | More specific recipient identification for internal use. |
| interchange_recipient_internal_sub_identification | A sub-identification string for the receiver for internal use. |
| interchange_recipient_password | A password to be verified by the recipient, such as a system or network password. |
| interchange_recipient_password_qualifier | A qualifier for the recipient password. |
| interchange_reference_number | A reference number for the interchange. |
| interchange_sender_identification | The identification for the interchange's sender. |
| interchange_sender_id_qualifier | The qualifier for the sender identification code. |
| interchange_sender_internal_identification | More specific sender identification for internal use. |
| interchange_sender_internal_sub_identification | A sub-identification string for the sender for internal use. |
| interchange_syntax_identifier | A identifier specifying the controlling agency and valid character set. |
| interchange_syntax_version_number | A 1-character numeric value indicating the syntax version. |
| interchange_test_indicator | If this property is '1', the interchange is a test interchange. |
| interchange_time | The time that the interchange was prepared. |
| msg_association_assigned_code | A code assigned to the message by the controlling organization. |
| msg_code_list_version_number | The version number of the code list that should be used. |
| msg_common_access_reference | A reference value to associate this message with related messages. |
| msg_controlling_agency | A code that identifies the controlling agency for this message type. |
| msg_first_and_last_transfer | A single-character property that indicates the first and last messages in a related set. |
| msg_message_impl_controlling_agency | A code value that identifies the controlling agency for the message implementation. |
| msg_message_impl_identification | Identifies the message implementation. |
| msg_message_impl_release | Identifies the release number for the message implementation. |
| msg_message_impl_version | Identifies the version number for the message implementation. |
| msg_message_release | Identifies the release number for the message. |
| msg_message_subset_controlling_agency | A code value that identifies the controlling agency for the message subset. |
| msg_message_subset_identification | Identifies the message subset. |
| msg_message_subset_release | Identifies the release number for the message subset. |
| msg_message_subset_version | Identifies the version number for the message subset. |
| msg_message_type | A code identifying the message's type. |
| msg_message_type_sub_function_identification | A code identifying the sub-function of the message's type. |
| msg_message_version | Identifies the version number for the message. |
| msg_reference_number | A unique reference number for the message. |
| msg_scenario_controlling_agency | Identifies the controlling agency for the message scenario. |
| msg_scenario_identification | The identifier for the message scenario. |
| msg_scenario_release | The message scenario's release number. |
| msg_scenario_version | The message scenario's version number. |
| msg_sequence_of_transfers | Specifies the message's position in a sequence. |
| output_data | The output data that has been written so far. |
| output_file | The name of the output file to which the EDI data will be written. |
| segment_suffix | The suffix that is appended to the end of a segment. |
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. |
| end_composite_element | Finish writing the composite element. |
| end_functional_group | Write the UNE(FunctionalGroup) segment to the output file/data/stream. |
| end_interchange | Write the UNZ(Interchange) segment to the output file/data/stream. |
| end_message | Closes the current message. |
| end_segment | Finish writing the segment, add SegmentSuffix at the end of the segment. |
| reset | Resets all properties to their default values. |
| start_composite_element | Starts a composite element within the current segment. |
| start_functional_group | Starts a new functional group in the EDI document. |
| start_interchange | Starts a new interchange in the EDI document. |
| start_message | Starts a new message in the EDI document. |
| start_segment | Starts a new segment with the specified tag. |
| write_component | Writes a class element value to the current composite element. |
| write_element | 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.
| on_error | Fires when an error occurs during message processing. Normally, the class fails with an error. |
| on_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.
delimiter_component property
The character used to separate the classes in a composite element.
Syntax
def get_delimiter_component() -> str: ... def set_delimiter_component(value: str) -> None: ...
delimiter_component = property(get_delimiter_component, set_delimiter_component)
Default Value
":"
Remarks
The character used to separate the components in a composite element.
delimiter_decimal property
The character used to separate the integer portion of a numeric value from the fractional portion.
Syntax
def get_delimiter_decimal() -> str: ... def set_delimiter_decimal(value: str) -> None: ...
delimiter_decimal = property(get_delimiter_decimal, set_delimiter_decimal)
Default Value
"."
Remarks
The character used to separate the integer portion of a numeric value from the fractional portion.
delimiter_element property
The delimiter used to separate elements within a segment.
Syntax
def get_delimiter_element() -> str: ... def set_delimiter_element(value: str) -> None: ...
delimiter_element = property(get_delimiter_element, set_delimiter_element)
Default Value
"+"
Remarks
The delimiter used to separate elements within a segment.
delimiter_release property
The character used to escape other characters within a property.
Syntax
def get_delimiter_release() -> str: ... def set_delimiter_release(value: str) -> None: ...
delimiter_release = property(get_delimiter_release, set_delimiter_release)
Default Value
"?"
Remarks
The character used to escape other characters within a field. For example, with the default EDIFACT delimiters, "?+" should be considered "+" character that appears within a field, not an element separator.
delimiter_repetition property
The character used to indicate a repeating element or class.
Syntax
def get_delimiter_repetition() -> str: ... def set_delimiter_repetition(value: str) -> None: ...
delimiter_repetition = property(get_delimiter_repetition, set_delimiter_repetition)
Default Value
"*(syntax 4) or empty(syntax 3)"
Remarks
The character used to indicate a repeating element or component.
delimiter_segment property
The character used to terminate a segment.
Syntax
def get_delimiter_segment() -> str: ... def set_delimiter_segment(value: str) -> None: ...
delimiter_segment = property(get_delimiter_segment, set_delimiter_segment)
Default Value
"'"
Remarks
The character used to terminate a segment.
file_write_mode property
Determines how the output file is opened for writing.
Syntax
def get_file_write_mode() -> int: ... def set_file_write_mode(value: int) -> None: ...
file_write_mode = property(get_file_write_mode, set_file_write_mode)
Possible Values
0 # Create
1 # Overwrite
2 # Append
Default Value
0
Remarks
When output_file 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. |
f_group_app_password property
The application password as specified in the functional group header.
Syntax
def get_f_group_app_password() -> str: ... def set_f_group_app_password(value: str) -> None: ...
f_group_app_password = property(get_f_group_app_password, set_f_group_app_password)
Default Value
""
Remarks
The application password as specified in the functional group header.
This is an alphanumeric field with a value up to 14 characters long.
f_group_app_recipient_identification property
The name or code of the intended recipient of the message group.
Syntax
def get_f_group_app_recipient_identification() -> str: ... def set_f_group_app_recipient_identification(value: str) -> None: ...
f_group_app_recipient_identification = property(get_f_group_app_recipient_identification, set_f_group_app_recipient_identification)
Default Value
""
Remarks
The name or code of the intended recipient of the message group.
This is an alphanumeric field with a value up to 35 characters long.
f_group_app_recipient_id_qualifier property
The qualifier for the recipient's identification (if it contains a code value).
Syntax
def get_f_group_app_recipient_id_qualifier() -> str: ... def set_f_group_app_recipient_id_qualifier(value: str) -> None: ...
f_group_app_recipient_id_qualifier = property(get_f_group_app_recipient_id_qualifier, set_f_group_app_recipient_id_qualifier)
Default Value
""
Remarks
The qualifier for the recipient's identification (if it contains a code value).
This is an alphanumeric field with a value up to 4 characters long.
f_group_app_sender_identification property
The name or code of the message group's sender.
Syntax
def get_f_group_app_sender_identification() -> str: ... def set_f_group_app_sender_identification(value: str) -> None: ...
f_group_app_sender_identification = property(get_f_group_app_sender_identification, set_f_group_app_sender_identification)
Default Value
""
Remarks
The name or code of the message group's sender.
This is an alphanumeric field with a value up to 35 characters long.
f_group_app_sender_id_qualifier property
The qualifier for the sender's identification (if it contains a code value).
Syntax
def get_f_group_app_sender_id_qualifier() -> str: ... def set_f_group_app_sender_id_qualifier(value: str) -> None: ...
f_group_app_sender_id_qualifier = property(get_f_group_app_sender_id_qualifier, set_f_group_app_sender_id_qualifier)
Default Value
""
Remarks
The qualifier for the sender's identification (if it contains a code value).
This is an alphanumeric field with a value up to 4 characters long.
f_group_association_assigned_code property
The assigned code for the message type.
Syntax
def get_f_group_association_assigned_code() -> str: ... def set_f_group_association_assigned_code(value: str) -> None: ...
f_group_association_assigned_code = property(get_f_group_association_assigned_code, set_f_group_association_assigned_code)
Default Value
""
Remarks
The assigned code for the message type.
This is an alphanumeric field with a value up to 6 characters long.
f_group_controlling_agency property
A code value that indicates the agency responsible for maintaining the message specifications.
Syntax
def get_f_group_controlling_agency() -> str: ... def set_f_group_controlling_agency(value: str) -> None: ...
f_group_controlling_agency = property(get_f_group_controlling_agency, set_f_group_controlling_agency)
Default Value
""
Remarks
A code value that indicates the agency responsible for maintaining the message specifications.
This is an alphanumeric field with a value up to 3 characters long.
f_group_date property
The date that the group of messages was prepared.
Syntax
def get_f_group_date() -> str: ... def set_f_group_date(value: str) -> None: ...
f_group_date = property(get_f_group_date, set_f_group_date)
Default Value
""
Remarks
The date that the group of messages was prepared.
f_group_group_identification property
The identification value for the functional group.
Syntax
def get_f_group_group_identification() -> str: ... def set_f_group_group_identification(value: str) -> None: ...
f_group_group_identification = property(get_f_group_group_identification, set_f_group_group_identification)
Default Value
""
Remarks
The identification value for the functional group.
This is an alphanumeric field with a value up to 6 characters long.
f_group_message_release property
The message release number for the message type appearing in the message group.
Syntax
def get_f_group_message_release() -> str: ... def set_f_group_message_release(value: str) -> None: ...
f_group_message_release = property(get_f_group_message_release, set_f_group_message_release)
Default Value
""
Remarks
The message release number for the message type appearing in the message group.
This is an alphanumeric field with a value up to 3 characters long.
f_group_message_version property
The message version number for message type appearing in the functional group.
Syntax
def get_f_group_message_version() -> str: ... def set_f_group_message_version(value: str) -> None: ...
f_group_message_version = property(get_f_group_message_version, set_f_group_message_version)
Default Value
""
Remarks
The message version number for message type appearing in the functional group.
This is an alphanumeric field with a value up to 3 characters long.
f_group_reference_number property
The reference number for the functional group.
Syntax
def get_f_group_reference_number() -> str: ... def set_f_group_reference_number(value: str) -> None: ...
f_group_reference_number = property(get_f_group_reference_number, set_f_group_reference_number)
Default Value
""
Remarks
The reference number for the functional group.
This is an alphanumeric field with a value up to 14 characters long.
f_group_time property
The time that the group of messages was prepared.
Syntax
def get_f_group_time() -> str: ... def set_f_group_time(value: str) -> None: ...
f_group_time = property(get_f_group_time, set_f_group_time)
Default Value
""
Remarks
The time that the group of messages was prepared.
interchange_ack_request property
If this property is '1', an ACK was requested in response to this interchange.
Syntax
def get_interchange_ack_request() -> str: ... def set_interchange_ack_request(value: str) -> None: ...
interchange_ack_request = property(get_interchange_ack_request, set_interchange_ack_request)
Default Value
""
Remarks
If this field is '1', an ACK was requested in response to this interchange.
interchange_agreement_identifier property
The identifier for the communication agreement used by the interchange.
Syntax
def get_interchange_agreement_identifier() -> str: ... def set_interchange_agreement_identifier(value: str) -> None: ...
interchange_agreement_identifier = property(get_interchange_agreement_identifier, set_interchange_agreement_identifier)
Default Value
""
Remarks
The identifier for the communication agreement used by the interchange.
This is an alphanumeric field with a value up to 35 characters long.
interchange_application_reference property
If the interchange contains only one type of message, this can contain the identifier for the type of message.
Syntax
def get_interchange_application_reference() -> str: ... def set_interchange_application_reference(value: str) -> None: ...
interchange_application_reference = property(get_interchange_application_reference, set_interchange_application_reference)
Default Value
""
Remarks
If the interchange contains only one type of message, this can contain the identifier for the type of message.
This is an alphanumeric field with a value up to 14 characters long.
interchange_character_encoding property
The character encoding used by the interchange.
Syntax
def get_interchange_character_encoding() -> str: ... def set_interchange_character_encoding(value: str) -> None: ...
interchange_character_encoding = property(get_interchange_character_encoding, set_interchange_character_encoding)
Default Value
""
Remarks
The character encoding used by the interchange.
This is an alphanumeric field with a value up to 3 characters long, and is only present for EDIFACT syntax 4.
interchange_code_list_version_number property
The identifier for the communication agreement used by the interchange.
Syntax
def get_interchange_code_list_version_number() -> str: ... def set_interchange_code_list_version_number(value: str) -> None: ...
interchange_code_list_version_number = property(get_interchange_code_list_version_number, set_interchange_code_list_version_number)
Default Value
""
Remarks
The identifier for the communication agreement used by the interchange.
This is an alphanumeric field with a value up to 6 characters long.
interchange_date property
The date that the interchange was prepared.
Syntax
def get_interchange_date() -> str: ... def set_interchange_date(value: str) -> None: ...
interchange_date = property(get_interchange_date, set_interchange_date)
Default Value
""
Remarks
The date that the interchange was prepared.
interchange_processing_priority_code property
A 1-character code that requests a specific processing priority for the interchange.
Syntax
def get_interchange_processing_priority_code() -> str: ... def set_interchange_processing_priority_code(value: str) -> None: ...
interchange_processing_priority_code = property(get_interchange_processing_priority_code, set_interchange_processing_priority_code)
Default Value
""
Remarks
A 1-character code that requests a specific processing priority for the interchange.
interchange_recipient_identification property
The identification for the interchange's recipient.
Syntax
def get_interchange_recipient_identification() -> str: ... def set_interchange_recipient_identification(value: str) -> None: ...
interchange_recipient_identification = property(get_interchange_recipient_identification, set_interchange_recipient_identification)
Default Value
""
Remarks
The identification for the interchange's recipient.
This is an alphanumeric field with a value up to 35 characters long.
interchange_recipient_id_qualifier property
The qualifier for the recipient identification code.
Syntax
def get_interchange_recipient_id_qualifier() -> str: ... def set_interchange_recipient_id_qualifier(value: str) -> None: ...
interchange_recipient_id_qualifier = property(get_interchange_recipient_id_qualifier, set_interchange_recipient_id_qualifier)
Default Value
""
Remarks
The qualifier for the recipient identification code.
This is an alphanumeric field with a value up to 4 characters long.
interchange_recipient_internal_identification property
More specific recipient identification for internal use.
Syntax
def get_interchange_recipient_internal_identification() -> str: ... def set_interchange_recipient_internal_identification(value: str) -> None: ...
interchange_recipient_internal_identification = property(get_interchange_recipient_internal_identification, set_interchange_recipient_internal_identification)
Default Value
""
Remarks
More specific recipient identification for internal use.
This is an alphanumeric field with a value up to 35 characters long.
interchange_recipient_internal_sub_identification property
A sub-identification string for the receiver for internal use.
Syntax
def get_interchange_recipient_internal_sub_identification() -> str: ... def set_interchange_recipient_internal_sub_identification(value: str) -> None: ...
interchange_recipient_internal_sub_identification = property(get_interchange_recipient_internal_sub_identification, set_interchange_recipient_internal_sub_identification)
Default Value
""
Remarks
A sub-identification string for the receiver for internal use.
This is an alphanumeric field with a value up to 35 characters long.
interchange_recipient_password property
A password to be verified by the recipient, such as a system or network password.
Syntax
def get_interchange_recipient_password() -> str: ... def set_interchange_recipient_password(value: str) -> None: ...
interchange_recipient_password = property(get_interchange_recipient_password, set_interchange_recipient_password)
Default Value
""
Remarks
A password to be verified by the recipient, such as a system or network password.
This is an alphanumeric field with a value up to 14 characters long.
interchange_recipient_password_qualifier property
A qualifier for the recipient password.
Syntax
def get_interchange_recipient_password_qualifier() -> str: ... def set_interchange_recipient_password_qualifier(value: str) -> None: ...
interchange_recipient_password_qualifier = property(get_interchange_recipient_password_qualifier, set_interchange_recipient_password_qualifier)
Default Value
""
Remarks
A qualifier for the recipient password.
This is an alphanumeric field with a value up to 2 characters long.
interchange_reference_number property
A reference number for the interchange.
Syntax
def get_interchange_reference_number() -> str: ... def set_interchange_reference_number(value: str) -> None: ...
interchange_reference_number = property(get_interchange_reference_number, set_interchange_reference_number)
Default Value
""
Remarks
A reference number for the interchange.
This is an alphanumeric field with a value up to 14 characters long.
interchange_sender_identification property
The identification for the interchange's sender.
Syntax
def get_interchange_sender_identification() -> str: ... def set_interchange_sender_identification(value: str) -> None: ...
interchange_sender_identification = property(get_interchange_sender_identification, set_interchange_sender_identification)
Default Value
""
Remarks
The identification for the interchange's sender.
This is an alphanumeric field with a value up to 35 characters long.
interchange_sender_id_qualifier property
The qualifier for the sender identification code.
Syntax
def get_interchange_sender_id_qualifier() -> str: ... def set_interchange_sender_id_qualifier(value: str) -> None: ...
interchange_sender_id_qualifier = property(get_interchange_sender_id_qualifier, set_interchange_sender_id_qualifier)
Default Value
""
Remarks
The qualifier for the sender identification code.
This is an alphanumeric field with a value up to 4 characters long.
interchange_sender_internal_identification property
More specific sender identification for internal use.
Syntax
def get_interchange_sender_internal_identification() -> str: ... def set_interchange_sender_internal_identification(value: str) -> None: ...
interchange_sender_internal_identification = property(get_interchange_sender_internal_identification, set_interchange_sender_internal_identification)
Default Value
""
Remarks
More specific sender identification for internal use.
This is an alphanumeric field with a value up to 35 characters long.
interchange_sender_internal_sub_identification property
A sub-identification string for the sender for internal use.
Syntax
def get_interchange_sender_internal_sub_identification() -> str: ... def set_interchange_sender_internal_sub_identification(value: str) -> None: ...
interchange_sender_internal_sub_identification = property(get_interchange_sender_internal_sub_identification, set_interchange_sender_internal_sub_identification)
Default Value
""
Remarks
A sub-identification string for the sender for internal use.
This is an alphanumeric field with a value up to 35 characters long.
interchange_syntax_identifier property
A identifier specifying the controlling agency and valid character set.
Syntax
def get_interchange_syntax_identifier() -> str: ... def set_interchange_syntax_identifier(value: str) -> None: ...
interchange_syntax_identifier = property(get_interchange_syntax_identifier, set_interchange_syntax_identifier)
Default Value
""
Remarks
A identifier specifying the controlling agency and valid character set.
This is an alphanumeric field with a value up to 4 characters long.
interchange_syntax_version_number property
A 1-character numeric value indicating the syntax version.
Syntax
def get_interchange_syntax_version_number() -> str: ... def set_interchange_syntax_version_number(value: str) -> None: ...
interchange_syntax_version_number = property(get_interchange_syntax_version_number, set_interchange_syntax_version_number)
Default Value
""
Remarks
A 1-character numeric value indicating the syntax version.
interchange_test_indicator property
If this property is '1', the interchange is a test interchange.
Syntax
def get_interchange_test_indicator() -> str: ... def set_interchange_test_indicator(value: str) -> None: ...
interchange_test_indicator = property(get_interchange_test_indicator, set_interchange_test_indicator)
Default Value
""
Remarks
If this field is '1', the interchange is a test interchange.
interchange_time property
The time that the interchange was prepared.
Syntax
def get_interchange_time() -> str: ... def set_interchange_time(value: str) -> None: ...
interchange_time = property(get_interchange_time, set_interchange_time)
Default Value
""
Remarks
The time that the interchange was prepared.
msg_association_assigned_code property
A code assigned to the message by the controlling organization.
Syntax
def get_msg_association_assigned_code() -> str: ... def set_msg_association_assigned_code(value: str) -> None: ...
msg_association_assigned_code = property(get_msg_association_assigned_code, set_msg_association_assigned_code)
Default Value
""
Remarks
A code assigned to the message by the controlling organization.
This is an alphanumeric field with a value up to 6 characters long.
msg_code_list_version_number property
The version number of the code list that should be used.
Syntax
def get_msg_code_list_version_number() -> str: ... def set_msg_code_list_version_number(value: str) -> None: ...
msg_code_list_version_number = property(get_msg_code_list_version_number, set_msg_code_list_version_number)
Default Value
""
Remarks
The version number of the code list that should be used.
This is an alphanumeric field with a value up to 6 characters long. This field only appears in EDIFACT syntax version 4.
msg_common_access_reference property
A reference value to associate this message with related messages.
Syntax
def get_msg_common_access_reference() -> str: ... def set_msg_common_access_reference(value: str) -> None: ...
msg_common_access_reference = property(get_msg_common_access_reference, set_msg_common_access_reference)
Default Value
""
Remarks
A reference value to associate this message with related messages.
This is an alphanumeric field with a value up to 35 characters long.
msg_controlling_agency property
A code that identifies the controlling agency for this message type.
Syntax
def get_msg_controlling_agency() -> str: ... def set_msg_controlling_agency(value: str) -> None: ...
msg_controlling_agency = property(get_msg_controlling_agency, set_msg_controlling_agency)
Default Value
""
Remarks
A code that identifies the controlling agency for this message type.
This is an alphanumeric field with a value up to 3 characters long.
msg_first_and_last_transfer property
A single-character property that indicates the first and last messages in a related set.
Syntax
def get_msg_first_and_last_transfer() -> str: ... def set_msg_first_and_last_transfer(value: str) -> None: ...
msg_first_and_last_transfer = property(get_msg_first_and_last_transfer, set_msg_first_and_last_transfer)
Default Value
""
Remarks
A single-character field that indicates the first and last messages in a related set.
msg_message_impl_controlling_agency property
A code value that identifies the controlling agency for the message implementation.
Syntax
def get_msg_message_impl_controlling_agency() -> str: ... def set_msg_message_impl_controlling_agency(value: str) -> None: ...
msg_message_impl_controlling_agency = property(get_msg_message_impl_controlling_agency, set_msg_message_impl_controlling_agency)
Default Value
""
Remarks
A code value that identifies the controlling agency for the message implementation.
This is an alphanumeric field with a value up to 3 characters long. This field only appears in EDIFACT syntax version 4.
msg_message_impl_identification property
Identifies the message implementation.
Syntax
def get_msg_message_impl_identification() -> str: ... def set_msg_message_impl_identification(value: str) -> None: ...
msg_message_impl_identification = property(get_msg_message_impl_identification, set_msg_message_impl_identification)
Default Value
""
Remarks
Identifies the message implementation.
This is an alphanumeric field with a value up to 14 characters long. This field only appears in EDIFACT syntax version 4.
msg_message_impl_release property
Identifies the release number for the message implementation.
Syntax
def get_msg_message_impl_release() -> str: ... def set_msg_message_impl_release(value: str) -> None: ...
msg_message_impl_release = property(get_msg_message_impl_release, set_msg_message_impl_release)
Default Value
""
Remarks
Identifies the release number for the message implementation.
This is an alphanumeric field with a value up to 3 characters long. This field only appears in EDIFACT syntax version 4.
msg_message_impl_version property
Identifies the version number for the message implementation.
Syntax
def get_msg_message_impl_version() -> str: ... def set_msg_message_impl_version(value: str) -> None: ...
msg_message_impl_version = property(get_msg_message_impl_version, set_msg_message_impl_version)
Default Value
""
Remarks
Identifies the version number for the message implementation.
This is an alphanumeric field with a value up to 3 characters long. This field only appears in EDIFACT syntax version 4.
msg_message_release property
Identifies the release number for the message.
Syntax
def get_msg_message_release() -> str: ... def set_msg_message_release(value: str) -> None: ...
msg_message_release = property(get_msg_message_release, set_msg_message_release)
Default Value
""
Remarks
Identifies the release number for the message.
This is an alphanumeric field with a value up to 3 characters long.
msg_message_subset_controlling_agency property
A code value that identifies the controlling agency for the message subset.
Syntax
def get_msg_message_subset_controlling_agency() -> str: ... def set_msg_message_subset_controlling_agency(value: str) -> None: ...
msg_message_subset_controlling_agency = property(get_msg_message_subset_controlling_agency, set_msg_message_subset_controlling_agency)
Default Value
""
Remarks
A code value that identifies the controlling agency for the message subset.
This is an alphanumeric field with a value up to 3 characters long. This field only appears in EDIFACT syntax version 4.
msg_message_subset_identification property
Identifies the message subset.
Syntax
def get_msg_message_subset_identification() -> str: ... def set_msg_message_subset_identification(value: str) -> None: ...
msg_message_subset_identification = property(get_msg_message_subset_identification, set_msg_message_subset_identification)
Default Value
""
Remarks
Identifies the message subset.
This is an alphanumeric field with a value up to 14 characters long. This field only appears in EDIFACT syntax version 4.
msg_message_subset_release property
Identifies the release number for the message subset.
Syntax
def get_msg_message_subset_release() -> str: ... def set_msg_message_subset_release(value: str) -> None: ...
msg_message_subset_release = property(get_msg_message_subset_release, set_msg_message_subset_release)
Default Value
""
Remarks
Identifies the release number for the message subset.
This is an alphanumeric field with a value up to 3 characters long. This field only appears in EDIFACT syntax version 4.
msg_message_subset_version property
Identifies the version number for the message subset.
Syntax
def get_msg_message_subset_version() -> str: ... def set_msg_message_subset_version(value: str) -> None: ...
msg_message_subset_version = property(get_msg_message_subset_version, set_msg_message_subset_version)
Default Value
""
Remarks
Identifies the version number for the message subset.
This is an alphanumeric field with a value up to 3 characters long. This field only appears in EDIFACT syntax version 4.
msg_message_type property
A code identifying the message's type.
Syntax
def get_msg_message_type() -> str: ... def set_msg_message_type(value: str) -> None: ...
msg_message_type = property(get_msg_message_type, set_msg_message_type)
Default Value
""
Remarks
A code identifying the message's type.
This is an alphanumeric field with a value up to 6 characters long.
msg_message_type_sub_function_identification property
A code identifying the sub-function of the message's type.
Syntax
def get_msg_message_type_sub_function_identification() -> str: ... def set_msg_message_type_sub_function_identification(value: str) -> None: ...
msg_message_type_sub_function_identification = property(get_msg_message_type_sub_function_identification, set_msg_message_type_sub_function_identification)
Default Value
""
Remarks
A code identifying the sub-function of the message's type.
This is an alphanumeric field with a value up to 6 characters long. This field only appears in EDIFACT syntax version 4.
msg_message_version property
Identifies the version number for the message.
Syntax
def get_msg_message_version() -> str: ... def set_msg_message_version(value: str) -> None: ...
msg_message_version = property(get_msg_message_version, set_msg_message_version)
Default Value
""
Remarks
Identifies the version number for the message.
This is an alphanumeric field with a value up to 3 characters long.
msg_reference_number property
A unique reference number for the message.
Syntax
def get_msg_reference_number() -> str: ... def set_msg_reference_number(value: str) -> None: ...
msg_reference_number = property(get_msg_reference_number, set_msg_reference_number)
Default Value
""
Remarks
A unique reference number for the message.
This is an alphanumeric field with a value up to 14 characters long.
msg_scenario_controlling_agency property
Identifies the controlling agency for the message scenario.
Syntax
def get_msg_scenario_controlling_agency() -> str: ... def set_msg_scenario_controlling_agency(value: str) -> None: ...
msg_scenario_controlling_agency = property(get_msg_scenario_controlling_agency, set_msg_scenario_controlling_agency)
Default Value
""
Remarks
Identifies the controlling agency for the message scenario.
This is an alphanumeric field with a value up to 3 characters long. This field only appears in EDIFACT syntax version 4.
msg_scenario_identification property
The identifier for the message scenario.
Syntax
def get_msg_scenario_identification() -> str: ... def set_msg_scenario_identification(value: str) -> None: ...
msg_scenario_identification = property(get_msg_scenario_identification, set_msg_scenario_identification)
Default Value
""
Remarks
The identifier for the message scenario.
This is an alphanumeric field with a value up to 14 characters long. This field only appears in EDIFACT syntax version 4.
msg_scenario_release property
The message scenario's release number.
Syntax
def get_msg_scenario_release() -> str: ... def set_msg_scenario_release(value: str) -> None: ...
msg_scenario_release = property(get_msg_scenario_release, set_msg_scenario_release)
Default Value
""
Remarks
The message scenario's release number.
This is an alphanumeric field with a value up to 3 characters long. This field only appears in EDIFACT syntax version 4.
msg_scenario_version property
The message scenario's version number.
Syntax
def get_msg_scenario_version() -> str: ... def set_msg_scenario_version(value: str) -> None: ...
msg_scenario_version = property(get_msg_scenario_version, set_msg_scenario_version)
Default Value
""
Remarks
The message scenario's version number.
This is an alphanumeric field with a value up to 3 characters long. This field only appears in EDIFACT syntax version 4.
msg_sequence_of_transfers property
Specifies the message's position in a sequence.
Syntax
def get_msg_sequence_of_transfers() -> str: ... def set_msg_sequence_of_transfers(value: str) -> None: ...
msg_sequence_of_transfers = property(get_msg_sequence_of_transfers, set_msg_sequence_of_transfers)
Default Value
""
Remarks
Specifies the message's position in a sequence.
This is an alphanumeric field with a value up to 2 characters long.
output_data property
The output data that has been written so far.
Syntax
def get_output_data() -> str: ... def set_output_data(value: str) -> None: ...
output_data = property(get_output_data, set_output_data)
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.
output_file property
The name of the output file to which the EDI data will be written.
Syntax
def get_output_file() -> str: ... def set_output_file(value: str) -> None: ...
output_file = property(get_output_file, set_output_file)
Default Value
""
Remarks
file_write_mode 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.
segment_suffix property
The suffix that is appended to the end of a segment.
Syntax
def get_segment_suffix() -> int: ... def set_segment_suffix(value: int) -> None: ...
segment_suffix = property(get_segment_suffix, set_segment_suffix)
Possible Values
0 # None
1 # CR
2 # LF
3 # CRLF
Default Value
3
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. |
close method
Closes the writer.
Syntax
def close() -> None: ...
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
Sets or retrieves a configuration setting.
Syntax
def config(configuration_string: str) -> str: ...
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.
end_composite_element method
Finish writing the composite element.
Syntax
def end_composite_element() -> None: ...
Remarks
This method is used to close a CompositeElement. This method may only be called after a successful call to start_composite_element
end_functional_group method
Write the UNE(FunctionalGroup) segment to the output file/data/stream.
Syntax
def end_functional_group() -> None: ...
Remarks
This method is used to close a functional_group. This method may only be called after a successful call to start_functional_group
end_interchange method
Write the UNZ(Interchange) segment to the output file/data/stream.
Syntax
def end_interchange() -> None: ...
Remarks
This method is used to close an interchange. This method may only be called after a successful call to start_interchange
end_message method
Closes the current message.
Syntax
def end_message() -> None: ...
Remarks
Calling this method will close the current message. If no message is open, an error will be raised. This method will also write the required Message Trailer (UNT) segment to the output.
end_segment method
Finish writing the segment, add SegmentSuffix at the end of the segment.
Syntax
def end_segment() -> None: ...
Remarks
This method is used to close a segment. This method may only be called after a successful call to start_segment
reset method
Resets all properties to their default values.
Syntax
def reset() -> None: ...
Remarks
This method resets all properties of the component to their default values as specified in the property definitions.
start_composite_element method
Starts a composite element within the current segment.
Syntax
def start_composite_element() -> None: ...
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 end_composite_element method. Component elements within the composite are added by calling the write_component method.
start_functional_group method
Starts a new functional group in the EDI document.
Syntax
def start_functional_group() -> None: ...
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 end_functional_group method. The functional group header segment (UNG) is written to the output when this method is called.
start_interchange method
Starts a new interchange in the EDI document.
Syntax
def start_interchange() -> None: ...
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 end_interchange method. The interchange header segment (UNB) 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.
start_message method
Starts a new message in the EDI document.
Syntax
def start_message() -> None: ...
Remarks
This method starts a new message in the EDI document. The message fields must be set using the appropriate properties before calling this method. The message is ended by calling the end_message method. The message header segment (UNH) is written to the output when this method is called. If opening a new message would result in an invalid structure (for example, starting a new message before ending the previous one), an error will be raised.
start_segment method
Starts a new segment with the specified tag.
Syntax
def start_segment(tag: str) -> None: ...
Remarks
This method starts a new segment with the specified tag. The segment is ended by calling the end_segment method. Element values within the segment are added by calling the write_element method. Composite elements can be added to the segment by calling the start_composite_element 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.
write_component method
Writes a class element value to the current composite element.
Syntax
def write_component(val: str) -> None: ...
Remarks
This method writes a component element value to the current composite element. The composite element must be started by calling the start_composite_element method before calling this method. The composite element is ended by calling the end_composite_element method. If this method is called when not within a composite element, an error will be raised.
write_element method
Writes an element value to the current segment.
Syntax
def write_element(val: str) -> None: ...
Remarks
This method writes an element value to the current segment. The segment must be started by calling the start_segment method before calling this method. The segment is ended by calling the end_segment method. If this method is called when not within a segment, an error will be raised.
on_error event
Fires when an error occurs during message processing. Normally, the class fails with an error.
Syntax
class EDIFACTWriterErrorEventParams(object): @property def error_code() -> int: ... @property def description() -> str: ... # In class EDIFACTWriter: @property def on_error() -> Callable[[EDIFACTWriterErrorEventParams], None]: ... @on_error.setter def on_error(event_hook: Callable[[EDIFACTWriterErrorEventParams], None]) -> None: ...
Remarks
The on_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.
on_output event
Fires when output data is written.
Syntax
class EDIFACTWriterOutputEventParams(object): @property def data() -> bytes: ... # In class EDIFACTWriter: @property def on_output() -> Callable[[EDIFACTWriterOutputEventParams], None]: ... @on_output.setter def on_output(event_hook: Callable[[EDIFACTWriterOutputEventParams], None]) -> None: ...
Remarks
This event is fired when output data is written. The Data parameter contains the segment that was written.
EDIFACTWriter Config Settings
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.EDIFACTWriter Errors
EDIFACTWriter 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. |