Skip to Content
avatar image
Former Member

Variable Substituion

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

8 Answers

  • Best Answer
    avatar image
    Former Member
    Nov 03, 2011 at 05:34 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • Nov 02, 2011 at 06:07 PM

    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

    Variable Substitution File Receiver Adapter

    regards,

    kesava.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 02, 2011 at 06:59 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 03, 2011 at 05:59 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 03, 2011 at 06:02 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 02, 2011 at 05:44 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 03, 2011 at 08:07 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 03, 2011 at 09:32 AM

    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

    Add comment
    10|10000 characters needed characters exceeded