Get source file name in the structure itself or in the payload

Hi everyone,
I have a task regarding mapping
In my  structure , i defined a field for Filename . What I need is, what ever source file name am sending, that should be mapped into this filed.
If am sending inputfile.txt.
My output file should appear like this,
<?xml version="1.0"?>
         <message id=u201DmessageIDu201D>
                 <header>
                         <filename>D:\\inputfile.txt</filename>
                 </header>
                 <body>
                          FileContent
                 </body>
         </message>
Any help would be appreciated. Do I need to create any UDF. If So please provide.
Regards,
Varun

Hi Varun,
are u using the same UDF that I replied. also note that the variable key should be declared only once.
Use this without changing any thing. It works for me...
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);
key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");
String dir =  conf.get(key);
return dir+'/'+ourSourceFileName;
Also let us know where do you het this error..
Thanks
SaNv...

Similar Messages

  • ** How to get Source File Name thru XSLT Mapping

    Hi friends,
    We require source file name after message processing (SXMB_MONI) in the output structure.  We understad from Forums and  blog 2664, this is possible thru UDF - DynamicConfiguration class. This UDF will work if we use message mapping. But, in our case we are using XSLT mapping. So, how do we call  the same from Java Pacakage ? (Imported Archives). For writing java class separately, what are the changes to be made in the program?
    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;
    Kindly reply, friends.
    Kind Regards,
    Jeg P.

    Hi,
    This is the example in this similar manner u have to call the method in which u have to write the code for picking the source file name.
    <name>
       <xsl:if test="function-available('javamap:concat')">
        <xsl:value-of select="javamap:concat($first, $last, $inputparam)"/>
       </xsl:if>
      </name>
    for reference check the Link,
    http://help.sap.com/saphelp_nw04s/helpdata/en/73/f61eea1741453eb8f794e150067930/frameset.htm
    Regards,
    Phani

  • Imported source file name changed for the external table

    Hi,
    I have external table from flat file. Now the source file name is changed. I can change the file location to point to the new file name, but I can't update the source for the flat file property(as seen under flat file properties,structure tab. the column "Sampled From"). Is there way to have this update without having to import the file using the new file name again?

    In the Files section in the object navigator find the flat file you want to change the source of.
    Double click on the actual file, and on the General tab change the old file name to the new one.
    The fact that it has been sampled from a different file should not 'disturb' the working of the external table.
    However, if the structure of the new file is different I'd suggest to resample.
    Good luck, Patrick

  • Getting the Source File name Info into Target Message

    Hi all,
    I want to get the Source file name Info into Target message of one of the fields.
    i followed Michal BLOG /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
    Requirement :
    1) I am able to get the Target file name as same as the source file name when i check the ASMA in Sender & Receiver Adapter , with out any UDF...............this thing is OK
    2) I took One field extra in the target structure Like "FileName" & I mapped it Like
                              Constant(" " )--UDF-----FileName
    I Checked the Option ASMA in Both Sender & Receiver Adapters
    Here iam getting the Target File name as same as Source file name + Source File name Info in the Target Field " FileName".
    I Dont want to get the Target File name as same as Source file name. I want like Out.xml as Target file name.
    If i de-select the Option ASMA in Adapters means it is showing " null" value in the target field "FileName".
    Please Provide the Solution for this
    Regards
    Bopanna

    Hi All,
    Iam able to do this by checking the Option ASMA in only sender adapter itself
    Regards
    Bopanna

  • UDF to capture the source file name or the source folder for mapping

    Hi All,
    i have 2 files -  File1 from File2 from 2 different folders- single comm channel FTP (FCC). i have to pass a constant A and B respectively to a field in target structure.
    my options are -
    either create a new field in source str populating different constants and  then map to the target str
    or a udf to get the source file name or the source folder so that i can map the constant using the value mapping/FixValue mapping.
    please suggest. thanks.
    rajib

    Hi,
    please use the UDF to determine the file name. Then based on file name either pass A or B to your target field.
    The code is as given below. Just tweak the code to pass either A or B as per your requirement.
    public String G_GetFileName(Container container) throws StreamTransformationException{
    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; 
    Regards,
    Deepak.

  • Get-ChildItem : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

    Hi, Im trying to get the whole path in my server, so i tried that with this following code
    Get-ChildItem $sourceFolder  -Recurse | ?{$_.PsIsContainer} |Get-Acl
    But then, it showed me somtehing like this :
    Get-ChildItem : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
     I tried to find the solver everywhere and mostly they propose to change the path name, which is impossible, since I am working with my company server, and those folder have already there before i start to work here, then the other ask me to use robocopy,
    but all of the trick just dont work
    is there any way to solve this problem? thanks

    There is no simple solution to this. And it is not a limitation of powershell itself, but of the underlying NTFS file system.
    If the problem is that a folder with a name longer than 248 exists anywhere within your directory structure, you are hooped.
    If the problem is that some fully qualified path names exceed 260 characters, then, in those cases, the solution already given is to create a psdrive partway up the path from the drive letter or server/share root of the path. Unfortunately, the output produced
    will be relative to that psdrive and not to what is specified as the $sourcefolder.
    unless you already know where those problematic paths are, you might consider trying to trap those errors and have your script figure out where it needs to create psdrives. You might then be able to calculate the equivalent path for each file or folder and
    output that. the programming effort would be simpler to just created a psdrive for each folder encountered, however I expect that would be very inefficient.
    Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.

  • Dynamic File Name depending on the Source File name

    Hi Experts,
    I have a problem like Dynamic File name depending on the Source File Name. I will explain with example as follwos
    Source File name                 Targer Folder/Filename
    NK01.VR59.L2007030         VR59/Rec.l200
    NK01.VR71.L2017030         VR71/Rec.l201
    NK01.VR77.L2027030         VR77/Rec.l202
    See above the exaple, Depending on the Source file name, I am deciding where i need to place my file and what name i need to name it.
    So please suggest me the solution and How can i do this with a single communication channel ? Do i need to create multiple CC for each folder??
    Points will be rewarded for Valuable anwer.
    Thanks in Advance,
    Best Regads,
    Vijay

    Hi VIjay,
    Thanks for quick reply. But i am getting error in End to End Scenarios only. If i remove the Return " "  statement from the UDF, while activating it is showing the error saying like missing return statement. I also mapped to the top most node to this UDF.
    I am getting the following error in End to End error Scenarios:
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Request Message Mapping
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>Application</SAP:Category>
      <SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>
      <SAP:P1>com/sap/xi/tf/_MM_Target_File_determined_</SAP:P1>
      <SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2>
      <SAP:P3>Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:P3>
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>During the application mapping com/sap/xi/tf/_MM_Target_File_determined_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>

  • Accessing comapny code from the source file name

    Hi,
    Iam doing FILE –FILE to scenario.
    My source file name is XXXX237061606.txt. (XXXX is company code)
    My requirement is …
    Based on company code from the source file name; I need to send the file to the corresponding receiver.
    How to retrieve the company code from the source file name?
    Thanks,
    Hem.

    hem chand wrote:>
    > Hi Varun,
    >
    > Could u please provide me detailed procedure to get the company code.
    >
    > Reg,
    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);
    This will get you the File name...TRuncate it to extract company code...
    Then have a mapping program with the receivers message type which is persent under SAP BASIS component....
    There map to the required receiver by getting the file name above..
    Create an int mapping for the above mapping and use that in ur enhanced recv determination

  • How do I map the source file name to a target table?

    I am mapping a source fixed length flat file to oracle target tables. One of the tables is a parent transaction table that stores the date, record number, status, etc. and the file name of the source flat file. The file name will change daily because the date is part of the naming convention. Is there an easy way to determine the source file name and map it?
    One option a co-worker is working on is writing a pre-mapping stored procedure. It would insert the file name into a table prior to the mapping. But I was hoping for a cleaner solution.
    Thanks!

    Hi
    Use extarnel table to load the data from the file into the table.
    Create a procedure which changes the external table definition as the filename chnages.
    Use this proceudre in the mapping as a premapping process.
    Ott Karesz
    http://www.trendo-kft.hu

  • File-File - Need to extract data from source file name???

    Hello Experts,
    I have a unique situation. In my file to file scenario, the source file name is of the format XYZ_yymmddHHMM.dat. there is field in the target file which has to filled with the date that is there in the file name of the source file (yymmdd). How can this be achieved? Normally we do the other way round using vaiable substitution where we can name a file depending on the value in any of the target field structure.
    Please help.
    Regards,
    Yash

    Hi,
      please prepare the udf with the following code.
      i mean, dynamic configuration concept.
      where u get the file name, then use substring function to capture date from right side.
       //write your code here
    // getFileName User Defined Function
    // function to create name of output file
    String filename;
    filename = strFile;
    try {
    // initialize DynamicConfiguration for create file with given name
    DynamicConfiguration conf = (DynamicConfiguration) container
    .getTransformationParameters()
    .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
    //create file with the specified name
    conf.put(key, filename);
    } catch (Exception ex) {
    return filename;
    warm regards
    mahesh.

  • File Sender adapter - source file name - weird

    Hi all,
    We have a sender file adapter polling an ftp location. The Dynamic config has been enabled to get the source file name.
    The actual file name is - "hrmd.xml", but in the dynamic configuration node, in sxmb_moni, the fileName is shown as ./hrmd.xml.
    This does not occur with any other file sender adapter comm channels polling ftp locations.
    I guess this has something to do with the ftp server. Did anyone face this issue?

    the fileName is shown as ./hrmd.xml
    The file name surely cant have a / in it....such characters are not allowed.
    is there any way we can change the fileName message attribute once the file is picked up
    Create a UDF for Dynamic Configuration and change the name as per your requirement (in XI)....the source file may be having proper format for name and i assume that you have to change it for receiver file name

  • Need Target File  Name  Timestamp  is  same  as Source File name Timestamp

    Hi ,
           I want to genereate Target file name (Target_09062008082030.xml)   but  this time stamp is exactly Sorce FileTime stamp..(Source_09062008082030.xml)..
         so, i want to create a  target file  with the same source file time stamp.. 
    for this.. i sed Message Specific attributes... in both sender and receiver side.. but  that was creating with the complete name.of source file name.. but i want only Timestamp of the source filename... and remaing is the constant.. for this  how can i proceed  ..
    Thanks
    Jain

    See in Sender CC when you set the Adapter Specific Message Attr  for file name it will send the filename in the header of the XI Message.
    To acces this file name inside mapping you need to create a UDF . The type can be any thing as you desire.
    You dont need to pass any variable .if suppose you want the file name (constant) e.g ABC_<timestamp>.xml
    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);
    //see above your key is FileName which will be sent by the sender CC automatically... You are simply accessing it here using get() method.
    //now ur filename will contain name of the source file... you need to perform a substring operation to get the timestamp and create a new file name as you desire.
    fileName = "New_<timestmp>.xml"; //for e.g
    //set this file name again in header message using put()
    conf.put(key, fileName);
    //when you check on the adapter specific message attr for fileName in the receiver CC ,it will automatically take this new file name value.
    return fileName;
    // if you want to use this new fileName inside your mapping payload (for other fields) you can assign this to any target field,else just assign it to the root tag which will make no difference if this file name is not used anywhere.

  • How to get Sequence File Name ?

    Hello everybody !!
    I'm using TestStand 3.1 and i would like to get sequence file name. I've tried to use NameOf() function, but without success.
    Of course, I've searched previous posts about the same question, but nothing works.
    Is there someone able to tell me how to get sequence file name ?
    Thanks a lot.
    MrOrange

    MrOrange,
    first of all, the solution i will present only works for saved sequence files.
    you got all information you need within TestStand itself, just browse for RunState.SequenceFile.Path. here you can find the filename. but the path of the file is also included in the string, so this is a part you have to get rid off.
    you can use statements to extract the filename from the path. just search the string for the last occurence of "\\" (searchinreverse!) and then you can retrieve the right() part of the path. beware that right() needs the number of characters you want to extract, not the startindex!!
    hope this helps,
    Norbert B.
    NI Germany
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Get image file name

    Hi ALL,
    I want all image file naming like a caption in my source document. Source document contains more than 100 images.
    But i got a script through the forum and tuned for my script. Still, the file naming comes for the Ist page image only.
    From second page onwards the file naming not comes like a caption.
    Trying script:
    //To Get image file name
    var tgt = app.activeDocument.rectangles;
    for (i=0;i<tgt.length;i++){
        myCaption = app.activeDocument.textFrames.add();
        myCaption.textFramePreferences.verticalJustification = VerticalJustification.TOP_ALIGN
        myCaption.contents = tgt[i].graphics[0].itemLink.name
        myCaption.paragraphs[0].justification = Justification.CENTER_ALIGN;
        bnds = tgt[i].visibleBounds;
        myCaption.visibleBounds =
            [bnds[2]+12, bnds[1], bnds[2]+4,bnds[3]];
            //[bnds[0]-6, bnds[1], bnds[0]-1,bnds[3]];
            myCaption.fit(FitOptions.FRAME_TO_CONTENT);
    Thanks in advance
    BEGINNER

    If you use the add() method in conjunction with the document without specifying the page or better the spread, all objects added will end up on the first spread of your document.
    But your testing scenario is also too narrow. You are expecting:
    1. All your graphics are sitting in Rectangle objects (what about Ovals or Polygons?)
    Therefore: All graphics placed in ovals or polygons are left out.
    2. That really ALL rectangles in your document contain graphics
    You are in trouble, if there happen to be empty rectangles on a page. I would suggest to test that with your script. It will give you an error, because there is no graphics[0] for this specific rectangle, where you can draw the "name" for the "itemLink".
    3. That there are no graphics in anchored objects or pasted inside other objects; left alone graphics inside table cells.
    And who can say that thiese three restrictions exist in all documents you want to run this script against?
    So, if you want to get to all image files in the document, why don't you start with the images in the first place?
    Let's see:
    the Document object has an "allGraphics" property.
    Use that as a starting point and you will not missing a single graphic.*
    Iterate through "allGraphics" will get you:
    the "name" of the placed image through its itemLink.name property;
    the container of the graphic, that's the "parent" of the graphic.
    Now you need one other thing:
    the page, or even better(!) the spread where the graphic is located. Imagine a graphic sitting outside of a page.
    If you want to handle thiese, you must know the spread.
    If  writing this script for InDesign CS5 or above, you are in luck. There is a "parentPage" property of the "Graphic" object, you could use for your add() method. For graphics outside of pages this property will be "null".
    And another important thing:
    if a graphic is copy/pasted from e.g. PhotoShop to InDesign, the "itemLink"  property of that graphic is also "null".
    We can handle that in a try/catch scenario…
    //Scope: all graphics on all pages
    //(that includes graphics of anchored objects, active states of MSOs, graphics in table cells as well)
    var tgt = app.activeDocument.allGraphics;
    for(var i=0;i<tgt.length;i++){
        //Narrow the scope to all graphics on pages only:
        if(tgt[i].parentPage != null){
            //What to do with graphics, that are pasted directly from none-InDesign files:
            //the caption will read "Undefined"
            try{
            var myName = tgt[i].itemLink.name;
            }catch(e){var myName = "Undefined"};
            //targets the page of the graphic:
            var myPage = tgt[i].parentPage;
            //adds a text frame to the page of the graphic:
            var myCaption = myPage.textFrames.add();
            myCaption.textFramePreferences.verticalJustification = VerticalJustification.TOP_ALIGN;
            myCaption.contents = myName;
            myCaption.paragraphs[0].justification = Justification.CENTER_ALIGN;
            //Why visible bounds and not geometric bounds?
            var bnds = tgt[i].parent.visibleBounds;
            myCaption.visibleBounds = [bnds[2]+12, bnds[1], bnds[2]+4,bnds[3]];
            myCaption.fit(FitOptions.FRAME_TO_CONTENT);
    *Not exactly true, because it is missing graphics in not-active states of  MultiStateObjects.
    Since MSOs were introduced in InDesign CS5 the DOM documentation left out this fact so far.
    //EDIT: in the first version I had a comment on a different scope. Since  Document Objects have no "graphic" property, I removed that comment. Sorry.
    Uwe
    P.S. And a Happy New Year to all!
    Message was edited by: Laubender

  • Same source file name with a different extension

    Hi All,
    I have a source file which is dynamic all the time. Can I create a target file which has the same name as the source file but with a different extension.
    Scenaio is file to file.
    test. xml is the source file name and the target file name should be as test.csv
    Regards,
    Amar

    Hi Amareshwar,
    you can write a java code (either in UDF or import in imported archive and use in imterface mapping).
    The piece of code is..
    DynamicConfiguration conf = (DynamicConfiguration) myParam.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey Filekey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String OriginalFileName = conf.get(Filekey);
    if (OriginalFileName != null)
    NewFileName=OriginalFileName.replaceAll(".csv",".txt");
    conf.put(Filekey,NewFileName);
    And in Integration Directory>Configuration Scenario>your communication channels (both sender and receiver) just select
    Adapter specific message attributes- File name
    This would solve your problem.....
    Regards,
    Vishal Gupta
    Plz reward points if you are satisfied with the solution.

Maybe you are looking for

  • Remote System Explorer on a Wireless LAN

    On a wireless LAN when I use Remote System Explorer, it knocks our Fieldpoint network modules off-line. We are unable to ping them. Once we restart the units, they work fine until someone uses the Remote System Explorer again. Any ideas?

  • Help!: Control reference seamingly "lost" in run-time execution mode

    Hi! The Facts: LabView 6.1 PC under NT. I've been using "Vi loader" technique since a few month s to distribute a LabView application on severals PCs without having to re-compile it each time. My application uses more than 500 VIs so I can't build it

  • Specific Business Object for Infotype 2012 Time Transfer Specifications

    Anyone know if there is a specific business object for infotype 2012 - Time Transfer Specifications? or should we use the standard EMPLOYEESU   Employee information according to infotype and subtype or create our own zclass, any experience/help is mu

  • Easiest RowHeader?

    Hi,I'm not good at programming and English. But I find a way to make RowHeader in JTable,so i'll try. if it has already sugegsted,I'm sorry. I cant find this method anyother website. Jtable has ColumnHeader,but not RowHeader. So, 1. "get Renderer at

  • Issues with Nokia Music - Nokia 5800 XpressMusic

    Hi All, I just bought my Nokia 5800XM today and I really am enjoying it. However, the issues I'm experiencing with Nokia Music are very frustrating... In short: 1) I already updated all components, my Nokia itself and all the applications that came w