Read filenames of directory

Hello to all forms developers !
I have a problem with Forms 6i (client/server). I want the user to select multiple files from a directory. I know this can be done using the OpenFileEx function of the d2kwutil library. But this function only returns a string which max. length is 4096 characters. This restricts the number of selectable files. So I tried another way : I used the HOST built-in to generate a file containing all filenames, like this :
host('dir /b > files.txt', no_screen) and then read out the filenames with routines of text_io package.
The parameter /b for the dir command lists only the filenames.
But to my surprise filenames longer than 8 characters are shortened to only 8 characters so that these filenames cannot be used by other routines.
Did anyone else face and solve this problem and share his experience with me ?
Regards
Kai

if you have d2kwutil library you can use :
win_api_directory_list.FirstFile and win_api_directory_list.NextFile functions. Something like :
WHEN-BUTTON-PRESSED Trigger :
declare
     hSearch PLS_INTEGER;
     vcFile VARCHAR2(60);
     bIsDir BOOLEAN;
     vcLDir VARCHAR2(1);
     vcRDir VARCHAR2(1);
begin
     hSearch := win_api_directory_list.FirstFile(:directory_list.directory, vcFile, bIsDir, toBoolean(:directory_list.exceptions));
     :directory_list.result := IsDir(vcFile, bIsDir);
     LOOP
          win_api_directory_list.NextFile(hSearch, vcFile, bIsDir, toBoolean(:directory_list.exceptions));
          EXIT when vcFile is null;
          :directory_list.result := :directory_list.result||chr(10)||IsDir(vcFile, bIsDir);
     end LOOP;
     win_api_directory_list.CloseSearch(hSearch);
