Routine Function

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

oracle
Participant
Posts: 43
Joined: Sat Jun 25, 2005 11:52 pm

Routine Function

Post by oracle »

Hi All ,

I have the below requirement .Please help me to write routinee function ?

Input: string (varchar) -> any character string
Output: int -> the position of first non-numeric character of the input string. If all are numbers return -1.

E.g.
Input Output
ADB234 1
123ABC 4
12 456 3
1224-52 5
1234 -1


Regards
Ora
oracle
Participant
Posts: 43
Joined: Sat Jun 25, 2005 11:52 pm

Re: Routinee Function

Post by oracle »

Hi All

I have developed server routinee for this logic .But I ca n't call server routinee in transformer stage.

Code: Select all

ConvertString=CONVERT(' ABCDEFGHIJKLMNOPQRSTUVWXYZ-!@#$%^&*()_+=<>?|`/\:.,;"','####################################################',Arg1)

StringPosition=INDEX(ConvertString,'#',1)

if num(Arg1)=1  then
Ans=-1
end
Else 
Ans=StringPosition
end

Can you please help me to write parallel routinee using above server routinee?
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

Why parallel routine?
Kandy
_________________
Try and Try again…You will succeed atlast!!
oracle
Participant
Posts: 43
Joined: Sat Jun 25, 2005 11:52 pm

Post by oracle »

Hi ,

Thanks for your quick reply.
We can't call server routineee in transformer stage .Due to that reason I want parallel routinee.Please guide me?
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

Why routine at the first place? Did you try in a transfomer?
Kandy
_________________
Try and Try again…You will succeed atlast!!
oracle
Participant
Posts: 43
Joined: Sat Jun 25, 2005 11:52 pm

Post by oracle »

Hi,

I tried in transformer stage with out using routinee and its working fine.But for reusable purpose they are expecting one routinee which will take input and retuen postion of the string.

Regards
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It appears to me that you lack C++ programming skills and want someone else to create the routine. You have implemented the logic in a Transformer stage, so that part is under control. Why not inspect the C++ source code that is generated when the Transformer stage is "compiled"? You will find this in the RT_SCnnn sub-directory in the project, where nnn is the job number from DS_JOBS table.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
oracle
Participant
Posts: 43
Joined: Sat Jun 25, 2005 11:52 pm

Post by oracle »

Hi Ray,

Thank you very much for your reply.

I don't have C++ programming skills and I want to develop parallel routinee .Can you please provide me the simillar template if you have .

thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Search DSXchange for examples, for example pxEreplace().
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
rupeshg
Premium Member
Premium Member
Posts: 60
Joined: Thu Dec 22, 2005 6:02 am
Location: United Kingdom

Post by rupeshg »

Have you tried creating a Transform ? That is reusable too.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

rupeshg wrote:Have you tried creating a Transform ? That is reusable too.
Transforms are only applicable in server jobs and BASIC Transformer stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
oracle
Participant
Posts: 43
Joined: Sat Jun 25, 2005 11:52 pm

Post by oracle »

Hi Ray,

Can you please provide me the simillar kind of parallel routinee if you have that .

Thank you very much
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I don't have one. That's why I told you to search DSXchange.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
oracle
Participant
Posts: 43
Joined: Sat Jun 25, 2005 11:52 pm

Post by oracle »

Hi All

I have developed parallel routine to get the position of first non-numeric character of the input string.Unfortunatley I don't have compiler previllages and can any one please execute the progarm and tell me the result if possible ?

Regards


Code: Select all

/****************************************************************************** 
* FirstNonNumPos
* 
* Finds the first character in a list of characters 
* e.g. [b]FirstNonNumPos( "1234abcd" ) returns 5[/b]* 
******************************************************************************/ 

#include <cstdlib>
#include <iostream>

using namespace std;

int findchar(char *str)
{
    int i=0;
    while(1)
    {
            if((str[i]>=48)&&(str[i]<=57))
            {
             ++i;
            continue;
            }
            else
            break;
           
    }
    return (i+1);
}            
oracle
Participant
Posts: 43
Joined: Sat Jun 25, 2005 11:52 pm

Post by oracle »

Hi All,

Can you please let me know where do i have to place the parallel routine (C++ program) and also I need a command to run the C++ program in unix


Regards
Post Reply