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

Generate a sequence number conditionally


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Increase the number of columns in the... IBM Tools 3
No new posts Cobol program with sequence number ra... COBOL Programming 5
Search our Forums:

Back to Top