CRC32 for a column in Parallel Job

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

Lohith
Participant
Posts: 8
Joined: Mon Feb 27, 2006 12:57 pm
Location: Ohio, United States

CRC32 for a column in Parallel Job

Post by Lohith »

Hi ,
First of all let me confess that i am very new to Ascential Datasatge and have been working on it only for last 3 weeks, with all the help i can get from DSXchange.

I have a new requirement where i have to take UserName and then generate a CRC code for it.
I am developing a parallel job.
So i would have to write a code, for that,i am using the below code,
***** InputRowCRC32 **
****
Include DSINCLUDE DSD_STAGE.H
Common /CheckSumTrans/ Init, StartPos, EndPos

If Not(Init) Then
StageVarCount = STAGECOM.STAGE
StartPos = StageVarCount + 1
EndPos = STAGECOM.PIN(1) + StageVarCount Init = 1 End

Row = Output_acct_table.AcctName; ! Init
For ColPos = StartPos To EndPos
Row:= STAGECOM.ARR(ColPos)
Next ColPos

Ans = CRC32(Output_acct_table.AcctName)

****
Can u please tell me what could be wrong with the code. I get the foll error message.

"External routine library file name "CRC.txt" is invalid routint CRC(AccountPak_VER1.Transformer).

Can you please help me with this.
Should i be placing the code in a specific DS directory.
Any suggestion you provide could be greatly helpful.
Thanks and regards
Lohith
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Lohith,

the code you have written is in the routines part of the repository and is only accessible from Server jobs, or from BASIC transfrom stages in Parallel jobs. In addition, the code uses undocumented internal COMMON block values that might change in the future, so the routine might stop working sometime during a future upgrade and you will have to recode it.

To use te
Lohith
Participant
Posts: 8
Joined: Mon Feb 27, 2006 12:57 pm
Location: Ohio, United States

Post by Lohith »

Thanks ArndW.

I got this code from one of the threads in the forum. Can i write a C code for generating the CRC.

Is there a specific folder, that i need to store this code in.

Can someone please provide me the code for the same.

I am bad in writing a c code. :cry:
Thanks and regards
Lohith
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Not too strong on C programming myself but you can have a look at the Advanced Parallel Job Developers Guide which has a short section on buildops and takes you through an example. There are also some example code in the PXHOME/samples folder on your server. You can also do a web search for CRC32 C code as some programmers have tackled this and put their code online.
benny.lbs
Participant
Posts: 125
Joined: Wed Feb 23, 2005 3:46 am

Post by benny.lbs »

Lohith wrote:Thanks ArndW.

I got this code from one of the threads in the forum. Can i write a C code for generating the CRC.

Is there a specific folder, that i need to store this code in.

Can someone please provide me the code for the same.

I am bad in writing a c code. :cry:
I think you can write a C/C++ code for generating the CRC, then create a Parallel Routine to call this C/C++ program. After that, you can call this Parallel Routine with Transformer.
Lohith
Participant
Posts: 8
Joined: Mon Feb 27, 2006 12:57 pm
Location: Ohio, United States

Post by Lohith »

benny.lbs wrote:
Lohith wrote:Thanks ArndW.

I got this code from one of the threads in the forum. Can i write a C code for generating the CRC.

Is there a specific folder, that i need to store this code in.

Can someone please provide me the code for the same.

I am bad in writing a c code. :cry:
I think you can write a C/C++ code for generating the CRC, then create a Parallel Routine to call this C/C++ program. After that, you can call this Parallel Routine with Transformer.
I have tried the above mentioned.
I put the code in my projects folder and point the Parallel routine to the CRC code, but i keep getting the following error message.

"External Routine library file name 'CRC.C' is invalid routine 'CRC'"
What is the solution for this.
Thanks and regards
Lohith
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Have you defined it as a parallel routine? In the DataStage Manager do a right mouse click on the Routine folder and choose "Add Parallel Routine". Add the library path, routine name and descriptions in there.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Vincent - the poster is pointing DataStage at the .c source file, not the library object.
Lohith
Participant
Posts: 8
Joined: Mon Feb 27, 2006 12:57 pm
Location: Ohio, United States

Post by Lohith »

ArndW wrote:Vincent - the poster is pointing DataStage at the .c source file, not the library object. ...
That's right Arndw. I am pointing to .c Source, and i am getting the error message.
How do i solve this problem.
Please let me know.
Problem is the code is not even getting compiled with DataStage Server Routine, it does not import the header files.
Is there a particular location that i need to store file at.
Last edited by Lohith on Wed Mar 22, 2006 9:54 am, edited 1 time in total.
Thanks and regards
Lohith
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

PX routines are c++, server routines are DS/Basic and one compiler can't touch code in the other. You need to compile your C++ code and load the entrypoint into a library object, then point the definition of the routine to that object.
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

I am so glad they didn't have questions about this in the certification exam.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Vincent - so am I, now that you've said it. I was waiting for a long weekend for me to go through the docs again and I was worried I'd have to link something external into PX in order to get some of the questions right. Phew, now I don't have to worry about that part.
pneumalin
Premium Member
Premium Member
Posts: 125
Joined: Sat May 07, 2005 6:32 am

Post by pneumalin »

Hope my two penny description make sense to you guys:
1. server routine cannot take the .c source, it can only take Basic code to compile and to be used in a Basic transformer.
2. .c source needs to be compiled using External C++ compiler to generate .so in Unix and .dll in Windows, and then copied into
.../DataStage/DSEngine/lib for runtime library loading. For sure the .c can be programmed to take Input Parameters and return the result as Basic Routines can do, in C/C++ language.
3. Add PX new routines using Designer or Manager as posted by Vincent in previous thread. The PX routine is shown as Red icon versus the Server routine as Yellow Icon.
4. You can call PX routine in PX transformer or Sequencer at will.
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

I counted four pennies and it was a very useful answer. I especially like the part where you mentioned that I was right about something.
Lohith
Participant
Posts: 8
Joined: Mon Feb 27, 2006 12:57 pm
Location: Ohio, United States

Post by Lohith »

Thanks to all the people in DSXchange for taking time out to help people like me.
I have not been able to try the above suggestions, as i was very busy with other project related work.
I will try it over the weekend.
Thank you all again for helping me.:)
Smile
Thanks and regards
Lohith
Post Reply