Dynamic target Directory

Hi All
      I have a scenario in which all my master IDOCS should flow form R3 to XI and form XI to the FTP Server's respective Folder loaction.
The Folder option is storewise , so for example for ST01 , the corresponding WP_PLU should be placed at ST01 folder location in the ftp server.
there is an UDF written foe file naminf convention:
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http:" + "/" + "/" + "sap.com/xi/XI/System/File", "FileName");
Calendar cal = Calendar.getInstance();
Date date = cal.getTime();
String s = date.toString();
String a1 = s.substring(8,10);
String b = s.substring(4,7);
String b1="a";
if(b.equals("Jan"))
{b1="01";}
if(b.equals("Feb"))
{b1="02";}
if(b.equals("Mar"))
{b1="03";}
if(b.equals("Apr"))
{b1="04";}
if(b.equals("May"))
{b1="05";}
if(b.equals("Jun"))
{b1="06";}
if(b.equals("Jul"))
{b1="07";}
if(b.equals("Aug"))
{b1="08";}
if(b.equals("Sep"))
{b1="09";}
if(b.equals("Oct"))
{b1="10";}
if(b.equals("Nov"))
{b1="11";}
if(b.equals("Dec"))
{b1="12";}
String c = s.substring(24);
String sDate = a1b1c;
String e = s.substring(11,13);
String f = s.substring(14,16);
String g = s.substring(17,19);
String sTime = efg;
String d = a.substring(9,25);
String Idoc = d;
String RecieverFilename = "WPDBBY_"Idoc"_"sDate"_"sTime".txt";
//<Receiver Filename> ; //you have to give the filename that has to be generated in the receiver adapter.
conf.put(key, RecieverFilename);
return a;
Could any1 please help how to add the directory to it,please let me know the code as i am not a JAVA developer
regards
Prajna

Hi,
add this extra code
DynamicConfigurationKey DIR_NAME = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");
String Dirname = "";
//write logic to generate a dynamic directory and make sure that this directory exists in FTP
//(or) the Receiver file channel Channel has access rights to create the folder.
conf.put(DIR_NAME, Dirname );//now put that Dirname value generated here
Also Make sure that in the receiver file channel Adapter Specific message Attributes is checked along with FileName & Directory.
Thanks,
Gujjeti.
Edited by: Praveen Gujjeti on Nov 21, 2008 1:07 PM

