cancel
Showing results for 
Search instead for 
Did you mean: 

How I can differentiate xml files coming from XI?

Former Member
0 Kudos

Hi all,

I have a dilemma!!! I’m using NW Portal to publish logs from R/3; this is made with file adapter. At the moment, this file adapter only uses one shared folder as a repository in Portal and it works well.

But, in future I will have a lot of different messages to process, or either, one message per organism. Because a variety of organism will use the same interface to send files to R/3, I need to differentiate all these organisms.

So, when organism “A” sends the files to R/3 and it goes to Portal to see the log of these transactions, it can only see the log of your messages. So I think in one repository folder per organism and with this we can guarantee that only the organism sees your respective logs. (In xml message I have a field code for which organism).

My question is: There is a way, in runtime, to check the content of xml file and read this field code to verify what organism is and put the file in respective folder?

Anybody have an idea how I do something like that?

Thanks in advance,

Ricardo.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member181962
Active Contributor
0 Kudos

Hi Ricardo,

You can do the dynamic Receiver Determination by writing the conditions in XPath Query.

Regards,

Ravi

Former Member
0 Kudos

Hi again Ravi,

Ok, but the way you said, I need to create one Business System, adapter channel, etc. per organism. Because in Receiver determination with Xpath query I can only associate this "routin rule" to one service.

My objective is doing this with the same service. Checking the Xpath query in runtime and change the target directory in file adapter. (ex. if code equal "A", the target directory is /home/logs/).

This is possible?

Thanks a lot for your help.

Ricardo.

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

yes this is easy with SP14

you can do the same with directory name as I did for filename:

/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14

and change the direcotry inside your mapping

(you can use one fileadapter communication channel only)

directory is also a part of dynamic configuration:)

Regards,

michal

Former Member
0 Kudos

Hi Michal,

This weblog is very helpfull ;o)

I come from ABAP world, so my knowledge about java is very poor, but I will try to be clear. I read it and the help sap too.

My user defined function is:

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

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

String ourSourceDirectory = conf.get(key);

return ourSourceDirectory;

When I try do the test "tab", I receive this error message:

RuntimeException in Message-Mapping transformation: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._IfContabilistico_XI_R3_Log_ method getTargetDirectory$[, com.sap.aii.mappingtool.tf3.rt.Context@1466ee4]

I don't know what appens? can you tell me please?

Thanks in adavence,

Ricardo.

MichalKrawczyk
Active Contributor
0 Kudos

hi,

but did you set adapter specific identifieris

in the sender channel?

BTW

this does ont work with test <b>TAB</b>

you have to send a real message

Regards,

michal

Former Member
0 Kudos

Michal,

I'm only using a receiver file adapter and I have checked the (user adapter-specific properties and Directory). in the Target Directory field of my receiver file adapter I put %ourSourceDirectory%.

When I try to send a message all xi logs are ok (sxmb_moni and adapter monitoring).

But the folder continues empty!

I did something wrong? or my java code its wrong?

Thanks in advance,

Ricardo.

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

the code form my weblog only <b>takes</b> the value from the dynamic configuration

if you want to<b> replace it</b> you have to use the code from help.sap.com (you can find the link on my weblog)

>>>file adapter I put %ourSourceDirectory%.

you don't need that

Regards,

michal

Former Member
0 Kudos

Michal,

>>>file adapter I put %ourSourceDirectory%.

you don't need that

If it stay blank, I receive this error when I try to acivate it: "Required field Target Directory missing".

Other thing that I saw is in sxmb_moni the soap header of my message doesn't have the Dynamic Configuration like your weblog! ...and the in body the tag to transport the path have this value: "<DIR_PATH>null</DIR_PATH> " the source tag is: <DIR_PATH>/sapmnt/IXD/logs/folder1</DIR_PATH>

So it means that my user defined function between these to message types are wrong!

Any ideas?

One more thing, you said that I have to use the code from help.sap.com! But I only see java code for developments modules you know where is the code that I need?

Thanks a lot for your help

Ricardo.

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

>>>If it stay blank, I receive this error when I try to acivate it: "Required field Target Directory missing".

I meant write anything you want over there:)

>>>>So it means that my user defined function between these to message types are wrong!

if should contain the path

One more thing, you said that I have to use the code from help.sap.com! But I only see java code for developments modules you know where is the code that I need?

you can use the code from help.sap.com

(this is the code for user advanced function)

if shows how to change and put a new value into a dynamic configuration

Regards,

michal

Former Member
0 Kudos

