Macros in Bex

Dear friends,
Please give me some information about Macros in BEx, I know that we can write some VB code in Workbook. But I want to clear picture on that, can you please send any documents on Macros to [email protected]
Thanks
Ganga.

Hi,
To create macro, menu tools->macro->macro->macro name and 'create', code check threads and bw expertonline
replacing '#'-sign for 'not assigned' in queries
Replace the default u0091#u0092 in BEx
http://www.bwexpertonline.com/downloads/boeke04.doc
The steps to do the same
1) In excel menu Tools->macro
2) Enter the macro name say SAPBEXonRefresh
3) click 'create', will go to visual basic editor
4) To display '#' as '', paste the following code
Sub SAPBEXonRefresh(queryID As String, resultArea As Range)
Dim c As Range
For Each c In resultArea.Cells
If c.Value = "#" Then c.Value = ""
Next c
End Sub
5) Close the editor and click on refresh again.
Pls chk this links; http://help.sap.com/saphelp_bw21c/helpdata/en/f1/0a55f9e09411d2acb90000e829fbfe/content.htm
How to include VBmacros in workbooks
Hope this helps,
Regards
CSM Reddy

Similar Messages

  • Which macros does BEx Analyzer use? How to call the refresh macro?

    Hi everybody,
    I would like to get an overview about which macros the BEx Analyzer uses, espacially the macro which is responsible for refreshing the workbook. I want to know what BEX Analyzer is doing when I open the variable screen, I assume there is an SAP macro that opens the variable screen?? I tried to look in the online help at help.sap.com but couldn't find a list of macros.
    The idea behind this is, that I have a BEx workbook with 5 queries in it. A colleague now wnats to write a VBA code that calls the variable screen, enters  company 1, period and year, runs the workbook and saves it. Then opens the variable screen again, enters company 2, period year, etc etc etc......
    What my colleague needs to know is which macro he has to call for the workbook refresh / variable screen in order to make his VBA coding.
    Many thanks in advance!!
    Michael

    Which version of Bex are you using ? Bex 3.5 or Bex 7 ? This will significantly affect the answer.
    For Bex 3.5, here is some useful information;
    http://help.sap.com/saphelp_nw04/helpdata/en/f1/0a55f9e09411d2acb90000e829fbfe/frameset.htm
    Edited by: Charlie Belt on Jun 7, 2011 9:12 AM

  • Drill Down Macro command BEx Analyzer BI 7.0

    Hi All,
    I'm having the following poblem. I'm working as a testautomation specialist having automated a test using (amongst others) the BEx Analyzer (SAP BW 3.X).
    In short, when the results of a query are shown in an excel sheet, I automated the vertical drilldown of every row in that resultssheet. I used the BEx Analyzer macro command: Run("sapbex.xla!SAPBEXfireCommand", "HDEX", myCell).
    Since we are going to use the new version of the SAP Bex Analyzer (BI 7.0), I have to convert/migrate all my testautomation scripts. And I just can not succeed in making this vertical drill down work in SAP Bex Analyzer 7.0. The SAPBEXfireCommand is not supported in SAP Bex Analyzer 7.0. Does anyone has an idea what SapBexAnalyzer (Excel) macro I can use to drill down in  SAP Bex Analyzer 7.0? Any help really appreciated, I'm really struglling with this one and also no luck finding any solution on the internet so far.
    Thanks!

    i'd suggest u research some oss notes.
    Take a look at the following:
    1073426
    1045244
    1039191
    these may not be exact solutions, but will guide you to other notes as well...

  • How to use for my own macro the Bex SAP Connection?

    Hello,
    with
    Dim sapConn As Object 'Declare variant
        Set sapConn = CreateObject("SAP.Functions") 'Create ActiveX object
        If sapConn.Connection.Logon(0, False) <> True Then 'Try Logon
           MsgBox "Cannot Log on to SAP"
        End If
        'Define function
        Dim objRfcFunc As Object
        Set objRfcFunc = sapConn.Add("RFC_READ_TABLE")
    you are able to connect to SAP via a VB macro and you can use it e.g. for a RFC call.
    Is it possible to use from my macro the connection that is establised by BEX? If yes - how? I haven't found any method to get the established connection. In the macro edior is BExAnalyzer.xla with all general functions. Test.XLS ist my workbook, but here is no variable with the connection. It seems that Test.XLS only call a sub of BExAnalyzer.xla.
    Best regards,
    Alexander

    [Hello Alexander,|http://chandranonline.blogspot.com]
    Yes its possible,
    SAP Note Number: 492561
    BEx Analyzer: Connection to the BW Server in a VBA macro
    Symptom
    Customer has written VBA macros which automate functions in the BEx Analyzer via the Analyzer's VBA-API. The customer wants to automate the logon as well, i.e. the user should not be forced to process the BEx Analyzer's dialog screen manually.
    Other terms
    Logon, Login, Visual Basic for Applications
    Solution
    The following VBA code sample shows how to create an RFC connection for the BEx Analyzer without bringing up the logon dialog. It assumes that the BEx Analyzer (i.e. the Add-in SAPBEX.XLA) has been loaded already.
    Function logonToBW() As Boolean
         logonToBW = False
        On Error GoTo leave
        Dim myConnection As Object
        Set myConnection = Run("SAPBEX.XLA!SAPBEXgetConnection")
        With myConnection
    '      .client =
    '       .user =
    '      .password =
    '      .Language =
    '       .systemnumber =
    '      .system =
    '      .systemid =
    '        .ApplicationServer =
    '       .SAProuter =
             .logon 0, True
            If .isConnected <> 1 Then
                 .logon 0, False
                If .isConnected <> 1 Then
                     MsgBox "something went wrong ..."
                     Exit Function
                 End If
            End If
        End With
        Run "SAPBEX.XLA!SAPBEXinitConnection"
         logonToBW = True
    leave:
    End Function
    Also see
    [SAP Network Blog: Accessing SAP Functions from Excel using Visual Basic Applications |/people/vikas.sreedharan/blog/2007/12/12/accessing-sap-functions-from-excel-using-visual-basic-applications]
    [Thanks|http://chandranonline.blogspot.com]
    [Chandran|http://chandranonline.blogspot.com]

  • Macro in BEx

    Hello Experts,
    Does anyone have experience with the following requirement?
    -After executing query, run a macro that does the following...
    -Re-runs the query, allowing the user to input new selection criteria and appends results to original results
    Thanks,
    Andy

    I can't answer your entire question without actually writing the code, but I can tell you how to execute a macro when a query executes. In order to save the macro, you have to run the query and save the workbook with the macro. When you access the workbook and refresh the query, the macro will run.
    In Visual Basic:
    Sub SAPBEXonRefresh(queryID As String, resultArea As Range)
    <insert code here>
    End Sub
    In the code section, you would need to put in the function to insert a query into the workbook and where exactly it should be "appended."
    http://help.sap.com/saphelp_nw04/helpdata/en/f1/0a55f9e09411d2acb90000e829fbfe/content.htm
    This has useful information about integrating VBA w/ bex.

  • VB Macro in Bex Analyser is taking long time to complete execution

    Hi Experts,
    In a FI query , we have a VB macro which update the excel sheets by taking values from the previous excel sheets .
    The issue is its taking long time for query execution and if we are keep on pressing 'ENTER' button . The query is running very fastly and is giving the results ,but its not a correct way to do.
    Its a critical issue in Production and can anyone help me to resolve the issue.
    Regards,
    Anju

    Hi Anju,
    I need to create a VB macro in one of my query but i not familiar how i can plug the VB code into the query.
    Please can you give me some basic procedure on how to do that?
    What i need to do exactly is to bring a KF from a query into another query. Not sure if this is possible using VB.
    Let me know.
    Thanks.
    Cesar

  • 2004s Bex Macro enhancements - BEx.DataProviders("DATA_PROVIDER_1").

    Hi,
    I need a quick answer to add dynamic Print functionality to 2004s Bex Reports.
    Was able to find out certain methods that provide the no. of dataproviders in a workbook, determine the query properties etc. BEx.DataProviders("DATA_PROVIDER_1")
    But stuck in finding out the no of rows and columns for a dataprovider, the characteristics and key figures etc.
    Is there a way to find out the no. of rows and columns for a data provider. More information on this would be appreaciated.
    Regards,
    Dinesh

    Here's a few different examples of how to use XML, Javascript, XSL:
    https://www.sdn.sap.com/irj/sdn/thread?threadID=97672
    function load(xmlFile)
       // code for IE
       if (window.ActiveXObject)
         xmldoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
         xmldoc.loadXML(xmlFile);
       else
          alert('Your browser cannot handle this script');
    function getResult(xmlitem)
       startnode=document.getElementById(xmlitem);
        load(startnode.innerHTML);
        item_node = xmldoc.firstChild.firstChild.firstChild.nextSibling.lastChild
        resultset = item_node.firstChild.firstChild.nodeValue;
        return(resultset); 
    function writeResults()
       myresult= eval(getResult('DATA_PROVIDER_INFO_ITEM_1')) + eval(getResult('DATA_PROVIDER_INFO_ITEM_2')) ;
       myresult= Math.round(myresult*100) / 100;
       document.getElementById('result').innerHTML='Overall result:  ' + myresult;
    You should just be able to write a one line xpath to get this value... The code samples just give you an idea of how you interact with xml...

  • How to create a custom button in Excel while log on to BI through BEx

    Hi all,
        I have an requirement to add a button in excel application, while we log on to BI
    through BEx.
       I know only that it has to be done with macros. I dont have any idea in this.
        When i click on that button an RFC should get executed.
        Pls help in this, I am not able to move anymore.
    Thanks.

    hello,
    You can try report to report interface, to allow you to jump from one report into a SAP transcation.
    http://help.sap.com/saphelp_nw04/helpdata/en/99/08629bd3e41d418530c6849df303c9/frameset.htm
    for macro's reference and procedure:
    BW Bex 3.x Macros to create Formatted Workbooks - Part 1
    Macros in Bex
    Reg,
    Dhanya

  • 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.

    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

  • VBA macro for hiding a row

    Hi everyone,
    I have a question regarding VBA macros in BEx analyzer. I have few rows in which all values are zeros. I would like to hide such rows. I am trying to write a VBA macro to implement it. Could someone help me with this.
    Thanks
    R

    Hi Ram,
    I agree with Roberto that there is probably a way to do this entirely within BEx.  I would try a Condition.
    But ... here is what you've asked for.  Note that it is written assuming that there is more than one query in the workbook and that local Query ID for this query is SAPBEXq0001.  You might need to adjust these.
    This code would replace (or augment) what is currently in the Module named SAPBEX.
    Regards, Pete
    Sub SAPBEXonRefresh(queryID As String, resultArea As Range)
    'code to hide any row where all Key Figures are zero
    Dim n As Integer, qRow As Integer, RowOffset As Integer
    Dim ColOffset As Integer, FirstRow As Integer, FirstCol As Integer
    Dim numCells As Integer, LastRow As Integer, LastCol As Integer
    Dim i As Integer, KFRange As Range, HideThisRow As Boolean
    Dim c As Range
        If queryID = "SAPBEXq0001" Then
            'locate this query's location in DIM table
            Set bexWS = Sheets("SAPBEXqueries")
            numQueries = bexWS.Range("A2")
            For n = 1 To numQueries
                If bexWS.Range("F" & n + 3) = queryID Then
                    qRow = n + 3
                    Exit For
                End If
            Next n
            'determine Key Figures offset
            RowOffset = bexWS.Range("G" & qRow)
            ColOffset = bexWS.Range("H" & qRow)
            'define first & last rows & columns for Key Figures
            FirstRow = resultArea.Rows(RowOffset).Row
            FirstCol = resultArea.Cells(ColOffset).Column
            numCells = resultArea.Cells.Count
            LastRow = resultArea.Cells(numCells).Row
            LastCol = resultArea.Cells(numCells).Column
            'search for and hide any row where all Key Figures are zero
            For i = FirstRow To LastRow
                Set KFRange = Range(Cells(i, FirstCol), Cells(i, LastCol))
                HideThisRow = True
                For Each c In KFRange.Cells
                    If IsNumeric(c.Value) Then
                        If c.Value <> 0 Then HideThisRow = False
                    End If
                Next c
                Rows(i).Hidden = HideThisRow
            Next i
        End If
    End Sub

  • How to learn VB Macros?

    Hi, If I want to write macros for BEx, where and how should I learn?
    Thanks,
    Radha

    Chk this blog
    /people/sap.user72/blog/2006/06/05/long-texts-in-sap-bw-displaying-in-bex-analyzer-introduction-to-excel-workbooks-formatting-part-i (It has links to other parts)
    Hope it helps,
    Regards,
    B

  • Adding 2 columns in BEX

    Hi friends,
    i have a requirement to add 2 columns in a query, i know there are some posts regarding this issues but i did not found any suitable answer for this, this will be solved by using some macros in BEX, can any one pls send coding for that.
    points will be awarded,
    thanks,
    pavan,

    >i need to add two char info objects in query please tell me >how?pls gurus solve my problem.
    If the object exists in the data provider then, there is nothing you really need to do except to drag and drop them in the column. But if the objects are not in the data provider and you need to add some logic to it, then you need to create some calculated key figure or Restricted Key figure or Formula to put your logic in and if it is CKF or RKF then drop it in the column section. Everything depends on the availability of the InfoObject in the data provider.
    thanks.
    Wond

  • RRMXP does not work with GUI 7.20

    Hi Experts,
    I have the following problem. RRMXP does not work with GUI 7.20, BEX 7.0 launches and I have to enter proper user and password. (I get SAP Logon screen with listed systems)
    It works properly with GUI 7.10 and I have not to log into BEX.
    Did anyone encounter such problem? Does anyone know what causes the problem?
    Regards&thanks
    Marek

    Hi,
    RRMXP uses OLE to launch Microsoft Excel together with the SAP BEx add-in. Then it use a macro within BEx to open the workbook. check whether  BEx is not installed properly (run SAPBEXC.XLA under C:Program FilesSAPFrontendBW) or the Excel macro security settings prevent execution of the macros.
    Also Check the below link it has some note to follow
    RRMX and RRMXP does not open the query and workbook
    Regards,
    Satya

  • Formula in workbooks

    hi all
    i have created a workbook with sheet1 and sheet2.
    now in sheet2 one of the rows needs to be calculated .
    ex:
    result from sheet1 = zres1
    result from sheet2=zres2
    now below zres2 ,i want to add another row ,which is zres1-zres2.
    how can i achieve this.is it possible?
    your thoughts plz.
    thanks,
    srinivas
    Edited by: srinivas reddy on Jun 16, 2009 5:04 PM

    Srini,
    If the position of zres1 and zres2 are constant relative to their result areas (for eg, if zres1 always appears at the bottom right corner of the result area of query 1), you can use a VB macro to get the values of both of them, subtract them and put the result wherever you want.
    For info on VBA macros in Bex 3.5: [http://help.sap.com/saphelp_bw21c/helpdata/en/f1/0a55f9e09411d2acb90000e829fbfe/content.htm|http://help.sap.com/saphelp_bw21c/helpdata/en/f1/0a55f9e09411d2acb90000e829fbfe/content.htm]
    If you can be little more clear about your scenario i.e. where do zres1 and zres2 get displayed in their respective query result areas, where do you want the result to be displayed etc, it will be helpful.
    Edited by: Suhas Karnik on Jun 18, 2009 8:51 AM

  • Running BEX7 workbook repeatedly from excel vba

    On a monthly basis I have about 300 reports to run,all from the same bex7 workbook,  just with slightly different variables.
    I was able to setup a macro in bex 3.5 that would refresh a report and fill in values into the SAPBEXqueries hidden sheet.  This would adjust each time and save each report with an individual name.  Saved me about 3 hrs of sitting and running each report manually.
    My company is now upgrading to BEX7 and I am having difficulty getting my head around how to run the same workbook in BEX7 through a VBA Macro and pass the variables to it.
    I understand you can use SAPBEXsetVariables to pass variables along to the workbook but what format do the variables have to be in to communicate successfully with the workbook
    Would someone have an example of the process?
    I do not have access to modify the query at all as I am an end user and I am forced to come up with a solution on my own.
    Any help would be appreciated.
    Thank you
    Dan Gerling

    Hi Dan, in the same situation I'm afraid. Just posted this in a similar thread:
    "Hi Alfredough, I'm afraid I'm in pretty much the same situation as yourself (although possibly slightly further down the line). The reason I add that possibility is because I'm pretty certain that SAPBEXsetVariables has been removed in 7.x.
    It looks like there are some cludges which can be done to work through this (possibly), but the entire comparison of bexanalyzer.xla to sapbex.xla seems to involve features being removed, rather than added.
    Here's the thread which seems to give a cludge, which I'm having trouble getting working: How to set variables values via VBA.
    There's also some work which someone's done here around script objects: List BEx Analyzer 7.X variables and generate the associated PROCESS_VARIABLES commands

Maybe you are looking for

  • Printing with CSS

    How do I setup a specific area to print using CSS. Currently, I have a certain table with misc. info that I assigned a CSS class: <table.SingleListing> I would like to have visitors print this table (area) only and not the rest of the webpage.

  • Music button do nothing

    When I make a slideshow in iPhoto 8 I'm not able to select the music button to choose the music of the slideshow. The button is there (iTunes logo) but when I click on it, nothing happen. Someone have the same problem? This button work well in the pa

  • The import parameters were not filled correctly

    Hi BW guru's I am working on BW 3.O AND USING A FLAT FILE. I was trying to create hierachy to a infoobject(SalesrepID-SREP). First i enabled the (with hierarchies) tab under the hierarchy tab of change characteristics of SalesrepID, and selected the

  • Data Loader

    The company has two sales commissions spread sheets coming in. One based on employee number. The other basedon SSN. The staging table should contain both employee number and SSN.How will you load the data for both of these spread sheets using sql loa

  • Central time not working?

    I've got an issue with my MacBook running 10.6.8 and Google Chrome.  My mail is 5 hours off, even though I have all of the time zones and time correctly set, in both Google and on the computer.  I checked under WinXp which I run on the same machine,