Transformer code evaluation

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
jwilliams
Participant
Posts: 10
Joined: Wed Aug 15, 2007 6:53 am
Location: Tennessee, USA

Transformer code evaluation

Post by jwilliams »

Hello all:

I have a bit of a beginner's question regarding Datastage's parallel transformer and code placed into the destination derivation.

I was looking at some old custom-made server routines the other day and saw that any custom routine could be "tested" outside of the job. That is to say, pretend that I created and coded a custom server routine called "ConvDate"; I could open up the properties for that routine in Manager and click a "test" button that would evaluate any given input against the routine's code. It's very useful to see--at a glance--what the routine will do to "real" data.

That server function got me thinking about the px transformer and how code placed in the destination derivation has no way of being tested before the program is run. Yes, Datastage will tell you (quickly!) if the code is valid, but it will not give you a medium by which you can evaluate any given data against your own code.

For instance, we had a server routine that formatted decimal datatypes for COBOL on a mainframe. It was complex code in the custom-made server routine but nice to have the ability to go into Manager and see that, yes, indeed, 12345.67 becomes +00123456700 when tested against the routine. It would be wonderful to have this same ability when it comes to the px transformer, as well... for when I went to go code the derivation for a parallel job that demanded similar formatting, I had to jump through all sorts of hoops to achieve the same result. At it's worst (and at my most stupid) the code would end up:

Code: Select all

If DSLink9.COLUMN_NAME < 0 Then "-":Str(0,10-Len(Trim(DecimalToString(((DSLink9.COLUMN_NAME*1000)/100),"suppress_zero"),".","A"))):Trim(DecimalToString(((DSLink9.COLUMN_NAME*1000)/100),"suppress_zero"),".","A")                                                                                              Else "+":Str(0,10-Len(Trim(DecimalToString(((DSLink9.COLUMN_NAME*1000)/000),"suppress_zero"),".","A"))):Trim(DecimalToString(((DSLink9.COLUMN _NAME*1000)/100),"suppress_zero"),".","A")   
That, of course, is awful code. Eventually I woke up and got it right (and shorter). The point was, in the middle of this frustration, I desperately wished I had a little script that would take sample data (say 123.45) and run it against my derivation code, just so that I could see what it would do without having to run the entire program.

The closest thing I could think of was to have a row generator push sample data through a transformer with the code, and then to a peek stage... but that's almost as bothersome as just running the job and seeing where I end up.

I know it's a long post, but I guess I'm thinking out loud... does anyone know of a better way to test sample data that goes into a px transformer against a particular line of code? Am I missing a feature? Or perhaps there's some sort of comparable feature in 8.0?

Thanks for your time, Gurus!
Best,
J
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Write a little test bed in C (C++) to invoke your routine.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply