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 SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm
No new posts Edit large number of datasets (QSAM) zh_lad TSO/ISPF 3 Tue Apr 04, 2017 6:08 pm
No new posts how to mask the phone number kumarinfy DB2 4 Mon Apr 03, 2017 5:23 pm
No new posts what is meaning of the number in dcl Martylin PL/I & Assembler 2 Thu Mar 09, 2017 7:18 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am


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