Invoking DataStage Functions within Parallel Routines

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
rbk
Participant
Posts: 23
Joined: Wed Oct 23, 2013 1:10 am
Location: India

Invoking DataStage Functions within Parallel Routines

Post by rbk »

Dear all,
Another day, another query..

We have a requirement to convert a string to a decimal/integer value.
Of course it is not a straight forward conversion.

We have few rules to apply say if the last character matches 'XYZ' then negate the value and add something else if.....

Also if the scale is 0 then we need to convert it to an integer value.

Since we have some 100 columns at the least we thought of creating a parallel routine. I have a few doubts regarding the same.

1. Is it possible to call the datastage functions within the C++ script ? e.g. TrimLeadingTrailing, Num, StringToDecimal ?
2. Is there any libraries that need to be added to access these functions ?
3. Does a simple "cout >>" print to the director log or do we need to handle them separately ?
4. Is it possible to get a sample parallel routine accepting a couple of input parameters ?

Any other suggestion to achieve the functionality is also welcome.
Please let me know if you need anymore information.

Thank you so much,
Cheers,
RBK
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

1) not sure but these are really simple functions to re-create. For example ATOF is string to float, sprintf(string, ... number) will do the reverse. They would be MUCH more efficient to simply use the built-in libraries and functions of C which are heavily optimized. (Not that the datastage versions are not efficient -- they are likely the C with wrappers -- but you will lose something in the wrappers that is not necessary).

2) if using the C versions, they are standard libraries. <cstdlib> for example.

3) No. You can write to a text file though, with filename << message and dump that to the log after the routine.

4) I am not sure what you are asking. Do you mean a multi-threaded parallel c++ routine? Look for pthread examples. But datastage can call your function in parallel, so this isnt necessary usually. just make sure your routine is thread safe.

---------
The beauty of C is you can do all your requirements in one function and with minimal iteration. But you need to be very specific about the input format and the requirements and behaviors. The result will be much faster than doing it with datastage string functions. Everything you asked here CAN be done in datastage, though.

These are simple and I will help if you get stuck with the C. I highly advise using c and not C++ string processing for this. The C++ stuff is overkill and much more frustrating to use for these types of tasks.
Post Reply