cancel
Showing results for 
Search instead for 
Did you mean: 

Counter column in the Receiver file

sridharreddy_kondam
Active Contributor
0 Kudos

Hi All,

My requirement -->

Souce is IDOC and target is a file.

In the Receiver file there is one column counter which will indicate the counter for each line...

So the Receiver file should be like this

FHEAD,0001

THEAD,00002,00001,20081103

TDETL,0003,0001,A,777,23456789

TDETL,0004,0002,M,881,45333333

TTAIL,0005

THEAD,0006,00002,20081103

TDETL,0007,0001,A,777,23456789

TDETL,0008,0002,M,881,45333333

TDETL,0009,0003,M,381,4533677

TTAIL,0010

FTAIL,0011

The problem is when i map with the source and use counter for the second column, i am getting the counters different, this is due to the condition on the node level, because if 10 idocs come the file may need only 5 based on condition. but since source occurence is 10 the counter cannot give correct values in the file as required,

Please suggest the best way to handle this..

Regards,

Sridhar Reddy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sridhar

Did you tried with the count function in graphical mapping. You can use Source -> Count -> Target and it will always return the correct count but it will count all occurrence. If it is condition based then you need to use a UDF to count based on that condition.

Thanks

Gaurav

Answers (3)

Answers (3)

sridharreddy_kondam
Active Contributor
0 Kudos

Used UDF

aashish_sinha
Active Contributor
0 Kudos

Hi,

>>this is due to the condition on the node level, because if 10 idocs come the file may need only 5 based on condition. but since source occurence is 10 the counter cannot give correct values in the file as required,

As far as i understand the question, you need the 5 Idocs based on condition and then you want to give the counter 1 to 5. Right ?

If this is the case just use one more additional parameter for counting the occurence when some Idoc come just increment it.

Like if you are using X variable for counting Idocs earlier n i think you are using that variable only for assigning count for filtered Idocs. or may be you are checking some condition and thats why that output for count is coming wrong. Use another variable and then increment that variable and assign that variable value to desired place.

Regards

Aashish Sinha

SudhirT
Active Contributor
0 Kudos

Hi Sridhar,

As suggested, you can use counter function but note that,

First implement the condition in mapping and the output result of that condition will be passed to the Counter function and then the counter output value to the target field.

Do this way, it will work.

Thanks!