Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Creating Volume sequence numbers for Volume records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Jul 09, 2012 8:06 pm    Post subject: Creating Volume sequence numbers for Volume records
Reply with quote

Hi,
I have a dataset which looks like,
Code:
DSN     VOLSER    NEXTVOL
AAAA    V0002      V0003
AAAA    V0001      V0002
AAAA    V0004           
AAAA    V0003      V0004
BBBB    A0001           
BBBB    A0004      A0003
BBBB    A0003      A0002
BBBB    A0002      A0001
BBBB    A0005      A0004
CCCC    K0001           
DDDD    J000B      J000C
DDDD    J000C           
DDDD    J000Z      J000B

The requirement is to create a column VOLSEQ which is volume sequence number.

Output required:

Code:
DSN     VOLSER    NEXTVOL    VOLSEQ
AAAA    V0001      V0002        1
AAAA    V0002      V0003        2
AAAA    V0003      V0004        3
AAAA    V0004                   4
BBBB    A0005      A0004        1
BBBB    A0004      A0003        2
BBBB    A0003      A0002        3
BBBB    A0002      A0001        4
BBBB    A0001                   5
CCCC    K0001                   1
DDDD    J000Z      J000B        1
DDDD    J000B      J000C        2
DDDD    J000C                   3


The logic is,
For DSN = AAA, VOLSER V0004 does not have NEXTVOL, so it is the last VOLSER in the sequence(VOLSEQ=4).
Next, the record
AAAA V0003 V0004
has V0004 as NEXTVOL, so it is the last but first VOLSER in sequence(VOLSEQ=3).

Next, the record
AAAA V0002 V0003
has V0003 as NEXTVOL, so its VOLSEQ=2 and so on..

Could you please let me know how this could be done with DFSORT/REXX/SAS?

The input and output file's 1st record is just for understanding and can be ignored in actual job. the input and output files can be assumed as FB LRECL 80.
Thanks & Regards,
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Jul 09, 2012 8:34 pm    Post subject:
Reply with quote

What about WHEN=GROUP with KEYBEGIN on the DSN and PUSH the SEQ?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Jul 09, 2012 8:52 pm    Post subject:
Reply with quote

Hi Vasanth,

As Bill mentioned, WHEN=GROUP can be your friend.

Suggest that you temporarily replace the "end of group" with all 9's so they will sort to the bottom rather than the top. . . When the output is generated, the blanks can be put back in (or the 9's left to indicate the end).
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Jul 09, 2012 8:57 pm    Post subject:
Reply with quote

There shouldn't be a need to sort the file. The contents of the columns for the volumes is not relevant to the sequence if just OPTION COPY/SORT FIELDS=COPY and simply do an increasing sequence for the records in the group (same DSN).Sortinng on the volumes would loose/make difficult the actual sequence.

I suspect Vasanthz you got too close to the problem through knowing the "next" volume...

Or I'm missing something obvious...
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Jul 09, 2012 9:18 pm    Post subject:
Reply with quote

Hi Bill and D,
Thanks for your time in responding.
Quote:
Sortinng on the volumes would loose/make difficult the actual sequence.

The VOLSER AND NEXTVOL can be in any order, they cannot be sorted.
Example for input.
Code:
DDDD    J1111      J3333
DDDD    J3333           
DDDD    J2222      J1111

the output has to be,
Code:
DDDD    J2222      J1111        1
DDDD    J1111      J3333        2
DDDD    J3333                   3


The source of the records is a snapshot file, which has 1 single record for each volume in which the dataset resides. So the volume names can be arbitrary and cannot be guaranteed to be in sequence.

Hope I clarified things.

Regards,
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Jul 09, 2012 9:52 pm    Post subject:
Reply with quote

vasanthz wrote:

The VOLSER AND NEXTVOL can be in any order, they cannot be sorted.
Example for input.
Code:
DDDD    J1111      J3333
DDDD    J3333           
DDDD    J2222      J1111

the output has to be,
Code:
DDDD    J2222      J1111        1
DDDD    J1111      J3333        2
DDDD    J3333                   3



Without SORTING , how do you plan to arrange the records as if they are sorted?
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Jul 09, 2012 10:05 pm    Post subject:
Reply with quote

