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

Adding a descending character to a file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Steve Ironmonger

New User


Joined: 19 Oct 2015
Posts: 15
Location: UK

PostPosted: Fri Jul 15, 2016 4:57 pm
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: 213
Location: Chennai

PostPosted: Fri Jul 15, 2016 8:02 pm
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

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Fri Jul 15, 2016 8:05 pm
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: 15
Location: UK

PostPosted: Fri Jul 15, 2016 8:19 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top