cancel
Showing results for 
Search instead for 
Did you mean: 

File Splitting after nth record

itabhishek9
Participant
0 Kudos

Hi SDNites,

Need to split file after every 2nd record,

Source File structure,

Header

Item1

Item2

Item3

Item4

Item5

Footer

Expected output,

Receiver File1 :

Header

Item1

Item2

Footer

Receiver File2 :

Header

Item3

Item4

Footer

Receiver File3 :

Header

Item5

Footer

I am able to do the splitting with graphical mapping. But the probelm is Header is not getting to Receiver File 2 and 3. Any suggestions on how to map the Header will be of great help.

Regards,

Abhi

Accepted Solutions (0)

Answers (5)

Answers (5)

itabhishek9
Participant
0 Kudos

Hi,

I am able to complete the above requirement with graphical mapping.

Thanks a lot to you all for your valuable inputs.

@Hareesh - I have analysed the UDF that you have provided and using it I have identified graphical mapping functions to achieve it.

Regards,

Abhi

former_member181985
Active Contributor
0 Kudos

Hi Abhishek,

Use Graphical variables and try like as shown below. For understanding purpose, I have grouped all target fields

createContexts UDF Code

for(int i = 0; i < var1.length; i++)

{

  if(i%2 == 0 && i != 0)

  {

  result.addValue("");

  }else if(i == 0){

  result.addValue("");

  }

}

split_Items UDF code

for(int i = 0; i < var1.length; i++)

{

  if(i%2 == 0 && i != 0)

  {

  result.addContextChange();

  result.addValue(var1[i]);

  }else{

  result.addValue(var1[i]);

  }

}

Best Rgds,

Praveen Gujjeti

Former Member
0 Kudos

Hello,

>>I am able to do the splitting with graphical mapping. But the probelm is Header is not getting to Receiver File 2 and 3

Try using copyvalue (0) function for header and its corresponding fields.

Thanks

Amit Srivastava

itabhishek9
Participant
0 Kudos

Hi Amit,


Your answer is absolutely correct.

Stuck up further in the same mapping,

1. Message split - Working fine.

2. Same records - Copying fine in each new message.

3. Structure based on which split is happening has to be populated in receiver message. It is getting populated but here all the records are seen in one message and not the split ones.

Ex:

Header

Item1

Item2

Item3

Item4

Item5

Footer

Expected output,

Receiver File1 :

Header (Fine)

Item1 -------------- Here I am getting all the Items (1,2,3,4,5)

Item2

Footer (Fine)

Receiver File2 :

Header (Fine)

Item3 -------------- Here I am getting no records

Item4

Footer (Fine)

Receiver File3 :

Header (Fine)

Item5 -------------- Here I am getting no records

Footer (Fine)

Regards,

Abhi

former_member184720
Active Contributor
0 Kudos

Did you try the solution i suggested?

Former Member
0 Kudos

Hello,

Looks like a context issue, paste ur mapping screenshot here..

Thanks

Amit Srivastava

former_member184720
Active Contributor
0 Kudos

Here

Products refers to Items:

Objects : Header

Calculate1 : UDF to split for every two records.

Target MT:

Header & it's fields...

Items :

Split:

PeterJonker
Active Contributor
0 Kudos

Use the function OneAsMany or define a parameter on header level in target where you map the header to. and then use this parameter to map the headerinfo again to every instance.