on 04-25-2007 11:08 AM
Hello,
How can I get file name in mapping.
Regards
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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>
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
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
>>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.
> 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.
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
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
User | Count |
---|---|
81 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.