cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

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

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..

bhavesh_kantilal
Active Contributor
0 Kudos

Navin,

Using Adapter Specific Identifiers is a better option as it provides a simple and eifficient way of handling the requirement.

Regards

Bhavesh

Former Member
0 Kudos

Thank you all for the information.

So looks like we have 3 options here

1) Variable substitution

a) Can I pass <b>complete "Target Directory"</b> that is coming from Idoc as variable?

2) UDF sample given above

b) What is the target field I should map to???

3) As Bhavesh mentiond, Adapter Specific Identifiers

How do I use Adapter Specific Identifiers and get the target directory?

I am sorry, I re-read the answers.....looks like option 2 and 3 are same. So we have to write UDF to get Adapter Specific Identifiers. Thats good I got the sample code too...Whats the target field I map to???

Target directory (source field from IDoc) --> UDF --> ???

Thanx

Navin

Message was edited by:

navin kumar

Former Member
0 Kudos

Hi Navin,

Yes. You are correct. Options 2 and 3 are the same. Map the UDF to the root node of the target msg (It can be the message type name).

Also make sure the option Directory is checked in Adapter specific Identifier in receiver file communication channel.

Regards,

Jai Shankar

prabhu_s2
Active Contributor
0 Kudos

yeah, u can go for variable substituion. also, like pointed by jai u can also go 4 a udf. here in variable substituuion no udf is invloved.

shud u have to refer below is the link for ur referecne:

<a href="/people/sravya.talanki2/blog/2005/08/11/solution-to-the-problem-encountered-using-variable-substitution-with-xi-sp12 to the problem encountered using Variable Substitution with XI-SP12</a>

<a href="/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14: The same filename from a sender to a receiver file adapter - SP14</a>

[url=http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/frameset.htm]http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/frameset.htm[/url]

Former Member
0 Kudos

Navin,

You have 2 options.

1. Variable Susbstitutuion

2. Accesing Adapter specifc Identifiers in mapping

I guees you can go with option 2. It gives you a lot of flexiblity.

Use this code...

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");

String ourSourceFileDir= conf.put(key,a);

return ourSourceFileDir;

This UDF takes one input(target directory) and map this field to target root node.

Regards,

Jai Shankar

Former Member
0 Kudos

Navin,

If you pass the target directory in any field of IDOC then you can grab that from variable substitution and write it out. That is possible. I have not personally done but it should work as it is nothing but a simple variable substitution.

...Satish

Former Member
0 Kudos

yes, it is through Variable Substitation. I get file name from payload.

please search SDN use term "get file name form paylaod", you will get tons of information.

SAP help link is:

http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm

--Wenning