Home      Mainframe Forum      Mainfarme Tutorials      IBM Manuals      Mainframe Interview Questions      Mainframe Books      IT News     SiteMap     Downloads


     
 
MAINFRAME - TIP OF THE DAY : All available storage is assigned to the job or jobstep, If REGION is coded 0K or 0M

Google
 
Web mainframegurukul.com

SORT INREC OUTREC OVERLAY - Adding sequential numbers

 
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> JCL
  View previous topic :: View next topic  
Author Message
venky
Member


Joined: 12 May 2012
Posts: 49

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Aug 08, 2012 1:35 am    Post subject: SORT INREC OUTREC OVERLAY - Adding sequential numbers Reply with quote

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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.

William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Aug 08, 2012 4:46 am    Post subject: Reply with quote

Code:
  INREC OVERLAY=(501:SEQNUM,3,ZD)


Are you saying you only want a single-digit number? Change the 3 to 1.

You want it instead leading-zero suppressed and left-justified? Look at SQZ in the manaul.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
DikDude
Moderator


Joined: 22 Jul 2011
Posts: 1001
Location: usa

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Aug 08, 2012 6:25 am    Post subject: Reply with quote

Why does someone believe the "number" should be zero suppressed rather than naturallly aligned as you are getting?
_________________
Have a good one
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
dbzTHEdinosauer
Moderator


Joined: 02 Oct 2006
Posts: 975

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Aug 08, 2012 8:15 am    Post subject: Reply with quote

DikDude wrote:
Why does someone believe the "number" should be zero suppressed rather than naturallly aligned as you are getting?


because then there is an opportunity to post a request on how to
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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
venky
Member


Joined: 12 May 2012
Posts: 49

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
2 salutes

PostPosted: Thu Aug 09, 2012 2:37 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Aug 09, 2012 3:34 am    Post subject: Reply with quote

OK. Problem is that all he PREBLANK characters get removed.

Try an EDIT on the sequence number to make it zero-suppressed. The SQZ (or JFY, perhaps better here, actually) the spaces. The trailing zeros will now be unaffected.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Anuj Dhawan
Moderator


Joined: 09 Aug 2008
Posts: 1631
Location: Mumbai, India

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
1 salutes

PostPosted: Thu Aug 09, 2012 4:25 pm    Post subject: Reply with quote

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:

Code:
//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))
//*
Okay, this might not be the efficient one, because of the passes...
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Aug 09, 2012 7:17 pm    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Anuj Dhawan
Moderator


Joined: 09 Aug 2008
Posts: 1631
Location: Mumbai, India

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Aug 10, 2012 9:45 am    Post subject: Reply with quote

Thanks William. I've not been using SORT for a while now, so played safe... Smile

Thanks 'gain for your comments & time,

Regards,
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
1 salutes

PostPosted: Sun Aug 19, 2012 11:53 am    Post subject: Reply with quote

A little late, but here it is in one OVERLAY.

Code:
//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


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:
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
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Anuj Dhawan
Moderator


Joined: 09 Aug 2008
Posts: 1631
Location: Mumbai, India

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Mon Aug 20, 2012 1:30 pm    Post subject: Reply with quote

This is rather neat, Thanks William.
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Tue Aug 21, 2012 5:09 am    Post subject: Reply with quote

That's OK. The SFF (UFF) was your idea Smile

It is also a good example for SYMNAMES, I think.

Code:
//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


Don't have to keep repeating the column number, and an aide memoire as to why UFF is used.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Anuj Dhawan
Moderator


Joined: 09 Aug 2008
Posts: 1631
Location: Mumbai, India

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Tue Aug 21, 2012 7:43 pm    Post subject: Reply with quote

You’re very generous, appreciate that.

Interestingly, this
Code:
********************************* 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 ********************************
with SYNCSORT FOR Z/OS 1.3.2.2R and with DFsort (ICE201I H RECORD TYPE IS F ) it generated:
Code:
DATA DICTIONARY SYMBOLS SUBSTITUTED :                     
OPTION COPY                                               
INREC OVERLAY=(5:SEQNUM,3,ZD,5:5,3,5:5,3,JFY=(SHIFT=LEFT))

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.
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Tue Aug 21, 2012 8:33 pm    Post subject: Reply with quote

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 Sad Can no longer verify Smile

So:

Code:
//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


Gives this output:

Code:
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
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Squashman
Member


Joined: 11 Jul 2009
Posts: 2

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Feb 25, 2015 2:03 am    Post subject: Reply with quote

dbzTHEdinosauer wrote:
DikDude wrote:
Why does someone believe the "number" should be zero suppressed rather than naturallly aligned as you are getting?


because then there is an opportunity to post a request on how to
sort left-justified/zero-suppressed numeric data.

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?
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Display posts from previous:   
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> JCL All times are GMT + 5 Hours
Page 1 of 1



 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Related topics
 Topics   Replies   Author   Views   Last Post 
No new posts Query For IEBPTPCH 3 padmajeet.gaikwad 13445 Mon Feb 01, 2016 10:56 pm
academyindia4 View latest post
No new posts Unable to achieve below scenario using ICETOOL 27 sirianangel 33683 Mon Feb 01, 2016 10:01 pm
academyindia4 View latest post
No new posts Need to put records a Sorting order as mentioned below. 14 Yash1911 12633 Mon Jan 25, 2016 9:50 pm
academyindia4 View latest post
No new posts how to deal with the below scenario using iebgener 7 mainframes_6002 11170 Wed Dec 07, 2011 10:34 am
DikDude View latest post
No new posts Coulu someone explain the parameters in the below code? 1 lovely sweety 11352 Thu Jun 09, 2011 3:50 pm
dbzTHEdinosauer View latest post
 


Cobol Tutorial
This cobol tutorial covers most of the important topics like STRING, UNSTRING, COMP, COMP-3.....
DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. Explains in simple language. Some Chapters are locked, Forum members have free access to these chapters
CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming...
JCL Tutorial
This is most popular JCL tutorial from mainframegurukul. It does contain important jcl ....
SORT Tutorial
This Tutorial covers all important aspects of DFSORT. Has more SORT examples
INTERVIEW Questions
This page covers important interview questions
Mainframe Jobs
Mainframe Jobs posted by members of mainframegurukul forum
FaceBook Page
MainframeGurukul FaceBook Page
LinkedIn Page
MainframeGurkul Linkedin Page

This widget requires Flash Player 9 or better







Go to top of the page
 

Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  DB2 INTERVIEW QUESTIONS ||  COBOL INTERVIEW QUESTIONS  ||  JCL INTERVIEW QUESTIONS ||  JCL2 INTERVIEW QUESTIONS ||  VSAM INTERVIEW QUESTIONS ||  CICS INTERVIEW QUESTIONS  ||  Online tutorials ||  Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  SiteMap  ||  Expeditor Tutorial  ||  FILE-AID Tutorial  ||  Changeman Tutorial  ||  COBOL   ||  DB2   ||  JCL  ||  CICS  ||  VSAM  ||  DB2 Interview Questions ( 110 )   || Simple JCL Tutorials  || JCL Tutorial from MainframeGurukul.com   || Simple JCL Tutorial - Chapter1 ;|| Mainframe Forum - Tutorials  || Mainframe Tutorials || Mainframe CICS tutorial|| Mainframe COBOL Tutorial

Drona Educational Forums - Mainframe Cobol DB2 CICS Board
Powered by phpBB

mainframetopic-6710.html