Page 1 of 1
Custom Stage Type BuildOp Help
Posted: Wed May 05, 2010 8:43 am
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
Posted: Wed May 05, 2010 4:39 pm
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.
Posted: Wed May 05, 2010 7:05 pm
by ray.wurlod
This isn't really server job question, is it?
Posted: Wed May 05, 2010 7:17 pm
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".
Thanks,
Seth
P.S. Sorry for posting in the wrong category if I did so.
Posted: Thu May 06, 2010 2:37 am
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.
Posted: Thu May 06, 2010 7:57 am
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
Posted: Thu May 06, 2010 9:19 am
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
Posted: Thu May 06, 2010 9:32 am
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.
Posted: Thu May 06, 2010 4:49 pm
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.
Re: Custom Stage Type BuildOp Help
Posted: Mon Jun 07, 2010 5:04 am
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]