Skip to Content

Sometimes it would be nice if we could call an abap function module right out of the BEx Analyzer. For example in an integrated planning environment for enriching data or something like this …

Fortunately this is possible with only a little effort in Visual Basic for Applications. You can take a look at this SAP Help Page.

There is a nice tutorial for this.

VBA Snippet:

=============================================================


Dim FunctionCtrl As Object
Dim func
' first we have to create an function module object
Set FunctionCtrl = CreateObject("SAP.Functions")
' now we fetch the bex connection
Dim bexCon As Object
Set bexCon = Application.Run("BExAnalyzer.xla!sapBEXgetConnection")
' setting the bex connection for our function module
FunctionCtrl.Connection = bexCon ' doing it this way let us do the call to the function module
                                                ' without embarassing the user with logon-dialogs, etc.
                                                               ' this is the real "feature" of this document
' calling the function module
Set func = FunctionCtrl.Add("....")     ' place the name of your abap function module here
With func
    .Exports("") = ...                                ' set the import values of the abap function module (for example to a value of an excel cell)
    ...
End With  
result = func.call()                               ' call the function module
x = func.imports("...")                          ' the export value of the abap function module is now in x, you can set for example the value of a cell to the content of x

=============================================================

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