DSXchange: DataStage and IBM Websphere Data Integration Forum
View next topic
View previous topic
Add To Favorites
This topic has been marked "Resolved."
Author Message
sangi1981
Participant



Joined: 13 Jun 2008
Posts: 66

Points: 701

Post Posted: Mon Sep 19, 2011 4:38 am Reply with quote    Back to top    

DataStage® Release: 8x
Job Type: Parallel
OS: Unix
Additional info: Sun Solaris Server
Hi all,
I write a server routine to add months to a date.
I have to use this routine in parallel job, inside a transformer, but it is not possible.

I found that there are following solutions:
*) use basic transformer,
*) create parallel routine, using a c++ file in which make porting of basic code.

What are the steps needed to do second solution?
What Have I to do to implement this solution?
What Have I to know?
Where can I find some explanation or examples?
What can go wrong?

I'm on Sun Solaris Server.

Thanks lot in advance
SURA



Group memberships:
Premium Members

Joined: 14 Jul 2007
Posts: 1065

Points: 7637

Post Posted: Mon Sep 19, 2011 6:00 am Reply with quote    Back to top    

You need to create PX Routine using C++ code. You need to use the object file.

Don't imagine much and start to develop, you will get the solution.

DS User
Rate this response:  
Not yet rated
battaliou
Participant



Joined: 24 Feb 2003
Posts: 138
Location: London
Points: 806

Post Posted: Mon Sep 19, 2011 7:08 am Reply with quote    Back to top    

If you publish your server routine, I could see your rule base and translate it into PX for you. An example transformer algorithim using the INT and MOD functions:

* (YYYY-MM-DD)
YEAR = ExtDate[1,4] + Int((ExtDate[6,2] + #MONTHS#) / 12)
MONTH = Mod((ExtDate[6,2] + #MONTHS#), 12)

_________________
CENTURION: What's this, then? 'Romanes Eunt Domus'? 'People called Romanes they go the house'?

BRIAN: It-- it says, 'Romans, go home'.

Rate this response:  
Not yet rated
sangi1981
Participant



Joined: 13 Jun 2008
Posts: 66

Points: 701

Post Posted: Mon Sep 19, 2011 12:18 pm Reply with quote    Back to top    

Thanks much.
I implemented a c++ function, compiled with options from administrator, linked *.o file whit a parallel routine: seems to be good.
In this way, I have basic and c++ version....
Rate this response:  
Not yet rated
vinothkumar
Participant

Group memberships:
Heartland Usergroup

Joined: 04 Nov 2008
Posts: 300
Location: OH,USA
Points: 1417

Post Posted: Mon Sep 19, 2011 12:23 pm Reply with quote    Back to top    

Please post your C++ source code. In case if anyone needed they can refer.
Rate this response:  
Not yet rated
sangi1981
Participant



Joined: 13 Jun 2008
Posts: 66

Points: 701

Post Posted: Mon Sep 19, 2011 2:07 pm Reply with quote    Back to top    

Of course.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>

char* AddMonthRoutine ( char* InDate, int AddMonths ) {

  if ( InDate == NULL || *InDate == '\0' ||
         strlen(InDate) == 0 || strlen(InDate) != 8 ) {
         char rt[8];
         time_t now = time(0);
         struct tm *d;
         d=localtime(&now);
         strftime(rt,15,"%Y%m%d",d);
        return rt;
        }
  if ( AddMonths < 0 ) return InDate;
 
   char *cyyyy=(char *)malloc(sizeof(char)*4);
   strncpy(cyyyy,InDate,4);
   int yyyy=atoi(cyyyy);
   
   char *cmm=(char *)malloc(sizeof(char)*2);
   strncpy(cmm,InDate+4,2);
   int mm=atoi(cmm);
   
   char *cdd=(char *)malloc(2*sizeof(char));
   strncpy(cdd,InDate+6,2);
   int dd=atoi(cdd);
   
   free(cyyyy); free(cmm); free(cdd);
   
   int OutYear=yyyy+(AddMonths-(AddMonths%12))/12;
   int OutMonth=mm+(AddMonths%12);
   int OutDay=dd;
   
   if ( OutMonth > 12 ) { OutYear+=1; OutMonth-=12; }
   
   if ( OutMonth == 2 ) {
      if ( OutDay > 28 ) {
         int rest1=OutYear%400;
         int rest2=OutYear%100;
         int rest3=OutYear%4;
         if ( (rest3 == 0 && rest2 != 0) || rest1 == 0 )
            OutDay=29;
         else
             OutDay=28;
         }
    }
    else if ( OutMonth == 4 || OutMonth == 6 || OutMonth == 9 | OutMonth == 11 )
              if (OutDay > 30) OutDay=30;
   else  if ( OutMonth == 1 || OutMonth == 3 || OutMonth == 5 || OutMonth == 7 || OutMonth == 8 | OutMonth == 10 || OutMonth == 12 );
   
   char cOutYear[5];
   char cOutMonth[3];
   char cOutDay[3];
   char rData[10];
   int zero=0;
   
   sprintf(cOutYear,"%d",OutYear);
   
   if (OutMonth < 10) { sprintf(cOutMonth,"%d%d", zero, OutMonth); }
   else { sprintf(cOutMonth,"%d",OutMonth); }
   
   if (OutDay < 10) { sprintf(cOutDay,"%d%d", zero, OutDay); }
   else { sprintf(cOutDay,"%d",OutDay); }
   
   sprintf(rData,"%s%s%s",cOutYear, cOutMonth, cOutDay);
   
   return rData;
}
Rate this response:  
Display posts from previous:       

Add To Favorites
View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2002 phpBB Group
Theme & Graphics by Daz :: Portal by Smartor
All times are GMT - 6 Hours