|
View previous topic :: View next topic
|
| Author |
Message |
Charles Wolters
New User
Joined: 30 Mar 2011 Posts: 48 Location: United States
|
|
|
|
Does anyone have a copy of Frank Yaeger's article: DFSORT: Parsing Delimited & Variable Length Fields? I think it was originally published in z/Journal in 2007 but its URL appears defunct. I did find a reprint at the following Web site but the figures cited by Frank are missing and it would be more informative with the figures. The article is very well written for a parsing newbie like myself.
enterprisesystemsmedia.com/article/dfsort-parsing-delimited-variable-length-fields
Charles Wolters |
|
| Back to top |
|
 |
Bill O'Boyle
CICS Moderator

Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Did you search the IBM Mainframes DFSORT forum, for Frank Yeager/Yaeger posts? Could very well be that he posted it there as well.
HTH.... |
|
| Back to top |
|
 |
Robert Sample
Global Moderator

Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Except that's the same link which Charles provided :-) |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I've rebuilt the examples from the text. Note that there are "scannos" in the text as well (failure of the Optical Character Recognition after text is scanned).
Figure 1
| Code: |
OPTION COPY
INREC PARSE=(%00=(ENDBEFR=C',',
FIXLEN=8),
%01=(ENDBEFR=C',',
PAIR=QUOTE,
FIXLEN=25),
%02=(FIXLEN=7)),
BUILD=(%00,
%01,
JFY=(SHIFT=LEFT,PREBLANK=C'"'),
%02) |
Data:
| Code: |
| APRIL,"REX,SELF,DUMBO",GRAY |
Output:
| Code: |
| APRIL REX,SELF,DUMBO GRAY |
Figure 2
| Code: |
INREC PARSE=(%00=(ABSPOS=6,
ENDBEFR=C';',
FIXLEN=7),
%=(ENDBEFR=C';'),
%01=(ENDBEFR=C';',
FIXLEN=12),
%02=(FIXLEN=12)),
OVERLAY=(41:
%02,
55:
%01,
70:
%00,
UFF,TO=PD,LENGTH=4)
SORT FIELDS=(41,12,CH,A,
55,12,CH,A,
70,4,CH,A)
OUTREC BUILD=(1,40) |
Data:
| Code: |
0001;16,786;R732;SUE V;RITZ
0002;20;SALES;RUPERT THE;BEAR
0003;10.01;R732;SUE V;RITZ |
Output:
| Code: |
0002;20;SALES;RUPERT THE;BEAR
0003;10.01;R732;SUE V;RITZ
0001;16,786;R732;SUE V;RITZ
|
Figure 3
| Code: |
INREC IFTHEN=(WHEN=INIT,
PARSE=(%1=(STARTAFT=C'FIRST=',
ENDBEFR=C' ',FIXLEN=8))),
IFTHEN=(WHEN=INIT,
PARSE=(%2=(STARTAFT=C'MIDDLE=',
ENDBEFR=C' ',FIXLEN=12))),
IFTHEN=(WHEN=INIT,
PARSE=(%3=(STARTAFT=C'LAST=',
ENDBEFR=C' ',FIXLEN=12))),
IFTHEN=(WHEN=INIT,
PARSE=(%4=(STARTAFT=C'PROFIT=',
STARTAFT=C'LOSS=',
ENDBEFR=C' ',FIXLEN=7))),
IFTHEN=(WHEN=INIT,
BUILD=(%01,
%02,
%03,
%04,
SFF,
EDIT=(IIT.TTS),
SIGNS=(,,+,-)))
SORT FIELDS=COPY |
Data:
| Code: |
MIDDLE=JEFFERSON FIRST=GEORGE LAST=WASHINGTON LOSS=152.03-
FIRST=SPACE LAST=SHIP |
Output:
| Code: |
GEORGE JEFFERSON WASHINGTON 152.03-
SPACE SHIP 0.00+ |
The article is indeed very good, as it shows some powerful use of PARSE, and trickier to follow without the examples.
I've included a link to this in the comments part of the article. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
There is a way to use ABSPOS=1, discussed by Frank Yaeger in the article, for the final example, so that the PARSE can be done only once:
| Code: |
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:
C' FIRST= ',
C' LAST= ',
C' MIDDLE= ',
C' PROFIT= ',
C' LOSS= ')),
IFTHEN=(WHEN=INIT,
PARSE=(%1=(STARTAFT=C'FIRST=',
ABSPOS=1,
ENDBEFR=C' ',FIXLEN=8),
%2=(STARTAFT=C'MIDDLE=',
ABSPOS=1,
ENDBEFR=C' ',FIXLEN=12),
%3=(STARTAFT=C'LAST=',
ABSPOS=1,
ENDBEFR=C' ',FIXLEN=12),
%4=(STARTAFT=C'PROFIT=',
ABSPOS=1,
STARTAFT=C'LOSS=',
ENDBEFR=C' ',FIXLEN=7))),
IFTHEN=(WHEN=INIT,
BUILD=(%01,
%02,
%03,
%04,
SFF,
EDIT=(IIT.TTS),
SIGNS=(,,+,-)))
SORT FIELDS=COPY |
The code ensures that a parameter will always be found, even if not existing in the source data, by adding all the valid parameters to the end of each record.
In itself, not especially useful, but it is a very convenient way to set default values for keyword-field parsing.
| Code: |
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:
C' FIRST=JOE ',
C' LAST=BLOGS ',
C' MIDDLE=X ',
C' PROFIT=+30.00 ',
C' LOSS= ')),
IFTHEN=(WHEN=INIT,
PARSE=(%1=(STARTAFT=C'FIRST=',
ABSPOS=1,
ENDBEFR=C' ',FIXLEN=8),
%2=(STARTAFT=C'MIDDLE=',
ABSPOS=1,
ENDBEFR=C' ',FIXLEN=12),
%3=(STARTAFT=C'LAST=',
ABSPOS=1,
ENDBEFR=C' ',FIXLEN=12),
%4=(STARTAFT=C'PROFIT=',
ABSPOS=1,
STARTAFT=C'LOSS=',
ENDBEFR=C' ',FIXLEN=7))),
IFTHEN=(WHEN=INIT,
BUILD=(%01,
%02,
%03,
%04,
SFF,
EDIT=(IIT.TTS),
SIGNS=(,,+,-)))
SORT FIELDS=COPY
|
The actual example doesn't lend itself to defaults as such, but serves. Here is the output from a blank line of input:
It's also a good example for the use of DFSORT symbols/SYMNAMES... |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|