cancel
Showing results for 
Search instead for 
Did you mean: 

Second Occurrence of the Source Field

Former Member
0 Kudos

Hi All,

I have a following mapping requirement

I have to map the target field with the second occurrence of the Source field1 when the source field2=some value and if the second occurrence of the source field is not populated then fill space.

Can you please tell me how can I implement this mapping?

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

former_member200962
Active Contributor
0 Kudos
I have to map the target field with the second occurrence of the Source field1 when the source field2=some value and if 
the second occurrence of the source field is not populated then fill space.

Make use of Index function to check which occurence of the source field it is.

Can you provide your source and target structure (along with the required output)....the requirement is a bit confusing

Former Member
0 Kudos

Hi VenkataRamesh and Abhishek,

Thanks for the reply.

The actual mapping requirement is like this

Source Structure

Sourcefield1

Sourcefield2

Target Structure

Targetfield1

Targetfield2

Mapping rule for Targetfield1 : Map Targetfield1 with the second occurrence of Sourcefield1 when Sourcefield2=5

and if second occurrence of the Sourcefield1 is not populated that is if it is empty then

fill it with value space

Can you please tell me how can I implement it?

Thanks in advance

Edited by: Shweta Kullkarni on Aug 16, 2010 11:59 AM

Former Member
0 Kudos

Hi,

> Mapping rule for Targetfield1 : Map Targetfield1 with the second occurrence of Sourcefield1 when Sourcefield2=5

> and if second occurrence of the Sourcefield1 is not populated that is if it is empty then

> fill it with value space

Map like below

sourcefield1 -- mapwithdefault node function -- copyValue -- targetfield

Sourcefield1 Context you have to change and double click on copy value and give 1 as input.

or

sourceField1 -- mapWithDefault -- ContexttypeUDF -- targetfield

Context type UDF code

Input as sourcefield1 and this variable name is say a

return a[1];

Regards

Ramesh

former_member208856
Active Contributor
0 Kudos

Use Standard functions for the mapping.

Use IF with else function

Use Function Counter (IF Counter = 2), this is for 2nd occurance.

Check IF Source1 (EXISTS (standard function)), IF Source2 = '5', Pass the value

Else IF Source1--> NOT --> EXISTS --> Pass CONSTANT (SPACE).

Former Member
0 Kudos

Hi VenkaRamesh ans Sandeep,

Thanks for the reply.

For the first occurrence,we need to keep the context of the CopuValue as 0,for the second occurrence as1,for the Third occurrence 2,and so on.Right?

Thanks in advance

Former Member
0 Kudos

Hi,

Use what ever Sandeep suggested, that is simple.

if Sourcefeild1 --- exists --- and --- sourceField1 -- counter

-


equals

-


2 (your condition value)

then map sourceField1 to targetfield.

else map space to the targetField.

Regards

Ramesh

former_member208856
Active Contributor
0 Kudos

For this purpose use COUNTER Function, which is available in Arthamatic functions.

Former Member
0 Kudos

Hi VenkataRamesh and Sandeep,

Thanks for the reply.

There are 2 values to be given to the counter function

Initial Value

Increment

What values should be given for the first,second,third and fourth occurrences?

Thanks in advance

Former Member
0 Kudos

Hi,

> There are 2 values to be given to the counter function

> Initial Value

> Increment

Give initial value as 0 and increment value as 1.

Regards

Ramesh

former_member200962
Active Contributor
0 Kudos

I would suggest that you use the Index function instead of Counter function....count may fail in case of a context change.....index will retain the value even in case of a context change.

Intial value will be 1 and increment will be 1

Former Member
0 Kudos

Hi VenkataRamesh,

Thanks for the reply.

Give initial value as 0 and increment value as 1.

This is for the occurrence 1.Right?

For occurrence 2,

initial value 1

increment value 2

And so on.Right?

Thanks in advance

Former Member
0 Kudos

Hi,

> This is for the occurrence 1.Right?

> For occurrence 2,

> initial value 1

> increment value 2

> And so on.Right?

Yes

Regards

Ramesh

Answers (2)

Answers (2)

prateek
Active Contributor
0 Kudos

User breaking forum rules frequently

Former Member
0 Kudos

Hi Shwetha,

map that variable to the target field in the middle use copyvalue and occurance is 1 (after double click give 1). Context you have to set. if you provide the actual source structure then i can give more details.

Regards

Ramesh