Java mapping - Setting the name of the file dinamically

Hi all,
Problem: I know how to set the name of the file in an Idoc to file interface if I'm using a message mapping, but not if I'm using a Java mapping.
I'm using this code inside a user-defined function of the message mapping so that I can set the name of the file dinamically:
public String GetFileName(String  inboundParameter,String IdocNumber,Container container){
String filename;
java.text.SimpleDateFormat dateformat = new java.text.SimpleDateFormat( "yyyyMMdd" );
filename = "cikk_" + dateformat.format( new java.util.Date() ) "_" IdocNumber + ".txt";
DynamicConfiguration conf = (DynamicConfiguration) container
       .getTransformationParameters()
       .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
conf.put(key, filename);
return inboundParameter;
(See also: /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14)
But how can I do that if I'm using a Java mapping??
I don't have the class Container there. How can I retrieve the DynamicConfiguration object without that class?
Thank you very much.

Thank you Jin,
I knew that it had to be related with the Map object got in setParameter, but in this link:
http://help.sap.com/saphelp_nw04/helpdata/en/0f/80243b4a66ae0ce10000000a11402f/frameset.htm
you can't find the constant DYNAMIC_CONFIGURATION.
I think it's not up to date.

Similar Messages

  • Export Indd to EPS/JPG and set the file name  for EPS/JPG file

    Hi,
       When I export the INDD to JPG/EPS, I want to set the file name with pageNumber  for JPG/EPS files using javascript.
    For Example
    If I set the file name as EPSFile.eps, after exporting the indd(with 2 pages) to eps
    ,files are generating in the following name EPSFile_1.eps, EPSFile_2.eps.
    but I want to set the file name as EPSFile_001.eps and EPSFile_002.eps using javascript.
    anyone knows please reply for this.
    Regards,
    Mubeen

    Hi,
      I tried the following code.
    var JPGe = new File("Applications/PDF/JPG/file.jp");
    app.activeDocument.exportFile(ExportFormat.jpg, );
    when I use this code ,exported jpg file names are
    file.jpg, file1.jpg,file3.jpg.
    but ,I want the output file names as file_001,file_002,file_003,
    Thanks,
    Mubeen

  • How to set the file transfer mode to binary

    Hi,
    I have a requirement to upload files from local machine to server, and it is working fine.
    But after uploading files junk characters are entered after each line, so want to set the file transfer mode to binary to get rid from this error.
    We have checked that if we ftp the files manually then also getting the same problem when the transfer mode is not selected as binary.
    Please give your valuable advice.
    Thanks,
    Ranita

    Hi,
    I want to set the file transfer mode through controller code, presently I am using the below code where no file transfer mode is specified ::
    public void upLoadFile(OAPageContext pageContext,OAWebBean webBean)
      String serverPath = null;
      OAApplicationModuleImpl am = (OAApplicationModuleImpl)pageContext.getApplicationModule(webBean);
       try {              
          Connection conn = am.getOADBTransaction().getJdbcConnection();     
          String query = "select  distinct variable_name, value from fnd_env_context where variable_name = 'XXCUST_TOP' and concurrent_process_id = ( select max(concurrent_process_id) from fnd_env_context )";
          PreparedStatement stmt = conn.prepareStatement(query);
           for (ResultSet resultset = stmt.executeQuery();
                          resultset.next(); )
                 serverPath  = resultset.getString("value");
            stmt.close();  
           catch(Exception ex)
             throw new OAException(ex.getMessage(), OAException.ERROR);
       String filePath = serverPath+"/"+pageContext.getParameter("FileType");
       //System.out.println("Default File Path---->"+filePath);
       String fileUrl = null;
       try
        DataObject fileUploadData =  pageContext.getNamedDataObject("MessageFileUpload");
      //FileUploading is my MessageFileUpload Bean Id
        if(fileUploadData!=null)
         String uFileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME"); 
         String contentType = (String) fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE");  
         //System.out.println("User File Name---->"+uFileName);
         FileOutputStream output = null;
         InputStream input = null;
         BlobDomain uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null, uFileName);
         //System.out.println("uploadedByteStream---->"+uploadedByteStream);
         File file = new File(filePath, uFileName);   //C:\\Ranita
         //System.out.println("File output---->"+file);
         output = new FileOutputStream(file);
         //System.out.println("input---->"+input);
         byte abyte0[] = new byte[0x19000];
         int i;
         while((i = input.read(abyte0)) > 0)
         output.write(abyte0, 0, i);
         output.close();
         input.close();
         HashMap map = new HashMap();
         map.put("fromPage","Y");
         pageContext.forwardImmediatelyToCurrentPage(map,true,OAWebBeanConstants.ADD_BREAD_CRUMB_YES);
       catch(Exception ex)

  • How to set the file path dynamically based on sytem, username, and date

    Hi All,
    My requirement is upload the data into one  structure like xyz that is related to t.code MCSZ.
    file will be in  UNIx SERVER .
    PATH IS: /sapif
    file name is xy789 load .txt
    I have  to write code in one user-exit
    how can i set the file path for this.
    shall i put hard code file path?
    because i have to writecode in user-exit.
    plz tell me how to set the file path based ons syetem, username, date
    Thanks in advance
    Ram.A

    Concatenate the field SY-SYSID, SY-UNAME and SY-DATUM for the file path

  • ChaRM class java.io.IOException:The file does not exist on the filesystem

    Hi All,
    We are implementing ChaRM with Portal. While deploying we are running into following issue.
      Deployable-Id:/usr/sap/trans/data/GPSK90001B/sktp14_20100806_095633.epa
      Returncode:'12'
      class java.io.IOException:The file (/usr/sap/trans/data/GPSK90001B/sktp14_20100806_095633.epa) does not exist on the filesystem.
    Any suggestion.
    Regards,
    Smita

    We resolved this issue by sharing the trans file across SolMan and Portal system.

  • How to set the File Path to run a javascript using Plugin Code?

    Hi All,
    Im new to Indesign Plugin Development.Can any one help me out with my problem.
    What i want to do is to run a javascript using Plugin Code.When i went through this forum i was able to find out that i should use the IscriptRunner Class to automate this.I could also figure out that the Member Function to use is "CanHandleFile" &"RunFile".
    The first parameter in CanHandleFile & RunFile Member Function is to specify the path of the JavaScript File i suppose!I could also find out that IDFile has to used to set the file path Information.
    But im clueless how to set the Javascript FilePath using IDFile.Can any one help me how to do this?Any Code Snippets Please?
    Waiting for reply.
    Thanks
    myRiaz

    Hi,  Andreas<br /><br />  Can you explain this in detail? I found it in your post before.<br /><br />  The content of elements are returned through the Characters callback function:<br /><br />From ISaxContentHandler.h:<br /><br />/**<br />        Receives character data<br /><br />The parser will call this method to report each chunk of<br />        character data. SAX parsers may return all contiguous<br />        character data in a single chunk, or they may split it into<br />        several chunks. But all characters in any single<br />        event must come from the same external entity so the<br />        Locator provides useful information.<br /><br />Note some parsers will report whitespace using the<br />        IgnorableWhitespace() method rather than this one (validating<br />        parsers must do so).<br /><br />@param Chars The characters from the XML document.<br />        */<br />virtual void Characters(const PMString& chars) = 0; <br /><br />  What i have done is implement my own SAXContentHandlerServiceBoss, and in my file XXXSAXContentHandler.cpp, I override the fonctions StartElement, EndElement, and Characters() like below: I add the PMString xmlData to collect the file content:<br /><br />class XXXSAXContentHandler : public CSAXContentHandler<br />{<br />void XXXSAXContentHandler::Characters(const WideString& chars)<br />{<br />xmlData.Append(chars);<br />}<br /><br />void XXXSAXContentHandler::StartElement(const WideString& uri, const WideString& localname, const WideString& qname, ISAXAttributes* attrs)<br />{<br />xmlData.Append("<"); xmlData.Append(localname); xmlData.Append(">");<br />}<br />void XXXSAXContentHandler::EndElement(const WideString& uri, const WideString& localname, const WideString& qname)<br />{<br />xmlData.Append("</"); xmlData.Append(localname); xmlData.Append(">");<br />}<br /><br />}<br /><br />and in my program, I use the code below to call the fonction I overrided, but I dont know how I can get the String xmlData I defined in the XXXSAXContentHandler.cpp<br /><br />InterfacePtr<IK2ServiceRegistry> serviceRegistry(gSession, UseDefaultIID());<br /><br />InterfacePtr<IK2ServiceProvider> xmlProvider(serviceRegistry->QueryServiceProviderByClassID(kXMLParserService, kXMLParserServiceBoss));<br /><br />InterfacePtr<ISAXServices> saxServices(xmlProvider, UseDefaultIID());<br />InterfacePtr<ISAXContentHandler> saxHandler(::CreateObject2<ISAXContentHandler>(kXXXSAXContentHandlerServiceBoss));<br />saxHandler->Register(saxServices);<br />bool16 parseFailed = saxServices->ParseStream(readStream, saxHandler);<br /><br />Can you give me any help?<br /><br />Thanks and regards!

  • Setting the file system size for the emulator

    Hi,
    I am trying to set the file system size of the emulator so I can test what happens when the system is full and I try to write to the file system. I am using WTK 2.5.1 and I went into preferences -> storage and set Storage size to 10KB. But when I run the emulator and check the available size of the root directories using:
    try {
             Enumeration roots = FileSystemRegistry.listRoots();
             while (roots.hasMoreElements()) {
                String dir = (String) roots.nextElement();
                FileConnection fc = (FileConnection) Connector.open( "file:///" + dir );
                System.out.println( "Available Size on " + dir + " : "+ fc.availableSize());
                fc.close();
          } catch ( IOException ex ) {
             ex.printStackTrace();
    }I get the remaining size of my pc's hard drive, not what is remaining from the 10KB I set.
    Can you tell me the correct way to do this? I don't want to fill up my pc's hard drive in order to test this!!

    Has anyone got an answer to this?

  • [svn] 1657: Rebuilt our modified Batik and Velocity JARs after setting the file properties correctly on modules /thirdparty.

    Revision: 1657
    Author: [email protected]
    Date: 2008-05-09 17:37:18 -0700 (Fri, 09 May 2008)
    Log Message:
    Rebuilt our modified Batik and Velocity JARs after setting the file properties correctly on modules/thirdparty.
    Modified Paths:
    flex/sdk/trunk/lib/batik-all-flex.jar
    flex/sdk/trunk/lib/velocity-dep-1.4-flex.jar

    Hi DST
    This is a great effort and gesture. thank you on behalf of all the newbies.
    PJ

  • Is there a way to automatically set the file name in Acrobat Properties when exporting a PDF from Indesign?

    When I used Quark to make a PDF, the title area in the PDF was automatically populated with the file name, there in the properties tab. We like use this area to confirm file names of original files, so we can keep track of drafts, (in case the file name of the PDF is changed, which our boss often does). Is there any way to set up InDesign to do the same?

    @stadlock – I think I know what you mean…
    You exported to PDF and changed the file name in the export dialog to a different one from the document name presented there the first time you exported that document. And in exports after that the new name will be presented in the dialog instead of the name of the document.
    What you can do against that?
    1. First time you want to export: Save before the document is exported. And do not save after it's exported with a new file name.
    2. After the new file name is already there in the export dialog:
    Type in the document name in the dialog. Export. Or abort after chosing a export preference. Save. Check again, if the document's file name is in the export dialog. If yes, procede like in suggestion #1. If not do a full export with the document's file name, save and then procede with suggestion #1.
    Uwe

  • Setting the file name of a resource to be downloaded

    Hi,
    I am trying to download files from the webserver to the client machine using code given below..
    The filename is the path to the file to be downloaded to the client. Some parsing of the filename is required as I modify the filename to a particular format. I use the parsed filename to get the Mime type which is then set to the content type.
    When I tested the code, the mime type is correct and also the file downloaded is corrext. But the browser prompts me to save the file with the name of the Url. Can I change this? I suppose setting of some http response header is needed.
    public class ReadServlet extends GenericServlet {
        public void service(ServletRequest req, ServletResponse res){
                   ServletContext context = this.getServletContext();
                   //check doc_id and doc_ver_index
                   String filename = (String)req.getAttribute("filename");
                   if(filename == null ){
                        return;
                   try{
                        File file = new File(filename);
                        int underscore = filename.lastIndexOf('_');
                        if(underscore!=-1){
                             filename = filename.substring(0, underscore);
                        String mimeType = context.getMimeType(filename);
                        if(mimeType == null){
                             mimeType = "application/octet-stream";
                        res.setContentType(mimeType);
                        InputStream in = null;
                        OutputStream out = res.getOutputStream();
                        byte[] buffer = new byte[1024*8];
                        try {
                             in = new BufferedInputStream(new FileInputStream(file) );
                             int ch;
                             while ((ch = in.read(buffer)) !=-1) {
                                  out.write(buffer, 0, ch );
                        finally {
                             if (in != null){
                                  in.close();
                             if(out!=null){
                                  out.close();
                   }catch(IOException ioe){
                        System.out.println(ioe.getMessage());
              return;
    }Thanks
    Rahul

    Hi Rahul,
    res.setHeader("Content-Disposition", "attachment; filename=\"" + your_file_name + "\"");
    res.setContentLength(your_file_length);Good luck.

  • How can I set the file name and folder for output to PDF from another application?

    I am developing an application in Microsoft Access where the printed reports are to be saved in PDF format for archive purposes. I can send the output to Adobe X, but the default file name is the Access report name and the folder selected is the one last used.
    What I need to do is to create the file with a specific name (which changes for each run) and to a specific folder (which also changes for each run).
    The language I'm using is Visual Basic for Applications which is located in an Access form that controls the report production.
    Any suggestions, please?

    Got it - many thanks.

  • Setting the file type in a file field

    Hi,
    I wonder if any body can help i am new to web application
    development, I am developing an asp application in dreamweaver 8,
    A few of my pages contain a file field which has a file
    browse button at the end of the field which works fine,
    now i want to set the default file type to *.pdf, Currently
    when i run my app in IE 7, when i click on the file browse
    button, the file browse dialog box appears but the default
    file type is *.* (All files), is it possible to set the default
    file type
    to pdf so that when the file browse dialog is displayed the
    default file type is *.pdf in stead of *.*.
    Thanks
    Fifo

    The OS just watch the extension of the file.Not always. If you create a word doc but name it with
    some other extension, the OS still can determine that
    it is a word doc.On which OS?
    if i take foo.exe and i rename foo.doc so my OSwill
    try to open it as a MS Word Document.Again, garbage in, garbage out.What you mean?
    If I create a MS Word Document for a file .doc that is not a real .doc and it is not able to read, i will just lose cpu time and a lot of memory.
    So it is important to understand if I need really to open MS Word watching what is the real file type
    Either way, you're going to be doing way too much
    work (and wheel-reinventing) if you're going to build
    your own detection scheme.In the SDK there is not any file type checker, and if eventually really exists an OS like you say that is able to read inside the file, i prefer to have my own Java class that do that work in a safe and opensource way.
    However in my first post i've given a site with some java code that do what I need, i just was asking if anyone know if there is any ready-to-work java class that is better for doing this work.

  • Set the file path of get image method

    I have a program that takes multiple IV curves of some nano-devices and saves each set of the IV curve data into a CSV file. I also have a graph on the main screen that gives me a visual representation of the data after each IV curve is taken.
    My program automatically names each IV curve with a different file path and at the end of the program execution I could have 50-60 IV curves.  What i'm trying to do is have LabVIEW export an image file of the graph on my front panel and save it with the save file path as the CSV file.
    Currently i'm using "Invoke Node -> Export Image" method, which is working fine and doing exactly what I want because i can tell it what file path to save to....however it is just a black and white image.
    There is another method that I found here: http://digital.ni.com/public.nsf/allkb/5AE4ADCBB65​A6D8F86256FBF007A1AC1
    That talks about a "Invoke Node -> Get Image Method" which physically captures the colorful chart on the front panel.  However I cannot figure out a way to tell it the file path to save to.  So when I run my program, after each IV curve, it takes the image from the front panel and then on the next IV curve, it interrupts my program to ask me to overwrite the previous file because it's using the same name.
    Is there a way to tell the Get Image Method to save to a specific file path?

    Hi Puneet_K,
    Thanks for the code....I didn't know you could wire the output of the image data to a write VI.  It makes sense in theory and i thought it would work....but it's not actually writing the PNG. I even tried BMP and JPEG but no results.
    I'm posting an image of my code with the before and after.  The before uses export image and it works, the after uses the get image and it doesn't create the file.
    Attachments:
    before.PNG ‏71 KB
    after.PNG ‏71 KB

  • JAVA Mapping: Convert the InputStream in  to OutputStream out

    Hi everybody,
    I'd like to code my first JAVA Mapping. For this I would just like to convert the InputStream in  to OutputStream out.
    This does not work:
    out = new FileOutputStream(new File(in));
    How has the code look like?
    Thanks, regards
    Mario

    Hi Mario.
    Do you want to convert input into output directly without doing any transformation?
    The way I've always used is to load the input document first:
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(inputStream);
    After loading the document you can parse it's content with DOM API.
    Finally you create the transformed document and return it through outputstream:
    Document resultDoc = builder.newDocument();
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    DOMSource source = new DOMSource(resultDoc);
    StreamResult result = new StreamResult(outputStream);
    transformer.transform(source, result);
    If  you want to convert the input to output you can use:
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(inputStream);
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    DOMSource source = new DOMSource(doc);
    StreamResult result = new StreamResult(outputStream);
    transformer.transform(source, result);
    At this point, I think you will have the input into the output.
    Regards,
    Gari.

  • How to set the file.encoding in jvm?

    I have some error in showing Chinese by used servlet,
    some one tole me that I can change the file.encoding in jvm to zh_CN, how can I do that?

    Add the java argument in your servlet engine.
    e.g
    java -Dfile.encoding=ISO8859-1
    garycafe

Maybe you are looking for

  • Error while deploying/Undeploying the SOA composite

    Hi All, I am a new bie to OIM 11g. I have created a simple batch file with the commands for deploying/Undeploying/Disbaling/Enabling the SOA composites. I am trying to deploy/Undeploy/Disbale/Enable the SOA composites using the batch file. Following

  • Cannot attach library webutil 40039 - any ideas....

    Hi I keep getting this error when running my Form in dev 10G. "Cannot attach library webutil while opening form TEST_FORM. 40039" 1. I have attached the library webutil.pll 2. I compiled it (.plx file) 3. All files are in my directory ../test_dir 4.

  • How to transfer Windows 3 data from a G3 with a bad floppy drive

    My first Mac was a PowerMac G3 beige tower (233 Ghz) in 1998.  At that time I installed VirtualPC running Windows 3.0 to use a genealogy program that didn't run on a Mac and input all my family data.  I have a 5 inch floppy disk with the data but whe

  • How to store pictures

    I am seeking how to store pictures in a table. I know I must use the LONG RAW Datatype but I don(t know how to insert the pictures. Could U help me please? Thanx in advance null

  • Premier Elements 12 auto-save location

    My daughter is working in Premier Elements 12 on a .mov file.  She did about 2 hours of movie editing and the program shut down unexpectedly.   The program was saving as she went, but she can not find her file.  Any ideas on where the program would p