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
 

 

Position (count) of a record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
shankarm

Active User


Joined: 17 May 2010
Posts: 175
Location: India

PostPosted: Tue Aug 28, 2012 10:27 pm    Post subject: Position (count) of a record
Reply with quote

Hi,

Is it possible to get the position of a particular record using syncsort or any utility?


E.G,

Code:


a
b
c
d
e
f


Position of d in the above file is 4. 'D' is the fourth record, 'e' is the fifth record.

Sorry, if this is a silly question. I tried sum fields but i am able to the number of occurences of a particular record.

Can you help?
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Aug 28, 2012 10:41 pm    Post subject: Reply to: Position (count) of a record
Reply with quote

You want to know the particular "record number" of a selected record?

COPY operations.
INREC with WHEN=INIT, OVERLAY at end of record, for fixed, or BUILD at begining, for variable, a sequence number big enough for all the records on the file. Identify those records NOT the one you want (WHEN=(logexp), and OVERLAY the sequence number to zero.

OUTFIL OMIT those which are zero. The only one left is the record you want, with the its sequence number.
Back to top
View user's profile Send private message
shankarm

Active User


Joined: 17 May 2010
Posts: 175
Location: India

PostPosted: Tue Aug 28, 2012 11:49 pm    Post subject:
Reply with quote

Thanks Bill. I got the idea but didn't get hold on the syntax. I have not used most of these.

I will try to test this and post it in forum.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Aug 29, 2012 12:03 am    Post subject: Reply to: Position (count) of a record
Reply with quote

This one can give you a start.

Leads to something like this.

Code:
 SORT FIELDS=COPY                                             
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,7,ZD)),           
       IFTHEN=(WHEN=(pos,len,type,NE,C'your criteria'),OVERLAY=(81:C'0000000')
 OUTFIL OMIT=(81,7,ZD,EQ,0)


I've knocked that up quickly, and it is not tested, but around about what you are after. Gives you a chance to consult the manual and understand anything you don't already know how to use.

This is for a fixed-length 80-byte record. For a different fixed-length, change appropriately.

For variable, change first OVERLAY to BUILD=(1,4,SEQNUM,7,ZD,5) and change the 81's in the other OVERLAY and OMIT to 5.

The 7 in the SEQNUM allows for just under 10m records. Adjust appropriately to your file.
Back to top
View user's profile Send private message
shankarm

Active User


Joined: 17 May 2010
Posts: 175
Location: India

PostPosted: Wed Aug 29, 2012 10:23 pm    Post subject:
Reply with quote

Awesome, It is working. Thanks Bill.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Aug 29, 2012 11:06 pm    Post subject: Reply to: Position (count) of a record
Reply with quote

No problem. Perhaps you can post the working code, as it can then help someone with a similar problem in the future.
Back to top
View user's profile Send private message
shankarm

Active User


Joined: 17 May 2010
Posts: 175
Location: India

PostPosted: Thu Aug 30, 2012 12:21 am    Post subject:
Reply with quote

Below is the sort card that worked.

Code:

SORT FIELDS=COPY                                             
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,7,ZD)),           
      IFTHEN=(WHEN=(1,3,CH,NE,C'555'),OVERLAY=(81:C'0000000'))
OUTFIL OMIT=(81,7,ZD,EQ,0)                                   


My file is LRECL = 80,FB and the data in the file is given below,

Code:

111
222
333
444
555
666
777
888
999


Output is given after the job execution is given below,
Code:

555                                                                      0000005


Note: 555 is the fifth record in the file and the sequence number in the output is 5.

Complete job below,


Code:

//JOBTEST JOB ('4935-000000-00-A-00000000000'),               
// 'TEST',CLASS=V,MSGCLASS=A,MSGLEVEL=1,NOTIFY=&SYSUID   
//*                                                             
//COPY EXEC PGM=SYNCSORT                                       
//SORTIN DD DSN=FILSM.TEST.FILE,DISP=SHR                       
//SORTOUT DD SYSOUT=*                                           
//SYSPRINT DD SYSOUT=*                                         
//SYSOUT   DD SYSOUT=*                                         
//SYSDUMP DD SYSOUT=*                                           
//SYSIN DD *                                                   
  SORT FIELDS=COPY                                             
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,7,ZD)),           
        IFTHEN=(WHEN=(1,3,CH,NE,C'555'),OVERLAY=(81:C'0000000'))
  OUTFIL OMIT=(81,7,ZD,EQ,0)                                   
/*                                                             
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Aug 30, 2012 4:26 am    Post subject: Reply to: Position (count) of a record
Reply with quote

Just got a friendly kicking. There is a better way.

Code:
  SORT FIELDS=COPY                   
  INREC OVERLAY=(81:SEQNUM,7,ZD)     
  OUTFIL INCLUDE=(1,3,CH,EQ,C'555')


This is also easier if you need more flexibility, like more than one "key value" to search for.

Note you can use SS if you want to find a string somewhere.

You could also use it to exclude a selected record(s) from a file, with another OUTFIL with SAVE for all the other stuff on the original file, with a little reassurance of knowing the record number(s) dropped.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm


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