Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segment is ambiguous #117

Open
gaxweb opened this issue May 31, 2023 · 1 comment
Open

Segment is ambiguous #117

gaxweb opened this issue May 31, 2023 · 1 comment

Comments

@gaxweb
Copy link
Contributor

gaxweb commented May 31, 2023

First problem

Example excerpt from a PRICAT file of a line item:

IMD+F+TPE+::91:UNISEX'
IMD+C+CL+8:EAS'
IMD+C+98+40::91'
IMD+C+UP5+J::91'
IMD+C++CU'
IMD+F+35+::91:ATLANTIC'
IMD+C+35+423041::91'
IMD+F+ANM+::91:ANDROS'
IMD+F+MD+::91:VENEZIA'
IMD+F+XB2+::91:01575423041.JPG'

I'm trying to extract the ATLANTIC string, but I can't seem to find an exact filter for it. $r->readEdiDataValue(['IMD',['1'=>'F', '2'=>'35']],1); doesn't do it but finds 7 matches: 5 for "F" in 1st place + 2 for "35" in 2nd.

Is it even possible? The code for readEdiDataValue() doesn't seem to combine the filters in the array, but just look for lines that match either, but not both at the same time.

Shouldn't that code combine filters via AND instead of OR? RIght now it breaks the inner loop, if the 1st entry in the filter array is "ok" without checking, if the 2nd entry matches, too.

I've got a patch ready, if you agree that this should be changed. With my change applied, $r->readEdiDataValue(['IMD', [1 => 'F', 2 => '35']], 3, 3); gets me the "ATLANTIC" string I wanted.

Second problem

From same PRICAT line item:

ALI+++96E'
ALI+DE'

How would I even filter these, if I need the "DE" string? Just "ALI" is ambiguous but the 2nd entry already contains what I need. Can you filter on "not empty"? Or is that an error and there should really just be one line containing both data points? Seems weird to have 2 "ALI" lines like that.

@sabas
Copy link
Collaborator

sabas commented Jun 5, 2023

Feel free to submit a pull request!
cc @uldisn as he's actually using the class, but as I look at it for the second problem you could tweak $el_value to test against a flag like "EMPTY" or similar..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants