Skip to Content

Splitting file based on field

Hi Group,

we have requirement to split the incoming file based on one field (PSGID) value chanage,can any body help how to achieve this:

Incoming Source:

------------------

<Record>
<DPZ>
<field1>201000</field1>
</DPZ>
<TDR>
<field11>20</field11>
</TDR>
<SUP>
<id>BEEN</id>
<\SUP>

<PSG>
<PSGID>A </PSGID>
<\PSG>
<DA>
<DAID>ex1</DAID>
</DA>
<PSG>
<PSGID>B </PSGID>
<\PSG>
<DA>
<DAID>ex2</DAID>
</DA>
<PSG>
<PSGID>C </PSGID>
<\PSG>
<DA>
<DAID>ex3</DAID>
</DA>
</Record>

Target
------

File1
----------
<Record>
<DPZ>
<field1>201000</field1>
</DPZ>
<TDR>
<field11>20</field11>
</TDR>
<SUP>
<id>BEEN</id>
<\SUP>
<PSG>
<PSGID>A </PSGID>
<\PSG>
<DA>
<DAID>ex1</DAID>
</DA>
</Record>

File 2
--------
<Record>
<DPZ>
<field1>201000</field1>
</DPZ>
<TDR>
<field11>20</field11>
</TDR>
<SUP>
<id>BEEN</id>
<\SUP>
<PSG>
<PSGID>B </PSGID>
<\PSG>
<DA>
<DAID>ex2</DAID>
</DA>
</Record>

File 3
--------

<Record>
<DPZ>
<field1>201000</field1>
</DPZ>
<TDR>
<field11>20</field11>
</TDR>
<SUP>
<id>BEEN</id>
<\SUP>
<PSG>
<PSGID>C</PSGID>
<\PSG>
<DA>
<DAID>ex3</DAID>
</DA>
</Record>

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Jun 07, 2012 at 11:48 AM

    You can try using SplitByValue(ValueChange) function so that all PSGID value A goes into one, B goes into another and so on. would be good if you can share the screenshot of mapping with source and target structure.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 07, 2012 at 12:05 PM

    Hi Rajiv,

    You could use multi.mapping for this issue http://scn.sap.com/people/ranga.rajan2/blog/2010/03/17/multi-mapping-with-a-simple-scenario--fledgling-kit

    (Also, don't forget to "like" or rate (or both) the blog in case you find it useful.)

    You use the function pointed by Zammer in order to create different messages.

    Regards.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 07, 2012 at 12:12 PM

    Below logic works in your case

    Source field---->remove context---->splitby value(value change)---->collapse context---->target.

    But how you are going to collect multiple files in to sinfle file, you need BOM for this.

    Regards,

    Raj

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.