cancel
Showing results for 
Search instead for 
Did you mean: 

File name in mapping

Former Member
0 Kudos

Hello,

How can I get file name in mapping.

Regards

Accepted Solutions (0)

Answers (4)

Answers (4)

Markus7
Participant
0 Kudos

I am working on a similar problem. In my case the problem seems to be the following. When I use this UDF with a proper xml-file it works, with a non-xml file it does not work.

I think it is not possible to put a UDF into a mapping if you are working with non-xml content.

Are you working with xml or non-xml content?

Former Member
0 Kudos

HI,

See the below link

Dynamic Configuration of Some Communication Channel Parameters using Message Mapping -

/people/william.li/blog/2006/04/18/dynamic-configuration-of-some-communication-channel-parameters-using-message-mapping

Dynamic folder - in payload

Regards

Chilla

Shabarish_Nair
Active Contributor
0 Kudos

Apart from Bhavesh's reply, well you can refer this blog by Mike which explains the whole flow - /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14

bhavesh_kantilal
Active Contributor
0 Kudos

1. In the sender file adapter , select Adapter Specific Attributes --> FileName.

2. Use the code in this link to read the filename inside a UDF in your mapping.

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);

http://help.sap.com/saphelp_nw2004s/helpdata/en/43/03612cdecc6e76e10000000a422035/content.htm

Regards

Bhavesh

Former Member
0 Kudos

I have made User Defined Function -- dynFileName

public String dynFileName(Container container)

{

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;

}

But when I test this in Message Mapping Error I am getting:

RuntimeException in Message-Mapping transformation: Runtime exception during processing target field mapping /ns0:FileName_Trg_MT/FileName. The message is: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._FileName_Src_To_FileName_Trg_MM_ method dynFileName$[Pra1.txt, com.sap.aii.mappingtool.tf3.rt.Context@cce0cce]

Regards

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Do not test the mapping in the IR.

As the DynamiCConfiguration is not available in the Design stage it will not work.

Test with by running your scenario by placing the source file and it should work.

Regards

Bhavesh

Shabarish_Nair
Active Contributor
0 Kudos

note that you will not get the result testing the mapping independently. try an end to end testing to see the desired result.

try reading thru the comment section of the blog i referred to, sud provide you with enough info.

Former Member
0 Kudos

Thanks All.

Regards

Former Member
0 Kudos

Hello ,

I have tested while running the scenario

but I am getting below mapping error

For my message mapping --- FileName_Src_To_FileName_Trg_MM

I have src Message Type which has one node -- FN of type String

I have Target Msg Type which has one node -- FN of type String

I have used my dynFileName function betwwen src node and target node

I am getting the error below for 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/_FileName_Src_To_FileName_Trg_MM_</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/_FileName_Src_To_FileName_Trg_MM_ 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>

bhavesh_kantilal
Active Contributor
0 Kudos

Rachit,

Disable the use of the UDF in your mapping and test if the message mapping works fine.

Also, in the sender file adapter , have you selected option --> Adapter Specific Identifiers --> FileName.

Regards

Bhavesh

Former Member
0 Kudos

Disable the use of the UDF in your mapping and test if the message mapping works fine. -- Removed UDF still I am getting the same error.

Also, in the sender file adapter , have you selected option --> Adapter Specific Identifiers --> FileName - Yes

I have one question, if the purpose is solved my using Adapter Specific Identifiers

in both File Sender and Receiver Adapter then why I require UDF.?

Regards

prateek
Active Contributor
0 Kudos

Hi Rachit,

This error occurs if the Source input file is not proper.

Execute the message mapping and use its source option. Get it copied into an xml file and try running the scenario again.

OR

Copy the XML message from monitoring and exectute the mapping in Integration Builder with maximal trace to get the reason.

Regards,

Prateek

Former Member
0 Kudos

>>Removed UDF still I am getting the same error.

Disable this UDF and test the mapping as shown in Michal's blog

/people/michal.krawczyk2/blog/2005/09/16/xi-how-to-test-your-mapping-in-real-life-scenarios

>>I have one question, if the purpose is solved my using Adapter Specific Identifiers

in both File Sender and Receiver Adapter then why I require UDF.?

Exactly, when you need the same file name, you dont require this UDF.

But, you never gave this information in your question. Your qu8estion was how to access the file name in mapping.

Regards,

Jai Shankar.

henrique_pinto
Active Contributor
0 Kudos

> Hi,

> Do not test the mapping in the IR.

> As the DynamiCConfiguration is not available in the

> Design stage it will not work.

>

> Test with by running your scenario by placing the

> source file and it should work.

>

> Regards

> Bhavesh

Actually you can test mappings with Dynamic Configuration in IR, just not in Message Mapping test tab.

That null pointer exception occurs because the container object is not instantiated in mapping program itself, but rather in the mapping runtime. If you create an Interface Mapping which uses that Message Mapping and use test tab in the interface mapping, you will be able to validate your Dynamic Configuration (the container object won't be null anymore), though you will always read null value from any dynamic configuration (since they were not actually filled).

Regards,

Henrique.

bhavesh_kantilal
Active Contributor
0 Kudos

Henrique,

Am i being stalked

That was something I was not aware of, thanks for the updates. I guess I always test my mappings from message mappings instead of interface mappings and hence couldnt figure this simple thing out

Regards

Bhavesh

Former Member
0 Kudos

HI,

In general first file should come into payload and then it will transfer to the respective reviver side config... to do this . we need the file name from sender side into MM (from runtime) due to that reason we need UDF..

please see the below link , ther Michal has explained why we need UDF in Mapping..

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

Regards

Chilla

henrique_pinto
Active Contributor
0 Kudos

Not at all, dude, on the contrary.

I'd rather comment on the messages of people I'm fond of, because I do want to share my knowledge with them, then to comment on messages of people I don't care about. 😄

Regards,

Henrique.

bhavesh_kantilal
Active Contributor
0 Kudos

I understand henrique, there is never any offence taken..it was just a light hearted comment...

After all we are here to learn from others experience here and what better way to learn than make mistakes ( you never forget the lessons learnt from your mistakes )..

I appreciate your correcting me if I am wrong, I would rather make a mistake here on the XI forum than at a client's location and design a incorrect solution..

Regards

Bhavesh