|
View previous topic :: View next topic
|
| Author |
Message |
Steve Ironmonger
New User
Joined: 19 Oct 2015 Posts: 15 Location: UK
|
|
|
|
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 |
|
 |
magesh23586
Active User

Joined: 06 Jul 2009 Posts: 213 Location: Chennai
|
|
|
|
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 |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1217 Location: Dublin, Ireland
|
|
|
|
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 |
|
 |
Steve Ironmonger
New User
Joined: 19 Oct 2015 Posts: 15 Location: UK
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|