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
 

 

Adding a descending character to a file

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

New User


Joined: 19 Oct 2015
Posts: 10
Location: UK

PostPosted: Fri Jul 15, 2016 4:57 pm    Post subject: Adding a descending character to a file
Reply with quote

Hi Guys,
just wondering if this is possible in one DFSORT step, I know I can do this by doing it in chunks then rejoining the file afterwards but wondered if it's possible in just one sort step.

Basically I have a list of customers and I want to create an dummy national insurance number for each of them.

So far i've come up with the following which just about gives me what I want but I also want to add a Character onto the end, but as there are well over a million customers I want the first million customers to have an A suffix, the next million, a B suffix, the next million a C suffix etc etc.

Sortin

000000386
000000388
...(nearly one million records further down the file)
358183249
358183250
358183251
358183252

//SYSIN DD *
SORT FIELDS=COPY
INREC FIELDS=(1,9,C',NI',SEQNUM,6,ZD)

Sortout
000000386,NI000001
000000388,NI000002
.....
358183249,NI999998
358183250,NI999999
358183251,NI000000
358183252,NI000001

What I want in the sortout :-

Sortout
000000386,NI000001A
000000388,NI000002A
.....
358183249,NI999998A
358183250,NI999999A
358183251,NI000000B
358183252,NI000001B

I have consulted with the Oracle (Google) but it's difficult to articulate my requirements into a google search.

cheers

Steve
Back to top
View user's profile Send private message

magesh23586

Active User


Joined: 06 Jul 2009
Posts: 159
Location: Chennai

PostPosted: Fri Jul 15, 2016 8:02 pm    Post subject: Reply to: Adding a descending character to a file
Reply with quote

What is the maximum number records or customers you have ?

Assuming 10 million customers max. After 10 million the character will reset and starts from A again.

Code:

OPTION COPY                                                 
INREC IFTHEN=(WHEN=INIT,                                     
              OVERLAY=(10:C',NI',SEQNUM,7,ZD)), 
      IFTHEN=(WHEN=INIT,                                     
              BUILD=(1,12,14,6,13,1,CHANGE=(1,C'0',C'A',     
                                              C'1',C'B',     
                                              C'2',C'C',     
                                              C'3',C'D',     
                                              C'4',C'E',     
                                              C'5',C'F',     
                                              C'6',C'G',     
                                              C'7',C'H',     
                                              C'8',C'I',     
                                              C'9',C'J')))       


similarly you can tweak the code to assign maximum of 26 chars (A to Z)
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 990
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Fri Jul 15, 2016 8:05 pm    Post subject:
Reply with quote

How many millions of records might you have?

If you change INREC to use SEQNUM,7,ZD (for example), you could check the high-order for '0', '1, '2,.... '9' and BUILD your required output record dropping the extgra higfh-order digit...

Code:

OUTREC IFTHEN=(WHEN=(13,1,CH,EQ,C'0'),
                           BUILD=(1,12,14,6,C'A')),
       IFTHEN=(WHEN=(13,1,CH,EQ,C'1'),
                           BUILD=(1,12,14,6,C'B')),
                     etc.... 


Garry
Back to top
View user's profile Send private message
Steve Ironmonger

New User


Joined: 19 Oct 2015
Posts: 10
Location: UK

PostPosted: Fri Jul 15, 2016 8:19 pm    Post subject:
Reply with quote

Thanks guys, there are approx 5 million records so the suggestion from Garry is perfect :-

Code:
SORT FIELDS=COPY                       
INREC FIELDS=(1,9,C',NI',SEQNUM,7,ZD) 
OUTREC  IFTHEN=(WHEN=(13,1,CH,EQ,C'0'),
        BUILD=(1,12,14,6,C'A')),       
IFTHEN=(WHEN=(13,1,CH,EQ,C'1'),       
        BUILD=(1,12,14,6,C'B')),       
IFTHEN=(WHEN=(13,1,CH,EQ,C'2'),       
        BUILD=(1,12,14,6,C'C')),       
IFTHEN=(WHEN=(13,1,CH,EQ,C'3'),       
        BUILD=(1,12,14,6,C'D')),       
IFTHEN=(WHEN=(13,1,CH,EQ,C'4'),       
        BUILD=(1,12,14,6,C'E')),       
IFTHEN=(WHEN=(13,1,CH,EQ,C'5'),       
        BUILD=(1,12,14,6,C'F')),       
IFTHEN=(WHEN=(13,1,CH,EQ,C'6'),       
        BUILD=(1,12,14,6,C'G'))       


the above works a treat !

thanks for all your help
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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


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