Skip to Content
author's profile photo Former Member
Former Member

BEx Questions

Hello Everyone,

I have few questions related to BEx .

1. Can we use a function module in BEx so that ABAP code can be called while executing Bex query/report in BEx Analyzer.

2. Can someone tell me how to use multiple structures / variables in query based on conditions.

3. Could someone tell me how to invoke/refresh a macro in BEx automatically on executing a query in BEx Analyzer.

Thanks.

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2004 at 04:54 PM

    Hi Gopi,

    I think I can answer question #3. When you refer to BEx Analyzer, I assume that you mean queries embedded in Microsoft Excel workbooks. If not, ignore this response.

    When a query is embeded in a workbook, BEx Analyzer adds a Visual Basic module named SAPBEX. To see this module, launch the Visual Basic Editor (on the Excel menu, the path is Tools >> Macro >> Visual Basic Editor; or, use the short cut Alt+F11).

    In the SAPBEX module, you will find one subroutine named SAPBEXonRefresh. The inital code provided is:

    Sub SAPBEXonRefresh(queryID As String, resultArea As Range)

    End Sub

    This subroutine runs automatically every time that BEx fills the Result Table ... which means after every query Refresh, or every change in navigational state (change of drill state or change in filter values or change in Condition state).

    The two variables provided from BEx to this subroutine are:

    queryID as string; this is the local Query ID that you would see if you right-click on a query cell, select Properties and look under the information tab. If there is more than one query embedded in the Excel workbook, this variable can be used so that different Visual Basic code is executed for different queries.

    resultArea as Range; as the name implies, this gives the precise location of the Result Table. For example, to go to the worksheet that contains the query that was just refreshed and select the Result Table, you would use the Visual Basic command:

    Application.Goto Reference:=resultArea

    Any Visual Basic code that you add to this subroutine will be executed immediately following query refresh and before control is returned to the user.

    I hope you find this information useful.

    Regards, Pete

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2004 at 05:13 PM

    1. There is an exit available for customer exit variables and for virtual key figure or characteristics, so maybe you can use one of these possibilities (depending on what you would like to do.

    2. Maybe you could explain more in detail or someone else can answer that one

    3. In the BW online documentation you can find what's copied below. I hope the following link works for you, if not let me know and I'll send you the full text.

    http://help.sap.com/saphelp_bw30b/helpdata/en/f1/0a5a2ee09411d2acb90000e829fbfe/frameset.htm

    You can also connect the Business Explorer (BEx) with your own VBA programs (Visual Basic for Applications). The BEx add-in can trigger your own VBA routines or you can control BEx add-in functions from your own VBA routines.

    Controlling from the BEx Add-in

    When inserting a query into the workbook, the following VBA routines are automatically generated in the workbook:

    Sub SAPBEXonRefresh(queryID As String, resultArea As Range)

    End Sub

    This routine is always called if the BEx Analyzer has filled the results area of the query. This routine has the parameters Query ID and the Results Area as the Excel range. You can use this routine to trigger your own processes after you refresh the query....

    Regards, Klaus

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2004 at 08:40 PM

    Hi Pete and Klaus,

    Thanks for your response. Klaus, could you tell me what is the exit you mentioned about in your answer to my first question. Could you brief me more.

    Thanks.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi here a short description for virtual key figure or characteristics and own variables (what Klaus means):

      1. Virtual Characteristics and Virtual Key figures

      - A virtual characteristic / key figure is an object of the InfoCube. The values are derived at query run time.

      - Examples:

      • The SalesRep is derived from Product and Customer. This assignment changes frequently. Therefore the value for the characteristic SalesRep can not be stored in the Cube.

      • You want to calculate with key figure-type attributes of an InfoObject. E.g. Price is an attribute of Product. Sold-quantity is an object of the InfoCube. You want to see the revenue (Sold-quantity * Price) in your query.

      • You have an "Open-order-InfoCube". One InfoObject is the Orderdate. You need a list with the number of days btw. the orderdate and today.

      How to program a corresonding Include:

      1. You must firstly define the characteristics, or key figures within the InfoCube

      2. Call up transaction CMOD in the Admin. Workbench

      Create a Project

      3. Select Enhancement Components

      4. Select Enhancement RSR00002

      5. Double-click on Exit EXIT_SAPMRSRU_001

      6. Double-click on include ZXRSRU02 within the Exit

      7. Display or change coding

      8. Maintain include ZXRSRTOP

      9. Maintain include ZXRSRZZZ

      10. Don't forget to activate the Project

      Interface Importing/Exporting:

      IMPORTING:

      I_S_RKB1D -> Information about Reporting-Object; here Query (Queryname, InfoCube, ...)

      EXPORTING:

      E_T_CHANM -> Table with the name of the virtual characteristics

      E_T_KYFNM -> Table with the name of the virtual key figures

      Remarks:

      - You should note that the data records transferred can be on a different aggregation level depending on read procedure and drilldown.

      - Moreover, compound information is not automatically changed with compounded characteristics after changing a higher-level characteristic. In addition, the compound characteristic must also be defined in the mode RRKE_C_MODE-NO_SELECTION.

      - Furthermore, the fiscal year (0FISCYEAR), the fiscal year period (0FISCPER) and the fiscal year variant (0FISCVARNT) cannot be read or changed in the enhancement. (*)

      - Enhancement 999 may not be changed. Calling up serves to update information via the structure C_S_DATA. This functionality is completely taken over by form USER_INIT_GLOBALS.

      2. User Exit for variables:

      -Enhancement: RSR00001

      - The component for the enhancement is the function module EXIT_SAPLRRS0_001.

      How to program a corresponding Include:

      - Create variable with corresponding type for User Exit

      - Call up transaction CMOD in the Admin. Workbench

      - Create a Project

      - Select Enhancement Components

      - Select Enhancement RSR00001

      - Double-click on Exit EXIT_SAPLRRS0_001

      - Double-click on include ZXRSRU01 within the Exit

      - Add or change coding

      - Don't forget to activate the Project

      - Use the variable in a query

      Interface - Importing:

      I_VNAM --> Name of the Variable; without &-signs

      I_VARTYP -->

      1: Characteristic Value

      2: Hierarchy node(s)

      3: Text

      4: Formula

      5: Hierarchy

      I_IOBJNM --> Name of the InfoObject

      I_S_COB_PRO --> Information about InfoObject(Dataelement, CheckTable, Length, Number of Decimals, ...)

      I_S_RKB1D --> Information about Reporting-Object; here Query (Queryname, InfoCube, ...)

      I_PERIV --> Fiscal year variant

      I_T_VAR_RANGE --> Table with all Variables and their values

      I_STEP

      1: Before Variable Pop up

      2: After Variable Pop up

      E_T_RANGE --> Table to return the values

      fields: low, high, sign, opt

      E_MEEHT --> Unit of measure

      E_MEFAC --> Number of Decimals for Unit

      E_WAERS --> Currency Code

      E_WHFAC --> Number of Decimals for Currency Value

      You can do many amazing things in BW. Well if you like you can use also ABAP in TableInterface for Web or JavaScript in Web. VBA in BEx Analyzer and many more interesting things. Just surf to http://hel.sap.com and find out!

      Regards,

      Adem

  • author's profile photo Former Member
    Former Member
    Posted on Dec 06, 2004 at 03:30 PM

    Hi Adem,

    What i meant is, just to mention the 'exit' name. Anyway, Thanks for taking some time out of your invaluable time and explaining me.

    Thanks.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.