cancel
Showing results for 
Search instead for 
Did you mean: 

Variable substitution with custom IDOC (Customer namespace) SAP PI 7.31

john_nijburg
Explorer
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member184681
Active Contributor
0 Kudos

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

john_nijburg
Explorer
0 Kudos

Hi Grzegorz,

Thanks for your reply.

I have tried all 3 of your option but unfortunately they did not work for me:

Exception caught by adapter framework: Cannot parse pseudo-path for variable substitution 'ip': java.text.ParseException: Expected word token as element name

Regards John

former_member184681
Active Contributor
0 Kudos

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

john_nijburg
Explorer
0 Kudos

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

former_member184681
Active Contributor
0 Kudos

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

john_nijburg
Explorer
0 Kudos

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

former_member184681
Active Contributor
0 Kudos

It sounds good - you can put the UDF execution anywhere in the mapping, at your convenience.

How about using

filename.replace(".txt" ,"_" );

instead of replaceAll?

john_nijburg
Explorer
0 Kudos

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

former_member184681
Active Contributor
0 Kudos

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.

john_nijburg
Explorer
0 Kudos

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?

former_member184681
Active Contributor
0 Kudos

Try getting back to:

DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");

I believe the attribute name is case-sensitive and apparently with your PI version, "FileName" is the right spelling.

john_nijburg
Explorer
0 Kudos

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

john_nijburg
Explorer
0 Kudos

Hi Grzegorz,

It is working now. The coding ect. was all fine. The value in the outgoing Idoc from SAP was empty and due to that the FileName was not added to the Dynamic Configuration.

Thank fro all you advice on this Topic.

Regards,

John

Answers (0)