MEMBER NAME xxxx
-------
-------
some date
--------
-------
MEMBER NAME yyyyy
-------
-------
some date
--------
-------
MEMBER NAME zzzzz
-------
-------
some date
--------
-------
I want to search for "MEMBER NAME" get the member name "xxxx" update the same in position 72 to 80. Updation must take place till the next member is encountered.
Ones next "member name" is encountered, -- my next member is "yyyyy". Similarly "yyyyy" Must get fill the same "yyyyy" in 72 to 80 column.
My input is
MEMBER NAME xxxx
-------
-------
some date
--------
-------
MEMBER NAME yyyyy
-------
-------
some date
--------
-------
output expected is
72 80
-----------------------------------------+
MEMBER NAME xxxx xxxx
------- xxxx
------- xxxx
some date xxxx
-------- xxxx
------- xxxx
MEMBER NAME yyyyy yyyyy
------- yyyyy
------- yyyyy
some date yyyyy
-------- yyyyy
------- yyyyy
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
vpr_118,
The following DFSORT/ICETOOL JCL will give you the desired results. I assumed that your input is 80 bytes FB recfm and the member name stars in pos 13 for 8 bytes
Code:
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
MEMBER NAME XXXX
-------
-------
SOME DATE
--------
-------
MEMBER NAME YYYYY
-------
-------
SOME DATE
--------
-------
//OUT DD SYSOUT=*
//TOOLIN DD *
SPLICE FROM(IN) TO(OUT) ON(81,8,CH) KEEPNODUPS WITHALL -
WITH(1,80) KEEPBASE USING(CTL1)
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,6,CH,EQ,C'MEMBER'),OVERLAY=(81:SEQNUM,8,ZD,13,8)),
IFTHEN=(WHEN=NONE,OVERLAY=(89:SEQNUM,8,ZD,
81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
And, why we are overlaying below WHEN=NONE condition. Are we trying to build from starting postion 89 also. Please explain why?
Why are we buliding 1,72,89,8
IFTHEN=(WHEN=NONE,OVERLAY=(89:SEQNUM,8,ZD,
81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
SORT FIELDS=COPY
OUTFIL FNAMES=OUT,BUILD=(1,72,89,8)
It will really help me understand the code.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
vpr_118,
Run the following job and browse the contents in position 81 thru 96 and it will answer your queries. The splice operator take the header record and appends it to all the records
Code:
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
MEMBER NAME XXXX
-------
-------
SOME DATE
--------
-------
MEMBER NAME YYYYY
-------
-------
SOME DATE
--------
-------
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,6,CH,EQ,C'MEMBER'),OVERLAY=(81:SEQNUM,8,ZD,13,8)),
IFTHEN=(WHEN=NONE,OVERLAY=(89:SEQNUM,8,ZD,
81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
What i understand is, when the condition is satifisfied, sequence number are written in position 89 (+ 8 bytes) . But we have charactes in 89th (+8 bytes) postion.
Also after that the sequence number is 81st position is subtracted from that present in 89th postion.
Here is what we will get after the none gets executed:-
00000001XXXX
0000000100000001
0000000100000002
0000000100000003
0000000100000004
0000000100000005
00000002YYYYY
0000000200000006
0000000200000007
0000000200000008
0000000200000009
0000000200000010
Quote:
Also after that the sequence number is 81st position is subtracted from that present in 89th postion
When we encounter the string MEMBER at position 1,we are starting the seqnum once again and also put the 8 bytes of the desired string at the end at pos 89.
This is where we exactly get the grouping. This a 2 part explanation. first we start another sequence numbering at pos 89 , but it will skip sequence numbers for the search strings. (when=NONE means that none of the above IF conditions are satisified.)
so for the header record you will not see a seqnum and the next lines are off a by a number. So now subtract these 2 numbers from each other to create the group.
Once we create the grouping then we use SPLICE to the put the header name on all records
Finally, we will have the desired string (i.e. string in 13th position when string member is encountered) in 89th position..
Will the string get overlayed in all the lines or records till the next string "member" is encounterd?
1) But when we subtract (for WHEN=NONE condition) we have string in 89th position. Will it ignore the subtraction.?
When i ran this, My output had string in 13th position @ 89th postion in all the lines.
My doubt is when point (1) is encountered...it is trying to overlay 89th postion with seq number. Our string as obtained from previous condition must have got overlayed with sequence number.
But still we have the sequence number @ 89th position.
also when subtraction of the seq numbers in 81st and 89th postion takes place, where does the result gets stored ? in 81st postion or 89th?