Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
sascha_mink2
Explorer
0 Kudos

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

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

Labels in this area