|
View previous topic :: View next topic
|
| Author |
Message |
anatol
Active User
Joined: 20 May 2010 Posts: 121 Location: canada
|
|
|
|
I have file:
20 read
10 write
15 skip
Output should be:
20 read
10 write
25 skip
The skip is 20(read)-10(write) + 15(skip) = 25 . is it possible? Thanks. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Is that it for the entire file? If not, show something representative and expected output.
Assuming that is it, you need WHEN=GROUP for 'read' and PUSH the 1,2 for the count to an extension of the record, RECORDS=3. WHEN=GROUP for 'write', PUSH 1,2 to a different place. WHEN=(logical expression) for 'skip' and calculate with 1,2 and the two PUSHed values. |
|
| Back to top |
|
 |
anatol
Active User
Joined: 20 May 2010 Posts: 121 Location: canada
|
|
|
|
| yes, it is entire file ...ok, I can push 1,2 for read and write ... then I can use ifthen skip, but how I can calculate the result from previous records? |
|
| Back to top |
|
 |
anatol
Active User
Joined: 20 May 2010 Posts: 121 Location: canada
|
|
|
|
| Thanks - it worked |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Glad you've got it.
If you can post the code, it may help someone with a similar tasks. |
|
| Back to top |
|
 |
anatol
Active User
Joined: 20 May 2010 Posts: 121 Location: canada
|
|
|
|
so you think your first sugesstion wasn't enough ( just kidding):
| Code: |
//STEP020 EXEC PGM=ICETOOL,
// PARM='SIZE(MAX),DYNALLOC=(SYSDA,100)'
//IN DD *
20 READ
10 WRITE
15 SKIP
//OUT DD SYSOUT=*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//SYSOUT DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(T1) USING(CTL1)
COPY FROM(T1) TO(OUT) USING(CTL2)
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(5,5,CH,EQ,C'READ '),PUSH=(81:1,2)),
IFTHEN=(WHEN=GROUP,
BEGIN=(5,5,CH,EQ,C'WRITE'),PUSH=(83:1,2)),
IFTHEN=(WHEN=(5,4,CH,EQ,C'SKIP'),
BUILD((81,2,ZD,SUB,83,2,ZD),ADD,01,2,ZD,EDIT=(TT),3,80))
//CTL2CNTL DD *
INREC BUILD=(1,80)
|
output is:
| Code: |
20 READ
10 WRITE
25 SKIP
|
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
This is basically your code from the first CNTL file. To cut back down to 80-byte records, you could have used OUTREC BUILD, or OUTFIL BUILD or you can use IFOUTLEN (the most efficient way to do it) which sets the record-length to the value specified. I've cange your BUILD to OVERLAY, and included the RECORDS= I suggested (not particularly give you much for this task, but gets you used to what they can do).
| Code: |
OPTION COPY
INREC IFOUTLEN=80,
IFTHEN=(WHEN=GROUP,
BEGIN=(5,5,CH,EQ,C'READ '),
RECORDS=3,
PUSH=(81:1,2)),
IFTHEN=(WHEN=GROUP,
BEGIN=(5,5,CH,EQ,C'WRITE'),
RECORDS=2,
PUSH=(83:1,2)),
IFTHEN=(WHEN=(5,4,CH,EQ,C'SKIP'),
OVERLAY=((81,2,ZD,
SUB,83,2,ZD),
ADD,01,2,ZD,
EDIT=(TT))) |
Untested, but should be about there. Make more use of indentation, you'll find things easy to flip around.
Other than choosing ICETOOL rather than SORT you did a fairly good job of implementing what I suggested. This will help you with similar tasks in the future. |
|
| Back to top |
|
 |
anatol
Active User
Joined: 20 May 2010 Posts: 121 Location: canada
|
|
|
|
| wow.... your code so elegant!!!! |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|