Page 1 of 2

C++ routine error

Posted: Fri Jul 10, 2009 2:12 am
by prasson_ibm
hi all,
We are trying to make C++ routine,we have developed a code

Code: Select all

]#include<stdio.h> 
#include<stdlib.h> 
#include<string.h> 
#include<conio.h> 

char * substr(char a[] ,int s,int l) 
{ 
int i; 
char * b; 
b=NULL; 
for(i=s;i<=s+l-1;i++) 
{ 
b[i-s]=a[i-1]; 
} 
b[i-1]='\0'; 
//printf("%s",b); 

return b; 
} 

int Calc_call_code(int CALL_TYPE_CODE,int CALL_SERVICE_TYPE_CODE, char CALL_TERMINATING_NBR[],char TER_OPR_CD[],char CALL_TYPE[],char ORG_TER_OPR_NAME[], char CALL_ROAM_NET_OPERATOR_CODE[]) 
{ 
int CALL_CODE; 

switch(CALL_TYPE_CODE) 
{ 
case 1: { CALL_CODE=55;break;} 
case 2: { CALL_CODE=56;break;} 
case 3: { 
switch(CALL_SERVICE_TYPE_CODE) 
{ 
case -722: {CALL_CODE=72;break;} 
case -679: {CALL_CODE=86;break;} 
case -99 : {CALL_CODE=52;break;} 
};break; 
} 
case 4:{switch(CALL_SERVICE_TYPE_CODE) 
{ 
case -732: 
case -728: 

case -726: 
case -724: {CALL_CODE=54;break;} 
case -730:{CALL_CODE=53;break;} 
}; break; 
} 
case 5: { {CALL_CODE=51;} 
break; 
} 
case 6: {if(CALL_TERMINATING_NBR != "-99" && strcmp(substr(CALL_TERMINATING_NBR,1,5),"56465") == 0) { 

CALL_CODE=35;} 
else CALL_CODE=39; 
break;} 

default: CALL_CODE=1000; 
} 
return CALL_CODE; 
} 
This code is working fine for case :1,2,3,4,5
but in the case of 6,30 my job get aborts :(
I am not able to find what exactly is the issue,i think this is due to some library,here i thnink Strcmp is not working
Please help me to resolve this problem.

Posted: Fri Jul 10, 2009 2:38 am
by ArndW
Please post the complete error message that you get at runtime.

Posted: Fri Jul 10, 2009 2:40 am
by Sainath.Srinivasan
Your call_terminating_nbr in 6 needs strcmp.

Please enclose the code in 'code' tag so others can see better.

Also you may reduce the burden by removing all codes after 6 and check whether 1-6 works fine.

Posted: Fri Jul 10, 2009 2:41 am
by Sainath.Srinivasan
Your call_terminating_nbr in 6 needs strcmp.

Please enclose the code in 'code' tag so others can see better.

Also you may reduce the burden by removing all codes after 6 and check whether 1-6 works fine.

Posted: Fri Jul 10, 2009 3:48 am
by meet_deb85
ArndW wrote:Please post the complete error message that you get at runtime.
when i run a job it dont give any error messabe but with fatal it gets aborts..... :(

Posted: Fri Jul 10, 2009 4:00 am
by Sainath.Srinivasan
Test the code as a stand-alone before calling from datastage.

Posted: Fri Jul 10, 2009 4:31 am
by meet_deb85
Sainath.Srinivasan wrote:Test the code as a stand-alone before calling from datastage.
When i am running the entire code with main on C++ compiler,its running fine and giving proper output.

Posted: Fri Jul 10, 2009 4:51 am
by ArndW
meet_deb85 wrote:
ArndW wrote:Please post the complete error message that you get at runtime.
when i run a job it dont give any error messabe but with fatal it gets aborts..... :(
Please just post the contents of the fatal message in the log, otherwise everyone here would just be guessing as to what your problem might be.

Posted: Fri Jul 10, 2009 4:57 am
by meet_deb85
ArndW wrote:
meet_deb85 wrote:
ArndW wrote:Please post the complete error message that you get at runtime.
when i run a job it dont give any error messabe but with fatal it gets aborts..... :(
Please just post the contents of the fatal message in the log, otherwise everyone here would just be guessing as to what your problem might be.
error message in log is

APT_CombinedOperatorController(2),0: Operator terminated abnormally: received signal SIGSEGV

Posted: Fri Jul 10, 2009 4:57 am
by Sainath.Srinivasan
Make the code write incoming values into a file so you can cross-check the failed values.

Posted: Fri Jul 10, 2009 5:41 am
by prasson_ibm
Sainath.Srinivasan wrote:Make the code write incoming values into a file so you can cross-check the failed values. ...
same error i m getting....... :(

Posted: Fri Jul 10, 2009 5:57 am
by Sainath.Srinivasan
Provide some sample values for which the code fails.

Posted: Fri Jul 10, 2009 9:59 am
by kduke
Edit the original post and fix your code tags. Your closing code tag is incomplete.

Posted: Sat Jul 11, 2009 11:59 am
by prasson_ibm
kduke wrote:Edit the original post and fix your code tags. Your closing code tag is incomplete. ...
I have made the code small........but still the problem is same......it is working well when i run this same code in turbo c++ compiler but when i call in routine its gives error...i think it is not able to call the other first function in the second function in datastage......well i need your input in this...

Posted: Sat Jul 11, 2009 1:44 pm
by chulett
Is this still true? And is the error exactly the same? If not, post it.
This code is working fine for case: 1,2,3,4,5 but in the case of 6,30 my job get aborts