Hi,
For a given input file, I need to append a generated (alphanumeric) series in a new column (and direct that to output file).
The series should look like AA0001, AA0002....., AA9999, AB0001, AB0002,............, AB9999, ......ZZ0001,....,ZZ9999
Could you suggest me some in-built function which I could use here?
What should be the simplest way of achieving this?
Its very urgent.
Thanks.
Regards,
Nitin
numeric and char series generators
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 21
- Joined: Wed Oct 01, 2003 11:53 am
-
- Premium Member
- Posts: 483
- Joined: Thu Jun 12, 2003 4:47 pm
- Location: St. Louis, Missouri USA
You can write a very simply DataStage function that does this. What you need to do is clarify your functional requirements:
What is the starting value? Does it always start with AA0000? Do you want to pass in a seed value? Do you need to continue where a previous job run left off? Does a given sequence correlate to any given conditions? How do you handle topping off at ZZ9999, do you roll over or start with AAA0000?
This is a simple function, you just have to be specific. You will write a function that does the simple algebra to increment your counter. What you have to decide is if you're starting with a seed value, referencing a seed value, correlating to a given condition, etc. Then, you will either use a stage variable or a COMMON statement in the function to "remember" your value from row to row.
Let us know, we'll help out.
Kenneth Bland
What is the starting value? Does it always start with AA0000? Do you want to pass in a seed value? Do you need to continue where a previous job run left off? Does a given sequence correlate to any given conditions? How do you handle topping off at ZZ9999, do you roll over or start with AAA0000?
This is a simple function, you just have to be specific. You will write a function that does the simple algebra to increment your counter. What you have to decide is if you're starting with a seed value, referencing a seed value, correlating to a given condition, etc. Then, you will either use a stage variable or a COMMON statement in the function to "remember" your value from row to row.
Let us know, we'll help out.
Kenneth Bland
Nitin
You using the UNIX split command? You could use options on the split command to make this easier.
Create a routine: (this should be close enough)
GetNextId(Arg1)
LastKey = Arg1
if LastKey = then
Ans = "AA0001"
end else
KeyXX = LastKey[1,2]
KeyNum = LastKey[3,4]
if KeyNum = "9999" then
KeyNum = "0001"
KeyX = KeyXX[2,1]
if KeyX = "Z" then
KeyX = "A"
Key1 = char(seq(KeyXX[1,1])+1)
KeyXX = Key1 : KeyX
end else
KeyX = char(seq(KeyX)+1)
Key1 = KeyXX[1,1]
KeyXX = Key1 : KeyX
end
end else
KeyNum += 1
KeyNum = fmt(KeyNum, "40R")
end
Ans = KeyXX : KeyNum
end
return(Ans)
Kim.
You using the UNIX split command? You could use options on the split command to make this easier.
Create a routine: (this should be close enough)
GetNextId(Arg1)
LastKey = Arg1
if LastKey = then
Ans = "AA0001"
end else
KeyXX = LastKey[1,2]
KeyNum = LastKey[3,4]
if KeyNum = "9999" then
KeyNum = "0001"
KeyX = KeyXX[2,1]
if KeyX = "Z" then
KeyX = "A"
Key1 = char(seq(KeyXX[1,1])+1)
KeyXX = Key1 : KeyX
end else
KeyX = char(seq(KeyX)+1)
Key1 = KeyXX[1,1]
KeyXX = Key1 : KeyX
end
end else
KeyNum += 1
KeyNum = fmt(KeyNum, "40R")
end
Ans = KeyXX : KeyNum
end
return(Ans)
Kim.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 21
- Joined: Wed Oct 01, 2003 11:53 am