end;
:directory_list.directory is item which contain folder which you want to list. You can choose folder with function:
begin
:directory_list.directory := get_file_name(:directory_list.directory,NULL,NULL,'Select a Folder to list',OPEN_FILE,FALSE)||'\*.*';
end;
Item :directory_list.result is result item where it will be stored all file names which exist in folder (instead of this you can create e.g PL/SQL table which will handle all files which is listed in folder.

Similar Messages

  • Read FileNames in Directory

    Hi,
    I have to read list of filenames in a directory(defined in topology) into a oracle table
    like
    filnames
    test.csv
    two.csv
    I know how to use procedure sure which is correct approach
    Please help
    Thanks

    Has anyone had any luck getting this to work?
    Is this OS Specific - For instance, Unix or Windows. I am trying to run this on a Windows PC.
    I am receiving an invalid syntax error. The set up I am using below.
    Command on Target =
    import java.lang as lang
    import java.sql as sql
    import snpsftp
    import java.lang.String
    import java.io.File as File
    import ftplib
    import re
    import os
    #db connection
    driverSrc ='<%=odiRef.getInfo("SRC_JAVA_DRIVER")%>'
    lang.Class.forName(driverSrc)
    urlSrc ='<%=odiRef.getInfo("SRC_JAVA_URL")%>'
    userSrc = '<%=odiRef.getInfo("SRC_USER_NAME")%>'
    passwdSrc = '<%=odiRef.getInfo("SRC_PASS")%>'
    ConSrc = sql.DriverManager.getConnection(urlSrc, userSrc, passwdSrc);
    readDBLink = ConSrc.createStatement()
    try:
    # f=open('C:/new.txt','w+')
    list = os.listdir('C:/')
    for fichier in list:
    # str = java.lang.String(fichier)
    # f.write(fichier)
    sqlDBLink = "insert into etl_user.hsd_usage_filenames (FILENAME_ID, FILENAME, CONSUMED) values (ROWNUM, '" + fichier + "', 0)"
    rqteDBLink = readDBLink.execute(sqlDBLink)
    finally:
    ConSrc.close()
    # f.close()
    =====================
    Error received = SyntaxError: ('invalid syntax', ('<string>', 23, 1, "list = os.listdir('C:/')"))
    Any assistance that can be offered is greatly appreciated.
    Thanks,
    Via
    Edited by: via_odi on Nov 1, 2012 12:49 PM

  • File Scenario with Dynamice Filename and Directory

    Hi All,
    we have a requirement that PI has to pickup the file from 2 FTP Server.
    First PI has to pickup an XML file from Server1 , this XML file has a details about the Filename and Directory of the second FTP server., then PI should login to the server2 and pickup the file form the directory.
    Regards,
    Mani

    Hi Mani,
    Can you try below approach ,
    Read file 1 from Server 1 using sender file Communication channel and read 2nd filename and directory details and pass these values to UDF/Java mapping to log in to server 2 and retrieve the data/file2 ?
    Thanks
    Hari.

  • Reading filenames with characters other than a-z

    Hi!
    My problem is that I'm writing very simple integration that only transfers files around. Problem is that some directories and filenames have for example scandinavien characters.
    Examples:
    D:\lähtevä\lähtö.xml
    Problem is that when I read files/directories via following code while in the D:\lähtevä folder:
    File dir = new File(fname);
    String[] chld = dir.list();
    if(chld == null){
    System.out.println("Specified directory does not exist or is not a directory.");
    System.exit(0);
    }else{
    for(int i = 0; i < chld.length; i++){
    String fileName = chld;
    System.out.println(fileName);
    variable "fname" would be "." given from command line when application starts up.
    Result is that all "ä" letters become "&#931;" characters. Other scandinavian letters are also messed up. I'm running on windows machine.
    What is the correct way to read filenames so that their country-specific characters are not messed up?

    Will this small test run correctly on your machine?
    public class ReadingFilesWithNonASCIINames {
        public static void main(String[] args) {
            String dirPath = "E:/lähtevä";
            String fName = "lähtö.txt";
            File directory = new File(dirPath);
            assert directory.exists();
            File file = new File(directory, fName);
            assert file.exists();
            //Now try to read it
            try {
                FileReader reader = new FileReader(file);
                int c;
                while((c = reader.read()) != -1) {
                    System.out.print((char)c);
            } catch (IOException e) {
                e.printStackTrace();
    }Compile it and run it with -ea flag. On my machine it ran without any problems (Windows XP, BE/fr locale, default encoding for files: System default -- windows-1252)

  • Javac can't read filename.java

    Hi
    my problem is that javac can't read filename.java
    i have saved the source code as filename.java under text document file type and i kept the capitalization the same for the[i] filename and classname but i am still having this error message: "error : can't read : filename.java" .
    does that have anything to do with windows xp that i am using or there is absolutely something else that prevents javac from reading and compiling the file?
    please help
    Kind regards
    Nour

    The only 2 reasons that I can figure out why you are getting this error is either because your java file has not been properly named ie. filename.java or else then it is not in the same location ie directory from where you are trying to run your compiler.
    Thus you need to run the compiler from the directory that contains your java source file so it really does'nt matter where you have saved your java file on the machine as long as your path is set to your j2sdk /bin Just cd your way to that directory where you have the java file and run the compiler javac

  • How can we read filenames from a specific folder

    Hi forum,
    I have a situation that, there are several files coming daily in a specific folder.
    I want to read filenames from that folder and want to get that filename in a variable.
    That filename contains account nos. which I need for further processing.
    Now, how can we read filenames from a specific folder with using Oracle PL/SQL Procedure?
    Please suggest.
    Thanks & regards,
    Kiran

    If you are on 10g (not sure which exact release I'm afraid) you might look at Chris Poole's XUTL_FINDFILES that lists the files in a directory using PL/SQL and DBMS_BACKUP_RESTORE.SEARCHFILES (all a bit undocumented as it seems to be provided as part of rman).
    The conventional (i.e. supported) approach is to use a Java stored procedure - there is an example on AskTom.
    Message was edited by:
    William Robertson

  • Read filename of email attachment for sender mail adapter

    Hi All,
    We have a requirement to read filename of email attachment received from Sender email adapter and send details to SAP by Proxy call.
    Can we retrieve the filename of email attachment ?
    Any help on this will be really useful.
    Regards,
    Ashish

    Hi,
    >>>Can we retrieve the filename of email attachment ?
    Please see the below link, it might be useful to you.
    http://wiki.sdn.sap.com/wiki/display/XI/AdapterModulePI7.0GetAttachmentName
    Regards,
    P.Rajesh

  • Java Message Mapping : Dynamic FileName and Directory for ASMA

    How to Put Dynamic FileName and Directory for ASMA Properties of File Receiver adapter in Java Message Mapping ???
    I know How to Do this in UDF , But In Java Type Message Mapping . How to do this ????
    Regards
    PS.

    Hi
    chk this:
    http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=95093307
    Thanks
    Amit

  • Read Filename form Adapter-Specific Message Attributes in Java Mapping

    Hi,
    I have scenario File to Mail adapter. How can i read filename from Adapter-Specific Message Attributes
    in java mapping.
    Thank you and Best regards
    Fernand

    Hello Fernand,
    Are u using DOM or SAX parser?
    In any case just put the Dynamic config code in the execute function or the other option is to define it as a private functionand call it in the execute,My personal advice would be the former.
    Just put this code in ur java mapping
    As fellow sdn ers have mentioned there is no need of the container method,just initialise the set param method and use it in the dynamice config code as follows
    public class YourClass implements StreamTransformation
         private Map map;
    public void setParameter(Map param)
         map = param;
    public void execute(InputStream in, OutputStream out) throws StreamTransformationException
                   DynamicConfiguration conf =(DynamicConfiguration) map.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
                   DynamicConfigurationKey KEY_FILENAME =DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    // read value
    File = conf.get(KEY_FILENAME);
    Now just call File in the mapping program,
    Should help u out 
    Regards,
    Tauseef

  • How to read Filename using FileAdapter

    I am trying to write some xml files using FileAdapter of SOA11g. For that I have created synchronous BPEL process.
    My xyz.jca file looks something like this:
    <endpoint-interaction portType="Write_ptt" operation="Write">
    <interaction-spec className="oracle.tip.adapter.file.outbound.FileInteractionSpec">
    <property name="PhysicalDirectory" value="/mnt/vol_ora_SOADEV1_apps_01/DevCsvFiles/Inventory"/>
    <property name="Append" value="false"/>
    <property name="FileNamingConvention" value="FileTemp%SEQ%.txt"/>
    <property name="NumberMessages" value="1"/>
    </interaction-spec>
    </endpoint-interaction>
    Now the problem is I want to know the filename which is just being written by this Adapter. I want to use that filename later in my code.
    I tried using filename property in invove activity, but I am unable to read filename after its written to disk.

    Got right way to do it. Create one variable eg varFileName, assign some value eg. "Filenamexyz.ext" and refer to that variable (set properties of invoke activity jca.file.filename as varFileName and type 'Input')in Invoke activity invoking read adapter .

  • Utl_file can't read from my directory

    hello
    I am trying to load XML data from an xml file into a CLOB object and i am getting an error in the unlikely segment of the code. The following code can't read from the directory specified by the utl_file_dir parameter.
    I am setting the "utl_file_dir" parameter at the sys level and dont have it in the SPFILE (initialization) file.
    sys@LOCAL> ALTER SYSTEM SET UTL_FILE_DIR='C:\XMLBOOK\Examples\Chapter25\src\xml' SCOPE=SPFILE;
    System altered.
    sys@LOCAL> shutdown
    sys@LOCAL> startup
    sys@LOCAL> select name,value from v$parameter where name like '%utl_file_dir%';
    NAME VALUE
    utl_file_dir C:\XMLBOOK\Examples\Chapter25\src\xml
    sys@LOCAL> DECLARE
    2 v_xmldoc DBMS_XMLDOM.DOMDocument;
    3 v_parser DBMS_XMLPARSER.parser;
    4 v_out CLOB;
    5 v_dir VARCHAR2(200) :=
    6 'C:\XMLBOOK\Examples\Chapter25\src\xml';
    7 BEGIN
    8 -- New parser
    9 v_parser := DBMS_XMLPARSER.newParser;
    10 -- Setting up the parsing parameters
    11 DBMS_XMLPARSER.setValidationMode(v_parser, FALSE);
    12 DBMS_XMLPARSER.setPreserveWhiteSpace(v_parser, TRUE);
    13 -- The v_dir has to be a valid directory in the UTL_FILE_DIR
    14 DBMS_XMLPARSER.setBaseDir(v_parser, v_dir);
    15 -- Parsing the XML file
    16 DBMS_XMLPARSER.parse(v_parser, 'contact.xml');
    17 -- Getting the XML DOMDocument
    18 v_xmldoc := DBMS_XMLPARSER.getDocument(v_parser);
    19 -- Print out the result
    20 DBMS_LOB.createtemporary(v_out,FALSE,DBMS_LOB.SESSION);
    21 DBMS_XMLDOM.writetoClob(v_xmldoc, v_out);
    22 DBMS_XMLDOM.writetoFile(v_xmldoc,v_dir||'/out.xml');
    23 :out := v_out;
    24 DBMS_LOB.freetemporary(v_out);
    25 END;
    26 /
    DECLARE
    ERROR at line 1:
    ORA-29280: invalid directory path
    ORA-06512: at "SYS.UTL_FILE", line 18
    ORA-06512: at "SYS.UTL_FILE", line 424
    ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 15
    ORA-06512: at "XDB.DBMS_XMLPARSER", line 90
    ORA-06512: at line 16
    sys@LOCAL>
    It would be great if i get some help here.
    Thanks.

    try this:
    create directory test_d as 'F:\OracleXML';
    DECLARE
    v_xmldoc DBMS_XMLDOM.DOMDocument;
    v_parser DBMS_XMLPARSER.parser;
    v_out CLOB;
    -- v_dir VARCHAR2(200) := 'F:\ORACLEXML'; don use this
    BEGIN
    v_parser := DBMS_XMLPARSER.newParser;
    DBMS_XMLPARSER.setValidationMode(v_parser, FALSE);
    DBMS_XMLPARSER.setPreserveWhiteSpace(v_parser, TRUE);
    DBMS_XMLPARSER.setBaseDir(v_parser, 'TEST_D');
    DBMS_XMLPARSER.parse(v_parser, 'newtab.xml');
    v_xmldoc := DBMS_XMLPARSER.getDocument(v_parser);
    DBMS_LOB.createtemporary(v_out,FALSE,DBMS_LOB.SESSION);
    DBMS_XMLDOM.writetoClob(v_xmldoc, v_out);
    DBMS_XMLDOM.writetoFile(v_xmldoc,'TEST_D'||'/out.xml');
    -- :out := v_out;
    DBMS_LOB.freetemporary(v_out);
    END;

  • When i try and open the auto cad Lt that i just downloaded i get this error The directory may be locked by another process or have been set Read Only. Directory: '/Users/hockaday' Please correct this problem and press OK to exit the application.

    i get this error why i try and open the auto cad that i just downloaded
    The directory may be locked by another process or have been set Read Only.
    Directory: '/Users/hockaday'
    Please correct this problem and press OK to exit the application.

    I did install it in the admin account.  Actually the computer has four accounts, one for my husband, where I installed it.  One for me which also is set to admin, one is called TEST and has nothing in it and one is guest user.
    I don't know how AutoCad is interfacing with the account.  That is why I am not sure what to do about it.  I read other threads in various places and some seemed to point to something having to do with having multiple users.  The solutions were not clear.  I was hoping someone else had this problem and could tell me what to do.  I tried apple support but no help.  I have not tried AutoCad yet as I assumed they wont help since this is a free educational version of their product.

  • File-to-File/RFC scenario with reading filename

    Hi,
    i have a File-to-File/RFC scenario which causes some problems in desining it correctly. Maybe some of you has an idea how to do this.
    Scenario:
    - A file is picked up by a File-Adapter. The files are different: pdf, doc, tiff, jpg, txt, ...
    - The file must now go through a business process (not necessary the file, but i need the filename in the business process).
    - The process has to contact several backend systems (SAP R/3) to collect some data. To achieve this the filename has to be send to this systems.
    - The collected data are send via SOAP to a receiver system
    - The file itself has to be stored in a directory via File-Adapter.
    Here's my problem:
    - Is it possible to transport the binary file content within a message which contains other elements (e.g. filename)?
    - Is it possible to do graphical mappings with such a payload (only 1 to 1)? Or must i use Java Mappings only?
    - How to generate a Message from the sender File Adapter which contains binary file content AND filename? Is this possible with a Module?
    - Is it better to create 2 messages with an adapter module? One with the image the other with the filename. Or is it better to split them later in a Mapping?
    Thanks in advance,
    ms

    If all that you need is the file name, use adapter specific settings in the sender file adapter. Then you can access the file name in mapping runtime in UDFs. If you want to have content of the pdf, jpg etc images, i do not think there are ready modules available except for reading pdfs ( you might have to research on this).
    For look ups etc with R3 systems, you can use the file name that you got from the adapter and store it in mapping fields.
    VJ

  • Get filename and directory name during runtime

    Hi guys,
    I am developing a file to file interface without content conversion, just a simple file transfer from one ftp server to another. I have to read the same filename (invent.txt) from multiple folders (mstransfer/M01/IN1, mstransfer/M02/IN1, mstransfer/M03/IN1....) that represent different stores and transfer it as it is with the same name to exactly the same directory name in the target ftp location.
    My problem is found inside a dummy mapping that I have created in order to specify the target directory and the name of the file. I am doing the following:
    A) A Java UDF to specify the filename
    trace = container.getTrace();
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String filename = conf.get(key);
    trace.addWarning("filename = "+filename);
    conf.put(key, filename);
    return "";
    //return filename;
    B) A Java UDF to specify the directory name
       //write your code here
    trace = container.getTrace();
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");
    String directory  = conf.get(key);
    trace.addWarning("directory before = "+directory);
    directory = "/usr/sap/trans"+directory;
    trace.addWarning("directory after = "+directory);
    conf.put(key, directory);
    return "";
    //return "/usr/sap/trans"+directory;
    In receiver file adapter I do not specify neither a filename nor a target directory.
    When I am testing it, I always get a mapping runtime error.
    Any ideas?
    --Evaggelos

    Guys,
    First of all, I am doing an end to end testing, i.e. I let the FTP adapter pick the file up and another FTP adapter delivers the file to target folder. I am definitely not testing the mapping in mapping editor.
    I get the error in Request message mapping (pipeline step, which I can see in SXMB_MONI transaction) which is a dummy mapping between two message types that I have created and are based on two data types with two fields each.
    The UDF's that I have created go in-between the source and target fileds of the message types/data types.
    The error that I see in the trace section of the XML message in SXMB_MONI is the following:
    "<Trace level="1" type="T">RuntimeException during appliction Java mapping com/sap/xi/tf/_MM_G_SRS_FileTransfer_MNS_</Trace>
      <Trace level="1" type="T">java.lang.NullPointerException at com.sap.aii.mappingtool.tf3.AMappingProgram.exceptionCaught$(AMappingProgram.java:59) at com.sap.aii.mappingtool.tf3.Transformer.checkParserException(Transformer.java:182) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:149) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:102) at com.sap.aii.ibrun.server.mapping.JavaMapping.executeStep(JavaMapping.java:64) at com.sap.aii.ibrun.server.mapping.Mapping.execute(Mapping.java:91) at com.sap.aii.ibrun.server.mapping.MappingHandler.run(MappingHandler.java:90) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleMappingRequest(MappingRequestHandler.java:95) at"
    I have included some trace.addWarning() lines in Java code to help me debug my code, but I cannot see them anywhere inside the trace to be getting executed.
    I will try Bhavesh's idea and I will write the code in the Java Section of my message mapping ( either Intialization or Destrcution ) section.

  • Reading from home directory in linux using ~/ or $HOME and BufferedReader

    I'm working on an app that reads in a number from a user's home directory using BufferedReader. The file is written by an external script to ~/filename. I don't know if the user of the app's home directory will be /homes/username, /home/username, or something else. I would prefer to read in a similar fashion:
    BufferedReader in = new BufferedReader( new FileReader("~" + File.separator + ".AppDisableUntilDate") );
    Unfortunately, this causes the following error:
    java.io.FileNotFoundException: ~/.AppDisableUntilDate (No such file or directory)
    less ~/.AppDisableUntilDate does read the file. Using $HOME in place of ~/ also fails. Any ideas what might work?
    Thanks,
    Joel

    ~ is understood only by the shell. And not by every shell either.
    Korn and Bourne-again shell (ksh and bash) understand it, I would conjecture, Bourne shell (good old sh) does not.

Maybe you are looking for

  • BI : dialog instance does not start

    Hi all. --> Before explain you our problem, I'm going to tell you our scenario: We have an HP-UX cluster where we have installed BI system ABAP+JAVA stack (NW 701). We have got one central package with SAP and oracle in node1 and one dialog instance

  • Subquery in materialized view

    I have this subquery in a materialized view. (SELECT COUNT(*)     FROM product_statistics_units psu     INNER JOIN scenes_identity_fact sif     ON (trunc(sif.date_acquired) = trunc(psu.scene_date))     AND ((SELECT satellite_sensor_key         FROM l

  • APPS (Vendor Bank Details)

    Does anyone have an SQL query to extract all payabales vendors with their bank account details from the Oracle APPS Database? I can see ap_bank_account_all which has bank data but cannot see how to join this to a vendor to get vendor name, address et

  • Finding Gaps In Date Range

    I was recently asked to help create a query at my company to search for date gaps in employment status history. My table data looks similar to this employee_id employment_status beg_date end_date 1               Active               1990-01-01       

  • J2EE architecture question

    Suppose you have a distributed application consisting of a number (max 100) of webservers (Servlets/JSPs technology) which send information (e.g. a random number) to one central system (using EJBs). The central system receives the random numbers thro