regarding last transaction and current transaction

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
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

regarding last transaction and current transaction

Post by ntr »

Hi,

I have input data like this

date , closingbal

12thmay,2000

13thmay,3000

14thmay,4000

17thmay,6000

20thmay,8000

and i need output like this

date closingbal,openingbal

12thmay,2000, 0

13thmay,3000, 2000

14thmay,4000, 3000

17thmay,6000,4000

20thmay,8000,6000

means my last transactions of closingbal current transactions opening bal


can please help me regarding this

iam using datastage 8.1, windows environment

Thanks
sreewin7
Participant
Posts: 41
Joined: Tue Sep 14, 2010 8:48 pm

Re: redgarding last transaction and current transaction

Post by sreewin7 »

As per my knowledge it is not possible in datastage, we can do in reporting level and which reporitng tool is used in your environment and discuss with them try to slove the requirment.

Example:- In the reporting level we can use filter for the same column like below.
As of yesterday balance = 1
Today balance = 2
Output coloumn = 1+2.

Regards,
Sree
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

This can be done in DataStage using properly sequenced stage variables, all you are doing is holding on to the previous value of the closingbal for use in the openingbal of the next record.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mobashshar
Participant
Posts: 91
Joined: Wed Apr 20, 2005 7:59 pm
Location: U.S.

Post by mobashshar »

Do this:
Create a rownum column as int so your input will look like this:

rownum, date , closingbal

1, 12thmay,2000

2, 13thmay,3000

3, 14thmay,4000

4, 17thmay,6000

5, 20thmay,8000

Now.. using Copy Stage, split the rows in Two stream as follows:
1. rownum and closingbal will go to Transformer.
2. rownum, date and closingbal will go to Merge.

In Transformer Add +1 to rownum and pass out the values (rownum+1 and openbal) to Merge.

In Merge, merge on Key=rownum and you will ge the result as follows:

12thmay,2000, 0
13thmay,3000, 2000
14thmay,4000, 3000
17thmay,6000,4000
20thmay,8000,6000

Hope this helps.
ntr
Participant
Posts: 110
Joined: Fri Dec 18, 2009 10:30 am
Location: pune

Post by ntr »

Thank you somuch i think it should work i will try iit now and i will come back with result
TPons
Participant
Posts: 18
Joined: Mon Jan 03, 2011 3:32 am
Location: India

Re: regarding last transaction and current transaction

Post by TPons »

Use the below logics in stage variables

sv_Opening_Bal ---> if @INROWNUM=1 Then 0 Else sv_Prev_Clsoing_Bal
sv_Prev_Clsoing_Bal ---> closingbal

in colunm deivation, assign the stage variable sv_Opening_Bal to openingbal column.

date - date
closingbal - closingbal
openingbal - sv_Opening_Bal

---------------
Pons
mobashshar
Participant
Posts: 91
Joined: Wed Apr 20, 2005 7:59 pm
Location: U.S.

Post by mobashshar »

Pons..
sv_Opening_Bal ---> if @INROWNUM=1 Then 0 Else sv_Prev_Clsoing_Bal
sv_Prev_Clsoing_Bal ---> closingbal
will not work in Parallel env unless you run your transformer in seq. mode.
svga
Participant
Posts: 73
Joined: Thu Aug 07, 2008 6:31 am
Location: Syracuse

Post by svga »

We don't need to use the @INROWNUM instead assign zero to initial value for stage variable.
Post Reply