IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Creating Volume sequence numbers for Volume records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Mon Jul 09, 2012 8:06 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jul 09, 2012 8:34 pm
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

Moderator Emeritus


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

PostPosted: Mon Jul 09, 2012 8:52 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jul 09, 2012 8:57 pm
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: 1742
Location: Tirupur, India

PostPosted: Mon Jul 09, 2012 9:18 pm
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
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: 1742
Location: Tirupur, India

PostPosted: Mon Jul 09, 2012 10:05 pm
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
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: 1742
Location: Tirupur, India

PostPosted: Mon Jul 09, 2012 10:34 pm
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
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: 1742
Location: Tirupur, India

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

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jul 10, 2012 5:12 am
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: 1742
Location: Tirupur, India

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

Bill, I did write a program with the logic you mentioned(without the array though),
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: 8797
Location: Welsh Wales

PostPosted: Tue Jul 10, 2012 11:58 am
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: 1742
Location: Tirupur, India

PostPosted: Tue Jul 10, 2012 2:04 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top