cancel
Showing results for 
Search instead for 
Did you mean: 

Variable Substituion

Former Member
0 Kudos

Hi Experts,

I am doing variable substitution in order to get any element of source payload and to create target file name based on that.

My payload is like this:-

- 
<ns0:MT_Employee_Src xmlns:ns0="urn://FileToFile_ERD">
- <Details>
  <EmpId>1</EmpId> 
  <Name>sds</Name> 
  <Designation>ABAP</Designation> 
  </Details>
  </ns0:MT_Employee_Src>

And my configurations are like this

File Name Scheme  :   res_%vars%.xml

vars :payload:MT_Employee_Src,1,Details,1

I gone through the blogs ,but not succeeded.

Would you please give your assistance on this.

Thanks

Rabi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Change the parameter which you have declared in Variable Subtitution in Communication channel.

if you want the file name as Empid then --> vars :payload:MT_Employee_Src,1,Details,1,Empid,1

if you want the file name as Name then --> vars :payload:MT_Employee_Src,1,Details,1,Name,1

if you want the file name as Designation then --> vars :payload:MT_Employee_Src,1,Details,1,Designation,1

Former Member
0 Kudos

Hi All,

I did exactly what you said.But still it is not working.

Please can you give any suggestions to make it correct?

Thanks

Rabi

Former Member
0 Kudos

Hi,

Are your source and target message structures same??

If different then, make sure you have used the target message type structure while giving variable substitution.

Regards,

Sunitha

Former Member
0 Kudos

refer this blog (step 3) and cross check ur configs:

former_member191435
Contributor
0 Kudos

Refer to this blog, hope this helps you

Also refer to this blog:

http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm

Thanks

Rohini

Former Member
0 Kudos

Hi Rabipanda,

I think you are applying the variable subtitution to the Source Structure..

you have to do this using target structure.

Try this Once,

vars : payload : TargetMessageType,1,Rootelement,1,Element,1

Example :

vars : payload:MT_Employee_Target,1,Details,1,EmpId,1

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi All,

Thanks for your suggestions and replies.

Great .

This is solved now.

I was using source payload in variable substitution which should be of target payload.

Thanks

Rabi

Former Member
0 Kudos

Hi,

Two corrections to what you have done

1.Use a field from your target message type for variable substitution.

2.Include the name of the field where you have stored the filename in * payload:MT_Employee_Src,1,Details,1* at the end

Regards,

Manjusha

Former Member
0 Kudos

Rabi

Only

vars :payload:MT_Employee_Src,1,Details,1

will not help as you need to pass the field value in variable which should contain a data to pass in file name. Her you have refered a node.

Pass:

vars :payload:MT_Employee_Src,1,Details,1,<Filed which contains file name scheme part eg. EmpId>,1

Regards

Raj

former_member191435
Contributor
0 Kudos

Hi,

As per your scenario, you want to use source field to get filename. Then create an extra field in your target structure, Assign that value to your field in target. (Assign value to designation field for instance)

In FCC , give filename schema as res_%var5%.xml (var5 is the field in target structure which you want to substitute)

Go to reference tab,

var5 : payload:MT,1,RecordSet,1,Detail,1,Designation,1 (hierarchy must be given )

In content conversion tab:

Details.fieldFixedLengths : 1,3,0,1..

Give 0 to the designation field as you are using it just as variable

Details.fixedLengthTooShortHandling : Cut

try this .

Thanks & Regards,

Rohini

anupam_ghosh2
Active Contributor
0 Kudos

Hi Rabi,

For the payload as shown below


<ns0:MT_Employee_Src xmlns:ns0="urn://FileToFile_ERD">
  <Details>
  <EmpId>1</EmpId> 
  <Name>sds</Name> 
  <Designation>ABAP</Designation> 
  </Details>
  </ns0:MT_Employee_Src>

Suppose you want to do variable substitution with value of say "Name" field. You want to achieve target filename as

res_sds.xml (as value of "Name" field is "sds").

Then you need following configurations


File Name Scheme  :   res_%var1%.xml

Variable substitution


 Variable Name                                                      Reference
var1                                                              payload:MT_Employee_Src,1,Details,1,Name,1

You need to mention name of the tag whose value you need in the filename. In your post you mentioned last tag as "Details" in reference field. This tag "Details" cannot be the last tag because it is being used as parent tag of the tags <EmpId>, <Name> and <Designation> and does not bear a value of its own.

Hope this solves your problem.

regards

Anupam

former_member303666
Active Participant
0 Kudos

hi RabiPanda,

the variable substitution feature of Receiver File adapter to get the Output file name as one of the Field value from payload.

take the file name from the paylode what u given...

please go through the below links.. this will slightly help u...

http://www.saptechnical.com/Tutorials/XI/Variable/substitution.htm

regards,

kesava.

baskar_gopalakrishnan2
Active Contributor
0 Kudos

refer this [link|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/13704] [original link is broken] [original link is broken];. This would give idea about using variable substitution.