Skip to Content

SAP CRM Mobile Client 4.0 SP11 and 5.0 SP07 features a new tool called SAP Environment Analyzer. This tool lets you run some quick checks on your system and verify the sanity of the environment. Along with this tool, the basic environment files to check the versions of various files that are distributed with the standard service packs are distributed on the installable media. SAP Environment Analyzer, referred to as SEA from this point on, uses an XML file called the ENV file to describe the checks that you would like to perform on the target machine. SEA is an extensible framework, which allows you to write your own plugins and perform custom checks. I will briefly discuss the structure of the Environment file and provide a simple example of a custom plugin and the various tools that you can use in conjunction with SEA. All of the checks shipping with SEA are implemented as plugins. Plugins can be of two types.

  • Actions: Actions are responsible for performing some action on the target machine. They really do not check for anything but perform some tasks like initialization, querying information for future use and so on.
  • Checks: Checks are responsible for checking something and reporting a success or failure. Some checks need not be mandatory such that their failure only results in a warning.

The environment file has the following structure.


















All SEA plugins are .NET assemblies. So we can start of by creating a new .NET Class Library project in Microsoft Visual Studio .NET.

  • Create a new .NET Class Library Project
  • Add reference to EnvCore.dll. This would usually be in C:\Program Files\SAP\Mobile\support\Tools\EnvironmentAnalyzer\ folder. This is essential to access several attributes.
  • Create a new class or rename the default Class1 to some convenient name. Let us call that AlwaysSucceeds.

using System;
using System.ComponentModel;

using SAP.EnvChecker.Core;

namespace SamplePlugin
{
     //PluginName attribute indicates the name of the tag which is used to load the plugin
    //Description attribute can be used later to generate documentation using gendoc.exe
    [PluginName("alwayssucceeds")]
    [Description("The wonderful plugin which does nothing.")]   
     public class AlwaysSucceeds : ICheck
     {
        //LogMessage delegate allows us to write messages to a trace file
        private LogMessage logger;
        private string _strParam;

        //The PluginParam attribute allows you to pass in strings/ints/enums as values via xml attributes
        // This attribute can be applied only on public properties that you wish to expose.
        [PluginParam("param")]
        [Description("The parameter to take in")]
        public string AParameter
        {
            get{return _strParam;}
            set{_strParam=value;}
        }

          public AlwaysSucceeds()
          {
        }

        #region ICheck Members
        //This property can be used to specify messages on the grid after execution.
        //A short helpful message would do.
        public string Message
        {
            get{return "This always succeeds";}
            set{}
        }

        //The check method returns true or false. True to indicate success and False for failure.
        public bool Check()
        {
            //The logger function helps writing to the log file along with essential context information.
            logger(this,MessageType.Info,"I am checking");
            return true;
        }
        //This function helps set a delegate if you would like to trace some messages.
        //The trace file is usually created in the TEMP location.
        public void SetLogMessageDelegate(SAP.EnvChecker.Core.LogMessage log)
        {
            this.logger=log;
        }

        //This delegate can be used to post messages to the status bar while executing the plugin.
        public void SetStatusBarTextDelegate(SAP.EnvChecker.Core.StatusBarTextDelegate del)
        {
            // TODO:  Add AlwaysSucceeds.SetStatusBarTextDelegate implementation
        }
       
        //The getprop and setprop can be used to query property values set by other actions or checks
        // or set some properties for later use. These properties are not .NET properties. They are a collection
        // of string based key value pairs.
        public void PropertyHandlers(SAP.EnvChecker.Core.GetProperty getprop, SAP.EnvChecker.Core.SetProperty setprop)
        {
            // TODO:  Add AlwaysSucceeds.PropertyHandlers implementation
        }
        #endregion
    }
}

Now build the assembly. You now have to register the assembly with SEA. To do that you can simply copy it into the SEA folder. (The folder which has EnvCore.dll) You would have noticed that the environment file has a xmlns schema declaration. To support this sort of dynamic plugin concept, the schema has to be generated. SEA does this automatically as soon as it detects a new file. You can find the schema in the following location on the target machine. %USERPROFILE%\Application Data\SAP\EnvSchema. You can manually trigger the schema generation by running envschema.exe. You can also use gendoc.exe present in the same location to generate a quick documentation about the plugins present with SEA. Although this documentation is not much, if the plugin has been written properly with adequate [Description] attributes, it takes care of easier documentation.

To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply