In ABAP How to locate an Input file  from a Directory during run time

I'm loading data from a flat file(text file) into SAP thru BDC programs. All my input files are present in Application server.How to locate an Input file in a directory during run time to process BDC programs programmatically. Are there any in-built functions?Provided me some sample code or any method of doing the same.

Hello Murali,
you should ask this question in the ABAP forum.
Regards
Gregor

Similar Messages

  • How do i move a file from one directory to another?

    Can anyone help me in moving a file from one directory to another?
    The following code just does not work!!
    File source_file = new File(source_file);
    if(source_file.exists())
    File dest_file = new File(destination_file);
    if(!dest_file.exists())
    boolean moved = source_file.renameTo(dest_file);
    System.out.println("moved.."+moved);
    The varirable moved is always false.
    Can anyone tell me whts wrong in this code?

    The problem in your code is you used file object as argument when you create a new File. I changed a little bit codes and it should be fine now.
    String source_file1="test111.txt";
    String destination_file1="test222.txt";
    try{
         File source_file = new File(source_file1);
         if(source_file.exists())
              File dest_file = new File(destination_file1);
              if(!dest_file.exists())
                   boolean moved = source_file.renameTo(dest_file);
                   System.out.println("moved.."+moved);
    catch(Exception e){
               e.printStackTrace();
    }

  • How do i delete Older files from the directory before create a new file?

    Hi,
    How do i delete older files in a particular directory,
    the senorio is count the number of .txt files in a directory and delete the older files if file count is more than 10. (if i add 11th file the very first file has to be deleted)
    i have written the code to count the files and delete , but it is deleting all the files instead of older file
    public class ExtensionFilter implements FilenameFilter {
      private String extension;
      public ExtensionFilter( String extension ) {
        this.extension = extension;            
      public boolean accept(File dir, String name) {
        return (name.endsWith(extension));
    public class FileUtils{
      public static void main(String args[]) throws Exception {
        FileUtils.deleteFiles("c:/countfile/", ".txt");
      public static void deleteFiles( String directory, String extension ) {
        ExtensionFilter filter = new ExtensionFilter(extension);
        File dir = new File(directory);
        String[] list = dir.list(filter);
        File file;
        if (list.length == 0) return;
        for (int i = 0; i < list.length; i++) {
          //file = new File(directory + list);
    file = new File(directory, list[i]);
    if ((list[i]).length()>=10)
         System.out.print(file + " deleted : " + file.delete());
    Thanks,
    Jamin Rosina                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    What your code is doing now, is deleting all filenames that are longer than 10 characters.
    Your problem lies in the line:
    if ((list).length()>=10)

  • How do I delete a file from a directory

    I want to delete the file I have finished processing in the c:\upload directory but the f.delete() command is not working. Am I using this command correctly?
    The f.delete() is after I copy the file to an archive directory.
    Program:
    import java.io.*;
    import java.util.*;
    import java.text.*;
    import java.sql.*;
    public class ReadSource {
    public static void main(String[] args) throws Exception {
         StringTokenizer st1;
              String val1, val3, val4, val5, val9, val10, val11, val12, val13, val14, val16;
              String val2, val6, val7, val8, val15, val17, val18, val19, val20;
              int cnt;
              File f = new File("C://upload" );
              FileWriter outFile = new FileWriter("C://RIFIS/log/logfile.txt", true);
              String filetext = "Starting RIFIS Upload";
              java.util.Date d = new java.util.Date();
              SimpleDateFormat form = new SimpleDateFormat("dd/MMM/yyyy hh:mm:ss");
              String dateString = form.format(d);
         try {
              Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@xxxxx.xxxx.xxx:1521:xx","xxxxxx","xxxx");
                        Statement st = conn.createStatement();
                        outFile.write(System.getProperty("line.separator"));
                        outFile.write(filetext+" - "+dateString);
                        if (f.isDirectory())
                        { String [] s = f.list();
                        for (int i=0; i<s.length; i++)
                        { outFile.write(System.getProperty("line.separator"));
                             outFile.write("Found file - "+f+"/"+s);
              FileReader file = new FileReader(f+"/"+s[i]);
                                  File inputFile = new File(f+"/"+s[i]);
                                  File outputFile = new File("C://RIFIS/archive/"+s[i]);
                        BufferedReader buff = new BufferedReader(file);
                        boolean eof = false;
                        String val0="";
                        ResultSet rec = st.executeQuery("SELECT landings_hold_batch_seq.nextval FROM dual");
                        while(rec.next())
                        { val0 = rec.getString(1); }
                                  cnt=0;
                        while (!eof)
                        { String line = buff.readLine();
                             if (line == null)
                             { eof = true; }
                             else
                             { //System.out.println(line);
                                       cnt = cnt+1;
                                  st1 = new StringTokenizer(line,",");
                                       val1 = st1.nextToken();
                                       val2 = st1.nextToken();
                                       val3 = st1.nextToken();
                                       val4 = st1.nextToken();
                                       val5 = st1.nextToken();
                                       val6 = st1.nextToken();
                                       val7 = st1.nextToken();
                                       val8 = st1.nextToken();
                                       val9 = st1.nextToken();
                                       val10 = st1.nextToken();
                                       val11 = st1.nextToken();
                                       val12 = st1.nextToken();
                                       val13 = st1.nextToken();
                                       val14 = st1.nextToken();
                                       val15 = st1.nextToken();
                                       val16 = st1.nextToken();
                                       val17 = st1.nextToken();
                                            val18 = st1.nextToken();
                                            val19 = st1.nextToken();
                                            val20 = st1.nextToken();
                                       /*System.out.println("Token 0: " + val0);
                                  System.out.println("Token 1: " + val1);
                                  System.out.println("Token 2: " + val2);
                                       System.out.println("Token 3: " + val3);
                                       System.out.println("Token 4: " + val4);
                                       System.out.println("Token 5: " + val5);
                                       System.out.println("Token 6: " + val6);
                                       System.out.println("Token 7: " + val7);
                                       System.out.println("Token 8: " + val8);
                                       System.out.println("Token 9: " + val9);
                                       System.out.println("Token 10: " + val10);
                                       System.out.println("Token 11: " + val11);
                                       System.out.println("Token 12: " + val12);
                                       System.out.println("Token 13: " + val13);
                                       System.out.println("Token 14: " + val14);
                                       System.out.println("Token 15: " + val15);
                                       System.out.println("Token 16: " + val16);
                                       System.out.println("Token 17: " + val17);
                                            System.out.println("Token 18: " + val18);
                                            System.out.println("Token 19: " + val19);
                                            System.out.println("Token 20: " + val20);*/
                                       st.executeUpdate("INSERT INTO LANDINGS_HOLD (lh_id, lh_batch, supplier_dr_id, supplier_unique_id, supplier_dealer_id, supplier_cf_id, supplier_vessel_id, unload_year, unload_month, unload_day, state_code, county_code, port_code, itis_code, market, grade, reported_quantity, unit_measure, dollars, lh_loaddt, lh_loadlive, purch_year, purch_month, purch_day)" +
                        "VALUES (0,'"+val0+"','"+val1+"',"+val2+",'"+val3+"','"+val4+"','"+val5+"',"+val6+","+val7+","+val8+",'"+val9+"','"+val10+"','"+val11+"','"+val12+"','"+val13+"','"+val14+"',"+val15+",'"+val16+"',"+val17+",SYSDATE,NULL,"+val18+","+val19+","+val20+")");
                             FileReader in = new FileReader(inputFile);
                             FileWriter out = new FileWriter(outputFile);
    int c;
                             while ((c = in.read()) != -1)
                             { out.write((char)c); }
                             in.close();
                             out.close();
                             outFile.write(System.getProperty("line.separator"));
                             outFile.write("Number of records inserted - "+cnt);
                             outFile.write(System.getProperty("line.separator"));
                             outFile.write("Copied upload file to archive directory");
                             f.delete(); // delete the upload file
                             outFile.write(System.getProperty("line.separator"));
                             outFile.write(f+"/"+s[i]+" - Has been removed from upload directory");
                             buff.close();
                        outFile.write(System.getProperty("line.separator"));
                        outFile.write("Upload Complete...NO ERRORS");
                        outFile.write(System.getProperty("line.separator"));
                        outFile.write("*************************************************************");
                        outFile.write(System.getProperty("line.separator"));
                        //outFile.flush();
              //outFile.close();
                        conn.close();
                        else
                        { outFile.write("No files to process"); }
              catch(Exception e)
                   { outFile.write(System.getProperty("line.separator"));
                   outFile.write("ALERT....ALERT....ALERT");
                        outFile.write(System.getProperty("line.separator"));
                        outFile.write("Error Occurred in ReadSource.java - RIFIS Upload");
                        outFile.write(System.getProperty("line.separator"));
                   outFile.write("My Error: " + e);
                        outFile.write(System.getProperty("line.separator"));
                        outFile.write("*************************************************************");
                   outFile.flush();
              outFile.close();

    Gave it a try but file c:\upload\DS121002.csv did not go away. Here is the location of my delete command:
    st.executeUpdate("INSERT INTO LANDINGS_HOLD (lh_id, lh_batch, supplier_dr_id, supplier_unique_id, supplier_dealer_id, supplier_cf_id, supplier_vessel_id, unload_year, unload_month, unload_day, state_code, county_code, port_code, itis_code, market, grade, reported_quantity, unit_measure, dollars, lh_loaddt, lh_loadlive, purch_year, purch_month, purch_day)" +
                        "VALUES (0,'"+val0+"','"+val1+"',"+val2+",'"+val3+"','"+val4+"','"+val5+"',"+val6+","+val7+","+val8+",'"+val9+"','"+val10+"','"+val11+"','"+val12+"','"+val13+"','"+val14+"',"+val15+",'"+val16+"',"+val17+",SYSDATE,NULL,"+val18+","+val19+","+val20+")");
                             FileReader in = new FileReader(inputFile);
                             FileWriter out = new FileWriter(outputFile);
    int c;
                             while ((c = in.read()) != -1)
                             { out.write((char)c); }
                             in.close();
                             out.close();
                             inputFile.delete();
                             outFile.write(System.getProperty("line.separator"));
    ............

  • How to give two Input File from Adapter Framework to EJB Modules

    hi,
    i'm using one EJB Module in SAP XI, which converts EDI file
    format to XML file format. But now i'm facing a problem, that is,
    in SAP XI we can able to give one file as an Input at a time, but
    in my case it is <input_file_name>.edi, but my issue is i need
    to refer another file also, if it is possible.?
    then,
    What and how we can able to use this, any clue
    inputModuleData.getSupplementalData("<Name>");
    or else,
    we can able to achieve this through Configuration settings,
    Option: addAdditionalFile
    please send your suggestion as well.
    thanks,
    rajesh

    hi check the development manual for reference
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f76f9f90-0201-0010-bf84-d0409ea425f1
    Note: reward points if solution found helpfull
    Regards
    Chandrakanth.k

  • How to Refresh JTree if a file System got changed during Run-time

    Hi,
    Can anyone tell me how to refresh a JTree(javax.swing.JTree) used for displaying file system(both local and remote).
    I'm getting a problem if a file/directoy is added to the file system, after my Applet is loaded. Actually, i have used DefaultTreeModel's reload() method for refreshing and calling it inside SwingUtilities.invokeLater() using Thread, but its not working.
    I want that the tree should reflect the latest Files/Directories on the click of a node, if any file or directory is added under that node.
    Plz tell me if this is possible or not.
    Thanks

    Hi Shay_te,
    Thanx for ur reply as i was eagerly waiting for the one.
    but the example is using the TreeTable
    and i have used JTree and DefaultTreeModel.
    I'm calling reload(node) within treeExpand() method
    Then, i'm regestring addTreeModelListener() as
    m_model.addTreeModelListener(new javax.swing.event. TreeModelListener(){ }
    inside which all 4 methods are over-ridden
    code snippet is as follows so plz help me and tell if this the right way:
    class DirExpansionListener implements TreeExpansionListener{
            DirExpansionListener(){
            public void treeExpanded(TreeExpansionEvent event) {
                final DefaultMutableTreeNode node = getTreeNode(event.getPath());
                final FileNode fnode = getFileNode(node);
                Thread runner = new Thread() {
                    public void run() {
                        if (fnode != null && fnode.expand(node)) {
                            Runnable runnable = new Runnable() {
                                public void run() {
                                    try{
                                       m_model.reload(node);
                                        m_model.addTreeModelListener(new javax.swing.event.TreeModelListener() {
                                            public void treeNodesChanged(javax.swing.event.TreeModelEvent evt) {
                                            public void treeStructureChanged(javax.swing.event.TreeModelEvent evt) {
                                                System.out.println("Path of node changed->"+evt.getTreePath());
                                            public void treeNodesInserted(javax.swing.event.TreeModelEvent evt) {
                                                System.out.println("Nodes Inserted method called..");
                                            public void treeNodesRemoved(javax.swing.event.TreeModelEvent evt) {
                                        System.out.println("Run inside DEvent called..");
                                        //Thread.sleep(500);
                                        //fnode.expand(node);
                                    }catch(Exception e){System.out.println("err :" +e);}
                            SwingUtilities.invokeLater(runnable);
                runner.start();
            public void treeCollapsed(TreeExpansionEvent event) {}
        Please reply...

  • Help.....problem with obtaining files from a directory

    Anaybody knows how to obtain list of files from a directory from j2me
    as in j2se ?

    I don't think it's possible because a MIDlet lives isolated from the rest of the device's filesystem. It can only store persistent data on the Record Media Store, which is unique for each MIDlet.

  • How to make SSIS packages automatically read the input file from a path?

    Currently I am using a SSIS package to read data from a .dat file and load it into SQL Server tables.
    I am placing the input .dat file on the desktop. In the connection manager -> Browse option, I am pointing this file to create connection.
    The file naming convention is like - aSNAP_Data_20140926_P-2014-09-26_07.02.36
    However, I need the SSIS package to automatically read the input file from a folder which is located in a remote server. This folder has lots of files where input files are added on a daily basis with the date value in the file name as mentioned above.
    I want to schedule the SSIS package to run daily and take the latest file in the folder based on the date.
    Please let me know how to do it. Any help would be highly appreciated.....
    Thanks in advance.

    Hi SQL_SSIS_Dev,
    According to your description, you want to get the latest file from a path to a SQL Server table. After testing the issue in my environment, we can refer to the following steps to achieve your requirement:
    Create two variables, VarFolderPath stores the folder path in which our files exist, VarFileName hold the value of most recent File Name.
    Drag a Script Task from SSIS Toolbox to Control Flow Pane, then select “User::VarFolderPath” as ReadOnlyVariables, select “User::VarFileName” as ReadWriteVariables.
    Then Edit Script with the C# code below:
    Add “using System.IO;” into namespace.
    Add the code below under Main function:
    var directory= new DirectoryInfo(Dts.Variables["User::VarFolderPath"].Value.ToString());
                FileInfo[] files = directory.GetFiles();
                DateTime lastModified = DateTime.MinValue;
                foreach (FileInfo file in files)
                    if (file.LastWriteTime > lastModified)
                        lastModified = file.LastWriteTime;
                        Dts.Variables["User::VarFileName"].Value = file.ToString();
    Drag a Data Flow Task to Control Flow Pane and connect to Script Task.
    In the Data Flow Task, drag a Flat File Source with a file in the source folder as all the files have same structure as the File name.
    Add the property below the Flat File Connection Manger expression:
    Property: ConnectionString      Expression: @[User::VarFolderPath] +"\\"+ @[User::VarFileName]
    Drag an OLE DB Destination that connect to the Flat File Source, then configure a table to store the data.
    The following screenshot is for your reference:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How do I import music files from a flash drive to my iTunes library on my laptop

    How can I import music files from a flash drive to my iTunes library? I put the flash drive into my laptop, selected " add file to library", selected the songs I wanted from the flash drive, and it looked like they were added as the names show under " recently added". Then I removed the flash drive from my laptop But when I select one of the songs and try to play it a message saying "the song could not be used because the original file could not be found. Would you like to locate it?"  So it seems the actual files did not transfer. What do I do? I have done this. With a cd in the past with nsomproble,.

    Suncadia wrote:
    Thank you!! This worked. It does seem there should be an easier way but this did work.
    Dragging the files to "Automatically Add..." is pretty easy once you know where to look.  Just make sure iTunes is running when you do it; otherwise the files will just sit there until the next time you open iTunes.
    (Interestingly, the way you originally tried to do would have worked fine except for one little detail:  you have to first go into Edit > Preferences > Advanced, and check the box for "Copy files..."  If that is not done, iTunes will reference the files on the flash drive, which of course are not accessible once the drive is removed, as you saw.)
    Anyway, glad that all is now sorted.  Enjoy the music!

  • I have e9 running a cpu A. I have e11 now running on cpu B. How do i move my files from A to B?

    I have elements 9 running on computer A. I now have elements 11 running on computer B. How do i move my files from computer A to B?

    Do a full backup using the organizer's backup command on computer A. Then restore that to computer B.
    EDIT It will probably go smoothest if you use some kind of removable drive for the backup location.

  • How do I retrieve a file from Trash using Time Machine in Mavericks?

    Is it even possible to retrieve a file from Trash from a Time Machine backup? Does Time Machine even back up the Trash? I've been told a total restore from a Time Machine backup will put the past Trash back on the Mac, but what if I just want to restore an individual file?
    Shortly after emptying my Trash on my Mac (10.9.4) for the first time in weeks, I realized I needed one of the files I'd just erased. Trying to retrieve with Time Machine was not fruitful, however, because I couldn't find the file on any of the past backups using the normal Enter Time Machine interface. However, I know it would have been in the Trash during all of the most recent backups.
    So I researched how to find the backups of Trash with Time Machine, but I think all of the solutions I found on various online forums were pre-Mavericks and do not seem to work now. I've basically tried 2 things:
    Show Trash in Finder using the Terminal command: open ~/.Trash
    It shows the hidden Trash folder in Finder, located in Macintosh HD/Users/User. For easy access, I added the .Trash folder to the Finder Sidebar. But I can't get to it in the backups. The Trash shortcut in the Finder Sidebar is always grayed out in the old backups using the Time Machine app. And it does not show up in ~ when looking through the backups.backupdb folder on my external HD.
    I also tried the Terminal command to show all hidden files in Finder: defaults write com.apple.finder AppleShowAllFiles YES
    But while many hidden files do suddenly appear in Finder, curiously, the User's .Trash folder is not one. This is true for the Finder of the Mac, the backups.backupdb folder on the External HD, and Time Machine app.
    Thanks.

    How do I retrieve a file from my backup in Time Capsule?
    It depends on the type of file that you are trying to retreive.
    In general.....
    Open Time Machine by clicking on the clock icon on the dock
    Wait a few minutes for Time Machine to fully load
    Use the timeline at the far right of the window to go back in time to a date when the file was still on your Mac
    Click that date
    Navigate using the Finder interface to locate the file that you want
    Click on the file to highlight it
    Click Restore at the lower right of the window to be brought back to the present
    You have to retrieve other types of files differently. For details, see:
    http://pondini.org/TM/28.html

  • How do I move a file from Icloud to my hard drive?

    How do I move a file from Icloud to my hard drive?

    From the appropriate application (eg, Pages, TextEdit, etc) find your file(s) in iCloud (use File - Open), then highlight (you can multiple-select) the files you want to move, and drag them to your desktop or another Finder location.
    Matt

  • HT2518 After using Migrate Assistant, I made several accounts for every attempt to migrate files from PC to Mac. How can I put all accounts together into one? How can I transfer the files from the other accounts to my primary account?

    Okay, so I did the entire Migrate Assistant process to transfer all my files and what not to my MacBook. Problem is that I did it on seperate occasions and now I have several accounts.
    How can I transfer my files from the other accounts to my primary account and delete the other accounts?

    Problem is that I did it on seperate occasions and now I have several accounts.
    If you had read carefully, Migration Assistant asks what you want to do in this event. That would have precluded the redundancy.
    Part of the fundamental design of OS X is to separate user accounts so that one user can't interfere with another. It's not possible to directly merge an account with another, but you can copy whatever you need to the Shared folder - it is in your Users folder.
    Log in to one account, prefereably a smaller one, and drag the files and folders into Shared. Log out, log into the account you want to be "primary" and drag the files from Shared into their appropriate locations. When you have copied everything you need delete the redundant account.
    Do this for each of them.
    Or, you can just run Migration Assistant again and follow the prompts that address the situation you described. It involves creating a secondary, temporary account from which you can administer the transfer. When it is complete you delete the temporary account(s).

  • Questions on how to utilize still/ Video files from 3Gs using iLife 09?

    Hi,
    Just got back from a trip where I took a bunch of stills and videos using the my 3Gs. I just downloaded them onto my Mac using iPhoto.
    1. How do get the video files from iPhoto into iMovie as it seems that iPhoto imported it all.
    2. How do I get the images that were taken with Location services turned "ON" to display the location they were taken?
    3. Will location mapping also work with iPhone video files?

    Maybe someone in the iMovie discussion forum would know some of the specifics from iPhoto to iMovie. I thought I remember seeing a way to import straight from my iMove.
    Here is the discussions link
    http://discussions.apple.com/category.jspa?categoryID=141

  • How can i transfer iweb files from one computer to another?

    Hi,
    Recently my harddrive crashed and i had to rebuild my computer. I retreived most of my files but i cannot find where my iweb files are located. Does anyone know where iweb saves files or how to retreive my domain files from the web (if at all possible)?
    Thanks

    AYetis wrote:
    Could there be other location for the iWeb files?
    Unless you moved the Domain file, that's its default location. Make sure you're looking in the Library folder in your Home folder rather than Macintosh HD. See also THIS recent post.

Maybe you are looking for

  • How do i back up music from Iphone 4 in to Icloud

    How do I back up the songs from Iphone 4 to I cloud ?

  • XSQL and insert

    This may sound like a dumb question but I can't figure out how to associate the xml doc with the xsql doc to do an insert. Here are my files: XSQL - filename custins.xsql <?xml version="1.0" ?> <xsql:insert-request table="CUSTOMERS_OV" connection="de

  • I'm stuck at the sent messages display and I need to see my inbox

    When I start my computer and click on the Thunderbird icon the screen that is displayed is the list of sent messages. I am unable to change this screen. I did touch the GO at the top of the page and from there I saw the in box and trash but could not

  • How to configure Send Handler for BizTalk 2013 Dynamic Send Port on deployment?

    Hi, I do know how to manually configure a send handler for a dynamic send port in BizTalk 2013 Administration console. Though, once you export your application's configuration to a binding file, the dynamic send port's configuration does not contain

  • Obsolete tables in ECC6.0

    Hi All, Please let us know the list of obsolete tables in ECC6.0 (after an upgrade from 4.6c). We already have TVARV & BP000 in our list. Thanks & Regards Anjali