Hi Michal,

In your weblog you said that first we need to set in sender file adapter "Adapter Specific Message Properties"

which tell the adapter to include those properties inside the SOAP message sent to XI. But my outbound interface is made by ABAP Proxy!

Using ABAP Proxy, how can set these properties?

Thanks in advance,

Ricardo.

Former Member
0 Kudos

Hi again Michal,

I’m trying this:

Using ABAP Proxy to connect R3 -> XI and a simple receiver file adapter to place the log files in a new temporary content folder. In same business system I created two more file adapters, a sender with "Adapter Specific Message Properties", which tell the adapter to include those properties inside the SOAP message and with “delete” processing mode to maintaining clear the temporary content folder. And a receiver file adapter with those properties checked too, through program mapping with the user defined function to get the target directory.

But I continues without a “DynamicConfiguration” section in my SOAP header of Inbound message (CENTRAL).

And when I open the message the tag wit the directory path have the null code.

<DIR_PATH>null</DIR_PATH>

It means that something in user-defined function are wrong! Should I put something in field “imports” of User-defined function that I have created?

Java code:

imports (blank)

public String getTargetDirectory(String a,Container container){

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

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

String ourSourceDirectory = conf.get(key);

return ourSourceDirectory;

}

Like I said my knowledge about java is very poor, do you see any error in this java code?

Thanks again for your great help.

Ricardo.

Former Member
0 Kudos

Hi

ricard try to give ("http"":"""/""/+"sap.com/xi/XI/System/File","Directory");

instead of ("http://sap.com/xi/XI/System/File","Directory");

In reciver channel just specify any directory but not %out...Directory%;

Ok

just try this out, hope your folder has a file.

Cheers

regards

Piyush

Former Member
0 Kudos

Hi Piyush

Thanks for your quick response,

I don’t have tried yet your suggestion because I’m in home, but Monday I will do this.

Tell me why the plus “+”?

What kind of function I choose. A simple user-defined function or an advance?

One more thing, In Michal web log I saw that he uses two file adapters for this Dynamic Configuration, one sender and one receiver. So, in the sender file adapter, he define the options (Adapter-Specific Message Properties) to able a dynamic configuration and do the same in receiver adapter.

But problem is: my sender adapter is an ABAP Proxy and I don’t know how to specify these properties!!!

You know if it be possible doing this Dynamic Configuration with a sender ABAP Proxy and a receiver File Adapter?

Thanks in advance,

Ricardo.

MichalKrawczyk
Active Contributor
0 Kudos

Hi Ricardo,

>>>You know if it be possible doing this Dynamic Configuration with a sender ABAP Proxy and a receiver File Adapter?

just use the code below in your message mapping:

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

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

conf1.put(key, "newfilename.xml");

if you want to use ABAP mapppin then

have a look at interface: IF_MAPPING_DYNAMIC_CONF

METHOD if_mapping~execute.

DATA l_record type mpp_dynamic.

  • copy payload

result = source.

  • add an adapter specific attribute

l_record-namespace = 'http://sap.com/xi/XI/System/File'.

l_record-name = 'FileName'.

l_record-value = 'test.xml'.

dynamic_configuration->add_record( l_record ).

ENDMETHOD.

remember to set <b>"use adapter specific...."</b> in your file receiver channel

Regards,

michal

Former Member
0 Kudos

Hi Michal,

I'm not using ABAP Mapping, but the XI Program Mapping.

The java source code you gave me have an error!

When I try to activate, I receive the following error:

Source code has syntax error: /usr/sap/IXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map427dc270707a11dacb01000d6099662a/source/com/sap/xi/tf/_IfContabilistico_XI_R3_Log_.java:239: missing return statement } ^ 1 error

I need a return statement to this function?

All I want is in runtime change the directory target of my file adapter and put this directory path also in my target message. Something like you did with file name. Like I said before I don't have java experience, but I think that I'm only need to change the attribute "Filename" to "Directory" in the java code. Tell me if I'm wrong.

Thanks a lot for your great help.

Ricardo.

Former Member
0 Kudos

Michal,

An example to clarify:

The idea is: I receive a message from ABAP Proxy, in runtime (mapping program) I read the xml tag with the directory path ex. <Directory>/sap/xi/logs</Directory> this is possible right? … When XI takes the path directory, put them in equivalent tag of the target message and also change the target directory of file adapter.

This trait is possible to make like you did in your web log?

Tanks in advance,

Ricardo.

Message was edited by: Ricardo Quintino