Custom Function in PX

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
Bill_G
Premium Member
Premium Member
Posts: 74
Joined: Thu Oct 20, 2005 9:34 am

Custom Function in PX

Post by Bill_G »

I wrote a simple function in C that returns a char* value after evlautating 4 char* arguments for Null. The idea was to consolidate and clean up the architecture. However, when I pass my new routine a NULL value for one of the 4 arguments, it drops the record and throws a warning message.

Code: Select all

 using namespace std;
#include <iostream>
#include <string>

char* return_value(char* Arg1,char* Arg2,char* Arg3,char* Arg4)

{
char* TmpVal = NULL;

	if (Arg1 != NULL)
		
		TmpVal = Arg1;
		
	else 
	
		if (Arg2 != NULL)
				    
			TmpVal = Arg2;
				
			
		else 
			
			if (Arg3 != NULL)
    				
				TmpVal = Arg3;
			else

				if (Arg4 != NULL)
    						     		
    			TmpVal = Arg4;
				else
	
	TmpVal = NULL;


 	return (TmpVal);

}
Warrning:

APT_CombinedOperatorController,0: Field 'ARG1' from input dataset '0' is NULL. Record dropped. [transform/tfmop_functions.C:130]


Any ideas?

BTW, my current version of the PARJDEV.pdf doc doesn't seem to have a chapter on custom routines. Did they write a seperate doc to cover custom routines?


Thanks in Advance.[/code]
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is the column that supplies a value to Arg1 declared to be nullable?

Yes, there is a separate manual called Advanced Parallel Job Developer's Guide (also in your Docs folder) that covers custom code.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Bill_G
Premium Member
Premium Member
Posts: 74
Joined: Thu Oct 20, 2005 9:34 am

Post by Bill_G »

Thanks Ray, for the post. The fields will accept null values. Apparently the issue occurs when passing null values into the routine.

Below is a posting from IBM support:
Unfortunately your C routine won't work with PX. There is an e.case explaining that, see below:
ECASE Date Opened Status State Product Found In Release Priority
82701 2005-10-19 REO O DATASTAGE 7.5.1A 3

Summary: Allow PX External Routines to use native orchestrate types
Details: The customer would like to write an external
routine where they can pass to nullable PX
fields and test them for NULL before doing some
other testing on them. Currently there are a few
limitations within the product that prevent this.
Initially, there is a limitation in Manager
where you define the datatypes since you can
only choose native C types. Additionally, in
the transformer compiled code, from what I
understand, we cast the PX data types to C types
in order to do the call.


I got your job working fine using the function NullToValue. That basically does the same thing you are doing in the C program.
You can use it as a workaround. Let me know if you have any questions.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That makes sense; C does not have a "native" representation of NULL.
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