NAME
Data::EDI::X12 - EDI X12 Processing for Perl
SYNOPSIS
my $x12 = Data::EDI::X12->new({ spec_file => 'edi.yaml', new_lines => 1, truncate_null => 1, hide_empty_sections => 1 });
my $data = $x12->read_record(...);
print $x12->write_record($data);
METHODS
new
my $x12 = Data::EDI::X12->new({ spec_file => 'edi.yaml', new_lines => 1, truncate_null => 1 });
read_record
my $record = $x12->read_record($string);
write_record
my $string = $x12->write_record($record);
EXAMPLES
SPEC FILE EXAMPLE
850:
structure:
header:
- BEG
- DTM
- N9
- N1
detail:
- PO1
- PID
footer:
- CTT
segments:
BEG:
definition:
- name: purpose_codse
min: 2
max: 2
- name: type_code
min: 2
max: 2
- name: order_number
min: 1
max: 22
- type: filler
- name: date
min: 8
max: 8
DTM:
definition:
- name: qualifier
min: 3
max: 3
- name: date
min: 8
max: 8
N9:
definition:
- name: qualifier
min: 2
max: 3
- name: identification
min: 1
max: 50
N1:
definition:
- name: identifier
min: 2
max: 3
- name: name
min: 1
max: 60
- name: identification_code_qualifier
min: 1
max: 2
- name: identification_code
min: 2
max: 80
PO1:
definition:
- type: filler
- name: quantity
min: 1
max: 15
- name: unit_of_measure
min: 2
max: 2
- name: unit_price
min: 1
max: 17
- type: filler
- name: id_qualifier
min: 2
max: 2
- name: product_id
min: 1
max: 48
- name: id_qualifier_2
min: 2
max: 2
- name: product_id_2
min: 1
max: 48
- name: id_qualifier_3
min: 2
max: 2
- name: product_id_3
min: 1
max: 48
PID:
definition:
- name: type
- type: filler
- type: filler
- type: filler
- name: description
min: 1
max: 80
CTT:
definition:
- name: total_items
min: 1
max: 6
- name: hash_total
min: 1
max: 10
PERL EXAMPLE
use Data::EDI::X12;
my $string = q[ISA*00* *00* *01*012345675 *01*987654321 *140220*1100*^*00501*000000001*0*P*>~
GS*PO*012345675*987654321*20140220*1100*000000001*X*005010~
ST*850*0001~
BEG*00*KN*1136064**20140220~
DTM*002*20140220~
N9*ZA*0000010555~
N1*ST*U997*92*U997~
PO1**1*EA*1.11**UC*000000000007*PI*000000000000000004*VN*113~
PID*F****Test Product 1~
PO1**1*EA*2.22**UC*000000000008*PI*000000000000000005*VN*114~
PID*F****Test Product 2~
CTT*4*4~
SE*12*0001~
GE*1*000000001~
IEA*1*000000001~
];
my $x12 = Data::EDI::X12->new({ spec_file => 't/spec.yaml', new_lines => 1, truncate_null => 1 });
my $record = $x12->read_record($string);
my $out = $x12->write_record($record);
LOOPS
Both implicit and explicit loop segments are also supported by this module. Please review the loops test for an example.
HISTORY
This module was authored for Bizowie.
AUTHOR
Bizowie
COPYRIGHT AND LICENSE
Copyright (C) 2014, 2015, 2016 Bizowie
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.