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

Increment a counter in a VB PS


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Vamshi Veludandi

New User


Joined: 17 Mar 2009
Posts: 27
Location: Bangalore

PostPosted: Wed Jan 25, 2012 4:05 pm
Reply with quote

Hi all,
I have a requirement where in I need to increment a counter at a specific column.
The counter should be incremented for all between the records where in AA and ZZ in the 1st column.


Regards,
Vamshi.
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: Wed Jan 25, 2012 4:17 pm
Reply with quote

Please Paste the samples and use the code tags, don't attach screen images.

You want to do this with a Sort? Which product are you using? Does it support a GROUP function? What have you tried? What problems did that give you?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jan 25, 2012 4:22 pm
Reply with quote

do not post screenshots, they waste space and p*** off people willing to help

( You cannot cut and paste from a screenshot, and retyping Your data to test the answers is pretty boring )

use a plain cut and paste ( text mode ) with the code tags

the screenshots will be deleted in a while
Back to top
View user's profile Send private message
elango_K

New User


Joined: 18 Aug 2011
Posts: 44
Location: India

PostPosted: Wed Jan 25, 2012 4:40 pm
Reply with quote

Hi Vamshi,

This can be achieved using DFSORT When=Begin condition.
Back to top
View user's profile Send private message
Vamshi Veludandi

New User


Joined: 17 Mar 2009
Posts: 27
Location: Bangalore

PostPosted: Wed Jan 25, 2012 4:48 pm
Reply with quote

My Sincere Apologies,
I shouldn't have attached screen images.

The counter position starts at 7th column for all the records.
The counter should be incremented for all the records between AA to ZZ in first column.
Can we do this using DFSORT ? If so, a sample code snippet would be much helpful.
Input file:
Code:
XY -- 000000000
BC -- 000000000
AA -- 000000000
BC -- 000000000
AD -- 000000000
C  -- 000000000
N3 -- 000000000
ZZ -- 000000000
11 -- 000000000
22 -- 000000000

Expected Output file:
Code:
XY -- 000000000
BC -- 000000000
AA -- 000000001
BC -- 000000002
AD -- 000000003
C  -- 000000004
N3 -- 000000005
ZZ -- 000000006
11 -- 000000000
22 -- 000000000



Regards,
Vamshi.
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: Wed Jan 25, 2012 4:53 pm
Reply with quote

Yes, it can be done in DFSORT. It should have therefore been posted in the DFSORT forum.

You still didn't put your data in the Code tags.

This is so Spacing is preserved.

Code:
This is so           Spacing is preserved.


If you click on the Quote button on this post, you'll see what I mean.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jan 25, 2012 4:57 pm
Reply with quote

TS post edited to add the code tags, in the hope that he will learn icon_cool.gif
screenshots deleted also
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jan 25, 2012 11:29 pm
Reply with quote

You can use a DFSORT job like the following to do what you asked for:

Code:

//S1 EXEC PGM=SORT                                         
//SYSOUT DD SYSOUT=*                                       
//SORTIN DD DSN=...  input file (VB)                                             
//SORTOUT DD DSN=...  output file (VB)                                     
//SYSIN DD *                                               
  OPTION COPY                                             
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(5,2,CH,EQ,C'AA'),       
    END=(5,2,CH,EQ,C'ZZ'),PUSH=(11:SEQ=9))                 
/*


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Jan 26, 2012 4:30 am
Reply with quote

Hi,

you will need to add 4 bytes to all of your start positions for a VB file.

Gerry
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Jan 26, 2012 5:09 am
Reply with quote

Oops. I missed the "VB" in the Subject ... wasn't mentioned in the posts.

I've changed my previous post to use a VB file.

Thanks for the correction.
Back to top
View user's profile Send private message
Vamshi Veludandi

New User


Joined: 17 Mar 2009
Posts: 27
Location: Bangalore

PostPosted: Fri Jan 27, 2012 7:13 pm
Reply with quote

Sorry for the delay in responding to your suggessions.

Thank you very much, Frank.

The code snippet you gave was perfect for my requirement.

But, I got the job done, by splitting the file for the records to be updated and then ran another step to update the sequence number and then again merged the files back icon_sad.gif .

I should have had the patience to look into the DFSORT tutorial, which is excellent, before posting it. It wasn't even hard to find the solution in the manual.

Regards,
Vamshi
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Two input files & writing counter... DFSORT/ICETOOL 12
No new posts Sort counter to show records combination JCL & VSAM 2
No new posts Add a step counter in a stack ? CLIST & REXX 23
No new posts Setting up a name counter in the coup... CICS 2
No new posts Increment number for every group of r... DFSORT/ICETOOL 7
Search our Forums:

Back to Top