SORT INREC OUTREC OVERLAY - Adding sequential numbers
Moderators: Frank Yaeger, DikDude, Moderator Group
SORT INREC OUTREC OVERLAY - Adding sequential numbers
Hi,
I have a PS file(500 record length) it contains 200 records, by using sort control card I have coded like this.
//sysin dd *
sort fields=copy
outrec fields=(1:1,500,501:seqnum,3,ZD)
/*
Output I am getting like below.
001
002
003
004
005 and so.....
but I need the output like below
1
2
3
4
5 and so on....for 200 records.
Please provide me a solution. Thanks.
Regards,
Venky.
I have a PS file(500 record length) it contains 200 records, by using sort control card I have coded like this.
//sysin dd *
sort fields=copy
outrec fields=(1:1,500,501:seqnum,3,ZD)
/*
Output I am getting like below.
001
002
003
004
005 and so.....
but I need the output like below
1
2
3
4
5 and so on....for 200 records.
Please provide me a solution. Thanks.
Regards,
Venky.
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Code: Select all
INREC OVERLAY=(501:SEQNUM,3,ZD)
You want it instead leading-zero suppressed and left-justified? Look at SQZ in the manaul.
- dbzTHEdinosauer
- Moderator
- Posts: 981
- Joined: Mon Oct 02, 2006 8:31 pm
because then there is an opportunity to post a request on how toDikDude wrote:Why does someone believe the "number" should be zero suppressed rather than naturallly aligned as you are getting?
sort left-justified/zero-suppressed numeric data.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
Thanks Willams,
I have used SQZ function as below.
OUTREC FIELDS=(1,500,501,3,SQZ=(SHIFT=LEFT,PREBLANK=C'0'))
the preblank is replacing zeros with spaces in postion 501 with length 3 as per the outrec positions.
input:
001
002
003
004
005
006
007
008
010
I am getting the output:
1
2
3
4
5
6
7
8
9
1
but I need only leading zeros should become spaces and make left allign
Output I need:
1
2
3
4
5
6
7
8
9
10
Please let me know this can be done.?
thanks once again.
Regards,
Venky
I have used SQZ function as below.
OUTREC FIELDS=(1,500,501,3,SQZ=(SHIFT=LEFT,PREBLANK=C'0'))
the preblank is replacing zeros with spaces in postion 501 with length 3 as per the outrec positions.
input:
001
002
003
004
005
006
007
008
010
I am getting the output:
1
2
3
4
5
6
7
8
9
1
but I need only leading zeros should become spaces and make left allign
Output I need:
1
2
3
4
5
6
7
8
9
10
Please let me know this can be done.?
thanks once again.
Regards,
Venky
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
venky, your latest question and the one at the start of this thread seems different, if you've new question - please remember to start a new thread.
For the latest question, this is one way of doing it:
Okay, this might not be the efficient one, because of the passes...
For the latest question, this is one way of doing it:
Code: Select all
//SORTIN DD *
001
002
003
004
005
006
007
008
010
//SYSIN DD *
OPTION COPY
INREC FIELDS=(1,3,SFF)
OUTREC BUILD=(1,3,JFY=(SHIFT=LEFT))
//*
Regards,
Anuj
Anuj
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Anuj,
Don't worry about passes here.
INREC, OUTREC and OUTFIL all take place in one pass of the data, just at different points.
INREC, before any sorting, OUTREC after any sorting, OUTFIL as records written.
With a COPY, the three will take place serially, repeatedly.
There's a nice explanation in the DFSORT manual of how all of such things hang together.
SFF is a nice thought. Might get a chance to "streamline" it later
Don't worry about passes here.
INREC, OUTREC and OUTFIL all take place in one pass of the data, just at different points.
INREC, before any sorting, OUTREC after any sorting, OUTFIL as records written.
With a COPY, the three will take place serially, repeatedly.
There's a nice explanation in the DFSORT manual of how all of such things hang together.
SFF is a nice thought. Might get a chance to "streamline" it later
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
A little late, but here it is in one OVERLAY.
OVERLAY allows you to change the same position more than once, so here changed three times: added as SEQNUM; sourced from where the SEQNUM was placed, but defined as UFF (a little more descriptive than Anuj's original idea) so that leading zeros are replaced by space; use JFY to left justify the number, again at the same location.
Output is:
Code: Select all
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(5:SEQNUM,3,ZD,
5:5,3,UFF,
5:5,3,JFY=(SHIFT=LEFT))
//SORTIN DD *
001
002
003
004
005
006
007
008
009
010
X
Y
Z
Output is:
Code: Select all
001 1
002 2
003 3
004 4
005 5
006 6
007 7
008 8
009 9
010 10
X 11
Y 12
Z 13
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
That's OK. The SFF (UFF) was your idea
It is also a good example for SYMNAMES, I think.
Don't have to keep repeating the column number, and an aide memoire as to why UFF is used.
It is also a good example for SYMNAMES, I think.
Code: Select all
//STEP0100 EXEC PGM=SORT
//SYMNAMES DD *
OVERLAY-SEQ,5,3,CH
OVERLAY-SEQ-LEADING-BLANKS,=,=,UFF
OVERLAY-SEQ-COL,=
//SYMNOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(OVERLAY-SEQ-COL:
SEQNUM,3,ZD,
OVERLAY-SEQ-COL:
OVERLAY-SEQ-LEADING-BLANKS,
OVERLAY-SEQ-COL:
OVERLAY-SEQ,JFY=(SHIFT=LEFT))
//SORTIN DD *
001
002
003
004
005
006
007
008
009
010
X
Y
Z
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
You’re very generous, appreciate that.
Interestingly, thiswith SYNCSORT FOR Z/OS 1.3.2.2R and with DFsort (ICE201I H RECORD TYPE IS F ) it generated:
Do you notice "UFF" did not 'show-up' in the generated 'card'. I'm experimenting with it, however, I thought I'll share it with you before I leave for the day.
Interestingly, this
Code: Select all
********************************* TOP OF DATA **********************************
****** SYMNAMES SYMBOL STATEMENTS ******
OVERLAY-SEQ,5,3
OVERLAY-SEQ-LEADING-BLANKS,5,3,UFF
OVERLAY-SEQ-COL,5
********** SYMBOL DEFINITIONS **********
OVERLAY-SEQ,5,3
OVERLAY-SEQ-LEADING-BLANKS,5,3,UFF
OVERLAY-SEQ-COL,5
******************************** BOTTOM OF DATA ********************************
Code: Select all
DATA DICTIONARY SYMBOLS SUBSTITUTED :
OPTION COPY
INREC OVERLAY=(5:SEQNUM,3,ZD,5:5,3,5:5,3,JFY=(SHIFT=LEFT))
Regards,
Anuj
Anuj
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Well, that gives me one of those "I wish I'd not purged that output" moments.
It shouldn't work as I coded it. In the OVERLAY, the SYMANES processing is only going to take the start position and length. To get the conversion, you have to be specific with the UFF. Apologies for that. Thanks for the spot.
I can only imagine I "looked" at the output before it was available in the queue, so looked at the previous hand-coded one Can no longer verify
So:
Gives this output:
It shouldn't work as I coded it. In the OVERLAY, the SYMANES processing is only going to take the start position and length. To get the conversion, you have to be specific with the UFF. Apologies for that. Thanks for the spot.
I can only imagine I "looked" at the output before it was available in the queue, so looked at the previous hand-coded one Can no longer verify
So:
Code: Select all
//STEP0100 EXEC PGM=SORT
//SYMNAMES DD *
OVERLAY-SEQ,5,3,CH
OVERLAY-SEQ-COL,=
//SYMNOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(OVERLAY-SEQ-COL:
SEQNUM,3,ZD,
OVERLAY-SEQ-COL:
OVERLAY-SEQ,UFF, /* TO REMOVE LEADING ZEROS
OVERLAY-SEQ-COL:
OVERLAY-SEQ,JFY=(SHIFT=LEFT))
//SORTIN DD *
001
002
003
004
005
006
007
008
009
010
X
Y
Z
Code: Select all
001 1
002 2
003 3
004 4
005 5
006 6
007 7
008 8
009 9
010 10
X 11
Y 12
Z 13
Bingo! Something I have been trying to figure out all day. I have no problems doing this in SAS, but SAS is slow with sorting large files. Is there no way to sort left justified zero suppressed numeric data?dbzTHEdinosauer wrote:because then there is an opportunity to post a request on how toDikDude wrote:Why does someone believe the "number" should be zero suppressed rather than naturallly aligned as you are getting?
sort left-justified/zero-suppressed numeric data.
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page