|
View previous topic :: View next topic
|
| Author |
Message |
Gabriel Araujo Alves
New User
Joined: 20 Jul 2010 Posts: 38 Location: Brazil
|
|
|
|
I have this input,
| Code: |
000000009
000000010
000000011
000000015
000000016
000000017
000000019
000000020
|
and i want this output
| Code: |
000000009 -> 000000011
000000015 -> 000000017
000000019 -> 000000020
|
the first and the last values from a range.
if someone can help. |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Gabriel Araujo Alves,
How do you define range? Any set of consecutive numbers?
RECFM and LRECL of the input file?
Thanks, |
|
| Back to top |
|
 |
Gabriel Araujo Alves
New User
Joined: 20 Jul 2010 Posts: 38 Location: Brazil
|
|
|
|
recfm=fb,lrecl=080
the range is up a break in the numerical sequence. |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Gabriel Araujo Alves,
Thanks for asking this question, just learnt something new about OVERLAY.
Please find below jcl which creates 21 byte output file. If you need output file of different length adjust OUTFIL accordingly.
Out of curiosity, is this requirement an entire picture or just a pixel of it?
| Code: |
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
000000009
000000010
000000011
000000015
000000016
000000017
000000019
000000020
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(21:SEQNUM,9,ZD,
31:1,9,ZD,SUB,21,9,ZD,TO=ZD,LENGTH=9,
41:SEQNUM,9,ZD,RESTART=(31,9))),
IFTHEN=(WHEN=GROUP,BEGIN=(41,9,ZD,EQ,1),PUSH=(51:1,9))
SORT FIELDS=COPY
OUTFIL BUILD=(1,21),
REMOVECC,NODETAIL,
SECTIONS=(31,9,
TRAILER3=(51,9,C'-->',1,9))
//* |
OUTPUT
| Code: |
000000009-->000000011
000000015-->000000017
000000019-->000000020
|
Thanks, |
|
| Back to top |
|
 |
