Udf to pass constant corrsponding to 2 file names from different location

if i have one source file, i m able to pass the file name directly to the target through the udf below:
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String ourSourceFileName = conf.get(key);
return ourSourceFileName;
But i have 2 files from different location. Now both files has dates at the end. how can i pass AAA for File1.txt and BBB for File2.txt. .
after the above code, i have included below code too, but not working(*-for date n timestamps):
if(ourSourceFileName.equals("ABC*.txt"))
return "FILE1";
else if(ourSourceFileName.equals("XYZ*.txt"))
return "FILE2";
please suggest

Hi Basker,
Error in activating object in IR - heres the total code i have used for this purpose. plz help in getting this.
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String ourSourceFileName = conf.get(key);
return  ourSourceFileName; 
if(ourSourceFileName.equals("SOURCE_1*.txt"))
return "File1";
else if(ourSourceFileName.equals("SOURCE_2*.txt"))
return "File2";
Source code has syntax error:  /usr/sap/DXI/DVEBMGS31/j2ee/cluster/server0/./temp/classpath_resolver/Map27461f402eff11e0898d00144f1e71f0/source/com/sap/xi/tf/_MM_UPDATE_.java:839: unreachable statement if(ourSourceFileName.equals("SOURCE1_*.txt")) ^ /usr/sap/DXI/DVEBMGS31/j2ee/cluster/server0/./temp/classpath_resolver/Map27461f402eff11e0898d00144f1e71f0/source/com/sap/xi/tf/_MM_UPDATE_.java:844: missing return statement } ^ 2 errors

