Merge files...... pick file dynamically Based on your content

Hi All,
In my current scenario I have 2 dependent sources (Proxy and File system) from which data is being sent to a common target service. The sources are dependent on Proxy/ECC to File System. Please let me know how I need to pick the file from File system because lot of files are there in File System. Based on my ECC/Proxy message details on field of ABN, according ABN number I need to be pick the file from the File system but I have lot of files in File system. Please let me know how to pick multiple files from one correct file based on my first file message.
After that picking the files I need merge the two messages and send to target file system.
Using fork I can merge files, no issues. But here problem to pick file dynamically Based on content .
Please provide your input......
Regards,
Ramesh

Hi Ramesh Sir,
You can go for JAVA Type Message Mapping.
ECC - >  JAVA BASED MESSAGE MAPPING ( HERE WE WILL PERFORM FILE LOOKUP) - > RECEIVER .
Is This approach sounds fisible to you ?
Please provide Sender DataType XML / Receiver DataType XML + any 1 csv file in which lookup has to perform.
and this approach is only possible , if your Flat file is on FTP Server which is on the same network.
Regards
Prabhat Sharma.

Similar Messages

  • Empty file picked although file have lot of data in file adapter SAP PI

    Hello All,
    We are facing the weired behaviour of SAP PI file adapter channel.
    In without mapping Scenario of 7.31
    At some time whole file is archived properly in archive folder but in SAP PI log we can see the file size 0 bytes.
    And at received side empty file will be sent.
    But in actual there is lot of data in the file.
    The same file triggered next time then it working fine.archived and sent as it is.
    So can anybody help me for this ?what is the issue why sometime file with no data is  picked by PI?
    If file is pick up by PI before it is written completely by third party then is it possible that archived file will have all data as it although processed empty ?
    Thanks in advance,
    Anant

    Hi,
    Thanks for reply.
    I know this is common issue of file picking before completing the process of file writting and also i can use Msec to wait before modification check for avoiding this but
    my question is how the archived folder have the file with all data that sender is sending.
    So is it possible that empty file (before compete writting )is picked up by sap pi and then after completing the picking process it will archive the file that is completely written by third party in source folder.
    In other way file picking & File archiving is separate process means file that is picked is not archived but once pi processed the file then it will again check the source folder and archive and delete the same file.
    Thanks
    Anant

  • Sender File adpater to Pick Two files at a time based on the file name

    Hi Everyone,
    I have a scenario where I need to pick two files at a time using file adapter where the two files names have a common string in between their names.For example , the file names can be sets like
    H123.txt and L123.txt
    H345.txt and L345.txt.
    Now how do we handle this in the File Adapter ?

    Anu,
    Two approaches.
    1.     Use BPM: use a collect pattern to pick those files: L and H files , use multi mapping to merge those files and map to IDoc. Constraint is that there must be a mandatory correlation field in both the files. Say a same po id  in L and H file.
    2.     Use an Adapter module with additional files option in file Adapter. Operate on the Main payload and attachment inside your module code to get a combined contents of both files and proceed.
    Module is preferable in terms of performance, but maintenance is difficult. Deployment after each changes, transport issues, etc.
    BPM is resource intensive, but easy to maintain, transport.
    Choose based on your requirement.
    Regards,
    Sudharshan N A

  • Merging of flat files based on some value in the file.

    Hi all,
      I have one requirment in which I need to pick some flat files(Let say N number of files).
    Third row in each file, needs to be read and all files having same value in 3rd row needs to be merged in single file.
    There should be as many output files as many different values at row 3rd in all files.
    All the files having unique 3rd row value, will be having sequence number in 4th row. While merging we need to take care of the sequence number and need to be merged based on sequence number.
    All the files need to be placed at some FTP location
    Thanks
    Jai

    thanks for ur response Raj.
    My input files don't have any fixed length or structure.. So It is not possible to write FCC.
    Can you please explain your point in detais
    My approach is to store the files at some intermediate location and go with two interfaces.
    If you have any other idea please let me know.
    Thanks
    Jai

  • Picking files based on the requested URL

    Hi Experts
    I have a requirement where I need to pick image files from SAP DMS server based on the URL requested.
    The scenario :
    Third-party sends a URL  corresponding to a particular image in DMS as request and PI needs to Pick the image
    file and send it as response.
    Due we need BPM? How to set up sender file adapter source directory as  the file name/directory   to be picked is dynamic in nature and there is no specifc pattern .We need to pick the exact file base on the Unique URL.
    Can we do this requirement in a synchronous interface by using HTTP or SOAP attachments for image? What about
    the performance impact as we have img files here.
    Regards,
    Srinivas
    Edited by: Srinivas on Sep 27, 2010 11:36 AM

    Third-party sends a URL corresponding to a particular image in DMS as request and PI needs to Pick the image
    file and send it as response.
    BPM would be required....We had a similar requirement wherein a URL was given at runtime to PI....then PI had to call the location and get back the details and we used SOAP for this (SYNC Call to the URL using SOAP channel from the BPM).
    Can we do this requirement in a synchronous interface by using HTTP or SOAP attachments for image?
    Not sure how the attachment will function inside a BPM....in my case I got the details as part of the message...even it was an image but it was stored as a base64 encoded message.
    Regards,
    Abhishek.

  • Creating Files Dynamically based on Condition

    Hi Experts,
    I want to create a scenario in which I want to have N number of target files based on some condition.
    Suppose I have following Source structure .
    <ns0:MT_Employee_Src xmlns:ns0="urn://FileToFile_ERD">
       <Details>
          <EmpId>1</EmpId>
          <Name>Rabi</Name>
          <Designation>ABAP</Designation>
       </Details>
          <EmpId>4</EmpId>
          <Name>Satya</Name>
          <Designation>ABAP</Designation>
       </Details>
    </ns0:MT_Employee_Src>
    My requirement is I want to have 2 different target files based on EmpId.
    And this should be dynamic that means N number of EmpId in my source will create N number of files.
    Can anyone help me to solve this?
    Any kind of suggestion will be appreciated.
    Thanks
    Rabi

    Hi All,
    As my requirement was to create N files dynamically based on some condition so I first used 1:N multimapping without BPM.
    Then I followed RP's steps.
    Follow those steps
    1) in the message Mapping go to Signature T..Outbounded.
    2)later go back to main tab . you shoud create a mapping like this:
    3)<EmpId>--> change the context to MT_Employee_Src. to do that press right button on the field and go to context menu option.
    map this field to the proper header target structure E.X: MT_Employee_Tgt
    4) doing this you will create as many target files as <EmpId> you receive.
    5) map the rest of the fields
    This is great.And  this helped me a lot and finally gave solution.
    I want to share one thing that I faced.
    when you are doing 1:N multi-mapping then you have to change the occurrence of target .
    Then your source and target structure will be changed .If you are taking the source schema from mapping then remove the extra tags those got generated due to multi mapping such as
    <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
    - <ns0:Message1>
    </ns0:Message1>
      </ns0:Messages>
    And then use the file and it will work fine.
    Thanks
    Rabi

  • How to pick the multiples based on file size

    Hi All,
    my sender file adapter needs to pick up 5 files based on file size.
    for example 1file size is 500kb,2nd file size 300kb,3rd file size 400kb, 4file size 100kb and 5file size 600kb.
    here my requirement is, my file adapter needs to pick in the below order like 5th file,1st file,3rd file 2nd file and 4th file.
    means based on file size, i need to pick up my file adapter.
    could you please ang inputs on this requirement.
    Thanks & Regards,
    AVR

    Hi AVR,
    for case 2:
    1. At specific time each day  "23:58:00" hours ,count the number of files in directory say "c:\apps\acm".
    2. sort the files on basis of their size.
    3. place the files one by one after definite  time interval (more than polling time of the sender communication channel).
    in target directory say "c:\apps\acm1" from where PI server  picks up the files for further processing. The file with smallest size is placed last.
    4. In this case you need to ensure all files are present in the directory "c:\apps\acm" before "23:58:00" hours.
    for case 2  java code
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    public class sortFilesOnSpecificTime {
    * @param args
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    try
    * In Unix/Linux OS, dir1="/usr/apps/test"  etc
    int pollingInterval=10,sleepTime=1*60;
    String dir1="c:\\apps\\acm";
    String dir2="c:\\apps\\acm1";
    File fread=new File(dir1);
    File fwrite=new File(dir2);
    if(fread.canRead()==false)
    System.out.println("error: "+dir1+" does not have read permission. Program Terminates.");
    return;
    if(fwrite.canWrite()==false)
    System.out.println("error: "+dir2+" does not have write permission. Program Terminates.");
    return;
    String fileNames[],fileNamesOut[];
    long fileSize[];
    int i,j;
    byte b[];
    int t=4;
    Calendar cal;
    int hour24,min,fileCopyHour=23,fileCopyMin=58;
    long waitSeconds=1,currentTime=0;
    while(t>0)
    cal = new GregorianCalendar();
    hour24 = cal.get(Calendar.HOUR_OF_DAY);     // 0..23
    min = cal.get(Calendar.MINUTE);             //0..59
    System.out.println("current time="+hour24+":"+min);
    /*loop unless time reaches a specific predetermined value
    * predetermined values are provided by values
    * fileCopyHour=8,fileCopyMin=30 i.e say 08:30 hours
    currentTime=(hour24*60+min)*60;
    waitSeconds=(fileCopyHour*60+fileCopyMin)*60 - currentTime;
    if(waitSeconds>0)
    * in case you wanna to make this thread sleep for
    * say sleepTime(10) minutes before it checks the files once again
    * because looping continuously causes wastage of CPU cycles.   
    Thread.sleep(waitSeconds*1000);
    //read list of files
    fileNames=fread.list();
    if(fileNames.length;=0)
    * time is up but there are no file
    * in dir1 to copy. Then this program
    * goes to sleep for some time and
    * checks only at 11:55 hours. That is
    * end of the day
    continue;
    fileSize=new long[fileNames.length];
    fileNamesOut=new String[fileNames.length];
    //read their sizes
    for(i=0;i<fileNames.length;++i)
    fileNamesOut<i>=fileNames<i>;
    fileNames<i>=dir1+System.getProperty("file.separator";)+fileNames<i>;
    fileSize<i>=new File(fileNames<i>).length();
    System.out.println(fileNames<i>+" size="+fileSize<i>);
    //sorting on basis of file size descending order
    long value;
    String temp;
    for(i=1;i<fileSize.length;++i)
    value=fileSize<i>;
    temp=fileNames<i>;
    for(j=i-1;j>=0 && fileSize[j]<value;--j)
    fileSize[j+1]=fileSize[j];
    fileNames[j+1]=fileNames[j];
    fileSize[j+1]=value;
    fileNames[j+1]=temp;
    //now copy files to dir2
    b=new byte[512];
    for(i=0;i<fileNames.length;++i)
    System.out.println(fileNames<i>+" size="+fileSize<i>);
    for(i=0;i<fileNames.length;++i)
    File f=new File(fileNames<i>);
    FileInputStream in=new FileInputStream(f);
    FileOutputStream out=new FileOutputStream(dir2+System.getProperty("file.separator";)+fileNamesOut<i>);
    int len=0;
    while(2>1)
    if((len=in.read(b))<0)
    break;
    out.write(b,0,len);
    in.close();
    //delete files after copying from dir1
    f.delete();
    out.close();
    //put each file after polling interval is over
    Thread.sleep(pollingInterval*1000);
    catch(Exception e)
    e.printStackTrace();
    The code runs in infinite loop. You need to run them in command line in DOS environment as you indicated that you OS is WIN XP.  I have a few print statements which I kept for debugging, you can safely remove them and run the codes. This code is independent of the Operating System you are using. Only change is required in values of "dir1","dir2", timings and file count, which I think you can take care easily.
    Hope this solves your problem.
    regards
    Anupam

  • How to Merge multiple XML  files in one file ( Env: XML Publisher 5.6.2)

    All,
    I have recently started working on XML publisher and have developed 3 reports in last 2 days using XML Publisher and integrating them with Concurrent programs.
    This is a great tool.
    I have got another requirement, where i need to use xml file generated by multiple run of same report with various parameters and then merge all xml file to a single report. Developing the whole custom process will take very long time and sure will have bugs in it. Instead i was thinking to use xml file generated by Oracle report itself.
    Report "US Gross to net summary" generates xml output in standard output directory and then show output in PDF file. I have 7 such file generated for each payroll. I want to merge output of xml into a single xml so that i can create single report having data from all 7 xml files showing me All payroll output in a single report.
    Can someone please guide me , how can i read xml file data from the output directory of a seeded concurrent program and how to manipulate data in it.
    Thanks
    Ankur

    Hi Tim,
    Thanks for replying. I have looked for "PDFBookBinder class" in xml publisher user guide for ver 5.6.2. I didn't get any reference of this text. Can you please guide me to a tutorial/link where i can get more information about this class.
    Also, i originally thought of similar to your second logic, as my design basis. Oracle process generates the xml file in output directory which i can get. What i didn't get is how do i "pick them up and merge" using publisher. Also, is there way to do this merging process using pl/sql ? Can you please give little more information on your second approach.
    My original plan of action is that i will create a report set in which i will call oracle seeded report for all 7 payrolls in a sequential manner. Then using the child requests of the report set i will get to 7 xml files generated by seeded oracle process. Then the piece i am not sure of , i will use those 7 files to generate a single xml file having payroll name as tree top for each output. Once single xml is ready, i can easily design a template and register the process to generate output as Excel.This process will not require me to actually change any data or do any calculation. It will only reformatting the feilds we see and abiity to see all 7 payroll at one time rather then entering these numbers manually into an excel to do analysis.
    Please provide your feedback, if you think above plan is not feasible or need corrections.
    Best Regards,
    Ankur

  • Dynamic Configuration-File to File in scenario

    Hi Experts,
    As per the requirement needs to supress the numeric extensions of the files and transfer to the receiver.
    Example: file name is XXX123.txt , but after picking up by sender communication channel in XI that file needs to converts XXX.txt and transfer to the receiver. Finally in the receiver end the file name should be Mahesh.txt only.
    Please share the inputs how to do dynamic configuration in XI in File to File scenario.

    Hi,
    First you need to have a UDF as shown below. No need to put any arguments in the UDF.
    public String getFileName(Container container){
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    //get file name in string s
    String s = conf.get(key);
    //remove all numeric values
    int i,l;
    l=s.length();
    String a="";
    for(i=0;i<l;++i)
    if(s.charAt(i)>='0' && s.charAt(i)<='9')
    continue;
    a=a+s.charAt(i);
    s=a;
    conf.put(key, s);
    return s;
    Now you need to map this UDF to any root element or dummy element of the target XML structure.
    Ensure that
    1. Sender Comm Channel has ASMA and file name ticked
    2. Receiver Comm Channel  has ASMA and file name and "fail if ASMA missing" ticked
    3. in receiver communication channel -> File access parameters-> File name scheme -
    > put any value say "*". This step is not compulsory.
    Hope this solves your problem.
    regards
    Anupam

  • Can a .m file be loaded dynamically????

    Dear All,
    Can anybody tell me whether a .m file be loaded dynamically loaded into a mathscript node and executed???
    Thanks in advance!
    Saranya

    Hello Saranya,
    Can you elaborate on exactly what you wish to accomplish?  One way to load a .m file into the MathScript node is to right-click on the border and select "Import..."  This will let you browse for a file to put in the node.  Do you want to run a different script based on different iterations when the node executes?  If so, perhaps a switch statement would work to switch among the different functions you wish to call.  Do you truly need to run a different, and perhaps unknown, script each time the node executes?  If so, perhaps the eval command will work for you.  You may also find the path command helpful when using eval.  Note that these commands will not work in the Run-Time Engine.  Also, in LabVIEW 8.5, you will not see a performance gain in your script if you use these functions.  If this does not answer your question, please tell me more about your application.
    Grant M.
    Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments

  • Merging 8 Flash Files

    Hi,
       There are 8 different flash files and all these flash files are being merged to a single PPT and this merged PPT is being sent for Users. As this involves repeated tasks, now there is a requirement to merge all these files to single dashboard. Each dashboard is having Panel Containers and there are many charts, tickers etc.
    1. Is this possible to merge all these 8 different dashboard? How Can I merge? I assume the performance will be affected as there will be multiple connections. Any tips to have same performance after merging (as LO connections will be more tah 8)
    2. I am thinking of using Next/Previous button options to link various dashboards, if first one fails. Which button to use to give link to another dashboard.
    Could you please help
    Regards, Nanda Kishore.

    Hi Nanda,
    It is very well possible to merge 8 separate dashboards into a single dashboard. Rather I would suggest you to call those dashboards into your main one (with the help on Image component or SWF loader with some workaround ). use a play control to give ti a dynamic display or use a next and previous button to navigate. Only problem with this approach is that every time you change it to next it will reload again (this might be annoying). To avoid this you can load all of the dashboards to separate  image components an show or hide dip-pending on the value of the play-control or the button used for transition. Benefit is that it wont load again and again rather it will load all the dashboards at once, so initially it will take some time. See which one is the best possible solution for you.
    As you said you can use buttons to dynamical display and hide the components or use the standard play control for the same.
    Let us know if you need further clarification.
    Good Luck.

  • Trying to load a javascript link from text file into a dynamic textfile

    Can anyone help me with this problem? Im trying to load in a
    newsfeed from freshcontent.net into my text field. If i put this
    javascript link on an html page, the page shows correctly, which is
    im supposed to get 3 dynamic links with news content headlines.
    Please view the link to see what i mean:
    http://www.freshcontent.net/directory/real-estate/real_estate.html
    Now, i cannot get this same type of display behavior in my
    text field if i just paste into my text file the javascript link
    thats supposed to bring up the 3 headlines. It is my understanding,
    that flash cannot do this without some sort of specific
    actionscripting, that involves asfusion, and/or externalInterface.
    Im not sure exactly how to go about setting this up to make this
    work. My current code looks like this:
    If anybody could tell me where im going wrong and what i
    should change in order to get the desired result im going for, Id
    very much appreciate it. Thanks

    well sorry there fanmap - but I don't think you're going to
    be able to get this to work. here's why: the link points to a php
    file - which gathers dynamic info from a DB - the return from the
    php is generating a string that is based on the DOM and
    'constructs' a javascript method that in turn writes to the html
    document. although we can embed html into a textField in Flash
    there are a limited number of supported html tags - and JS methods
    will not operate internally. in addition, (i'm not certain someone
    correct this if i'm off) there's no way to 'change' the output of
    the php call, therefore you will not be able to read the return
    because it is designed to use the DOM and write solely to the
    current document. Even if you were to access the JS method from the
    swf file (which one can) it will still only write the content of
    the php return to the html document - and the output is not
    compatible with the textField class.

  • How do i merge two pdf files into one

    How do i merge 2 pdf files into one.

    Open up the first pdf in Preview
    Then from Menu
    select from Edit Menu
    Select Insert (your choice of)
              Page from Scanner
              Page from File (select your PDF file)
              Blank Page
    You can then save as your first file or rename it

  • How do I merge multiple Excel files with more than one tab in each file using PowerQuery?

    Hello
    I have 12 Excel (.xlsx) files and each file has three identically named and ordered tabs in them. 
    I know how to merge multiple Excel files in a folder using M (those guides are all over the web) but how do I merge multiple Excel files with multiple (yet identically named and ordered) tabs? Surely it is possible? I just don't know how to do it in M.
    Cheers
    James

    What Laurence says is correct, and probably the best thing to do when the sheets have differing structures. Here is an alternate approach that works well when the sheets all have the same structure.
    When you first open the Excel file from Power Query, you can see its structure in the navigator at the right-hand-side of the screen. If you select the root (which is the filename itself) and click Edit, you'll see all the tabs in the sheet as a single table.
    You can now do filtering based on the Name, Item and Kind values. When you've reduced the set of things down to the sheets you want, select the Data column and say "Remove Other Columns". If the sheets don't have any header rows, you can just click the expand
    icon in the header and you'll be done.
    Otherwise, if the sheets have headers or if some other kind of sheet-level transformation is required against each sheet before doing a merge, you'll have to write some M code manually. In the following example, each sheet has a header row consisting of
    two columns: Foo and Bar. So the only step I need to perform before merging is to promote the first row into a header. This is done via the Table.TransformColumns operation.
    let
        Source = Excel.Workbook(File.Contents("C:\Users\CurtH\Desktop\Test1.xlsx")),
        RemovedOtherColumns = Table.SelectColumns(Source,{"Data"}),
        PromotedHeaders = Table.TransformColumns(RemovedOtherColumns,{{"Data", each Table.PromoteHeaders(_)}}),
        ExpandData = Table.ExpandTableColumn(PromotedHeaders, "Data", {"Foo", "Bar"}, {"Data.Foo", "Data.Bar"})
    in
        ExpandData

  • Uploading data from excel file to a dynamically created internal table

    Hi,
    I have a requirement where i have to upload data from an excel file into a database table. I would be able to determine the structure of the table only at runtime based on the user input.. so i have created an internal table dynamically.
    Could you please tell me if its possible to upload data from an excel file to the dynamically created internal table using any function modules?
    I thought of doing this by declaring a generic internal table of one field and then uploading the *.csv file into it and then splitting it based on "," and then assigning it to the field symbol referencing the internal table.. but my file length exceeds 132 characters and i'm only able to get data of lenght 132 char's in my internal table ( generic one).
    Could anyone please show me a way around this.
    Thanks in advance,
    Harsha

    Sure, check this out.
    report zrich_0002.
    type-pools: slis.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: it_fldcat type lvc_t_fcat,
          wa_it_fldcat type lvc_s_fcat.
    type-pools : abap.
    data: new_table type ref to data,
          new_line  type ref to data.
    data: iflat type table of string.
    data: xflat type string.
      data: irec type table of string with header line.
      data: tabix type sy-tabix.
    data: file type string.
    selection-screen begin of block b1 with frame title text .
    parameters: p_file type  rlgrap-filename default 'c:Test.csv'.
    parameters: p_flds type i.
    selection-screen end of block b1.
    start-of-selection.
    * Add X number of fields to the dynamic itab cataelog
      do p_flds times.
        clear wa_it_fldcat.
        wa_it_fldcat-fieldname = sy-index.
        wa_it_fldcat-datatype = 'C'.
        wa_it_fldcat-inttype = 'C'.
        wa_it_fldcat-intlen = 10.
        append wa_it_fldcat to it_fldcat .
      enddo.
    * Create dynamic internal table and assign to FS
      call method cl_alv_table_create=>create_dynamic_table
                   exporting
                      it_fieldcatalog = it_fldcat
                   importing
                      ep_table        = new_table.
      assign new_table->* to <dyn_table>.
    * Create dynamic work area and assign to FS
      create data new_line like line of <dyn_table>.
      assign new_line->* to <dyn_wa>.
      file = p_file.
      call method cl_gui_frontend_services=>gui_upload
        exporting
          filename                = file
        changing
          data_tab                = iflat
        exceptions
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          others                  = 17.
      loop at iflat into xflat.
        clear irec. refresh irec.
        split xflat at ',' into table irec.
        loop at irec.
          tabix = sy-tabix.
          assign component tabix of structure <dyn_wa> to <dyn_field>.
          <dyn_field> = irec.
        endloop.
        append <dyn_wa> to <dyn_table>.
      endloop.
    * Write out data from table.
      loop at <dyn_table> into <dyn_wa>.
        do.
          assign component  sy-index  of structure <dyn_wa> to <dyn_field>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <dyn_field>.
          else.
            write: <dyn_field>.
          endif.
        enddo.
      endloop.
    Regards,
    Rich Heilman

Maybe you are looking for