External routine compliation problem

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
monaz
Participant
Posts: 98
Joined: Sat Aug 23, 2008 3:14 am

External routine compliation problem

Post by monaz »

Hi All,

i am developing an external routine in C programing and calling in the transformer stage .

I am facing the problem while compling the code.
Output from transformer compilation follows:

##I TFCN 000001 03:15:47(000) <main_program>
Ascential DataStage(tm) Enterprise Edition 7.5
Copyright (c) 2004, 1997-2004 Ascential Software Corporation.
All Rights Reserved


##I TOSH 000002 03:15:48(000) <main_program> orchgeneral: loaded
##I TOSH 000002 03:15:48(001) <main_program> orchsort: loaded
##I TOSH 000002 03:15:48(002) <main_program> orchstats: loaded
##E TBLD 000000 03:16:00(000) <main_program> Error when checking composite operator: Subprocess command failed with exit status 40192
##E TFSR 000019 03:16:00(001) <main_program> Could not check all operators because of previous error(s)
##W TFCP 000000 03:16:00(002) <transform> Error when checking composite operator: The number of reject datasets "0"is less than the number of input datasets "1".
##I TBLD 000000 03:16:00(003) <main_program> Error when checking composite operator: Output from subprocess: P:\Ascential\DataStage\Projects\DEV_LY00ODS_EE\RT_BP1072.O\V0S16_CopyOfCopyOfjob2_Transformer_16.C(240) : warning C4244: '=' : conversion from 'APT_Int64' to 'int', possible loss of data

##I TFCP 000008 03:16:00(004) <transform> Error when checking composite operator: cxx -W/TP -W/dll -LP:/Ascential/DataStage/Projects/DEV_LY00ODS_EE/RT_BP1072.O/ -LC:/Ascential/DataStage/PXEngine/lib -LC:/Ascential/DataStage/PXEngine/user_lib -lliborchnt -lliborchcorent -lliborchbuildopnt H:\DEV_LY00ODS_EE\mapping_code_test.o P:/Ascential/DataStage/Projects/DEV_LY00ODS_EE/RT_BP1072.O/V0S16_CopyOfCopyOfjob2_Transformer_16.tmp.o -o P:/Ascential/DataStage/Projects/DEV_LY00ODS_EE/RT_BP1072.O/V0S16_CopyOfCopyOfjob2_Transformer_16.dll
##I TBLD 000000 03:16:00(005) <main_program> Error when checking composite operator: Output from subprocess: LINK : warning LNK4224: /DEBUGTYPE:BOTH is no longer supported; ignored
LINK : fatal error LNK1181: cannot open input file 'H:DEV_LY00ODS_EEmapping_code_test.o'

##E TCOS 000029 03:16:00(006) <main_program> Creation of step finished with status = FAILED (CopyOfCopyOfjob2.Transformer_16)

*** Internal Generated Transformer Code follows:
0001: //
0002: // Generated file to implement the V0S16_repos_Transformer_16 transform operator.
0003: //
0004:
0005: // define external functions used
0006: extern int32 mapping_code_test(string entry_cd,string trid,string batch_cd,string debit_credit_cd,string adp_sec_num,sfloat amt,sfloat qty,string sec_desc,string trans_desc);
0007:
0008: // define our input/output link names
0009: inputname 0 DSLink10;
0010: outputname 0 DSLink17;
0011:
0012: initialize {
0013: // define our row rejected variable
0014: int8 RowRejected0;
0015:
0016: // define our null set variable
0017: int8 NullSetVar0;
0018:
0019: // Stage variable declaration and initialisation
0020: int32 StageVar0_stgvarmap;
0021: StageVar0_stgvarmap = 0;
0022: }
0023:
0024: mainloop {
0025: // initialise our row rejected variable
0026: RowRejected0 = 1;
0027:
0028: // evaluate the stage variables first
0029: StageVar0_stgvarmap = mapping_code_test(DSLink10.entry_cd , DSLink10.trans_acct_hist_cd , DSLink10.batch_cd , DSLink10.debit_credit_cd , DSLink10.security_adp_nbr , DSLink10.amt , DSLink10.qty , DSLink10.sec_desc , DSLink10.tdesc);
0030:
0031: // evaluate columns (no constraints) for link: DSLink17
0032: DSLink17.mapping_cd = StageVar0_stgvarmap;
0033: writerecord 0;
0034: RowRejected0 = 0;
0035: }
0036:
0037: finish {
0038: }
0039:
*** End of Internal Generated Transformer Code


I have generated C program and followed below Steps
Define your routine in DataStage manager: Routines -> New Parallel Routine
Set your routine definition.
Routine Name: External subroutine name: this is the function name in your c program:* Type: External Function
Object Type: Object <- you can also choose library if you compiled a DLL
Return type: int <- return type of your C function
And placed in the datastage local directory