Similar Messages

  • How to pick different files from different locations

    suppose ur having multiple files(csv) from different locations,then how do u move those files to the SAP system.Please expalin me the scenario

    Venu,
    If the files are present in different folders, then you need different sender communication channels to bring this data to XI. Regarding connection with SAP, you can go for a proxy (If the webAs version is > 6.2) or else go for an IDOCor RFC adapter.
    Regards,
    Jai Shankar

  • Same file name from sender to receiver file adapter with out using UDF

    Hi All,
    I am working on FILE TO FILE. My requirement is same file name from sender to receiver file adapter. Is it possible to do using only Adapter Specific message properties?  i mean with out using UDF.
    Thanks
    Karthik

    Hi,
    >>>Is it possible to do using only Adapter Specific message properties?
    yes
    just enable Adapter Specific message properties in sender and receiver channel for file name
    and you're done
    Regards,
    Michal Krawczyk

  • Flat file name from Sender Side Dynamically into subject of Receiver Mail

    Hi All,
             I am Using a file to Mail Scenario, My requirement is to get dynamically the file name from flat file of the Sender Side into Subject of Receiver Mail Adapter and attachment of file from the Sender Side. Can anyone help me out.
    Thanks in Advance

    Hi....
              You can write udf in the message mapping to get the Dynamic file name and map that to the subject of the receiver mail.
      DynamicConfiguration conf = (DynamicConfiguration) param.get(
              StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey KEY_FILENAME = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
          // read value
          String Filename = conf.get(KEY_FILENAME);
    Regards,
    Leela

  • File name from an attribute of an element of the payload

    Dear Experts,
    Could you suggest the syntax for specifying the file name from a variable in the file receiver communication channel? I need to grab the file name from an ATTRIBUTE of an element of the payload.
    Thanks a lot.
    Example: Need to pass the attribute "descReceipt" of the element "promotionEvent" to the variable in the following payload:
    <?xml version="1.0" encoding="UTF-8"?>
    <promotionExport>
    <promotionEvent eventIdentifier="30" status="A" descReceipt="FILE1">

    The scenario is IDOC to FILE. I need to get the value of the receiving partner.
    The message header has the node "DynamicConfiguration". Please see the xml below. I need to grab the key RCVPRN (0000002104) from this and pass as the file name in the receiver file adapter.
    How do I setup my receiver file adapter for this? I tried changing the values for the variable, and also enabling the adapter specific message attributes. No solution yet.
    <SAP:DynamicConfiguration xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">
      <SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="RCVPOR">LXDCLNT250</SAP:Record>
      <SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="SNDPRT">LS</SAP:Record>
      <SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="RCVPRN">0000002104</SAP:Record>
      <SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="SNDPOR">SAPLCD</SAP:Record>
      <SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="SNDPRN">LCDCLNT220</SAP:Record>
      <SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="CIMTYP" />
      <SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="IDOCTYP">WPDBBY01</SAP:Record>
      <SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="MESTYP">WPDBBY</SAP:Record>
      <SAP:Record namespace="http://sap.com/xi/XI/System/IDoc" name="RCVPRT">KU</SAP:Record>
      </SAP:DynamicConfiguration>

  • How to access Excel files from different locations?

    Hello,
    I have successfully tested the Excel sample on WLS 7, and trying to run it on
    the WLS 8.1.
    Anyways, the common question for both is, how to access an excel files from different
    locations (e.g. c:\path\1.xls, \\domain1\finance\fin.xls, \\domain1\marketing\customer.xls,
    \\domain2\accounts\vouchers.xls)?
    From example i can see that it picks from a specific path under repository.
    Thanks
    Ashok Gupta

    The custom function sets the MS-Excel default directory to System.getProperty("user.dir")+"/excel"
    (the domain directory), then opens the filename passed as a parameter. I assume
    that if you pass in the fully specified path for the excel file ( like d:\MyDir\data\test.xls),
    that it would open that file.
    - Mike
    "Ashok Gupta" <[email protected]> wrote:
    >
    Hello,
    I have successfully tested the Excel sample on WLS 7, and trying to run
    it on
    the WLS 8.1.
    Anyways, the common question for both is, how to access an excel files
    from different
    locations (e.g. c:\path\1.xls, \\domain1\finance\fin.xls, \\domain1\marketing\customer.xls,
    \\domain2\accounts\vouchers.xls)?
    From example i can see that it picks from a specific path under repository.
    Thanks
    Ashok Gupta

  • How to delete file names from Adobe Reader list

    How can I delete file names from the Adobe Reader list?  I have deleted the file & it's empty, but deleted file names remain in my list & it's very annoying.  I can't seem to find an option anywhere to delete the file names.

    Thanks for the answer, I will try this & post my results with this method.  I have set the amount to zero, & it seems if I want to put back valid files into my list I first need to find them in another file in my pc, such as documents, open them in Adobe Reader, & then then they will reappear in the Adobe Reader list.  Is this correct?  Thank you!
    This seems to be the case, you need to restore each file you want in your list one by one by accessing them elsewhere on your pc, & then you must open them with Adobe Reader to have files reappear in your Adobe Reader list.  However, this seems to be a tedious process if you only want to delete one obsolete file from your list by first emptying the list & rebuilding it file by file.  It works, but I'm wondering if there is a more sensible & efficient way to do this?

  • How can I assign image file name from Main() class

    I am trying to create library class which will be accessed and used by different applications (with different image files to be assigned). So, what image file to call should be determined by and in the Main class.
    Here is the Main class
    import org.me.lib.MyJNIWindowClass;
    public class Main {
    public Main() {
    public static void main(String[] args) {
    MyJNIWindowClass mw = new MyJNIWindowClass();
    mw.s = "clock.gif";
    And here is the library class
    package org.me.lib;
    public class MyJNIWindowClass {
    public String s;
    ImageIcon image = new ImageIcon("C:/Documents and Settings/Administrator/Desktop/" + s);
    public MyJNIWindowClass() {
    JLabel jl = new JLabel(image);
    JFrame jf = new JFrame();
    jf.add(jl);
    jf.setVisible(true);
    jf.pack();
    I do understand that when I am making reference from main() method to MyJNIWindowClass() s first initialized to null and that is why clock could not be seen but how can I assign image file name from Main() class for library class without creating reference to Main() from MyJNIWindowClass()? As I said, I want this library class being accessed from different applications (means different Main() classes).
    Thank you.

    Your problem is one of timing. Consider this simple example.
    public class Example {
        public String s;
        private String message = "Hello, " + s;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example();
            ex.s = "world";
            System.out.println(ex.toString());
    }When this code is executed, the following happens in order:
    1. new Example() is executed, causing an object to constructed. In particular:
    2. field s is given value null (since no value is explicitly assigned.
    3. field message is given value "Hello, null"
    4. Back in method main, field s is now given value "world", but that
    doesn't change message.
    5. Finally, "Hello, null" is output.
    The following fixes the above example:
    public class Example {
        private String message;
        public Example(String name) {
            message = "Hello, " + name;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example("world");
            System.out.println(ex.toString());
    }

  • From Forms 5.0 I want to copy a file/folder from one location to another.

    Hi,
    I have a question and I really appreciate your help.
    My Question is
    I would like to copy a file/folder from one location to another.
    (For ex: From my Hard disk to a Network folder).
    I want to do this from Oracle Forms 5.0 and my operating system is Windows 2000/NT Workstation.
    At present my users are doing this by using drag and drop windows functionality,
    But now they want to do this by using a GUI screen.
    I would greatly appreciate if somebody can answer my question.
    Thank you very much and have a nice day.
    Thanks & Regards
    Sanjeev.

    Hi Shay,
    Am able to copy the files/folders by doing the follwing.
    Declare
    My_Command Varchar2(1000);
    Begin
    MY_COMMAND := 'XCOPY /E ' ||:FROM_LOC ||' '|| :TO_LOC ;
    HOST(MY_COMMAND);
    End;
    But my problem is am not able to trap the errors.
    Do you have any idea?
    Thanks

  • File name from a path

    hi ,
    there is a path "c:\abc\abc\abc\abc\abc.doc", i have to get file name from it.
    but i had to write a dynamic code which can get the file name from any given path.

    Smoke me a kipper, I'll be back before breakfast.
    SQL> var extended_filepath varchar2(128)
    SQL> exec :extended_filepath := '/this/is/a/path/to/a/file.txt'
    PL/SQL procedure successfully completed.
    SQL> select instr(:extended_filepath, '/', -1)
      2  from dual
      3  /
    INSTR(:EXTENDED_FILEPATH,'/',-1)
                                  21
    SQL> select substr(:extended_filepath, instr(:extended_filepath, '/', -1) +1)
      2  from dual
      3  /
    SUBSTR(:EXTENDED_FILEPATH,INSTR(:EXTENDED_FILEPATH,'/',-1)+1)
    file.txt
    SQL> Cheers, APC

  • Retreiving the file names from directory inside another directory from application server

    Hi,
    I had a problem in retreiving the file names from a directory inside another directory.
    I tried using the FM's  SUBST_GET_FILE_LIST, RZL_READ_DIR_LOCAL and EPS_GET_DIRECTORY_LISTING
    But here I am getting only one directory details.
    Actually my file is located a directory inside one more directory and one more directory and inside the files are located.
    i.e total 3 directories inside the 3rd one my files are there.
    I need to read the latest file name in the directory.
    So that i can do some manipulation after getting the file name.
    Is there option like OPEN DATASET , READ DATASET and CLOSE DATASET?
    Can anyone please let me know How can i acheive this one.
    Regards
    Ram

    Hi Ram,
        Following thread can be helpful for you, were it shows in the tables structure rsfillst a field RSFILLST-TYPE whether its a directory or file..........
    http://scn.sap.com/thread/865272
    thanks and regards,
    narayan

  • How to get the target file name from an URL?

    Hi there,
    I am trying to download data from an URL and save the content in a file that have the same name as the file on the server. In some way, what I want to do is pretty similar to what you can do when you do a right click on a link in Internet Explorer (or any other web browser) and choose "save target as".
    If the URL is a direct link to the file (for example: http://java.sun.com/images/e8_java_logo_red.jpg ), I do not have any problem:
    URL url = new URL("http://java.sun.com/images/e8_java_logo_red.jpg");
    System.out.println("Opening connection to " + url + "...");
    // Copy resource to local file                   
    InputStream is = url.openStream();
    FileOutputStream fos=null;
    String fileName = null;
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
                    fileName=st.nextToken();
    System.out.println("The file name will be: " + fileName);
    File localFile= new File(System.getProperty("user.dir"), fileName);
    fos = new FileOutputStream(localFile);
    try {
        byte[] buf = new byte[1024];
        int i = 0;
        while ((i = is.read(buf)) != -1) {
            fos.write(buf, 0, i);
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (is != null)
            is.close();
        if (fos != null)
            fos.close();
    }Everything is fine, the file name I get is "e8_java_logo_red.jpg", which is what I expect to get.
    However, if the URL is an indirect link to the file (for example: http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719 , which link to a file named JavaSetup6u18-rv.exe ), the similar code return AutoDL?BundleId=37719 as file name, when I would like to have JavaSetup6u18-rv.exe .
    URL url = new URL("http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719");
    System.out.println("Opening connection to " + url + "...");
    // Copy resource to local file                   
    InputStream is = url.openStream();
    FileOutputStream fos=null;
    String fileName = null;
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
                    fileName=st.nextToken();
    System.out.println("The file name will be: " + fileName);
    File localFile= new File(System.getProperty("user.dir"), fileName);
    fos = new FileOutputStream(localFile);
    try {
        byte[] buf = new byte[1024];
        int i = 0;
        while ((i = is.read(buf)) != -1) {
            fos.write(buf, 0, i);
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (is != null)
            is.close();
        if (fos != null)
            fos.close();
    }Do you know how I can do that.
    Thanks for your help
    // JB
    Edited by: jb-from-sydney on Feb 9, 2010 10:37 PM

    Thanks for your answer.
    By following your idea, I found out that one of the header ( content-disposition ) can contain the name to be used if the file is downloaded. Here is the full code that allow you to download locally a file on the Internet:
          * Download locally a file from a given URL.
          * @param url - the url.
          * @param destinationFolder - The destination folder.
          * @return the file
          * @throws IOException Signals that an I/O exception has occurred.
         public static final File downloadFile(URL url, File destinationFolder) throws IOException {
              URLConnection urlC = url.openConnection();
              InputStream is = urlC.getInputStream();
              FileOutputStream fos = null;
              String fileName = getFileName(urlC);
              destinationFolder.mkdirs();
              File localFile = new File(destinationFolder, fileName);
              fos = new FileOutputStream(localFile);
              try {
                   byte[] buf = new byte[1024];
                   int i = 0;
                   while ((i = is.read(buf)) != -1) {
                        fos.write(buf, 0, i);
              } finally {
                   if (is != null)
                        is.close();
                   if (fos != null)
                        fos.close();
              return localFile;
          * Returns the file name associated to an url connection.<br />
          * The result is not a path but just a file name.
          * @param urlC - the url connection
          * @return the file name
          * @throws IOException Signals that an I/O exception has occurred.
         private static final String getFileName(URLConnection urlC) throws IOException {
              String fileName = null;
              String contentDisposition = urlC.getHeaderField("content-disposition");
              if (contentDisposition != null) {
                   fileName = extractFileNameFromContentDisposition(contentDisposition);
              // if the file name cannot be extracted from the content-disposition
              // header, using the url.getFilename() method
              if (fileName == null) {
                   StringTokenizer st = new StringTokenizer(urlC.getURL().getFile(), "/");
                   while (st.hasMoreTokens())
                        fileName = st.nextToken();
              return fileName;
          * Extract the file name from the content disposition header.
          * <p>
          * See <a
          * href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html">http:
          * //www.w3.org/Protocols/rfc2616/rfc2616-sec19.html</a> for detailled
          * information regarding the headers in HTML.
          * @param contentDisposition - the content-disposition header. Cannot be
          *            <code>null>/code>.
          * @return the file name, or <code>null</code> if the content-disposition
          *         header does not contain the filename attribute.
         private static final String extractFileNameFromContentDisposition(
                   String contentDisposition) {
              String[] attributes = contentDisposition.split(";");
              for (String a : attributes) {
                   if (a.toLowerCase().contains("filename")) {
                        // The attribute is the file name. The filename is between
                        // quotes.
                        return a.substring(a.indexOf('\"') + 1, a.lastIndexOf('\"'));
              // not found
              return null;
         }

  • How to get the file name from Oracle B2B 10g

    Hi My requirement is I am getting a CSV file from Trading partner, I am using oracle 10g b2b to translate the data.
    In my BPEL 10g I am using AQ adapter to get the message from IP_IN_QUEUE.
    Now I want to get the file name Eg: SampleFile.dat of the CSV file in my BPEL process.
    I tried using the b2b.filename property in the receive activity and it is not getting the file name.
    <sequence name="main">
        <receive name="Receive_Note" partnerLink="GetB2BNote"
                 portType="ns1:Dequeue_ptt" operation="Dequeue"
                 variable="Receive_Note_Dequeue_InputVariable"
                 createInstance="yes">
                 <bpelx:property name="b2b.fileName" variable="WriteFileName"/>
        </receive>
      </sequence>
    Can you help me to get the file name from Oracle b2b 10g ?
    Thanks,
    b2b user

    Hi My requirement is I am getting a CSV file from Trading partner, I am using oracle 10g b2b to translate the data.
    In my BPEL 10g I am using AQ adapter to get the message from IP_IN_QUEUE.
    Now I want to get the file name Eg: SampleFile.dat of the CSV file in my BPEL process.
    I tried using the b2b.filename property in the receive activity and it is not getting the file name.
    <sequence name="main">
        <receive name="Receive_Note" partnerLink="GetB2BNote"
                 portType="ns1:Dequeue_ptt" operation="Dequeue"
                 variable="Receive_Note_Dequeue_InputVariable"
                 createInstance="yes">
                 <bpelx:property name="b2b.fileName" variable="WriteFileName"/>
        </receive>
      </sequence>
    Can you help me to get the file name from Oracle b2b 10g ?
    Thanks,
    b2b user

  • Retrieve file name from full file path

    I am trying to retrieve a file name from a path (ex. c:\temp\tes.txt) using the following code, but it is given me an error of "The method split(String) in the type String is not applicable for the arguments (char).
    {code}
    String filepath = item.getName();
    String[] buf = filepath.split('/');
    String filename = buf[buf.length-1];
    {code}
    I tried to use double quote instead of single quote, but it is not returning anything.
    {code}
    String[] buf = filepath.split("/");
    {code}
    Anyone knows why? Thanks.

    How is this related to JDBC?
    Anyway, is the path separator actually a forward slash? Isn't it a backward slash?
    If you're using Apache Commons FileUpload (which I guess, the 'item.getName()' is recognizeable), then just read their FAQ: [http://commons.apache.org/fileupload/faq.html#whole-path-from-IE].

  • Can we possible to retrive the file name from the directory...?

    Can we possible to retrive the list of files or file names from the directory...?
    The directory called create or replace directory [directory_name] as ....

    Yeah, yeah its very good example for this scenario.
    I agree. But, I want to learn about Java based PL/SQL code development for that just I am asking any link for this kind of material.....:-)

Maybe you are looking for

  • How to send Oracle AS report automatically by email

    Dear Gurus, I would like to generate a Oracle report automatically and send it by Email. so for that I am trying by using below command C:\home\BIN\rwclient server=rep_servername_FRHome report=C:\reportpath\report.rdf userid=username/password@aliasna

  • ABAP to delete a specific request (last one) from a Cube

    Hello Experts, In a process chain, I would like to delete the last request in a cube before proceeding through with the rest of the PC. For that purpose, I have an ABAP program which will retrieve the "last request ID" from the cube, then call FM RSS

  • Displaying my macbook pro to the tv

    hi, im trying to connect my macbook pro to my samsung series 6 1080p lcd tv, iam using an hdmi cable and a mini display port.  when i connect everything the mac turns blue as is going to display properly but nothing happens on the tv, any suggestions

  • IDVD file to iMovie

    I created a photo slideshow on iDVD (because I needed to play it on a DVD player), but now I'd like to upload it to YouTube. How can I accomplish this? YouTube won't accept any files created in iDVD. Is there a way to open this file in iMovie to shar

  • Nokia Maps wrong language

    Hi, I have a problem with nokia maps on my N8 (latest version on belle refresh...) From a day to another, the categories submenu is now in english. My phone is set to italian. Everything else inside nokia map is in italian but under search > category