Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Repeat Sequence Number Until change i... rahulabvp DFSORT/ICETOOL 6 Thu Mar 29, 2018 12:51 pm
No new posts Detect break in the sequence tuxama DFSORT/ICETOOL 6 Tue Mar 20, 2018 1:35 pm
No new posts How to Generate JCL using Sort naveen katkuri DFSORT/ICETOOL 7 Tue Mar 13, 2018 3:50 pm
No new posts add sequence number for duplicate rec... SRUTHI DRAVIDAMANI COBOL Programming 11 Thu Feb 22, 2018 5:37 pm
No new posts PARSE GDG name to separate generation... Abid Hasan SYNCSORT 2 Sun Feb 11, 2018 3:40 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us