cancel
Showing results for 
Search instead for 
Did you mean: 

Global Variable in XSLT mapping

Former Member
0 Kudos

Hi ,

I have a scenario where ther are multiple mapping in my Opertion mapping.

  • 1st Mapping is XSLT mapping and 3rd Mapping is a message mapping.
  • I have to use a variable value (source file name extarcted into 1 st mapping) from my 1 st mapping  into 3rd mapping.

can we set global variables in XSLT mapping.  If so how ? Do global variables availables in all the mappings ?

Thanks ,

Prem.

Accepted Solutions (1)

Accepted Solutions (1)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>Do global variables available in all mapping?

global variables can be used in multiple udf calls in a sequence . But it won't be available in different mapping type  like xslt or message mapping. They are executed in different containers. You can store file name in jdbc table and use it in message mapping.


Former Member
0 Kudos

Hi Baskar,

Is there any way without using another system(jdbc)/making external calls .. ?

Thanks,

Prem.

Answers (1)

Answers (1)

udo_martens
Active Contributor
0 Kudos

Hi Prem,

Sriram's blog Effective XSL : for Multimapping, getting Source filenames in Legacy-Legacy scenarios is describing the solution. You use a Java function inside XSL to store a value in Dynamic Configuration. Unfortunately the screenshots are gone here, this is a pity, a lot of good knowledge is lost with the new scn design.

Regards,

Udo

Former Member
0 Kudos

Thanks Udo, Extarcting the varaible is fine.

Also,  Do global variables availables in all the mappings ?  Can I extarct the varaible into my third mapping which is populated during 1 st mapping ?

Thanks,

Prem

udo_martens
Active Contributor
0 Kudos

Hi Prem,

Do global variables availables in all the mappings ?  Can I extarct the varaible into my third mapping which is populated during 1 st mapping ?

Why do you repeat the questions instead of reading the answer?

Regards,

Udo

Former Member
0 Kudos

OK , Understood that Global Variable can't be available in different mapping programmings ( from Bhaskar's Reply)

Question :

Is there any way to do this without using another system(jdbc)/making external calls .. ? ?

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>OK , Understood that Global Variable can't be available in different mapping programmings ( from Bhaskar's Reply)

What I meant was if you do different type of mappings like Java mapping followed by abap mapping followed by message mapping then it won't be possible to retrieve inside different mapping because they are executed in different containers. If you use sequence of UDFs then sure global variable is available for all the consecutive UDFs.  Again Udo  pointed above clearly to create  a java function in XSLT mapping. Inside java function use/call the dynamic configuration class and set the values. Then in your second  mapping (message mapping) use a UDF and retrieve the value from the dynamic configuration logic. This way you don't need to rely on global variables.

Former Member
0 Kudos

Hi Bhaskar,

Sorry if my Question is simple..but I am unable to proceed..

>>>call the dynamic configuration class and set the values. Then in your second  mapping (message mapping) use a UDF and retrieve the value

I have set the file name value to the variable "YYY" . How to retrieve this into message mapping UDF ?

         <xsl:variable name="dynamic-conf" select="map:get($inputparam, 'DynamicConfiguration')"/>

        <xsl:variable name="dynamic-key"

               select="key:create('http://sap.com/xi/XI/System/File','FileName')"/>

        <xsl:variable name="YYY" select="dyn:get($dynamic-conf, $dynamic-key)"/>

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>I have set the file name value to the variable "YYY" . How to retrieve this into message mapping UDF ?

You already set filename. Search SCN for dynamic configuration related coding. There are plenty available.  You need to write simple java coding in UDF.You can use get method by passing the key to retrieve value from the DynamicConfiguration object. Please refer this class and available methods.

http://help.sap.com/javadocs/NW04S/SPS09/pi/com/sap/aii/mapping/api/DynamicConfiguration.html

Former Member
0 Kudos

Sorry I am confused. I don't If I am clear or not ...

As you said a variable can't be extarcted into another mapping .....

1. I got my source file name into the variable "YYY" in my XSLT Mapping ( 1st mapping)

2. I need to get this into my third mapping (Variable YYY value) ..... this variable is not a dynamic configuration object ...what is the need of writing the java udf to retrive  DynamicConfiguration object ?

>>" get method by passing the key to retrieve value from the DynamicConfiguration object"

Please note that the source file name holds good only upto first mapping . The second mapping is actually a Java SOAP lookup where i have to extract the SOAP XML and have to write to some other folder ..in this scenario I am writting the target file with the source file name fetched during my first mapping..