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
 

 

Generate a sequence number conditionally

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

New User


Joined: 30 Sep 2006
Posts: 60

PostPosted: Sun Jun 29, 2008 1:13 am    Post subject: Generate a sequence number conditionally
Reply with quote

Hi,

I have a file that has location number and customer number.

File FB 80 bytes
Location 9(4)
Filler X(20)
Customerid 9(14)
Filler X (42)

I have a requirement to generate a 6 digit sequence number starting from 1 at the end of the file with the condition - everytime a location changes, sequnce number should be incremented. Within the same
location, after every 150 customers, the sequence number should be incremented.

Sample Input

Location Customer-id
0331 00000000000001
0331 00000000000002
... (150 customer records for same location)
0331 00000000000149
0331 00000000000150
0331 00000000000151
0332 00000000000001
0332 00000000001234
0333 00000000001234


Sample Output

Location Customer-id Sequence number
0331 00000000000001 000001
0331 00000000000002 000001
... 000001
0331 00000000000149 000001
0331 00000000000150 000001
0331 00000000000151 000002
0332 00000000000001 000003
0332 00000000001234 000003
0333 00000000001234 000004

Any pointers for this to be done with sort would be helpful.

Aneesh.
Back to top
View user's profile Send private message

Skolusu

Senior Member


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

PostPosted: Tue Jul 01, 2008 12:48 am    Post subject:
Reply with quote

The following DFSORT Control cards will give you the desired results

Code:

//SYSIN    DD *                                                 
  SORT FIELDS=(1,4,CH,A)                                         
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,6,ZD,RESTART=(1,4),
                 SEQNUM,8,ZD)),                                 
  IFTHEN=(WHEN=(81,6,ZD,EQ,1,OR,81,6,ZD,GT,150),                 
  OVERLAY=(81:6X),HIT=NEXT),                                     
  IFTHEN=(WHEN=(81,6,CH,EQ,C' '),OVERLAY=(87:SEQNUM,8,ZD)),     
  IFTHEN=(WHEN=NONE,OVERLAY=(95:SEQNUM,8,ZD,                     
             87:87,8,ZD,SUB,95,8,ZD,M11,LENGTH=8))               
                                                                 
  OUTFIL BUILD=(1,4,25,14,89,6)                                 
//*                                                             


The output lay of the file is

Code:

Location 9(4)
Customerid 9(14)
Seqnume 9(6)


Hope this helps...

Cheers
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 Sequence number add in SORT pshongal SYNCSORT 3 Fri Sep 02, 2016 3:32 pm
No new posts Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm
No new posts Generate Cohort report using SORT Indrajit_57 SYNCSORT 6 Wed Jun 01, 2016 9:41 am
No new posts GDG vsersion number change Raghu navaikulam JCL & VSAM 5 Fri May 27, 2016 4:49 pm
No new posts CPU time Vs Number of records Nileshkul JCL & VSAM 5 Mon May 09, 2016 4:05 pm


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