cancel
Showing results for 
Search instead for 
Did you mean: 

how to use attributes in variable substitution???:(

Former Member
0 Kudos

Hi all,

Could you please help me out in how to use attributes in variable substitution....

Regards,

Sundar

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Guys,

I'm doing multi-mapping...so i can not use dynamic configuration for each msg in the target. If i use dynamic configuration only the last dynamic configuration which i have specified for the last msg will be effective for all..(Is there any way to overcome this?). so i'm specifying an attribute to the root node and assiging filename to it. I can not add an addition element to the XML structure and then remove the value of that element in File Content Conversion using fixedLengthTooShortHandling.....what i can have is extra attributes...so for example consider my XML structure to be like this

<?xml version="1.0" encoding="utf-8"?>

<Root fname="myfile.txt">

<a>.....

</a>

</Root>

so how to assign the value in the attribute fname as my output filename using the variable substitution?

Regards,

Sundar.

Former Member
0 Kudos

Hi Sundararamaprasad,

<i>>>If i use dynamic configuration only the last dynamic configuration which i have specified for the last msg will be effective for all..(Is there any way to overcome this?).</i>

To overcome this u can use Dynamic Configuration to extract the file name in the beginning of the message mapping itself. Once u have extracted the name u can save it in a Global Container and use it anywhere in the same message Mapping.

Regards

Neetu

Former Member
0 Kudos

Hi Neetu,

I dont think it will work for my scenario. The Problem is using multi mapping i'm going to produce 3 files. If i use dynamic configuration as you said it will not work. what ever global variable i use when i define it as a filename in one message it will override the filename which i specified for the previous message.

Regards,

Sundar

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

><i>The Problem is using multi mapping i'm going to produce 3 files. If i use dynamic configuration as you said it will not work. what ever global variable i use when i define it as a filename in one message it will override the filename which i specified for the previous message.</i>

This makes a lot of sense. I guess you will have to use Variable Name substitution, but you will not be able to access the attributes . Need to make a dummy field or something of that sort.

Regards,

Bhavesh

Former Member
0 Kudos

I have a similar problem - I am producing 38 files which come to the receiver adapter and variable substitution doesn't work (I get no output). The message comes in form: Messages

|___ Message1

|__ 38 x MyRootElement

|__ pob <xxx>

How to use variable substituion here? I tried to put into reference:

payload:MyRootElement,1,pob,1

but got nothing to the output. In SXMB_MONI see even no payload in Response section..

Any idea how to workaround it? SAP documentation states nothing about such situation

Thank for anything Rasto

Former Member
0 Kudos

I found later, that there were error messages in output file adapter, which helped me to solve the problem

henrique_pinto
Active Contributor
0 Kudos

Mario,

by attributes I guess he means XML tags attributes (which can be accessed through XPath's expressions such as /Root/@Attribute ).

Sundy (lol, your name is too large),

for that, I think you'll have to use dynamic configuration instead of plain variable substitution.

Regards,

Henrique.

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Use Adapter Specific Identifiers , instead of Variable Name substitution.

Sender File adapter --> Adapter Specific Attributes --> Select File Name

Reciver File Adapter -->Adapter Specific Attributes --> Select File Name

In the mapping , use this code in an UDF to change the filename to what you want,

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

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

String filename="YOURFILENAME";

String rSourceFileName = conf.put(key,filename);

Regards,

Bhavesh

Former Member
0 Kudos

Hi Sundar,

please give some more detailled information.

Regards Mario