cancel
Showing results for 
Search instead for 
Did you mean: 

Output multi files based on field value

former_member260907
Participant
0 Kudos

Hi All,

Can PI pick up one file and output multi files based on key field value? That is when the key field value changes, create a new file?

Thanks,

Charles

Accepted Solutions (1)

Accepted Solutions (1)

former_member186851
Active Contributor
0 Kudos

Hello Charles,

Is it like below

Key

1--------------------------------------------One File

1

2---------------------------------------------Second File

3----------------------------------------------Third file

Multimapping should help in your case.

former_member260907
Participant
0 Kudos

Hi Rag,

Yes. The first field is a key. How I can do the multi mapping?

Thanks,

Charles.

former_member186851
Active Contributor
0 Kudos

Hello Charles,

The requirment  mentioned is correct?

check the below document

nabendu_sen
Active Contributor
0 Kudos

It should be similar:

former_member260907
Participant
0 Kudos

Hi ,

My source files is like this

1, sssss

1, aaaaa

1, ddddd

2, bbbbb

2, wwww,

3, rrrrrr,

3,tttttt

3, pppppp

I want to output all 1 to file1, all the 2 to file2, all the 3 to file3, etc.

How the mapping should look like?

Thanks,

Charles

nabendu_sen
Active Contributor
0 Kudos

Hi Charles,

I think you know how to perform FCC in your Sender File channel to generate xml. Please find the below blog to understand how you need to develop the mapping to group the fields:

Regards,

Nabendu.

former_member186851
Active Contributor
0 Kudos

Hello Charles,

You can group and split based on the value change as well.

former_member260907
Participant
0 Kudos

Hi Nab,

I have created a UDF as below. But seems hashset does not work. I got the same output as the input, anyone could help?

Set<String> unique = new HashSet<String>(); 

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

   if( unique.add( ebeln[ i ] )) {

      ebeln_out.addValue(ebeln[ i ]);

   }

}

Snavi
Active Participant
0 Kudos

you need to use message split in mapping to create multiple messages, and in turn multiple files for every value change

for example,

message type for source and target

use SplitByValue on each value change as below

when execute this mapping the result will be as below,

your message type could be different based on your exact requirements, but as Raghuraman has already mentioned , with group and split by value you should be able to achieve this.

former_member260907
Participant
0 Kudos

Hi Rav,

Thank you very much for providing the mapping example. One question is what is the context for "ID", and what do you map to node "messages" and "message1"? I am getting error saying" Cannot create target element /ns0:Messages/ns0:Message1/ns1:MT_TEST"

Thanks a lot!

Charlesns1

Snavi
Active Participant
0 Kudos

Hi Charles,

All other nodes are one to one mapping and ID context is set to MT_Source

former_member260907
Participant
0 Kudos

Hi Nav,

I still keep getting error " Cannot create target element /ns0:Messages/ns0:Message1/ns1:MT_TEST". I tested in MM and OM. It works there. But when I use my source file, I keep getting that error.


Do you have any idea what is wrong with it? I have attached my mapping, FCC setting and source file. I would like to output 3 files based on it.


Thanks a lot!

Charles

Snavi
Active Participant
0 Kudos

Hi Charles,

most likely FCC is adding a RecordSet to your input message which is why it is failing in the mapping at runtime .

I cannot see all the FCC parameters in your screen shot, can you add ignoreRecordsetName = true in your FCC if it is already not there

former_member260907
Participant
0 Kudos

Hi Nav,

I have added ignoreRecordsetName = true. But I am still getting the same error.

Here is my FCC setting

Snavi
Active Participant
0 Kudos

Hi Charles,

can you check you are using the correct operation mapping in configuration,

your error says cannot create 'MT_TEST', whereas the mapping that you tested does not have this tag.

please check the configuration again,

provide the payload that you are getting after the content conversion.

former_member260907
Participant
0 Kudos

I did some research. Seems like file I can't take it away with standard SAP adapter.

Thank you for helping me such patient.

Rewarded!

Charles!

Answers (0)