on 10-28-2014 8:53 AM
Hello everybody,
I have the following problem when using Variable Substitution in SAP PI 7.31 with a customer idoc created with a customer name space.
How can i use the Variable Substitution for the IDOC displayed below to use for example the value for PLANT (NL90):
<?xml version="1.0" encoding="UTF-8" ?>
<_-TEST_-QM_DATA_SECUSTAR>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="1">
</EDI_DC40>
<_-TEST_-E1QM005 SEGMENT="1">
<INSPLOT>940000003354</INSPLOT>
<PLANT>NL90</PLANT>
What i have done is the following code in the Variable Substitution:
IP payload:/TEST/QM_DATA_SECUSTAR,1,IDOC,1,/TEST/E1QM005,1,PLANT,1
also i have tested it with:
IP payload:_-TEST_-QM_DATA_SECUSTAR,1,IDOC,1,_-TEST_-E1QM005,1,PLANT,1
(/TEST/ is not the original customername space, just to show the example)
The used Idoc is build up as:
/TEST/QM_DATA_SECUSTAR
/TEST/E1QM005
INSPLOT
PLANT
ect..
The File adapter shows the following error-message:
Attempt to process file
failed with
com.sap.aii.adapter.file.configuration.DynamicConfigurationException: Error
during variable substitution:
com.sap.aii.adapter.file.varsubst.VariableDataSourceException: The following
variable was not found in the message payload:IP
MP: exception caught with
cause com.sap.engine.interfaces.messaging.api.exception.MessagingException:
com.sap.aii.adapter.file.configuration.DynamicConfigurationException: Error
during variable substitution:
com.sap.aii.adapter.file.varsubst.VariableDataSourceException: The following
variable was not found in the message payload:IP
Any ideas?
Kind regards,
John
Hi John,
I think you might need to use an escape character before the slash "/" character, when specifying the value path. I'm just not fully sure what escape character it has to be - try using double slashes:
payload://TEST//QM_DATA_SECUSTAR, 1, IDOC, 1, //TEST//E1QM005, 1, PLANT, 1
or:
payload:\/TEST\/QM_DATA_SECUSTAR, 1, IDOC, 1, \/TEST\/E1QM005, 1, PLANT, 1
or a quotation mark:
payload:"/TEST"/QM_DATA_SECUSTAR, 1, IDOC, 1, "/TEST"/"E1QM005, 1, PLANT, 1
Frankly speaking I'm not sure if this will solve your problem, but I think it is at least worth trying
Regards,
Grzegorz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I know it's a workaround solution and you might not be happy with it, but why don't you use Dynamic Configuration instead, as described e.g. in this post:
I checked the SAP documentation for Variable Substitution, but it doesn't specify any escape characters nor how to cope with a scenario similar to yours.
Regards,
Grzegorz
Hi Grzegorz,
I have tried the Dynamic Configuration and created an UDF to detremine the Filename. After that i have created a Message Mapping Idoc -> Idoc where i have used the UDF at the top node and also i have testdd it to fill a Field within the Idoc with the UFD. After that i have inserted the message mapping in my Operation Mapping as first step and the existing XSLT mapping as 2. step. When i try to test this first step it not working.
java.lang.NullPointerException: while trying to invoke the method java.lang.String.replaceAll(java.lang.String, java.lang.String) of an object loaded from local variable '<3>'
If i send the IDOC to the PI System, the Filename is not added to the DynamicConfiguration.
In my UFD i have use the following code:
try {
String filename = "";
DynamicConfiguration conf1 = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");
filename = conf1.get(key1);
filename = filename.replaceAll( ".txt" ,"_" );
filename = filename+".xml";
conf1.put(key1,filename);
return filename;
Do you have any ideas?
Regards,
John
Dear John,
I think this line of your code did not return proper value, which is why the "filename" variable is empty and therefore replaceAll could not be executed and raises an exception:
>>> filename = conf1.get(key1);
Try replacing:
>>> DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");
with:
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "filename");
or:
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
Regards,
Grzegorz
Hi Grzegorz,
Thx for you help.
I have tried both of your option but none of them helps. Now the message is:
java.lang.NullPointerException: while trying to invoke the method com.sap.aii.mapping.api.DynamicConfiguration.get(com.sap.aii.mapping.api.DynamicConfigurationKey) of an object loaded from local variable '<4>'
Below the new coding:
String filename = "";
DynamicConfiguration conf1 = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File","filename");
filename = conf1.get(key1);
/*filename = filename.replaceAll( ".txt" ,"_" );
filename = filename+".xml";
*/
conf1.put(key1,filename);
return filename;
As variable name in the UDF i have used "var1" as well as "filename".
I it correct that i insert a message mapping in the Operation mapping where i map all the fields (idoc-idoc) and for a certain field with the use of the UDF or is there a better solution?
Regards,
John
Hi Grzegorz,
I have changed it for testing too:
String str = fname + ".xml";
try{
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
conf.put(FileName, str);
}catch(Exception ex){}
return str;
This is working correctly now in the message mapping and operation Mapping. But when i send the Idoc i cant see the FileName in the Dynamic Configuration of the incomming XML-message (not at Inbound message but alos not at Call Adapter).
Do i need something more to get the Filename into the XML data stream as shown in SXI_Monitor like a additional module in the Communication Channel?
Regards,
John
Did you mark the "Use Adapter-Specific Message Attributes" and "File Name" indicators in your receiver Communication Channel?
By the way I think I know the reason for your first error. When defining the filename variable, use the following statement:
String filename = new String("");
Otherwise, your variable might remain unassigned.
Yes the "Use Adapter-Specific Message Attributes" and "File Name" indicators are marked.
The error-message in the CC is regarding the missing FileName:
MP: exception caught with
cause com.sap.engine.interfaces.messaging.api.exception.MessagingException:
com.sap.aii.adapter.file.configuration.DynamicConfigurationException: The
Adapter Message Property 'FileName' was configured as mandatory element, but was
not supplied in the XI Message header.
Is there something else I am missing in my setup of the Interface when using Dynamic Configuration?
Thanks again but same issue.
In the DynamicConfiguration the Fields for the Idoc are available but still no Filename.
Tried also the following from a othter post but same result:
try {
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);
FileName = fname;
conf.put(key, FileName);
}catch(Exception ex){}
return " ";
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.