DSXchange: DataStage and IBM Websphere Data Integration Forum
View next topic
View previous topic
Add To Favorites
Author Message
HariniAruna
Participant



Joined: 31 Mar 2008
Posts: 12

Points: 77

Post Posted: Tue Apr 01, 2008 9:14 pm Reply with quote    Back to top    

DataStage® Release: 6x
Job Type: TX
OS: Unix
Hi
This is savitha.
How to generate the running sequence number for records.
For example my input is X12 format. My output has to be genrated depending on the number of ST's in input file.
The expected output is :
HDR|1
DTL|2
DTL|3
HDR|4
DTL|5
DTL|6
but iam getting the ouput as
HDR|1
DTL|2
DTL|3
HDR|2
DTL|3
DTL|4

Please any one help to see this one.
Keith
Participant



Joined: 21 Sep 2007
Posts: 18

Points: 211

Post Posted: Tue Apr 08, 2008 2:16 pm Reply with quote    Back to top    

So, you have intentions of increasing/making this sequence number every time you hit an ST segment ? It appears that the sequence number for the Header is being added to + 1 while the detail resets and adds +1 to whatever the Header counter is at the time?
Its a little difficult to understand; you will have to explain in much more detail what you are attempting.

_________________
Keith
Rate this response:  
Not yet rated
HariniAruna
Participant



Joined: 31 Mar 2008
Posts: 12

Points: 77

Post Posted: Wed Apr 09, 2008 8:15 am Reply with quote    Back to top    

Keith wrote:
So, you have intentions of increasing/making this sequence number every time you hit an ST segment ? It appears that the sequence number for the Header is being added to + 1 while the detail resets and adds +1 to whatever the Header counter is at the time?
Its a little difficult to understand; you will have to explain in much more detail what you are attempting.


HI
thanks for reply
my map has the input format EDI X12 and output format is the output format.The flat file contains single header and multiple details
For single ST and SE pnly one HDR and multiple DTL has to be generate.
depend on the number of ST and SE the HDr and detail also repeats
For example:
if My input contains only on st and se then
my ouput has to be like
HDR|1|filed3|
DTL|2|filed3|
DTL|3|field3|
DTL|4|field3|

so this is the output format
the first filed is the identifier and the seconf field is the sequence number

Suppose i have multiple ST and SE like 2 ST and SE's in my input then my output should be like

HDR|1|filed3|
DTL|2|filed3|
DTL|3|field3|
DTL|4|field3|

HDR|4|filed3|
DTL|5|filed3|
DTL|6|field3|
DTL|7|field3|

menas the sequence number of the next header has to increment by one from the last seuqence number of DTL .
but iam getting the output as

HDR|1|filed3|
DTL|2|filed3|
DTL|3|field3|
DTL|4|field3|

HDR|2|filed3|
DTL|2|filed3|
DTL|3|field3|
DTL|4|field3|
Rate this response:  
Not yet rated
janhess
Participant



Joined: 18 Sep 2003
Posts: 201
Location: UK
Points: 950

Post Posted: Wed Apr 09, 2008 9:00 am Reply with quote    Back to top    

Can't tell anything without some idea of the rules you are using. Even my magic crystal ball won't tell me.
Rate this response:  
Not yet rated
Keith
Participant



Joined: 21 Sep 2007
Posts: 18

Points: 211

Post Posted: Wed Apr 09, 2008 2:23 pm Reply with quote    Back to top    

I’ll assume the following:

1. Every time you read an ST segment you generate a Header Number [ HDR ]
2. Every segment between the ST and SE segments is considered DETAIL
3. Every time you read any segment between the ST & SE you generate a Detail Number [DTL ]


SETUP

• Two counters needed: Header Counter [ Hdr_Cntr ] and a Detail Counter [ Dtl_Cntr ]

First ST & SE Loop/Envelope

At the beginning, possibly when reading the ISA segment, you set both counters to zero.

Add 1 to your Hdr_Cntr when reading the ST segment.

Update your Dtl_Cntr with the amount in your Hdr_Cntr,

When reading all segments between ST & SE add 1 to your Dtl_Cntr.

When SE segment encountered move amount in Dtl_Cntr to Hdr_Cntr


Second ST & SE Loop/Envelope

START

ST segment - move Hdr_Cntr to output, and also move Hdr_cntr to Dtl_cntr
Segments in between - add 1 to Dtl_cntr, move Dtl_cntr to output

SE segment - move Detail Cntr to Hdr_cntr ; move Zero to Dtl_cntr

Then go to START


Maybe you could get by with just one counter instead of two but the above is what came to mind at the time.

_________________
Keith
Rate this response:  
Not yet rated
wtx_dev
Participant



Joined: 18 Jul 2007
Posts: 10

Points: 75

Post Posted: Wed Apr 16, 2008 4:52 am Reply with quote    Back to top    

use the INDEX function, while passing the arguments pass as INDEX($).
Rate this response:  
Not yet rated
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