Please suggest where i have gone wrong
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I don't see any mention of compiling and linking your C++ routine, nor any evidence that it compiled successfully and lacked a main() function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
monaz
Participant
Posts: 98
Joined: Sat Aug 23, 2008 3:14 am

Post by monaz »

ray.wurlod wrote:I don't see any mention of compiling and linking your C++ routine, nor any evidence that it compiled successfully and lacked a main() function. ...
Thanks Ray,

Its my first routine so please guide me if i have missed anythiing.

Its will be greatfull if you give me steps to follow
monaz
Participant
Posts: 98
Joined: Sat Aug 23, 2008 3:14 am

Post by monaz »

ray.wurlod wrote:I don't see any mention of compiling and linking your C++ routine, nor any evidence that it compiled successfully and lacked a main() function. ...
HERE is the C program Code i have wrriten for the External Routine
#include <stdio.h>
#include <string.h>

int map_code = 0;
int get_mapping_code ( char *entry_cd,char *trans_acct_hist_cd,char *batch_cd,char *debit_credit_cd,char *security_adp_nbr,char *tran_total_amt,char *share_trans_qty,char *desc_sec_line1_txt,char *desc_trans_sec_txt )
{
char *para[10][100];
int i = 0,k = 1,j,max_rules=0,flag=0;
int pos_val1,pos_val2,pos_val3;

FILE *configfile;
char *delims = ",";

char *configpara[80];
char configInput[80];
strcpy(para[0],entry_cd);
strcpy(para[1],trans_acct_hist_cd);
strcpy(para[2],batch_cd);
strcpy(para[3],debit_credit_cd);
strcpy(para[4],security_adp_nbr);
strcpy(para[5],tran_total_amt);
strcpy(para[6],share_trans_qty);
strcpy(para[7],desc_sec_line1_txt);
strcpy(para[8],desc_trans_sec_txt);


configfile = fopen ( "config_mapping.txt","r" );

while ( !feof(configfile) )
{
flag = 0;
i = 0;
fgets(configInput, sizeof(configInput), configfile);
configpara[0] = strtok(configInput, ",\n");
while(configpara != NULL) {
i++;
configpara = strtok(NULL, ",\n");
}


max_rules = atoi(configpara[k]);
/* Checking for 2 business rules */
if ( max_rules == 2 )
{
pos_val1 = get_position_param(configpara[k+1]);
pos_val2 = get_position_param(configpara[k+4]);
/*printf("para[pos_val1]:%s,configpara[k+3]:%s\n",para[pos_val1-1],configpara[k+3]);
printf("para[pos_val2]:%s,configpara[k+6]:%s\n",para[pos_val2-1],configpara[k+6]); */

if ( strcmp(para[pos_val1-1],configpara[k+3]) == 0 )
{
if ( strcmp(para[pos_val2-1],configpara[k+6]) == 0 )
{
flag = 1;
if ( flag == 1 )
return atoi(configpara[k-1]);
}
}
}/* End of conditions two */

/* Checking for 3 business rules */
if ( max_rules == 3 )
{
pos_val1 = get_position_param(configpara[k+1]);
pos_val2 = get_position_param(configpara[k+4]);
pos_val3 = get_position_param(configpara[k+7]);
/*printf("para[pos_val1]:|%s|,configpara[k+3]:|%s|\n",para[pos_val1-1],configpara[k+3]);
printf("para[pos_val2]:|%s|,configpara[k+6]:|%s|\n",para[pos_val2-1],configpara[k+6]);
printf("para[pos_val3]:|%s|,configpara[k+9]:|%s|\n",para[pos_val3-1],configpara[k+9]); */
if ( strcmp(para[pos_val1-1],configpara[k+3]) == 0 )
{
if ( strcmp(para[pos_val2-1],configpara[k+6]) == 0 )
{

if ( strcmp(configpara[k+8],"=") == 0 )
{
if ( pos_val3 == 6 || pos_val3 == 7 ) /* To Handle float values */
{
if ( atof(para[pos_val3-1]) == atof(configpara[k+9]) )
{
flag = 1;
if ( flag == 1 )
return atoi(configpara[k-1]);
}
}
else
{
if ( strcmp(para[pos_val3-1],configpara[k+9]) == 0 )
{
flag = 1;
if ( flag == 1 )
return atoi(configpara[k-1]);

}
}
}
}
}
if ( strcmp(para[pos_val1-1],configpara[k+3]) == 0 )
{

if ( strcmp(para[pos_val2-1],configpara[k+6]) == 0 )
{

if ( strcmp(configpara[k+8],">") == 0 )
{

if ( pos_val3 == 6 || pos_val3 == 7 ) /* To Handle float values */
{
if ( atof(para[pos_val3-1]) > atof(configpara[k+9]) )
{
flag = 1;
if ( flag == 1 )
return atoi(configpara[k-1]);
}
}
}
}
}
if ( strcmp(para[pos_val1-1],configpara[k+3]) == 0 )
{

if ( strcmp(para[pos_val2-1],configpara[k+6]) == 0 )
{

if ( strcmp(configpara[k+8],"<") == 0 )
{

if ( pos_val3 == 6 || pos_val3 == 7 ) /* To Handle float values */
{
if ( atof(para[pos_val3-1]) < atof(configpara[k+9]) )
{
flag = 1;
if ( flag == 1 )
return atoi(configpara[k-1]);

}
}
}
}
}
/* To handle less then equal to */
if ( strcmp(para[pos_val1-1],configpara[k+3]) == 0 )
{

if ( strcmp(para[pos_val2-1],configpara[k+6]) == 0 )
{

if ( strcmp(configpara[k+8],"<=") == 0 )
{

if ( pos_val3 == 6 || pos_val3 == 7 ) /* To Handle float values */
{
if ( atof(para[pos_val3-1]) < atof(configpara[k+9]) )
{
flag = 1;
if ( flag == 1 )
return atoi(configpara[k-1]);

}
}
}
}
}

/* To handle not equal conditions */
if ( strcmp(para[pos_val1-1],configpara[k+3]) == 0 )
{

if ( strcmp(para[pos_val2-1],configpara[k+6]) == 0 )
{

if ( strcmp(configpara[k+8],"<>") == 0 )
{

if ( pos_val3 == 6 || pos_val3 == 7 ) /* To Handle float values */
{
if ( atof(para[pos_val3-1]) != atof(configpara[k+9]) )
{
flag = 1;
if ( flag == 1 )
return atoi(configpara[k-1]);

}
}
else
{
if ( strcmp(para[pos_val3-1],configpara[k+9]) != 0 )
{
flag = 1;
if ( flag == 1 )
return atoi(configpara[k-1]);

}
}
}
}
}

/* To handle include */
if ( strcmp(para[pos_val1-1],configpara[k+3]) == 0 )
{
if ( strcmp(para[pos_val2-1],configpara[k+6]) == 0 )
{
if ( strcmp(configpara[k+8],"include") == 0 )
{

if ( strstr(para[pos_val3-1],configpara[k+9]) != NULL )
{
flag = 1;
if ( flag == 1 )
return atoi(configpara[k-1]);
}
}
}
}

/* To handle exlcude */
if ( strcmp(para[pos_val1-1],configpara[k+3]) == 0 )
{
if ( strcmp(para[pos_val2-1],configpara[k+6]) == 0 )
{
if ( strcmp(configpara[k+8],"exclude") == 0 )
{

if ( strstr(para[pos_val3-1],configpara[k+9])==NULL )
{
flag = 1;
if ( flag == 1 )
return atoi(configpara[k-1]);
}
}
}
}

} /* End of conditions three */

/* printf("entry_cd=%s,trans_acct_hist_cd=%s,batch_cd=%s,debit_credit_cd=%s,security_adp_nbr=%s,tran_total_amt=%d,share_trans_qty=%d,desc_sec_line1_txt=%s,desc_trans_sec_txt=%s\n",para[0],para[1],para[2],para[3],para[4],amt[0],amt[1],para[5],para[6]); */
}
return 99999;
} /* End of mapping code function */

/* To return entry code. */

int set_map_code( int mapval, int flag )
{

if ( flag == 1 )
{
return mapval;
}
else
{
return 99999;
}
}

/* Get the input position parameter. */

int get_position_param( char *configval )
{
if ( strcmp(configval,"entry_cd") == 0)
return 1;
if ( strcmp(configval,"trans_acct_hist_cd") == 0)
return 2;
if ( strcmp(configval,"batch_cd") == 0)
return 3;
if ( strcmp(configval,"debit_credit_cd") == 0)
return 4;
if ( strcmp(configval,"security_adp_nbr") == 0)
return 5;
if ( strcmp(configval,"tran_total_amt") == 0)
return 6;
if ( strcmp(configval,"share_trans_qty") == 0)
return 7;
if ( strcmp(configval,"desc_sec_line1_txt") == 0)
return 8;
if ( strcmp(configval,"desc_trans_sec_txt") == 0)
return 9;

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

Post by ray.wurlod »

Please edit your previous post, surround your code with Code tags (to preserve the indenting) and disable smilies before clicking Submit.
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