Gabriel Araujo Alves
New User
Joined: 20 Jul 2010 Posts: 38 Location: Brazil
|
|
|
|
thank`s a lot sqlcode1,
i only can test it in monday...
I did not know you can refer to some fields that you just created.
i only did this in 3 steps... an elegant solution, thanks man.
ah, its just a pixel of it, regards... |
|
| Back to top |
|
 |
Gabriel Araujo Alves
New User
Joined: 20 Jul 2010 Posts: 38 Location: Brazil
|
|
|
|
Hi,
sqlcode1, how SECTION works?
i did not understand. if you can explain to me, i1m thankful. |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Gabriel Araujo Alves,
Its not something I can explain here in the forum. Read about Sections here
Thanks, |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Gabriel Araujo Alves,
Looking back at your posts,I just realized I missed your post in which you mentioned your file is FB 80 lrecl.
Please find below corrected jcl which creates 80 byte output file.
| Code: |
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
000000009
000000010
000000011
000000015
000000016
000000017
000000019
000000020
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,9,ZD,
091:1,9,ZD,SUB,81,9,ZD,TO=ZD,LENGTH=9,
101:SEQNUM,9,ZD,RESTART=(91,9))),
IFTHEN=(WHEN=GROUP,BEGIN=(101,9,ZD,EQ,1),PUSH=(111:1,9))
SORT FIELDS=COPY
OUTFIL BUILD=(1,80),
REMOVECC,NODETAIL,
SECTIONS=(91,9,
TRAILER3=(111,9,C'-->',1,9))
//* |
Thanks, |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Good Trick Sqlcode1. You can simplify it
Gabriel Araujo Alves,
The following DFSORT JCL will give you the desired results.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
000000009
000000010
000000011
000000015
000000016
000000017
000000019
000000020
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(11:SEQNUM,9,ZD,21:1,9,ZD,SUB,11,9,ZD,M11,LENGTH=9)
OUTFIL REMOVECC,NODETAIL,BUILD=(80X),
SECTIONS=(21,9,
TRAILER3=(MIN=(1,9,ZD,M11,LENGTH=9),'-->',
MAX=(1,9,ZD,M11,LENGTH=9)))
//* |
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
Use [URL] BBCode for External Links |
|
| Back to top |
|
 |
manuwankenobi
New User

Joined: 02 Mar 2006 Posts: 32 Location: FRANCE
|
|
|
|
Hello experts,
Very nice trick.
I wonder what would be the trick for hexadecimal strings :
| Code: |
//SORTIN DD *
00000200A
00000200B
000002009
000002008
000001009
00000100A
00000100B
00000100C
|
And a result needed :
| Code: |
000001009-->00000100C
000002008-->00000200A
|
Any ideas ?
Thanks. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
manuwankenobi,
With z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026 (Oct,2010), you can now use DFSORT's new TRAN=UNHEX function to get the numeric and then get the range.
The following DFSORT JCL will give you the desired results.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
00000200A
00000200B
000002009
000002008
000001009
00000100A
00000100B
00000100C
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,BUILD=(C'0',1,9)),
IFTHEN=(WHEN=INIT,OVERLAY=(11:1,10,TRAN=UNHEX))
SORT FIELDS=(11,5,BI,A),EQUALS
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(16:SEQNUM,5,BI)),
IFTHEN=(WHEN=INIT,OVERLAY=(21:11,5,BI,SUB,16,5,BI,M11,LENGTH=8)),
IFTHEN=(WHEN=GROUP,KEYBEGIN=(21,8),PUSH=(29:2,9))
OUTFIL REMOVECC,NODETAIL,BUILD=(80X),
SECTIONS=(21,8,TRAILER3=(29,9,'-->',2,9))
//* |
The output from this job is
| Code: |
000001009-->00000100C
000002008-->00000200B
|
For complete details on the new functions for DFSORT and DFSORT's ICETOOL available with the Oct, 2010 PTF, see:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242 |
|
| Back to top |
|
 |
manuwankenobi
New User

Joined: 02 Mar 2006 Posts: 32 Location: FRANCE
|
|
|
|
Thank you very much Skolusu,
I do not have the PTF (will have it in January...).
So with the help of this thread and the help of this other thread :
http://www.ibmmainframeforum.com/viewtopic.php?f=61&t=3068 ,
I tried something that seems to be working :
| Code: |
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
300A
200A
200B
2009
2008
1009
100A
100B
100C
//SORTOUT DD SYSOUT=*
//SYSIN DD *
ALTSEQ CODE=(F000,F101,F202,F303,F404,F505,F606,F707,F808,F909,
C10A,C20B,C30C,C40D,C50E,C60F)
INREC IFTHEN=(WHEN=INIT,OVERLAY=(5:1,4,TRAN=ALTSEQ)),
IFTHEN=(WHEN=INIT,
OVERLAY=(9:(8,1,BI,ADD,
(7,1,BI,MUL,+16),ADD,
(6,1,BI,MUL,+256),ADD,
(5,1,BI,MUL,+4096)),LENGTH=6,ZD))
SORT FIELDS=(9,6,CH,A)
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(15:SEQNUM,6,ZD)),
IFTHEN=(WHEN=INIT,OVERLAY=(21:9,6,ZD,SUB,15,6,ZD,LENGTH=6,ZD)),
IFTHEN=(WHEN=INIT,OVERLAY=(27:SEQNUM,6,ZD,RESTART=(21,6))),
IFTHEN=(WHEN=GROUP,BEGIN=(27,6,ZD,EQ,1),PUSH=(33:1,4))
OUTFIL REMOVECC,NODETAIL,BUILD=(80X),
SECTIONS=(21,6,TRAILER3=(33,4,'-->',1,4))
/* |
The result is :
| Code: |
1009-->100C
2008-->200B
300A-->300A |
 |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|