MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
Gerd Hofmans Beginner Joined: 15 Jan 2016 Posts: 20 Topics: 7
Posted: Mon Jan 25, 2016 8:37 am Post subject: How to properly parse and test the parsed field
Input
Code:
-6----+----7----+----8----+----9----+---
A5207 012
02603712 012
04302109 012
03938288 012
04594116 012
04722592 012
04739675 012
04800575 012
2150 012
02415578 012
464089 012
00464089 012
08951C 012
05099328 012
4683828 012
04683828 012
04759945 012
047BD17 012
04947152 012
03864444 012
0442 012
FC0192 012
2491180 012
01761823 012
Output
Code:
-6----+----7----+----8----+----9----+---
A0005207 012
02603712 012
04302109 012
03938288 012
04594116 012
04722592 012
04739675 012
04800575 012
00002150 012
02415578 012
00464089 012
00464089 012
0008951C 012
05099328 012
04683828 012
04683828 012
04759945 012
0047BD17 012
04947152 012
03864444 012
00000442 012
FC000192 012
02491180 012
01761823 012
if 90,3,CH,EQ,C'012' then i need to parse, test and modify the field in position 60 with a length of 8.
i am stuck, any suggestions?
Kind Regards, Gerd.
[/code]
Back to top
William Collins Supermod Joined: 03 Jun 2012 Posts: 437 Topics: 0
Posted: Mon Jan 25, 2016 10:11 am Post subject:
Nice test data
So you can have leading, trailing or embedded non-numerics.
Leading non-numerics stay where they are with the numerics that following right-justified and left-zero-filled if necessary.
Embedded non-numerics and trailing non-numerics and entirely numeric (apart from trailing spaces) just get right-justified and left zero-filled.
Is that about it?
Back to top
Gerd Hofmans Beginner Joined: 15 Jan 2016 Posts: 20 Topics: 7
Posted: Mon Jan 25, 2016 10:28 am Post subject:
unfortunately, yes, that's the case.
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Mon Jan 25, 2016 10:30 am Post subject:
Gerd Hofmans ,
Can your data at position 60 have the following data?
Code:
----+---
AB C F1
C HH
and do you populate the spaces with zeroes as follows?
Code:
----+---
AB0C0F01
C0000HH0
_________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
Gerd Hofmans Beginner Joined: 15 Jan 2016 Posts: 20 Topics: 7
Posted: Mon Jan 25, 2016 10:41 am Post subject:
Hi, the data (field 60,8 ) does not include spaces. If the non-numeric data is at the left, then, if the whole length is LT 8, pad after the non-numeric data with zeroes, so shift the numeric portion right and include leading zeroes. If the data is numeric, then write it as EDIT=(TTTTTTTT).
Kind Regards, Gerd.
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Mon Jan 25, 2016 10:47 am Post subject:
Gerd Hofmans ,
Yikes, just realized that you have imbedded character data. So ignore my earlier solution. _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Mon Jan 25, 2016 10:56 am Post subject:
Gerd Hofmans ,
Assuming your input LRECL is 100(change the value in IFOUTLEN=n if it is different) and RECFM=FB and you are running DFSORT V2R1, use the following DFSORT control cards
Code:
//SYSIN DD *
OPTION COPY
ALTSEQ CODE=(40F0)
INREC IFOUTLEN=100,
IFTHEN=(WHEN=(90,3,CH,EQ,C'012'),
PARSE=(%01=(ABSPOS=60,ENDBEFR=NUM,ENDBEFR=C' ',FIXLEN=8),
%02=(SUBPOS=1,ENDBEFR=C' ',FIXLEN=8)),
OVERLAY=(101:%01,
109:%02,JFY=(SHIFT=RIGHT),
109:109,8,TRAN=ALTSEQ),HIT=NEXT),
IFTHEN=(WHEN=(101,1,CH,NE,C' '),OVERLAY=(109:X),HIT=NEXT),
IFTHEN=(WHEN=(102,1,CH,NE,C' '),OVERLAY=(110:X),HIT=NEXT),
IFTHEN=(WHEN=(103,1,CH,NE,C' '),OVERLAY=(111:X),HIT=NEXT),
IFTHEN=(WHEN=(104,1,CH,NE,C' '),OVERLAY=(112:X),HIT=NEXT),
IFTHEN=(WHEN=(105,1,CH,NE,C' '),OVERLAY=(113:X),HIT=NEXT),
IFTHEN=(WHEN=(106,1,CH,NE,C' '),OVERLAY=(114:X),HIT=NEXT),
IFTHEN=(WHEN=(107,1,CH,NE,C' '),OVERLAY=(115:X),HIT=NEXT),
IFTHEN=(WHEN=(108,1,CH,NE,C' '),OVERLAY=(116:X),HIT=NEXT),
IFTHEN=(WHEN=(90,3,CH,EQ,C'012'),
OVERLAY=(60:101,16,SQZ=(SHIFT=LEFT,LENGTH=8)))
//*
If you are running an older version that does NOT support ENDBEFR=NUM, then you need to specify multiple ENDBEFR's to parse the numeric data in the first IFTHEN statment like this
Code:
IFTHEN=(WHEN=(90,3,CH,EQ,C'012'),
PARSE=(%01=(ABSPOS=60,FIXLEN=8,ENDBEFR=C' ',
ENDBEFR=C'0',ENDBEFR=C'1',
ENDBEFR=C'2',ENDBEFR=C'3',
ENDBEFR=C'4',ENDBEFR=C'5',
ENDBEFR=C'6',ENDBEFR=C'7',
ENDBEFR=C'8',ENDBEFR=C'9'),
%02=(SUBPOS=1,ENDBEFR=C' ',FIXLEN=8)),
OVERLAY=(101:%01,
109:%02,JFY=(SHIFT=RIGHT),
109:109,8,TRAN=ALTSEQ),HIT=NEXT),
Edit : Added SUBPOS=1 on %02 as it will skip the significant digit. Thanks Bill _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
William Collins Supermod Joined: 03 Jun 2012 Posts: 437 Topics: 0
Posted: Mon Jan 25, 2016 7:25 pm Post subject:
Here's my reformatting of the first part of Kolusu's second answer, and an alternative ending.
Because the original leading alphabetics can be used as the start of the data, and because the first PARSEd field can indicate the length (by number of trailing blanks) of the right-just-left-zero-filled field, use those facts to fill in the original data from the second PARSEd field after it has been adjusted suitably.
The use of ALTSEQ for the change is a fairly recent invention of Kolusu's. Prior to that, FINDREP would probably have been used.
Code: OPTION COPY
ALTSEQ CODE=(40F0)
INREC IFOUTLEN=100,
IFTHEN=(WHEN=(91,3,CH,EQ,C'012'),
PARSE=(%01=(ABSPOS=60,
FIXLEN=8,
ENDBEFR=C' ',
ENDBEFR=C'0',ENDBEFR=C'1',
ENDBEFR=C'2',ENDBEFR=C'3',
ENDBEFR=C'4',ENDBEFR=C'5',
ENDBEFR=C'6',ENDBEFR=C'7',
ENDBEFR=C'8',ENDBEFR=C'9'),
%02=(ENDBEFR=C' ',
FIXLEN=8,
SUBPOS=1)),
OVERLAY=(101:%01,
109:%02,
JFY=(SHIFT=RIGHT),
109:109,8,
TRAN=ALTSEQ),
HIT=NEXT),
IFTHEN=(WHEN=(101,8,CH,EQ,C' '),
OVERLAY=(60:109,8)),
IFTHEN=(WHEN=(102,7,CH,EQ,C' '),
OVERLAY=(61:110,7)),
IFTHEN=(WHEN=(103,6,CH,EQ,C' '),
OVERLAY=(62:111,6)),
IFTHEN=(WHEN=(104,5,CH,EQ,C' '),
OVERLAY=(63:112,5)),
IFTHEN=(WHEN=(105,4,CH,EQ,C' '),
OVERLAY=(64:113,4)),
IFTHEN=(WHEN=(106,3,CH,EQ,C' '),
OVERLAY=(65:114,3)),
IFTHEN=(WHEN=(107,2,CH,EQ,C' '),
OVERLAY=(66:115,2)),
IFTHEN=(WHEN=(108,1,CH,EQ,C' '),
OVERLAY=(67:116,1))
I tested with data in position 1 and 31, so apologies for any typos relating to that. Last edited by William Collins on Tue Jan 26, 2016 4:37 am; edited 1 time in total
Back to top
Gerd Hofmans Beginner Joined: 15 Jan 2016 Posts: 20 Topics: 7
Posted: Tue Jan 26, 2016 1:50 am Post subject:
Many thanks for these very nice solutions, not only the code but also the logic!
Ofcourse this is working
It's part of a bigger conversion logic where a 4th gen language is replaced by DFSORT.
By doing so, i also need to replace some functions that are handled within the program logic, and sometimes, this is not that easy. Ofcourse for wizards like you it seems extremely easy.
Your help has made it easier for me and i learn to dfsort the right way.
Kind Regards, Gerd.
Back to top
William Collins Supermod Joined: 03 Jun 2012 Posts: 437 Topics: 0
Posted: Tue Jan 26, 2016 11:31 am Post subject:
Mine isn't quite as working as would be desired
Not having Kolusu's second test for 012, it will mash any record that isn't a 012.
So here's a working version using symbols/SYMNAMES
Include this DD in the step:
Referencing this data:
Code: INPUT-RECORD,*,100,CH
* INSERT SKIP HERE
INPUT-FIELD-TO-MESS-WITH,=,8,CH
SKIP,22
INPUT-TEST-TO-CHANGE,*,3,CH
SKIP,67
EXT-LEADING-ALPHA,*,8,CH
EXT-NOW-FORMATTED-FIELD,=,=,=
POSITION,EXT-LEADING-ALPHA
SKIP,1
ELA-2-L-7,*,7,CH
POSITION,EXT-LEADING-ALPHA
SKIP,2
ELA-3-L-6,*,6,CH
POSITION,EXT-LEADING-ALPHA
SKIP,3
ELA-4-L-5,*,5,CH
POSITION,EXT-LEADING-ALPHA
SKIP,4
ELA-5-L-4,*,4,CH
POSITION,EXT-LEADING-ALPHA
SKIP,5
ELA-6-L-3,*,3,CH
POSITION,EXT-LEADING-ALPHA
SKIP,6
ELA-7-L-2,*,2,CH
POSITION,EXT-LEADING-ALPHA
SKIP,7
ELA-8-L-1,*,1,CH
EXT-OTHER-DATA-LEFT-JUST,*,8,CH
EXT-OTHER-DATA-RIGHT-JUST,=,8,CH
POSITION,EXT-OTHER-DATA-RIGHT-JUST
SKIP,1
EODRJ-2-L-7,*,7,CH
POSITION,EXT-OTHER-DATA-RIGHT-JUST
SKIP,2
EODRJ-3-L-6,*,6,CH
POSITION,EXT-OTHER-DATA-RIGHT-JUST
SKIP,3
EODRJ-4-L-5,*,5,CH
POSITION,EXT-OTHER-DAT
SKIP,4
EODRJ-5-L-4,*,4,CH
POSITION,EXT-OTHER-DAT
SKIP,5
EODRJ-6-L-3,*,3,CH
POSITION,EXT-OTHER-DAT
SKIP,6
EODRJ-7-L-2,*,2,CH
POSITION,EXT-OTHER-DAT
SKIP,7
EODRJ-8-L-1,*,1,CH
LEADING-ALPHA,%01
OTHER-DATA-LEFT-JUST,%02
RECORD-TO-CHANGE,C'012'
Also include this one:
Code: //SYMNOUT DD SYSOUT=yourpreference
Then the code looks like this:
Code: OPTION COPY
ALTSEQ CODE=(40F0)
INREC IFOUTLEN=150,
IFTHEN=(WHEN=(INPUT-TEST-TO-CHANGE,
EQ,
RECORD-TO-C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-1,EQ,TRAILING-BLANKS),
OVERLAY=(ELA-8-L-1:
EODRJ-8-L-1),
HIT=NEXT),
IFTHEN=(WHEN=(INPUT-TEST-TO-CHANGE,
EQ,
RECORD-TO-CHANGE),
OVERLAY=(INPUT-FIELD-TO-MESS-WITH:
EXT-NOW-FORMATTED-FIELD))
One advantage of symbols is documentary: code can be "read" with more meaning, and written with fewer typos.
Another is the ease of changing things. I tested with data in 1,8 and the 012 in 30,3.
To change back to the original, add a SKIP where indicated, change the SKIP before the 012 code, and change the ABSPOS on the PARSE.
Since I don't like multiple HIT=NEXT when avoidable, this type of thing is also possible:
Code:
IFTHEN=(WHEN=((INPUT-TEST-TO-CHANGE,
EQ,
RECORD-TO-CHANGE),
AND,
(EXT-LEADING-ALPHA,EQ,NO-VALUE)),
OVERLAY=(EXT-LEADING-ALPHA:
EXT-OTHER-DATA-RIGHT-JUST,
INPUT-FIELD-TO-MESS-WITH:
EXT-NOW-FORMATTED-FIELD))
Back to top
misi01 Advanced Joined: 02 Dec 2002 Posts: 629 Topics: 176 Location: Stockholm, Sweden
Posted: Wed Mar 02, 2016 3:29 am Post subject:
Gerd. Okay, so I don't know from where the original test data came (how it was created), I'm left wondering whether it wouldn't be easier (if possible) to change the results "at source". _________________ Michael
Back to top
Gerd Hofmans Beginner Joined: 15 Jan 2016 Posts: 20 Topics: 7
Posted: Wed Mar 02, 2016 7:23 am Post subject:
Hi, i can see your suggestion, but these are external production files. It is not possible to change them, that's why it takes a lot of effort to make them useable. Thanks for your concern.
Cheers, Gerd.
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum