How to create multiple files with Receiver File Adapter in SAP PI 7.31 Java Stack

Dear Friends,
I am using Sender JDBC Adapter and Receiver File Adapter in Integration Flow in SAP PI 7.3 EHP 1 SP08 Java Stack environment. The requirement is that we need to create multiple files based on the row count in jdbc resultset. If there are 5 rows in resultset, we need to create 5 XML files with one row elements in one file. Similarly if there are 10 rows, we need to create 10 XML files.
So how can we create multiple files in this scenario. I tried placing a for loop in the Java Mapping as below in the transform method:
DynamicConfiguration conf = arg0.getDynamicConfiguration();
StringBuffer sbFileData = new StringBuffer();
for (int i =0; i < record.size(); i++ {
     . // Create XML for each row and Marshal the object into to the String Buffer
     String strFileName = "DC_" + new SimpleDateFormat("ddMMyyyyHHmm").format(new java.util.Date())+"_"+i+".xml";
     conf.put(KEY_FILENAME, strFileName);
     arg1.getOutputPayload().getOutputStream().write(sbFileData.toString().getBytes("UTF-8"));
     arg1.getOutputPayload().getOutputStream().flush();
So here I'm flushing the OutputStream for each record. But it's not creating the multiple file, instead it creates only one file will all record XMLs appended to each other.
Please let me know if I missing something or need to do some thing else.
Regards,
Shreyansh Shah

Hi
You can easily achieve this using graphical mapping.  Create your target message type like below
MT_Target
  Details  0 to 1
      Data  0 to 1
Source sample structure
<resultset>
<row>
<column-name>column-value</ column-name>
</row>
Then do the message mapping like below
map <row> with  MT_Target
contant ----> Deatils
column-name ------>Data
In the signature tab of message mapping, choose the occurrence of your target message type as
0 to unbounded.
This will generate multiple files from multiple rows.
Let me know if you have any doubt.

Similar Messages

  • How to create multiple copies of a file with renamed filenames

    hi,
     I want to create multiple copes of a  file [ say abc.docx] which has 3.5 MB of size  and want to rename it through power shell.
    so, in the end, i want to get abc_1.docx,abc_2.docx, abc_3.docx ....abc_10.docx in the same folder with the same size. i mean, after running the ps script i should get the foldwer size set to 35 MB .
    can anyone help, how to achieve this?
    I am newbie in powershell. 
    i tried the below :
    $File = Get-ChildItem -Path "D:\ABCFolder\" -Filter Copying.bat -Recurse
    for($i = 0; $i -lt $File.Count; $i++)
    Copy-Item $File[$i].FullName ("D:\ABCFolder\" + $File[$i].BaseName + $i +".doc")
    help is appreciated!

    but the below one didnt work:
    $File = Get-ChildItem -Path "D:\ABCFolder\" -Filter Copying.Bat -Recurse
    for($i = 0; $i -lt $File.Count; $i++)
    1..10 | Copy-Item $File[$i].FullName "$($File[$I].DirectoryName)\$($File[$i].BaseName)_$_$($File[$i].Extension)"
    am getting the below erro when executing this code:
    $File = Get-ChildItem -Path "D:\mfolder\"
    $count = $file.Count
    for ($x = 0; $x -lt $count; $x++)
    $ext = $file[$x].Extension$name = $file[$x].BaseName
    for($i = 0; $i -lt 100; $i++)
    Copy-Item $File[$x].FullName -destination "D:\mfolder\$name_$i$ext"
    /////////////////////////////error below://///////
    At D:\mfolder\createcopies2.ps1:7 char:27
    + $ext = $file[$x].Extension$name = $file[$x].BaseName
    + ~~~~~
    Unexpected token '$name' in expression or statement.
    + CategoryInfo : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken

  • How to creat a document with a file

    i'm coding a texteditor-like programme.
    I did use a Jtable instead of a JtextComponent's subclass to display & edit text.
    however, i want to realize some function just like a texteditor such as undo & redo.
    Shoud i must creat a document to realize function i mentioned above?
    if yes, i searched in the google to find that always use method jtextComponent.setDocument () to automatically creat a document by files loaded in the jtextComponent.
    if i just creat a jtextarea for creating document & did not make it visible, whether it will waste too much resouces
    or i should make a subclass of AbstractDocument to transformer file to document?

    Hi Gilo,
       Check these docs...
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/0403a990-0201-0010-38b3-e1fc442848cb">How to… Download a Hierarchy to a Flat File</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/fa/e92637c2cbf357e10000009b38f936/content.htm">Uploading Hierarchies from Flat Files</a>
    <a href="http://sapbwneelam.blogspot.com">More Docs...</a>
    Hope it Helps
    Srini

  • How to create a mapping with text file as my target

    I need to create a mapping with source as a table and target as a text file.
    I am using OWB 10g R2. with database Oracle10g.
    Any one can help me to create a mapping with a text file as target.

    Hi,
    just create a File-Location and File-definition and use this file-operator as target object inside your mapping.
    Regards jwehner

  • How to create a form with sequential file numbers everytime it is saved?

    I created a pdf form in LiveCycle and my plan is to have people to fill in the form, then print it. Each time the person fills in the form, it should have a new file number. Like the old carbon copy receipts. I believe that either it counts and verifies if it exists or it uses an xml file. How can i make this happen, i am very new to this so any help will be truly appreciated. Thank you.

    Hi sebvoid,
    Did you ever get an answer to this? I am wanting to do the same thing.

  • How to handle multiple responses in Receiver Mail adapter?

    Hello,
    I have a scenario where I get n number of responses which has to be sent as an email.
    My response looks like this -
       <Response>
          <Status/>
          <Text>TEST 1</Text>
       </Response>
       <Response>
          <Status/>
          <Text>TEST 2</Text>
       </Response>
    Please let me know if there is any way to send this response as email.
    Thanks

    Hello,
    Check below mapping and change it as per ur source (response) and target (content) fields.
    Note - In below mapping i have used return as xml functionality on Record node, u have to use the same on ur source field.
    After implementing above mapping, just execute ur E2E scenario and check how content is getting generated in ur mail?
    Thanks
    Amit Srivastava

  • How create 1 dvd with 2 file

    how create 1 dvd with 2 file

    As you probably know,  DVD creation in Compressor and FCPX is very limited – and it only accommodates single tracks.
    But there is no reason why you can't put multiple movies on a single timeline in FCP. Separate them with inserted gaps and add chapter markers to provide some level of navigation among them.
    Good luck.
    Russ

  • How to create a table with datatype blob and insert a pdf file (ravi)

    how to create a table with datatype blob and insert a pdf file,
    give me the explain asap
    1.create the table?
    2.insert the pdffiles into tables?
    3.how to view the files?
    Thanks & Regards
    ravikumar.k
    Edited by: 895044 on Dec 5, 2011 2:55 AM

    895044 wrote:
    how to create a table with datatype blob and insert a pdf file,
    give me the explain asapPerhaps you should read...
    {message:id=9360002}
    especially point 2.
    We're not just sitting here waiting to answer your question as quickly as possible for you.

  • How to Open multiple form with only one screen painter file

    Hi all ,
    I want to reopen the form without closing the active form ,i want to use same srf file ..
    I have already try it but form already exist error occur .
    pl help me , how to do it ?
    how to open multiple form with same srf file without closing active forms .
    thanks in advance,
    msw

    <?xml version="1.0" encoding="utf-16" ?>
    <Application>
      <forms>
        <action type="add">
          <form appformnumber="-1" FormType="-1" type="0" BorderStyle="0" uid="BOE" title="Bill of Entry" visible="1" default_button="1" pane="0" color="0" left="365" top="62" width="801" height="410" client_width="785" client_height="372" AutoManaged="1" SupportedModes="15" ObjectType="">
            <datasources>
              <dbdatasources>
                <action type="add">            
                </action>
              </dbdatasources>
              <userdatasources>
                <action type="add"/>
              </userdatasources>
            </datasources>
            <Menus>
              <action type="enable">
                <Menu uid="1282"/>
              </action>
              <action type="disable">
                <Menu uid="5890"/>
              </action>
            </Menus>
            <items>
            </items>
            <ChooseFromListCollection>
              <action type="add">
                <ChooseFromList UniqueID="-1" ObjectType="-1" MultiSelection="0" IsSystem="1"/>          
              </action>
            </ChooseFromListCollection>
            <DataBrowser/>
            <Settings Enabled="0" MatrixUID="" EnableRowFormat="1"/>
          </form>
          <form appformnumber="-1" FormType="-1" type="0" BorderStyle="0" uid="BOE1" title="Bill of Entry" visible="1" default_button="1" pane="0" color="0" left="365" top="62" width="801" height="410" client_width="785" client_height="372" AutoManaged="1" SupportedModes="15" ObjectType="">
            <datasources>
              <dbdatasources>
                <action type="add">
                </action>
              </dbdatasources>
              <userdatasources>
                <action type="add"/>
              </userdatasources>
            </datasources>
            <Menus>
              <action type="enable">
                <Menu uid="1282"/>
              </action>
              <action type="disable">
                <Menu uid="5890"/>
              </action>
            </Menus>
            <items>
            </items>
            <ChooseFromListCollection>
              <action type="add">
                <ChooseFromList UniqueID="-1" ObjectType="-1" MultiSelection="0" IsSystem="1"/>
              </action>
            </ChooseFromListCollection>
            <DataBrowser/>
            <Settings Enabled="0" MatrixUID="" EnableRowFormat="1"/>
          </form>
        </action>
      </forms>
    </Application>

  • How to create multiple pages in the output file?

    hi, we have an application (C++) that generates PDF output. I've been asked to figure out how to create multiple copies of each page (uncollated). i.e. the output would be 4 copies of p 1 followed by 4 copies of p 2, etc. I'd like to do this without actually replicating each page if possible ... any ideas?

    Why not just put four copies of the same CosObj reference into the Pages array/tree?

  • How to create a table in the file using java code.?

    HI,
    I should export the data from the view objects to a word document. I have done that but I should
    display the data in the form of a table.
    Kindly come up with the necessary information on how to create a table in the file using java.
    Thanks,
    Phani

    Hi, Thank you for responding to my query.
    The below are the details of my code.
    DCBindingContainer dcBindings =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding StudentDetailsContent =
    (DCIteratorBinding)dcBindings.get("StudentView1Iterator");
    OutputStreamWriter w = new OutputStreamWriter(outputStream, "UTF-8");
    Row currentRow =
    StudentDetailsContent.getRowSetIterator().first();
    Object a[]= currentRow.getAttributeValues();
    int i;
    for(i=0 ;i<=a.length;i++){
    w.write(a.toString());
    w.write(" ");
    w.flush();
    I am usning this coding to achieve the task of exporting data to file.
    I need to display this information in the table that is where I need help from you people.
    Thanks,

  • Problem with Receiver File adapter

    Hi
    I have a problem with receiver file FTP adapter, while writting file in target folder, connection is failing, after retries, it writting file again. How to avoid this situation, is there any way to write the leftout part in the file.
    VS

    Hi
    Thank u all,  Problem is solved, i changed write mode to Over write existing file. It is working fine.
    VS

  • Save file in multiple directories using receiver file adapter?

    Hi,
    Is it posible to save file in multiple directories using receiver file adapter?
    Regards,
    Ashish

    Well, there is a round about way to do that -
    The idea is to use multi mapping. 1:n mapping
    1) Map ur message to 2 different record set nodes. Since you want to use the same file both the mapping will look exactly the same. make sure that the filepath and filename are a part of the output payload message
    2) In the file adapter config. make sure the the file name and file path are from these payload fields. You can use a context object to refer these fields. Voila...the files are created in the 2 direcoties you mentioned.
    of course the simplest way is to route the same message to 2 business systems/services and write them out using 2 ccs.,
    Arvind R

  • How to create Inbound Idoc from XML file-Need help urgently

    Hi,
    can any one tell how to create inbound Idoc from XML file.
    we have xml file in application server Ex. /usr/INT/SMS/PAYTEXT.xml'  we want to generate inbound idoc from this file.we are successfully able to generate outbound XML file from outbound Idoc by using the XML port. But not able to generate idoc from XML file by using we19 or we16.
    Please let me know the process to trigger inbound Idoc with out using  XI and any other components.
    Thanks in advance
    Dora Reddy

    Hi .. Did either of you get a result on this?
    My question is the same really .. I am testing with WE19 and it seems SAP cannot accept an XML inbound file as standard.
    I see lots of mention of using a Function Module.
    Am I correct in saying therefore that ABAP development is required to create a program to run the FM and process the idoc?
    Or is there something tht can be done with Standard SAP?
    Thanks
    Lee

  • How to map Idoc fields with external file

    Hi All,
    How to map Idoc fields with external file.
    I want to check the settings where Idoc fields are mapped with external file.
    Thanks in advance.
    Regards,
    Govind.

    If you have configured a fileport where on trigger of IDOC you are creating the file, you can look at the message type documentation and get the offset values for each field in each segment

Maybe you are looking for

  • CRM 7.0 Unable to open/view PDF Attachments in Email (Intermittent issue)

    Hi, Unable to open an attachment (PDF format) sent from exchange server(Lotus) to SAP CRM,Actually its an intermittent issue When i try to open email in UI ,getting an error message "File is damaged and couldnot be repaired". I understand that PDF at

  • Maximum number of elements in Structure

    Hello all: what is max .of elements inside one structure. Best Regards, Manthana

  • Is there any rhyme or reason to order in which app updates are displayed?

    I posted this on the iPhone forum a while ago, with no useful response. I'm asking again here, because it is equally applicable to iPad. Is it completely random, or is there an order I am unaware of? I would expect to see app updates displayed by dat

  • Error In LOV

    I have attached lov to a field and when i click the torch i get the following error oracle.apps.fnd.framework.OAException: The application id or shortname (common) you entered does not exist. where can the error be?

  • Need help with column formatting (see image)

    I am trying to make a spreadsheet that calculates proportional image sizes of a fixed original size. I have it set up so you enter an original size on the left (see image below) and the spreadsheet calculates the proportional sizes on the right (in t