Comments (8)
yes, that commit indeed solves it, my fault, sorry!
from edifact.
You are right..
You can mantain the segment disabling the patching $interpreter->togglePatching(false);
The problem lies here
https://github.com/php-edifact/edifact/blob/master/src/EDI/Interpreter.php#L660
The issue is that the code doesn't check currently if the first element of the next group (or a repetition of the same) is the same.
from edifact.
@szocsbarni I pushed a commit which should deal with this case, can you test with a larger sample? Thanks :)
from edifact.
@sabas the fix is ok, parsing does not stop on the double NAD
command and processes larger files. I am still getting a warning though, will it be eliminated?
Array
(
[0] => Array
(
[text] => The message has some additional segments beyond the maximum repetition allowed (skipped)
[position] => 4
[segmentId] => NAD
)
)
from edifact.
On the same file? Strange..
Here's my sample (yes I should write tests.... :/)
require('vendor/autoload.php');
$c = new EDI\Parser();
$file = <<<END
UNA:+.?'
UNB+UNOC:3+0000000000000:14+0000000000000:14+231126:1830+502+0000++++PRICAT'
UNH+1+PRICAT:D:01B:UN:EAN009'
BGM+9:::PREISLISTE+11+4'
DTM+137:20231126:102'
NAD+BY+1111111111111::9'
NAD+SU+2222222222222::9'
UNT+0+1'
UNZ+1+502'
END;
$c->loadString($file);
$o = $c->get();
d($o);
d($c->errors());
$mapping = new EDI\Mapping\MappingProvider($c->getMessageDirectory());
$analyser = new EDI\Analyser();
$segs = $analyser->loadSegmentsXml($mapping->getSegments());
$svc = $analyser->loadSegmentsXml($mapping->getServiceSegments(3));
$interpreter = new EDI\Interpreter($mapping->getMessage($c->getMessageFormat()), $segs, $svc);
//$interpreter->togglePatching(false);
$prep = $interpreter->prepare($o);
d($prep);
d($interpreter->getErrors());
from edifact.
yes, even running this concrete code segment of yours (replaced function calls of d()
to print_r()
). Below is my full output:
Array
(
[0] => Array
(
[0] => UNB
[1] => Array
(
[0] => UNOC
[1] => 3
)
[2] => Array
(
[0] => 0000000000000
[1] => 14
)
[3] => Array
(
[0] => 0000000000000
[1] => 14
)
[4] => Array
(
[0] => 231126
[1] => 1830
)
[5] => 502
[6] => 0000
[7] =>
[8] =>
[9] =>
[10] => PRICAT'
)
[1] => Array
(
[0] => UNH
[1] => 1
[2] => Array
(
[0] => PRICAT
[1] => D
[2] => 01B
[3] => UN
[4] => EAN009'
)
)
[2] => Array
(
[0] => BGM
[1] => Array
(
[0] => 9
[1] =>
[2] =>
[3] => PREISLISTE
)
[2] => 11
[3] => 4'
)
[3] => Array
(
[0] => DTM
[1] => Array
(
[0] => 137
[1] => 20231126
[2] => 102'
)
)
[4] => Array
(
[0] => NAD
[1] => BY
[2] => Array
(
[0] => 1111111111111
[1] =>
[2] => 9'
)
)
[5] => Array
(
[0] => NAD
[1] => SU
[2] => Array
(
[0] => 2222222222222
[1] =>
[2] => 9'
)
)
[6] => Array
(
[0] => UNT
[1] => 0
[2] => 1'
)
[7] => Array
(
[0] => UNZ
[1] => 1
[2] => 502'
)
)
Array
(
)
Array
(
[0] => Array
(
[messageHeader] => Array
(
[segmentIdx] => 0
[segmentCode] => UNH
[segmentGroup] =>
[messageReferenceNumber] => 1
[messageIdentifier] => Array
(
[messageType] => PRICAT
[messageVersionNumber] => D
[messageReleaseNumber] => 01B
[controllingAgency] => UN
[associationAssignedCode] => EAN009'
)
)
[beginningOfMessage] => Array
(
[segmentIdx] => 1
[segmentCode] => BGM
[segmentGroup] =>
[document] => Array
(
[documentNameCode] => 9
[codeListIdentificationCode] =>
[codeListResponsibleAgencyCode] =>
[documentName] => PREISLISTE
)
[document1] => Array
(
[documentIdentifier] => 11
)
[messageFunctionCode] => 4'
)
[dateOrtimeOrperiod] => Array
(
[segmentIdx] => 2
[segmentCode] => DTM
[segmentGroup] =>
[date] => Array
(
[dateOrTimeOrPeriodFunctionCodeQualifier] => 137
[dateOrTimeOrPeriodValue] => 20231126
[dateOrTimeOrPeriodFormatCode] => 102'
)
)
[SG2] => Array
(
[0] => Array
(
[nameAndAddress] => Array
(
[segmentIdx] => 3
[segmentCode] => NAD
[segmentGroup] => SG2
[partyFunctionCodeQualifier] => BY
[partyIdentificationDetails] => Array
(
[partyIdentifier] => 1111111111111
[codeListIdentificationCode] =>
[codeListResponsibleAgencyCode] => 9'
)
)
)
)
[messageTrailer] => Array
(
[segmentIdx] => 5
[segmentCode] => UNT
[segmentGroup] => SG2
[numberOfSegmentsInTheMessage] => 0
[messageReferenceNumber] => 1'
)
)
)
Array
(
[0] => Array
(
[text] => The message has some additional segments beyond the maximum repetition allowed (skipped)
[position] => 4
[segmentId] => NAD
)
)
from edifact.
Can I help you anything with this issue? @sabas
from edifact.
With the commit dffa093 in the test case you provided it seemed fixed.
Do you replicate it with the same test or with another file? If it's private you can share by email..
from edifact.
Related Issues (20)
- How to create edi document with .edi extension for healthcare HOT 4
- readEdiSegmentDTM for SG12 HOT 5
- File has multiple messages HOT 6
- question marks are not parsed correctly HOT 5
- Fatal error on integer-value segments for Encoder HOT 2
- Reader cannot be init with a null param HOT 3
- Release 0.5.0 not available via Composer HOT 2
- Possibility to have IDs instead of name as output from Interpreter::prepare HOT 5
- CDR read HOT 4
- Problems reading RFF segment from EDI-File HOT 1
- Array to string conversion, if an epty array met. HOT 1
- X12 HOT 6
- Package ramsey/array_column is abandoned HOT 2
- Trouble understanding how to get the data we need HOT 5
- Segment is ambiguous HOT 1
- Elements with maxrepeat > 1 should be considered arrays when parsed as json HOT 6
- Reader doesn't return full multi-line texts HOT 4
- Issue parsing linebreaks in segments HOT 9
- Unable to parse DESADV with multiple NAD HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edifact.