Check for module is installed or not Livelink

In some cases, you may want to access functionality provided in another module, and in manu cases this is an optional, rather than core, module. If you call an function in another module that does not exist, you will get an error for the user and a Trace file. This code snippet provides a method so you can test if a module is installed on a server prior to calling it withing your code. The code for this function is as follows :

 Text |  copy code |? 
01
// This function returns TRUE if the specified module is loaded, and FALSE otherwise
02
function Boolean isAModule (string moduleName)
03
    dynamic module=$Kernel.ModuleSubsystem.GetItem(moduleName)
04
    // if the module is loaded
05
    if (IsDefined(module)) 
06
        return true
07
    else
08
        return false
09
    end
10
end 

The following code snippet shows how you could use this function to test if the Directory Services module (module name directory) is installed on the server, assuming that the function is in the same Object or Request Handler as the calling function :
 ABAP |  copy code |? 
1
if (.isAModule("directory"))
2
    echo("Directory module installed")
3
else
4
    echo("Directory module NOT installed")
5
end 

Source: http://www.greggriffiths.org/livelink/development/oscript/snippets/isamodule.html

  • Share/Bookmark
No Responses to “Check for module is installed or not Livelink”

Post a Comment