.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Business::EDI 3pm" .TH Business::EDI 3pm "2022-06-30" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Business::EDI \- Top level class for generating U.N. EDI interchange objects and subobjects. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Business::EDI; \& \& my $edi = Business::EDI\-new(\*(Aqd09b\*(Aq); # set the EDI spec version \& my $rtc = $edi\->codelist(\*(AqResponseTypeCode\*(Aq, $json) or die "Unrecognized code!"; \& printf "EDI response type: %s \- %s (%s)\en", $rtc\->code, $rtc\->label, $rtc\->value; \& \& my $msg = Business::EDI::Message\->new($ordrsp) or die "Failed Message constructor"; \& foreach ($msg\->xpath(\*(Aqline_detail/all_LIN\*(Aq) { \& ($_\->part(7143) || \*(Aq\*(Aq) eq \*(AqEN\*(Aq or next; \& print $_\->part(7140)\->value, "\en"; # print all the 13\-digit (EN) ISBNs \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The focus of functionality is to provide object based access to \s-1EDI\s0 messages and subelements. At present, the \s-1EDI\s0 input processed by Business::EDI objects is \s-1JSON\s0 from the \fBedi4r\fR ruby library, and there is no \s-1EDI\s0 output beyond the perl objects themselves. .SH "NAMESPACE" .IX Header "NAMESPACE" When you \f(CW\*(C`use Business::EDI;\*(C'\fR the following package namespaces are also loaded: Business::EDI::Segment_group Business::EDI::Message .PP That's why the example message constructor in \s-1SYNOPSIS\s0 would succeed without having done \f(CW\*(C`use Business::EDI::Message;\*(C'\fR .SH "EDI Structure" .IX Header "EDI Structure" Everything depends on the spec. That means you have to have declared a spec version before you can create or parse a given chunk of data. The exception is a whole \s-1EDI\s0 message, because each message declares its spec version internally. .PP \&\s-1EDI\s0 has a hierachical specification defining data. From top to bottom, it includes: .IP "\fBCommunication\fR \- containing one or more messages (not yet modeled here)" 4 .IX Item "Communication - containing one or more messages (not yet modeled here)" .PD 0 .IP "\fBMessage\fR \- containing segment groups and segments" 4 .IX Item "Message - containing segment groups and segments" .IP "\fBSegment Group\fR \- containing segments" 4 .IX Item "Segment Group - containing segments" .IP "\fBSegment\fR \- containing composites, codelists and data elements" 4 .IX Item "Segment - containing composites, codelists and data elements" .IP "\fBComposite\fR \- containing multiple codelists and/or data elements" 4 .IX Item "Composite - containing multiple codelists and/or data elements" .IP "\fBCodelist\fR \- enumerated value from a spec-defined set" 4 .IX Item "Codelist - enumerated value from a spec-defined set" .IP "\fBData Element\fR \- unenumerated value" 4 .IX Item "Data Element - unenumerated value" .PD .PP This module handles messages and everything below, but not (yet) communications. .SH "CLASS FUNCTIONS" .IX Header "CLASS FUNCTIONS" Much more documentation needed here... .SS "\fBnew()\fP" .IX Subsection "new()" Constructor .SH "OBJECT METHODS (General)" .IX Header "OBJECT METHODS (General)" .SS "\fBvalue()\fP" .IX Subsection "value()" Get/set accessor for the value of the field. .SS "\fBcode()\fP" .IX Subsection "code()" The string code designating this node's type. The code is what is what the spec uses to refer to the object's definition. For example, a composite \*(L"C504\*(R", segment \*(L"\s-1RFF\*(R",\s0 data element \*(L"7140\*(R", etc. .PP Don't be confused when dealing with CodeList objects. Calling \fBcode()\fR gets you the 4\-character code of the CodeList field, \s-1NOT\s0 what that CodeList is currently set to. For that use \fBvalue()\fR. .SS "\fBdesc()\fP" .IX Subsection "desc()" English description of the element. .SH "METHODS (for Traversal)" .IX Header "METHODS (for Traversal)" .SS "\fBpart_keys()\fP" .IX Subsection "part_keys()" This method returns strings that can be fed to \fBpart()\fR like: foreach ($x\->part_keys) { something($x\->part($_)) } .PP This is similar to doing: foreach (keys \f(CW%x\fR) { something($x{$_}) } .PP In this way an object can be exhaustively, recursively parsed without further knowledge of it. .SS "part($key)" .IX Subsection "part($key)" Returns subelement(s) of the object. The key can reference any subobject allowed by the spec. If the subobject is repeatable, then prepending \*(L"all_\*(R" to the key will return an array of all such subobjects. This is the safest and most comprehensive approach. Using part($key) without \*(L"all_\*(R" to retrieve when there is only one \f(CW$key\fR subobject will succeed. Using part($key) without \*(L"all_\*(R" to retrieve when there are multiple \f(CW$key\fR subobjects will \s-1FAIL.\s0 Since that difference is only dependent on data, you should always use \*(L"all_\*(R" when dealing with a repeatable field (or xpath, see below). .PP Examples: .PP .Vb 2 \& my $qty = $detail\->part(\*(AqQTY\*(Aq); # FAILURE PRONE! \& my @qtys = $detail\->part(\*(Aqall_QTY\*(Aq); # OK! .Ve .SS "xpath($path)" .IX Subsection "xpath($path)" \&\f(CW$path\fR can traverse multiple depths in representation via one call. For example: .PP .Vb 1 \& $message\->xpath(\*(Aqall_SG26/all_QTY/6063\*(Aq) .Ve .PP is like this function \fBfoo()\fR: .PP .Vb 9 \& sub foo { \& my @x; \& for my $sg ($message\->part\->(\*(Aqall_SG26\*(Aq) { \& for ($sg\->part(\*(Aqall_QTY\*(Aq) { \& push @x, $\->part(\*(Aq6063\*(Aq); \& } \& } \& return @x; \& } .Ve .PP The xpath version is much nicer! However this is nowhere near as fully featured as W3C xpath for \s-1XML.\s0 This is more like a multple-depth \fBpart()\fR. .PP Examples: my \f(CW@obj_1154\fR = \f(CW$message\fR\->xpath('line_detail/SG31/RFF/C506/1154'); .SS "xpath_value($path)" .IX Subsection "xpath_value($path)" Returns value(s) instead of object(s). .PP Examples: '\s-1ORDRSP\s0' eq \f(CW$ordrsp\fR\->xpath_value('\s-1UNH/S009/0065\s0') or die \*(L"Wrong Message Type!\*(R"; .SH "WARNINGS" .IX Header "WARNINGS" This code is experimental. \s-1EDI\s0 is a big spec with many revisions. .PP At the lower levels, all data elements, codelists, composites and segments from the most recent spec (D09B) are present. .SH "SEE ALSO" .IX Header "SEE ALSO" .Vb 2 \& Business::EDI::Spec \& edi4r \- http://edi4r.rubyforge.org .Ve .SH "AUTHOR" .IX Header "AUTHOR" Joe Atzberger