Similar Messages

  • File Adapter : Dynamic Target Directory

    Hi EveryBody,
    I have an IDOC to File Scenario in which based on some field value X in IDOC i need to send the file to Different locations under the same FTP Server.
    For Example : if X = 01 then Target folder T1
                            X = 02 then Target folder T2.
    Can somebody help me out on the same.Possibly this can be done by Dynamic Configuration.Can somebody send me some links.
    Regards,
    Zabiulla

    Hi,
    First of all I would suggest to avoid the mail communications for the query.
    Its against the SDN rules.
    please read [Rules of Engagement|/thread/117188 [original link is broken];.
    About Solution, you need not have to go for Dynamic Target Directory
    You can use the Variable substitution concept here.
    In the Target directory pass the %Var1%
    and use Var1 ---> payload:<fieldName>
    Refer to the last part of this link to understand this better,
    http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
    For dynamic configuration you can also refer below link
    Dynamic configuration of Receiver FTP File channel
    Thanks
    Swarup

  • Dynamic Target Directory name: DEV QUA and PRD

    Dear All,
    Scenario Idoc to File:
    I need to configure file directory's dynamically - when the object is moved to D, Q and Prd. for that am using plant and location to differenciate.
    InExample: D:\SX\Common\ <plant><location>
    TinAdvance
    Swarna.

    Swarna wrote:
    Dear All,
    >
    > Scenario Idoc to File:
    >
    > I need to configure file directory's dynamically - when the object is moved to D, Q and Prd. for that am using plant and location to differenciate.
    >
    > InExample: D:SXCommon <plant><location>
    >
    > TinAdvance
    > Swarna.
    I am assuming that the plan and location fields are part of the data structure and the path D:SXCommon will always remain the same in all the environments.
    In that case, you can write a generic UDF for this that will handle in Dev, QA and PRD
    use this blog to help you - Dynamic Configuration vs Variable Substitution - The Ultimate Battle for the File Name

  • Dynamic target directory with variable substitution

    Hi everyone.
    I'm trying to save a file in a folder with receiver adapter.
    This folder is determined in runtime and passed to the adapter with variable substitution. My problem is that in RWB i get a error like this : 'Content of variable XXXXX is not safe'
    Does anybody have done a variable substituion for output directory receiver file adapter?
    Regards,
    Inigo.

    Hi,
    Check this links,
    /people/sameer.shadab/blog/2005/09/23/an-interesting-usage-of-variable-substitution-in-xi
    http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
    Regards,
    Phani

  • Dynamic Config for Target directory

    Hello Experts,
    My interface is from MQ (JMS) to FILE.
    I have one sender and one receiver.
    I have the Lockbox data placed into the single Queue for 2 countries (AU u2013 Australia and NZ u2013 Newzeland)
    Point 1: My PI Interface Picks the lockbox data up from the Queue, then the respective file (dynamically by using dynamic configuration) is being created based on the condition in mapping.
    Here my mapping logic:
    SourceStrucutre                                                       ReceiveStrucutre                          
         Filed1               Filed1
         Filed2               Filed2
    INPUT -
     FIXED VALUES u2026u2026u2026..> UDF1 u2026u2026u2026> ReceiveStrucutre ( root node)
    Expected input values for INPUT: ABC and XYZ (ABC for AU and XYZ for NZ)
    Expected values in FIXED VALUES: ( if ABC -  create file name  FILE1.TXT; if XYZ -  create file name FILE2.TXT)
    The below UDF is mapped to root node of Receiver Structure.
    UDF1 code: ( with single Argument with name : arg)
    DynamicConfiguration conf = (DynamicConfiguration) container
        .getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
    conf.put(key, arg);
    return "";
    the above mentioned logic works fine and am able to generate the file names (FILE1.TXT & FILE2.TXT ) in the target directory ( /tmp/common ) which mentioned in the receiver file adapter.
    Point 2:
    My Requirement is to generate the target directory dynamically based the file name generated..
    Expected Target directory:
    /tmp/AU/FILE1.TXT for the file FILE1.TXT
    /tmp/NZ/FILE2.TXT for the file FILE2.TXT
    I know we can do this by writing another UDF2 (DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "Directory"); for the directory and by making ASMA ticked for Directory in communication channel..
    My question is how to map the two UDFs to the same root node of receiver..
    Valuable inputs are much appreciated!!
    Thanks,
    Kumar

    what i mean is have :
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
    and
    DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "Directory");
    conf.put(key, arg)
    conf.put(key1, value for Directory)
    If you are worried on how to map two UDFs to root node then FYI you can map the o/p of the UDFs to any node in your target structure......it wont cause any harm....
    If you say no node is free then you can have two inputs to your UDF and then in the return statement send out the value that you want to pass to the target node (presently you are using return"".......if applying above then you will have return arg2)....
    Regards,
    Abhishek.

  • Dynamically deciding the target directory without ESR objects

    Hi Experts,
    I have come across File to File scenario(NFS) where I have to serve 2 purpose in one scenario using single receiver communication channel as the client have more than 40 plants.
    1.     I need to copy the file from source directory to target directory without creating the mapping objects.
    2.     based on source file name the target directory path will be the 'target directory + First 4 character of source file name i.e.(Plant name)'.
    I am able to achieve the First requirement, can any one tell me how to achieve Second requirement.
    Thanks in advance.
    Ragards,
    Gopi

    Hi Inaki Villa/ Anupam Ghosh,
    Thanks for your previous reply. I was busy with some other WS related task.
    I have gone through the thread which uses java code to dynamically set the Target Directory.
    'Dynamic file name for pass-through scenario - Process Integration - SCN Wiki'.
    But the mentioned JAR files are not available on our clients PI System (PI 7.0) I tried by importing the required JAR files from other system but it was giving some error. So I decided to go with ABAP Mapping and I am quite successful in setting the target directory. I am able to view the Target Directory and Target File name in 'DynamicConfiguration' in SXMB_MONI.
    But it is not over writing the 'Target Directory' path mentioned in Receiver Communication Channel.
    Could you please help me in this? Do I need to set anything else?
    Regards,
    Gopi

  • Decide target directory dynamically.

    Hi All
    I need to configure a receiver communication channel with file adapter. Important thing is target directory need to be decided dynamically based on some content in the message.  Please let me know what are the possibilities to achieve this.
    Thanks & Regards
    Shantha
    Edited by: Shantha Bandara on Feb 12, 2008 1:05 AM

    Hi Shantha,
    Create UDF in that you derive directory name and/or file name based on message content and store them in Dynamic Configuration.
    When you are giving Directory name just give generic name from UDF(from the following code in place of directory name just give %Directory%  File name %FileName%).
    Here the sample value UDF code
    AbstractTrace 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 fnam = conf.get(key);
    String dir = <Path to directory>;
    String newfnam =  <File name>;
    conf.put(key,newfnam);
    key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");
    conf.put(key,dir);
    return("");
    Please let me know if you have any issues.
    Cheers,
    Jag

  • How to populate target directory from the source XML in Receiver File Adap?

    Hi All,
    Our scenario is IDoc - XI -(Receiver File adapter) File. Is it possible to populate complete "Target Directory" from the source XML message??
    Lets say we added field to maintain target directory in Idoc structure and some how populated value to it, then grab this target directory from the IDoc-XML and pass in Comunication Channel. I think its possible through Variable Substitation ...just want to make sure and if sombody has done the similar scenario their inputs would be great.
    Thanx
    Navin

    Hi,
    Please see the belowlinks
    /people/jayakrishnan.nair/blog/2005/06/28/dynamic-file-namexslt-mapping-with-java-enhancement-using-xi-30-sp12-part-ii
    /people/sriram.vasudevan3/blog/2005/11/21/effective-xsl-for-multimapping-getting-source-filenames-in-legacy-legacy-scenarios
    Re: Dynamic  File Name for Receiver File Adapter
    Variable Substitution
    http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
    try with adapter specific
    Example code...
    String newfilename="";
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    // Get Sourcefilename
    String oldfilename=conf.get(key);
    //extract first 3 chars of source filename
    newfilename=oldfilename.substring(0,2);
    //get the date
    java.text.SimpleDateFormat dateformat = new java.text.SimpleDateFormat( "yyyyMMdd" );
    dateformat.format( new java.util.Date() );
    //append sourcedateL
    newfilename=newfilenamedateformat"L";
    // determine if prod/ dev / qa
    map = container.getTransformationParameters();
    senderService = (String) map.get("SenderService");
    if(senderServcie.equald("Prod"){
    newfilename=newfilename+"P";
    // change to new file name
    conf.put(key, newfilename+".tmp");
    Change it according to your requirement
    Regards
    Chilla..

  • Dynamic file Directory : Sender File Adapter

    Hi all
    In one of our interface development ,at  we require a dynamic Directory path at the sender file adapter ..
    ex :
    path = Root/A/B/C
    filename = test.txt
    now in Root Directory, Folder & subfolder  " A ( B ( C )))  are dynamic.
    Subfolder "C"  wil contain the source file..
    Will it possible...with Z module development..??
    Regards,
    Ashutosh

    hi,
    if you want your directory name dynamically from Payload, you can use the option variable substitustion;
    For example follow below procedure:
    1)in the Target directory name --> /%dir%
    2)go to advanced tab and check for the variable substitution option(enable),
    3)variable name:dir
       Reference:Payload:mt_filetest,1,name,1
    according to the given details in the communication channel your  payload should be like this
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:mt_filetest xmlns:ns0="urn://filetest">
       <name>madhav</name>
    </ns0:mt_filetest>
    now  directory is created with the name of madhav (Dynamically according to the payload directory name is created).
    Note: points if it is useful
    Thanks
    Madhav

  • Dynamic taget directory usinf Filename

    Hi all
    I have a requirement in which I have to Dynamically choose target directory depending on the filename??
    Example
    If File name is FI08.txt ,it should be posted to following folder
    server\Test\<FileName>. If it has deiiferent file name it should be posted to different directory.
    I am usind a simple file to file interface without using IR.
    So there is no Mapping involved.
    Regards
    Abhishek Mahajan
    Is there any other solution possible without using Variable Substitution.

    Variable substitution :
    When you specify the target directory and file name schema, you now have the option of setting variables and defining them in a table. The variables are replaced by elements from the XML structure at runtime.
    Contrary to the description in the documentation, you cannot yet replace with attributes from the XI message header. Do not use the prefix during variable substitution
    http://help.sap.com/saphelp_nw2004s/helpdata/en/8e/464442c1a1c253e10000000a1550b0/content.htm
    Also see the below links to use the dynamic variable substitution
    /people/michal.krawczyk2/blog/2005/03/29/xi-error--unable-to-convert-the-sender-service-to-an-ale-logical-system
    /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
    /people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i - Dynamic File Name Part 1
    /people/jayakrishnan.nair/blog/2005/06/28/dynamic-file-namexslt-mapping-with-java-enhancement-using-xi-30-sp12-part-ii - Dynamic File Name Part 2
    reward points if found helpfull
    regards
    chandra.k

  • Dynamic target direcoty - no mapping used

    Hi All,
    I have a file to file scenario like this.....
    source:
    \folder1\source1.xml
    \folder2\source2.xml
    \folder3\source3.xml
    target:
    \test1\source1.xml
    \test2\source2.xml
    \test3\source3.xml
    The files from diffarent folders should be moved to the corresponding target directories(dynamic directory) with same file name.
    for example,
    source1.xml from the source directory folder1 should be copied to target directory test1 with the file name source1.xml.
    here the target path depends on source directory.
    I know it works with ASMA. but here in my scenarion iam not using any mapping. How can we get the target directory when there is no mapping.
    please help me to solve this..

    The files from diffarent folders should be moved to the corresponding target directories(dynamic directory) with same file
    name.
    for example,
    source1.xml from the source directory folder1 should be copied to target directory test1 with the file name source1.xml.
    here the target path depends on source directory.
    If you want that both source and target files have the same name, then just enable the File Name ASMA in both the sender and receiver File Channels.
    Now your requirement is also to send File1 to Folder1 and not to Folder2, you have to maintain different interfaces/ scenarios....one from SOurce1 to Target1 and similarly for Target2/ 3.....since you are not using any mapping!
    Regards,
    Abhishek.

  • In comm channel target directory is %variable%.txt

    hi,
         warm wishes...
    if in communication channel target directory is %variable% then what does it mean..
    thanks in advance,
    jp.

    Hi,
    If you are new to SDN, please read /thread/117188 [original link is broken]
    Please do not open multiple threads at the same time and follow up on the answers on your existing threads. Awar points for helpful answers, close your threads and make SDN a better place.
    Answering your question, the %variable% is used set the directory name dynamically using the concept of Variable Name Substiution.
    Refer to the last part of this link to understand this better,
    http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
    Regards
    Bhavesh

  • Date and Time in Sender File Adapter Target Directory

    Hi there,
    is there a way of using Date and Time from XI to the Target Directory naming? To use variable substitution some fields of the message had to contain that date and time information, which is not our case.
    For filename you can use "add time stamp" option, but and for target directory?
    Thanks and regards,
    Henrique.

    > <i>Do you have further information on how to perform
    > this with shell commands?</i>
    > >> You need to write a shell script. This script will
    > add the date/time stamp into the folder in the target
    > system. This shell script is executed from the File
    > adapter. So once the file is written into the target
    > directory, then it will rename the directory.
    Hi there, Moorthy
    We've tried to write that shell script that you mentioned, but now we have a few doubts on how to make it create the proper directory.
    In the file adapter, my target directory is "/%var1%/%var2%/", where %var1% and %var2% are variable substitutions, referencing data which comes from the payload. Now, I need the shell script to append "/<Year>/<Month>/" in the target directory. But where to archive the script? If it stays in the root directory, than how to make it create "/<Year>/<Month>/" folders inside a directory which is variable (/%var1%/%var2%/)?
    Is there a way of passing %var1% and %var2% as parameters for the shell script?
    Thanks a lot,
    Henrique.

  • How to set the target directory from source filename using adaptor module.

    Hi,
    How im using a logical bypass scenario.I have to set the target directory using the sorce filename.There is no chance of using a Java UDF as my scenario does not have a Mapping(as it is a Bypass Scenario).The only option that i got is to use a Adaptor module.Can anyone help  me this.
    Thanks,
    Bhargav

    Hi,
    See this link,
    http://help.sap.com/saphelp_nw04/helpdata/en/e9/61e1407e858031e10000000a1550b0/content.htm
    hope it helps.
    Regards,
    Akshay Jamgaonkar.
    Reward points if find useful.

  • Target Directory in File Receiver Adapter

    Experts,
    I am trying for a scenario (File to File) and I am not sure if the target directory is a directory in XI server or my local machine. I used HTML client to send the message to the adapter. Also if any of you could give clear idea about source and target direcory without pointing to any weblog, I would greatly appreciate it. As I have tried every weblog available with a word File in it.
    Thanks
    Thilothama

    Thilothama,
    I've seen your previous posts and you never assigned any points. People in the forum spend their valuable time answering questions.
    I request u to reward the people who have replied to your posts. IF u consider that the replies have helped u , u can assign,
    2 points -- helpful
    6 points -- very helpful
    10 points -- problem solved..
    If u are not able to see the assign point s button refer to this thread...
    Unable to award points
    regards
    Shravan

Maybe you are looking for

  • MS 6577 V4.1 HELP! no video output!

    My HP Pavilion a705w recently stopped working the other week. After opening it up and trying to figure out what may be wrong with it, I realized that everything powers up and seems to work normally, except that no video signal was not being sent out

  • Database Window cant recognize a file in site

    I m using dreamweaver cs4.I have created a site and add a jsp file by right clicking in file browser of site window.After that I opened the jsp file by double clicking on it.Now If I want to add a database from database window it says - create a site

  • [iPhone] How to kill UIAlertView programmatically?

    My app is activating a UIAlertView upon disconnection from a server. If the connection is resumed without any user interference, I want my app to kill the UIAlertView so as not to annoy the user in case of a spotty connection by making them repeatedl

  • Cursor Misalignme​nt in Intensity Graph (LV6.1)

    Howdy. I have an Intensity Graph, with a 2D array of data (about 300x300) and a cursor. The cursor is locked to the plot, which for intensity graphs, means that the cursor is drawn at the lower left corner of the pixel that is being addressed. Most o

  • Assigning a "Job" to a User in the Org Structure

    Hi, I'm trying to assign a Job to a User in PPOMA but don't know where this data is created or maintained? (SRM 5) Any info would great. Regrds, S