| 1 | # | ||||||||||||||||||||||||||
| 2 | # $Id: Catalogs.pm,v 1.8 2004/08/25 21:49:38 brian.kaney Exp $ | ||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||
| 4 | # XML::ASCX12::Catalogs | ||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||
| 6 | # Copyright (c) Vermonster LLC <http://www.vermonster.com> | ||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||
| 8 | # This library is free software; you can redistribute it and/or | ||||||||||||||||||||||||||
| 9 | # modify it under the terms of the GNU Lesser General Public | ||||||||||||||||||||||||||
| 10 | # License as published by the Free Software Foundation; either | ||||||||||||||||||||||||||
| 11 | # version 2.1 of the License, or (at your option) any later version. | ||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||
| 13 | # This library is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||||||||||||||||||||||
| 16 | # Lesser General Public License for more details. | ||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||
| 18 | # For questions, comments, contributions and/or commercial support | ||||||||||||||||||||||||||
| 19 | # please contact: | ||||||||||||||||||||||||||
| 20 | # | ||||||||||||||||||||||||||
| 21 | # Vermonster LLC <http://www.vermonster.com> | ||||||||||||||||||||||||||
| 22 | # 312 Stuart St. 2nd Floor | ||||||||||||||||||||||||||
| 23 | # Boston, MA 02116 US | ||||||||||||||||||||||||||
| 24 | # | ||||||||||||||||||||||||||
| 25 | # vim: set expandtab tabstop=4 shiftwidth=4 | ||||||||||||||||||||||||||
| 26 | # | ||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||
| 28 | =head1 NAME | ||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||
| 30 | XML::ASCX12::Catalogs - Catalog Looping Rules for ASCX12 EDI Data | ||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||
| 32 | =cut | ||||||||||||||||||||||||||
| 33 | package XML::ASCX12::Catalogs; | ||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||
| 35 | 1 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 36 | 1 | ▶ | use vars qw(@ISA @EXPORT $VERSION $LOOPNEST); | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||
| 38 | BEGIN | ||||||||||||||||||||||||||
| 39 | 1 | ▶ | { | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 40 | 1 | @ISA = ('Exporter'); | |||||||||||||||||||||||||
| 41 | 1 | @EXPORT = qw($LOOPNEST load_catalog); | |||||||||||||||||||||||||
| 42 | 1 | $VERSION = '0.1'; | |||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||
| 47 | =head1 DESCRIPTION | ||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||
| 49 | This defines how the loops are constructed per catalog. By catalog | ||||||||||||||||||||||||||
| 50 | we mean EDI transaction set. | ||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||
| 52 | The C<0> catalog is the general relationship for ASCX12. It say | ||||||||||||||||||||||||||
| 53 | that the parent loop C<ISA> can have C<GS> child loops. Also, C<GS> child | ||||||||||||||||||||||||||
| 54 | loops can have C<ST> child loops. This one shouldn't have to change. | ||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||
| 56 | To include additional catalogs, use the pattern and enclose in the | ||||||||||||||||||||||||||
| 57 | conditional structure. | ||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||
| 60 | =head1 PUBLIC STATIC VARIABLES | ||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||
| 62 | =over 4 | ||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||
| 64 | =item $LOOPNEST | ||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||
| 67 | This is a reference to an array hash. The array contains the looping | ||||||||||||||||||||||||||
| 68 | rules on a per-catalog basis. | ||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||
| 70 | =item $IS_CHILD | ||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||
| 73 | This is a reference to a hash of hashes. It is not used with all Catalogs. | ||||||||||||||||||||||||||
| 74 | The hash contains all the the parent (current loop) and child (next segment) | ||||||||||||||||||||||||||
| 75 | loop rules on a per-catalog basis. Returns one of three possible values: | ||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||
| 77 | Undef - exit current loop (next segment not valid child) | ||||||||||||||||||||||||||
| 78 | True (1) - segment is valid child for current loop | ||||||||||||||||||||||||||
| 79 | false (0) - segment begins new loop within current loop | ||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||
| 81 | The false response corresponds to the $LOOPNEST functionality. But some | ||||||||||||||||||||||||||
| 82 | Catalogs can create loop patterns that $LOOPNEST alone was unable to | ||||||||||||||||||||||||||
| 83 | unravel. Leaving $IS_CHILD undefined will default to using just $LOOPNEST. | ||||||||||||||||||||||||||
| 84 | =back | ||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||
| 86 | =cut | ||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||
| 88 | 1 | our $LOOPNEST; | |||||||||||||||||||||||||
| 89 | 1 | our $IS_CHILD; | |||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||
| 91 | =head1 PUBLIC STATIC METHODS | ||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||
| 93 | =over 4 | ||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||
| 95 | =item void = load_catalog($catalog_number) | ||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||
| 98 | This is a static public method that loads the C<$LOOPNEST> reference with | ||||||||||||||||||||||||||
| 99 | the appropiate catalog relationship data. It is called by L<XML-ASCX12|XML::ASCX12>. | ||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||
| 101 | To add additional catalogs, follow the same pattern. If you do add catalogs, | ||||||||||||||||||||||||||
| 102 | please submit this file and the Segments.pl to the author(s) so we can make | ||||||||||||||||||||||||||
| 103 | this library grow. | ||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||
| 105 | =cut | ||||||||||||||||||||||||||
| 106 | sub load_catalog($) | ||||||||||||||||||||||||||
| 107 | 0 | ▶ | { | ||||||||||||||||||||||||
|
Subroutine
load_catalog: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||
| 108 | 0 | ▶ | if ($_[1] eq '0') | ||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||
| 110 | # | ||||||||||||||||||||||||||
| 111 | # CATALOG 0 - Fake catalog used to load up general ASCX12 relationship | ||||||||||||||||||||||||||
| 112 | # | ||||||||||||||||||||||||||
| 113 | 0 | push @{$LOOPNEST->{ISA}}, qw(GS); | |||||||||||||||||||||||||
| 114 | 0 | push @{$LOOPNEST->{GS}}, qw(ST); | |||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||
| 116 | elsif ($_[1] eq '110') | ||||||||||||||||||||||||||
| 117 | { | ||||||||||||||||||||||||||
| 118 | # | ||||||||||||||||||||||||||
| 119 | # CATALOG 110 - Airfreight Details & Invoice | ||||||||||||||||||||||||||
| 120 | # | ||||||||||||||||||||||||||
| 121 | 0 | push @{$LOOPNEST->{ST}}, qw(N1 LX SE L3); | |||||||||||||||||||||||||
| 122 | 0 | push @{$LOOPNEST->{LX}}, qw(N1 L5); | |||||||||||||||||||||||||
| 123 | 0 | push @{$LOOPNEST->{L5}}, qw(L1); | |||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||
| 125 | elsif ($_[1] eq '820') | ||||||||||||||||||||||||||
| 126 | { | ||||||||||||||||||||||||||
| 127 | # | ||||||||||||||||||||||||||
| 128 | # CATALOG 820 - Payment Order / Remittance Advice | ||||||||||||||||||||||||||
| 129 | # | ||||||||||||||||||||||||||
| 130 | 0 | push @{$LOOPNEST->{ST}}, qw(N1 ENT); | |||||||||||||||||||||||||
| 131 | 0 | push @{$LOOPNEST->{ENT}}, qw(NM1 RMR); | |||||||||||||||||||||||||
| 132 | 0 | push @{$LOOPNEST->{RMR}}, qw(REF ADX); | |||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||
| 134 | elsif ($_[1] eq '997') | ||||||||||||||||||||||||||
| 135 | { | ||||||||||||||||||||||||||
| 136 | # | ||||||||||||||||||||||||||
| 137 | # CATALOG 920 - Functional Acknowledgement | ||||||||||||||||||||||||||
| 138 | # | ||||||||||||||||||||||||||
| 139 | 0 | push @{$LOOPNEST->{ST}}, qw(AK2); | |||||||||||||||||||||||||
| 140 | 0 | push @{$LOOPNEST->{AK2}}, qw(AK3); | |||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||
| 142 | # | ||||||||||||||||||||||||||
| 143 | # XXX Add your catalogs here following the pattern. | ||||||||||||||||||||||||||
| 144 | # XXX Remember to update XML::ASCX12::Segments as well. | ||||||||||||||||||||||||||
| 145 | # | ||||||||||||||||||||||||||
| 146 | # XXX Please submit additional catalogs to the authors | ||||||||||||||||||||||||||
| 147 | # XXX so they can become part of the library for everyone's | ||||||||||||||||||||||||||
| 148 | # XXX benefit! | ||||||||||||||||||||||||||
| 149 | # | ||||||||||||||||||||||||||
| 150 | elsif ($_[1] eq '175') | ||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||
| 152 | # | ||||||||||||||||||||||||||
| 153 | # CATALOG 175 - Court Notice | ||||||||||||||||||||||||||
| 154 | # | ||||||||||||||||||||||||||
| 155 | 0 | push @{$LOOPNEST->{ST}}, qw(CDS); | |||||||||||||||||||||||||
| 156 | 0 | push @{$LOOPNEST->{CDS}}, qw(CED); | |||||||||||||||||||||||||
| 157 | 0 | push @{$LOOPNEST->{CED}}, qw(LM NM1); | |||||||||||||||||||||||||
| 158 | # | ||||||||||||||||||||||||||
| 159 | # Close loop unless next seqment is a legal loop or child | ||||||||||||||||||||||||||
| 160 | # $IS_CHILD->{parent}->{child} = value; | ||||||||||||||||||||||||||
| 161 | 0 | $IS_CHILD->{ISA}->{ISA} = '0'; | |||||||||||||||||||||||||
| 162 | 0 | $IS_CHILD->{ISA}->{GS} = '0'; | |||||||||||||||||||||||||
| 163 | 0 | $IS_CHILD->{ISA}->{IEA} = '1'; | |||||||||||||||||||||||||
| 164 | 0 | $IS_CHILD->{GS}->{ST} = '0'; | |||||||||||||||||||||||||
| 165 | 0 | $IS_CHILD->{GS}->{GE} = '1'; | |||||||||||||||||||||||||
| 166 | 0 | $IS_CHILD->{ST}->{BGN} = '1'; | |||||||||||||||||||||||||
| 167 | 0 | $IS_CHILD->{ST}->{SE} = '1'; | |||||||||||||||||||||||||
| 168 | 0 | $IS_CHILD->{ST}->{CDS} = '0'; | |||||||||||||||||||||||||
| 169 | 0 | $IS_CHILD->{CDS}->{LS} = '1'; | |||||||||||||||||||||||||
| 170 | 0 | $IS_CHILD->{CDS}->{LE} = '1'; | |||||||||||||||||||||||||
| 171 | 0 | $IS_CHILD->{CDS}->{CED} = '0'; | |||||||||||||||||||||||||
| 172 | 0 | $IS_CHILD->{CED}->{DTM} = '1'; | |||||||||||||||||||||||||
| 173 | 0 | $IS_CHILD->{CED}->{REF} = '1'; | |||||||||||||||||||||||||
| 174 | 0 | $IS_CHILD->{CED}->{CDS} = '1'; | |||||||||||||||||||||||||
| 175 | 0 | $IS_CHILD->{CED}->{MSG} = '1'; | |||||||||||||||||||||||||
| 176 | 0 | $IS_CHILD->{CED}->{LM} = '0'; | |||||||||||||||||||||||||
| 177 | 0 | $IS_CHILD->{LM}->{LQ} = '1'; | |||||||||||||||||||||||||
| 178 | 0 | $IS_CHILD->{CED}->{NM1} = '0'; | |||||||||||||||||||||||||
| 179 | 0 | $IS_CHILD->{NM1}->{N2} = '1'; | |||||||||||||||||||||||||
| 180 | 0 | $IS_CHILD->{NM1}->{N3} = '1'; | |||||||||||||||||||||||||
| 181 | 0 | $IS_CHILD->{NM1}->{N4} = '1'; | |||||||||||||||||||||||||
| 182 | 0 | $IS_CHILD->{NM1}->{REF} = '1'; | |||||||||||||||||||||||||
| 183 | 0 | $IS_CHILD->{NM1}->{PER} = '1'; | |||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||
| 185 | else | ||||||||||||||||||||||||||
| 186 | { | ||||||||||||||||||||||||||
| 187 | 0 | croak "Catalog \"$_[0]\" has not been defined!"; | |||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||
| 191 | =back | ||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||
| 193 | =head1 AUTHORS | ||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||
| 195 | Brian Kaney <F<brian@vermonster.com>>, Jay Powers <F<jpowers@cpan.org>> | ||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||
| 197 | L<http://www.vermonster.com/> | ||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||
| 199 | Copyright (c) 2004 Vermonster LLC. All rights reserved. | ||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||
| 201 | This library is free software. You can redistribute it and/or modify | ||||||||||||||||||||||||||
| 202 | it under the terms of the GNU Lesser General Public License as | ||||||||||||||||||||||||||
| 203 | published by the Free Software Foundation; either version 2 of the | ||||||||||||||||||||||||||
| 204 | License, or (at your option) any later version. | ||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||
| 206 | Basically you may use this library in commercial or non-commercial applications. | ||||||||||||||||||||||||||
| 207 | However, If you make any changes directly to any files in this library, you are | ||||||||||||||||||||||||||
| 208 | obligated to submit your modifications back to the authors and/or copyright holder. | ||||||||||||||||||||||||||
| 209 | If the modification is suitable, it will be added to the library and released to | ||||||||||||||||||||||||||
| 210 | the back to public. This way we can all benefit from each other's hard work! | ||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||
| 212 | If you have any questions, comments or suggestions please contact the author. | ||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||
| 214 | =head1 SEE ALSO | ||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||
| 216 | L<XML::ASCX12> and L<XML::ASCX12::Segments> | ||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||
| 218 | =cut | ||||||||||||||||||||||||||
| 219 | 1 | 1; | |||||||||||||||||||||||||