cancel
Showing results for 
Search instead for 
Did you mean: 

Creation of Target Node for particular counts

0 Kudos

Hi,

I am recieveing a file and would need to populate Header and Detail fields based on count of 15.

ex: if I recieve a file with 100 records, then first 15 records should be in One Header and 1 to 15 details, Second Header with 16 to30 details records .....

Like the above I have to pouplate. can some one please guide me n this.

Thank you.

John

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

Could u share ur sample input and expected output file?

Thanks

Amit Srivastava

0 Kudos

Below is the example:

In the below header K1,K2 are constants we are passing for each 15 records.

Input:

123 abc
456 xyz
:
:
918 opu

output:

<Header>
K1
K2
<Detail>
123
abc
</Detail>
<Detail>
456
xyz
</Detail>
.
.
.
</Header>
<Header>
K1
K2
<Detaiil>
.
.
</Detail>
<Detail>
918
opu
</Detail>
</Header>

0 Kudos

Please help me out.. as it is show stopper for me..

Thank you

Former Member
0 Kudos

Hello,

I am providing u mapping for Header and Detail nodes and for rest u can do one to one mapping

Create 2 UDFs

UDF1: Header

Execution type: all values of a context

Input: input of type int


  if(input[0]%15==0)

    {

    for (int i=0;i<input[0]/15;i++)

    {                         

    result.addValue("");

    }

    }

    else

    {

    for (int i=0;i<input[0]/15+1;i++)

    {                         

    result.addValue("");

     }

    }

UDF2: Detail

Execution type: all values of a context

Input: var1 of type string


int j = 0;

int len = var1[0];

for(int i=0;i<len;i++)

{

if(j==15)

{

j=0;

result.addContextChange();

}

result.addValue("");

j=j+1;

}

Mapping:

Thanks

Amit Srivastava

0 Kudos

Hi Amit,

Thanks you..your help has given me hopes on this.

BUt here If I get same values in the queue i should consider them as single value.

ex:

Input:

123 abc
456 xyz

190 abc
:
:
918 opu

In the above sructure I have added 190 abc , but in target side the count should be same based on abc values should be 123+190 = 313.

Can you please help in this case also.

former_member184720
Active Contributor
0 Kudos

I think you can achive it with the above UDF's itself.

change the mapping to below.

For the sum field -

former_member184720
Active Contributor
0 Kudos

fyi..

L1 ->"abc" field
L2 -> value field (123..190..)

Calculate 4 - Header UDF

Calculate 5 - Details UDF

Former Member
0 Kudos

Hello,

I think Hareesh's reply will help u in clubbing values of same type, but in case u face any issues then u can get back here.

BTW, i think there is no need to use 2 different UDFs, so u can remove Header UDF and use only Detail UDF (u can rename it also) for creating Header and Detail nodes as below:

Thanks

Amit Srivastava

Answers (0)