|
View previous topic :: View next topic
|
| Author |
Message |
jzhardy
Active User
Joined: 31 Oct 2006 Posts: 150 Location: brisbane
|
|
|
|
Asking this more out of academic interest as I have a plan B (REXX)
I have a requirement to split an input file into an output file + (NEW) Input file.
eg, INPUT1:
| Code: |
1,2,3
4 5 6 7
12 24 ,45
66 77
777
... |
OUTPUT1 (first N records, formatted) - suppose N = 2 for simplicity
| Code: |
// ,1,2,3 //
// ,4 ,5 ,6 ,7 // |
==>INPUT1 (remainer, but unformatted)
| Code: |
12 24 ,45
66 77
777
... |
Input records sometimes have space separators, sometimes commas, sometimes a mix.
My solution is :
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=<some DSN>
//SORTOUT1 DD DSN=&&SRTOUT,DISP=(,PASS)
//SORTOUT2 DD DISP=OLD,DSN=<some DSN>
//SYSIN DD *
OPTION COPY
OMIT COND=(1,80,CH,EQ,C' ')
OUTFIL FNAMES=SORTOUT1,ACCEPT=10
OUTFIL FNAMES=SORTOUT2,SAVE
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&SRTOUT,DISP=(SHR,PASS)
//SORTOUT DD DSN=<another DSN>,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(3,2),RLSE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//SYSIN DD *
OPTION COPY
OUTREC FIELDS=(1,80,SQZ=(SHIFT=LEFT,
PREBLANK=C',',LEAD=C'// ,',MID=C',',TRAIL=C' //'))
//* |
1\
can this be collapsed into one step ? The SAVE records are implicitly formatted, and I can't see an obvious way to switch that behaviour off.
2\
Ideally what I'd really like is to split based on a tally of numbers rather than an arbitrary record count (10 in the example above). Some records in the INPUT dataset might have just one number; others may have up to 8. i'd like to break when the tally exceeds a limit (say, 100).
I can do this in REXX which is my fallback. |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1430 Location: Bamberg, Germany
|
|
|
|
| Even if you specify SAVE keyword for an OUTFIL, you can still apply formatting. |
|
| Back to top |
|
 |
jzhardy
Active User
Joined: 31 Oct 2006 Posts: 150 Location: brisbane
|
|
|
|
that's correct, which is why I don't think this can be reduced to a single step, at least not elegantly.
When I tried this as one step, I found that formats were applied across both OUTFILEs. I want only the first N records to have formats applied (==>OUTFILE1); but no formats applied into (OUTFILE2 ==> INPUT)
In terms of part (2), I could have rephrased the problem better as : split after N commas have been applied. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2272 Location: USA
|
|
|
|
| Code: |
. . . . . .
//SYSIN DD *
OPTION COPY
OMIT COND=(1,80,CH,EQ,C' ')
OUTFIL FNAMES=SORTOUT1,ACCEPT=10,
BUILD=(format part 1)
OUTFIL FNAMES=SORTOUT2,SAVE,
BUILD=(format part 2)
//*
. . . . . . . . . . |
|
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1430 Location: Bamberg, Germany
|
|
|
|
| sergeyken wrote: |
| Code: |
. . . . . .
//SYSIN DD *
OPTION COPY
OMIT COND=(1,80,CH,EQ,C' ')
OUTFIL FNAMES=SORTOUT1,ACCEPT=10,
BUILD=(format part 1)
OUTFIL FNAMES=SORTOUT2,SAVE,
BUILD=(format part 2)
//*
. . . . . . . . . . |
|
What I meant, but didn't dare to write.  |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2272 Location: USA
|
|
|
|
| Joerg.Findeisen wrote: |
| sergeyken wrote: |
| Code: |
. . . . . .
//SYSIN DD *
OPTION COPY
OMIT COND=(1,80,CH,EQ,C' ')
OUTFIL FNAMES=SORTOUT1,ACCEPT=10,
BUILD=(format part 1)
OUTFIL FNAMES=SORTOUT2,SAVE,
BUILD=(format part 2)
//*
. . . . . . . . . . |
|
What I meant, but didn't dare to write.  |
Nowadays IT experts do not understand any hints, besides copy-and-paste examples. It makes me crazy...  |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1430 Location: Bamberg, Germany
|
|
|
|
| I treasure your expertise. I miss that since my colleague has retired. |
|
| Back to top |
|
 |
jzhardy
Active User
Joined: 31 Oct 2006 Posts: 150 Location: brisbane
|
|
|
|
thanks, yes that works fine
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1 2, 4
4 5 6 7 555
333 444 666
23456
3333 4444
/*
//SORTOUT1 DD SYSOUT=*
//SORTOUT2 DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OMIT COND=(1,80,CH,EQ,C' ')
OUTFIL FNAMES=SORTOUT1,ACCEPT=2,
BUILD=(1,80,SQZ=(SHIFT=LEFT,
PREBLANK=C',',LEAD=C'// ,',MID=C',',TRAIL=C' //'))
OUTFIL FNAMES=SORTOUT2,SAVE,
BUILD=(1:1,80)
//* |
yields:
SORTOUT1:
| Code: |
// ,1,2,4 //
// ,4,5,6,7,555 // |
SORTOUT2:
| Code: |
333 444 666
23456
3333 4444 |
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|