Skip to Content

Have you ever wondered how to pass environment variables to xMII transactions ?

You are trying to create a BLS transaction and you need to create a text file, maybe a log, with the name of the user logged in and the datetime but you have absolutely no clue as to how to pass the xMII username at runtime ?

Fear not, as the solution is not as difficult as it seems !

To get started we would have to do a small configuration in the Xacuteconnector in the Data Servers under the Data Services tab.

!https://weblogs.sdn.sap.com/weblogs/images/251690412/DataServers.gif|height=178|alt=The Data Servers link|width=189|src=https://weblogs.sdn.sap.com/weblogs/images/251690412/DataServers.gif|border=0!

On the Data Servers page select the Xacuteconnector and on the properties tab check Autobind if not already checked and click on save.

XacuteConnector

Now open the BLS editor by going to Business Logic Services -> Logic Editor. We’ll be creating a new transaction now. Now add a Transaction Parameter by going to *Transaction -> Properties * and click on Add. Call the parameter IllumLoginName, choose the Data Type as String and click OK. Now add another Transaction Parameter called UserName, choose the Data Type as String, check the Output Parameter? checkbox and click OK.

Transaction Properties

We’ll go on with the BLS, but first let me explain what we just did. If Autobind is checked for the XacuteConnector, in BLS transaction, xMII searches for Transaction variables having a name which is same as that of any environment variable and if it finds one, substitutes the value of the Transaction variable with that of the environment variable at runtime.

Note that this binding takes place only at runtime so executing the Transaction and checking the step trace will not return the value of this parameter.

Here IllumLoginName is the name of the environment variable which holds the value of the Login Name of the xMII user.

Now, in the Logic Editor add a Assignment Block from Logic -> Assignment by dragging and dropping it on the sequence. Right click on the Assignment Block and select Links.

On the Link Editor expand the Transaction Node on the both sides in the Incoming tab. Now drag and drop the IllumLogiName field on the left side to the Username field on the right side.

Link Editor

Now in the Expession Editor change the expression from : + Transaction.IllumLoginName+ to  + “Hello ” & Transaction.IllumLoginName & ” !!!”+ and click on Update.

!https://weblogs.sdn.sap.com/weblogs/images/251690412/Expr.gif|height=261|alt=Expression Editor|width=491|src=https://weblogs.sdn.sap.com/weblogs/images/251690412/Expr.gif|border=0!

Now save the Transaction as QRY_Autobind. It’s time now to create a Xacute Query to test our creation. Go to Data Services and click on the Query Templates link. When the Query Template Editor pops up click on  New and select XacuteQuery from the list.

Choose Template

In the Servers tab select XacuteConnector and in the Modes tab select Query.

Xacute Query

Click on the Transaction tab, from the Folders tab select the folder you saved your BLS transaction to, select your transaction in the Transactions tab, which in our case will be Xacute_Autobind and select the Output Parameter UserName in the Outputs tab.

Transaction tab

Save the Query as QRY_Autobind, fire up your browser and run the query using the Illuminator service as :

http://<server>:<port>/Lighthammer/Illuminator?QueryTemplate=Abesh/QRY_Autobind

The output of the Query should be “Hello <username> !!!”.

Output when tested from local machine on which xMII is installed :

Output on xMII Server

Output when tested from another machine in the network with my user :

image

Phew ! Done at last ! Was not that difficult was it ?

Update

Since quite a few people have been asking for a List of Environment Variables here’s a bit of info about them as well.

A list of the Environment Variables set can be found by using the following URL :

http://<server>:<port>/Lighthammer/PropertyAccessServlet?mode=list

(Thanks Fran)

And any User Attributes we set for a particular user is also available as an environment variable.

This can be accessed via “Security Services -> Security Manager -> User Management -> Users” link. Choose any Attribute, click on add and then set a value to the attribute. You can also create User Attributes by using the “User Attributes” menu under “User Management”.

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Dipankar Saha
    This is a very useful blog for xMII developers. let us know the list of standard environment variables available in xMII runtime and how to set a custom environment variable
    -Dipankar
    (0) 
    1. Abesh Bhattacharjee Post author
      A list of the Environment Variables set can be found by using the following URL :

      http://:/Lighthammer/PropertyAccessServlet?mode=list

      (Thanks Fran)

      And any User Attributes we set for a particular user is also available as an environment variable.

      This can be accessed via “Security Services -> Security Manager -> User Management -> Users” link. Choose any Attribute, click on add and then set a value to the attribute. You can also create User Attributes by using the “User Attributes” menu under “User Management”.

      (0) 

Leave a Reply