Custom Stage Type BuildOp Help

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

Post Reply
scoope
Participant
Posts: 6
Joined: Mon Jun 05, 2006 1:50 pm

Custom Stage Type BuildOp Help

Post by scoope »

I am trying to find the index of a character (whitespace) in a string in a custom buildop. When I generate the buildop I get an error that .find is not part of the APT_String class. How can I accomplish this in a buildop? Any help would be appreciated.

Code: Select all

char gen_ssn_cde(APT_String ssn)
{

  APT_String constspace = " ";
  size_t found;
  ssn.removePadding(' ');
  found=ssn.find(constspace);
  if (found > 2)
     return 'N';

}
and when I try to Generate the buildop I get the following error.

Code: Select all

1540-0217 (S) "find" is not a member of "class APT_String".
Thanks,
Seth
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The API is documented in the Parallel Job Advanced Developer's Guide.

But why are you reinventing the wheel? The inbuilt Index() function can perform the task you describe.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

This isn't really server job question, is it?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
scoope
Participant
Posts: 6
Joined: Mon Jun 05, 2006 1:50 pm

Post by scoope »

ray.wurlod wrote:The API is documented in the Parallel Job Advanced Developer's Guide.

But why are you reinventing the wheel? The inbuilt Index() function can perform the task you describe. ...
Ray,

I tried to use the index function with no luck... I was doing it like so... but getting errors. I'm not in front of the code right now so I cannot give you the exact error. Is this the correct way to use "index".

Code: Select all

if (index(ssn, " ", 1) > 2)
Thanks,
Seth

P.S. Sorry for posting in the wrong category if I did so.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Your Index() function syntax is good (assuming you have a Then and an Else clause for the If, and that this is an expression in a Transformer stage rather than in Build stage code). Therefore please post any error message; there is not enough information for us to suggest anything more.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
scoope
Participant
Posts: 6
Joined: Mon Jun 05, 2006 1:50 pm

Post by scoope »

ray.wurlod wrote:Your Index() function syntax is good (assuming you have a Then and an Else clause for the If, and that this is an expression in a Transformer stage rather than in Build stage code). Therefore please post any error message; there is not enough information for us to suggest anything more.
Here is the code with my if statement...

Code: Select all

  if (index(ssn, " ", 1) > 2)
    return 'N';
and here is the error I am getting... Please let me know what I am missing.

Code: Select all

##E TBLD 000000 Subprocess command failed with exit status 256.
##W TBLD 000000 Output from subprocess: "File Scope Code (buildop/SSN_JEN_FIX.opd)", line 103.18: 1540-0256 (S) A parameter of type "int" cannot be initialized with an expression of type "const char [2]".
"File Scope Code (buildop/SSN_JEN_FIX.opd)", line 103.18: 1540-1205 (I) The error occurred while converting to parameter 2 of "index(const char *, int)".
Thanks,
Seth
CharlesNagy
Premium Member
Premium Member
Posts: 66
Joined: Mon Feb 21, 2005 10:40 am
Location: Paris

Post by CharlesNagy »

scoope wrote:
ray.wurlod wrote:Your Index() function syntax is good (assuming you have a Then and an Else clause for the If, and that this is an expression in a Transformer stage rather than in Build stage code). Therefore please post any error message; there is not enough information for us to suggest anything more.
Here is the code with my if statement...

Code: Select all

  if (index(ssn, " ", 1) > 2)
    return 'N';
and here is the error I am getting... Please let me know what I am missing.

Code: Select all

##E TBLD 000000 Subprocess command failed with exit status 256.
##W TBLD 000000 Output from subprocess: "File Scope Code (buildop/SSN_JEN_FIX.opd)", line 103.18: 1540-0256 (S) A parameter of type "int" cannot be initialized with an expression of type "const char [2]".
"File Scope Code (buildop/SSN_JEN_FIX.opd)", line 103.18: 1540-1205 (I) The error occurred while converting to parameter 2 of "index(const char *, int)".
Thanks,
Seth
You don't need a buildop for this. if you create a stage variable inside a transformer using the following code :

Code: Select all

if (index(ssn, " ", 1) > 2) then 'N' else 'Y'
It should work.

index is a Basic function only available inside a ttransformer. It is not a c function
scoope
Participant
Posts: 6
Joined: Mon Jun 05, 2006 1:50 pm

Post by scoope »

CharlesNagy wrote:
scoope wrote:
ray.wurlod wrote:Your Index() function syntax is good (assuming you have a Then and an Else clause for the If, and that this is an expression in a Transformer stage rather than in Build stage code). Therefore please post any error message; there is not enough information for us to suggest anything more.
Here is the code with my if statement...

Code: Select all

  if (index(ssn, " ", 1) > 2)
    return 'N';
and here is the error I am getting... Please let me know what I am missing.

Code: Select all

##E TBLD 000000 Subprocess command failed with exit status 256.
##W TBLD 000000 Output from subprocess: "File Scope Code (buildop/SSN_JEN_FIX.opd)", line 103.18: 1540-0256 (S) A parameter of type "int" cannot be initialized with an expression of type "const char [2]".
"File Scope Code (buildop/SSN_JEN_FIX.opd)", line 103.18: 1540-1205 (I) The error occurred while converting to parameter 2 of "index(const char *, int)".
Thanks,
Seth
You don't need a buildop for this. if you create a stage variable inside a transformer using the following code :

Code: Select all

if (index(ssn, " ", 1) > 2) then 'N' else 'Y'
It should work.

index is a Basic function only available inside a ttransformer. It is not a c function
Is there a way to do this inside the C code buildop? We would have to modify a lot of jobs if we do it with a transform and we would like to do this with the buildop.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No. As I mentioned earlier, the Index() function I mentioned is used in a Transformer stage - to do what you're trying to write a routine to do.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
satyanarayana
Participant
Posts: 13
Joined: Fri Jul 15, 2005 12:01 am

Re: Custom Stage Type BuildOp Help

Post by satyanarayana »

Hi,

1)You can find the occurrence of sub string in string using offsetOfSubstring() function, It is a APT_STRING function.
2)If sub string is found then find the index of sub string using occurrences() function,it is also a APT_STRING function.[/i]
Post Reply