Hi Kolusu,

Thanks for your time.

For the set of input records,
Code:
DDDD    J1111      J3333
DDDD    J3333           
DDDD    J2222      J1111


the record
DDDD J3333
does not have NEXTVOL column, so it is has to be the last in the group with VOLSEQ = 3, making required output record as
DDDD J3333 3

Next, for the input record
DDDD J1111 J3333
has J3333(VOLSER from previous record) as NEXTVOL so it has to be VOLSEQ = 2, making the required output record as
DDDD J1111 J3333 2

Next, for the input record
DDDD J2222 J1111
has J1111(VOLSER from previous record) as NEXTVOL, so it has to be
VOLSEQ = 1, so output record is
DDDD J2222 J1111 1

Hope I am not complicating this too much :S

P.S tried using the code tags for records, they look more confusing than as it is now (:
Regards,
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Jul 09, 2012 10:19 pm    Post subject:
Reply with quote

vasantz,

If your intention is to make the Space record the last in the group and assign seq numbers then it is very easy.

Code:

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD *                                     
AAAA    V0002      V0003                             
AAAA    V0001      V0002                             
AAAA    V0004                                       
AAAA    V0003      V0004                             
BBBB    A0001                                       
BBBB    A0004      A0003                             
BBBB    A0003      A0002                             
BBBB    A0002      A0001                             
BBBB    A0005      A0004                             
CCCC    K0001                                       
DDDD    J000B      J000C                             
DDDD    J000C                                       
DDDD    J000Z      J000B                             
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'0')),       
  IFTHEN=(WHEN=(20,5,CH,EQ,C' '),OVERLAY=(81:C'1')) 
  SORT FIELDS=(01,5,CH,A,                           
               81,1,CH,A),EQUALS                     
  OUTREC IFOUTLEN=80,                               
  IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,5),PUSH=(30:SEQ=1))
//*


This will produce
Code:

AAAA    V0002      V0003     1
AAAA    V0001      V0002     2
AAAA    V0003      V0004     3
AAAA    V0004                4

BBBB    A0004      A0003     1
BBBB    A0003      A0002     2
BBBB    A0002      A0001     3
BBBB    A0005      A0004     4
BBBB    A0001                5

CCCC    K0001                1

DDDD    J000B      J000C     1
DDDD    J000Z      J000B     2
DDDD    J000C                3
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Jul 09, 2012 10:34 pm    Post subject:
Reply with quote

Hi Kolusu,
Thanks for the code, but the output records has to be arranged as shown in the attachment.

Hope this makes things clear.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Jul 09, 2012 10:55 pm    Post subject:
Reply with quote

vasanthz,

I guess you are trying to find a relationship chain. I don't think sort would be an ideal choice here. I suggest you code a program for it.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Jul 09, 2012 11:33 pm    Post subject:
Reply with quote

Kolusu, Thanks again for your thoughts.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Jul 10, 2012 5:12 am    Post subject:
Reply with quote

You need to store all your information for one DSN in a table/array. You need to locate the entry fpr which the "next vol" is blank. Assign this the final sequence number. Take the volume from that entry and search for it as "next vol". Reduce the sequence number. Repeat until sequence equals one. Write table/array out. Repeat until end-of-file. Sort file on DSN/sequence.

Apologies for only reading what I thought I saw.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Tue Jul 10, 2012 11:21 am    Post subject:
Reply with quote

Bill, I did write a program with the logic you mentioned(without the array though),
http://ibmmainframes.com/viewtopic.php?t=58798&highlight=
but the program was making more than 4 passes of the same file.

The array idea you mentioned might save some passes of the file and make the program little more efficient. I will try out the array logic.

Regards,
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Jul 10, 2012 11:58 am    Post subject:
Reply with quote

Vasanthz, take a look at the IGGCSIRX code that comes in SYS1.SAMPLIB

It lists volsers in order, and from that you can then arrange the table as required
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Tue Jul 10, 2012 2:04 pm    Post subject:
Reply with quote

Expat, the data is passed to us with many other DSN details in a single file from client LPAR(snapshot from some utility). So I will not be able to change it.

Regards,
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us