一、BEx 3.X可用API函数列表
1. Function SAPBEXinitConnection(Optional newConnectionObj As Object) As Boolean
Set up a connection to BW Server
2. Function SAPBEXgetConnection(Optional what As Integer) As Variant
Get the existing connection object if already connected to BW server by help of BEX
3. Sub SAPBEXattachGIS(Optional refreshOnly As Boolean)
Attach GIS-MAP (same as clicking the BEX-Toolbar button)
4. Sub SAPBEXpauseOn()
In case you like to fire more than one API command (like two individual filter values) without immediate refresh
5. Sub SAPBEXpauseOff()
After this command all of the commands called after SAPBEXpauseOn will be executed
6. Function SAPBEXsetVariables(varValues As Range) As Integer
Set variable Values for User to provide Pop-Up Filter selections (Filter dialogs will be disabled if properly filled)
7. Function SAPBEXrefresh(allQueries As Boolean, Optional atCell As Range) As Integer
Refresh either all Queries in Workbook allQueries=FALSE or selected Queries by identifying the Query range
8. Function SAPBEXsetDrillState(newState As Integer, Optional atCell As Range) As Integer
Set the Drill state via coding to: vertical (newState=1) or horizontal (newState=2) or no drill state (newState=0)
9. Function SAPBEXgetDrillState(currentState As Integer, Optional atCell As Range) As Integer
Find out what DrillState is defined for a specific object
10. Function SAPBEXsetFilterValue(intValue As String, Optional hierValue As String, Optional atCell As Range) As Integer
Set a filter value for a specific characterictic ( i.E. 0CUSTOMER = 1002) to filter either on simple or hierarchy values.
11. Function SAPBEXgetFilterValue(intValue As String, hierValue As String, Optional atCell As Range) As Integer
Get a filter value for a specific characterictic ( i.E. 0CUSTOMER) to use it later on either on simple or hierarchy node.
12. Function SAPBEXcopyFilterValue(fromCell As Range, Optional atCell As Range) As Integer
Copy a filter value for a specific characteristic see our little example above
13. Function SAPBEXfireCommand(fCode As String, Optional atCell As Range) As Integer
Fire commands like remote control context menu or toolbar (values can be found via Trace file)
14. Function SAPBEXcheckContext(fCode As String, Optional atCell As Range) As Integer
Check if an OLAP command like SAPBEXfireCommand can be used on that particular cell
15. Function SAPBEXshowTextElements(Optional selectGroup As String, Optional atCell As Range) As Integer
Like display of text elements (filters, global values) via Toolbar
16. Function SAPBEXjump(jumpType As String, jumpTarget As String, Optional atCell As Range) As Integer
ReportReport Interface(RRI) ; Jump to a specified Workbook or view
17. Function SAPBEXgetResultRangeByID(ByVal queryID As String, Optional ByVal charName As String) As Range
Find out where data from query is being displayed; for example in case you like to add data to last column
18. Function SAPBEXsaveWorkbook(Optional wbName As String) As Integer
Save your workbook after refresh (no name needed) or save as new file
19. Function SAPBEXreadWorkbook(wbID As String) As String
Open your workbook via Workbook ID (GUID) see text above for later use
20. Function SAPBEXgetWorkbookID(wbName As String) As String
Find out workbook Id by open Workbook by 'human friendly' name. Return value is GUID
21. Function SAPBEXembedQuery(genUID As String, Optional atActiveCell As Boolean) As String
Like Toolbar function; embed a new query (not workbook) to your active workbook.
二、函数调用样例(Functions to Automate and Enhance Your BW Reports in Excel)
The following examples illustrate some of the functionality supported by the BEx API. See March 2004 BW Expert (page 10) for the complete list of functions and their corresponding numbers. Note that this is a partial list of the functions and some of the code offered below is used to combine features and build new functionality.
Functions 1 and 2 can be combined along with the following code to establish a connection with the server:
Public Function LogonToYourBW()
' create Logon & RFC-Handle
logonToBW = False ‘ clear connect Flag the flag can be used to find out if connected or not
'load SAP functionality by opening BEX file ( use your installation path)
Workbooks.Open (“c:\sappc\bw\sapbex.xla”)
With Run("sapbex.xla!sapbexGetConnection") ‘ call the connection
' Set the params for Auto logon
.client = “YOUR CLIENT NO”
.user = “YOUR BW USER”
.Password = “YOUR BW PWD” ‘ I recommend to create a dummy reporting user for this task
.Language = “YOUR LANGUAGE YOU LIKE TO USE FOR QUERY DISPLAY ( i.E. “EN”)”
.SystemNumber = “YOUR SYSTEM NO” ‘
.ApplicationServer = “YOUR SERVER Name OR IP-ADDRESS”
.UseSAPLOgonIni = FALSE 'important for automatic connection
.logon 0, True ‘ This will provide a dialog to appear
If .IsConnected <> 1 Then
.logon 0, False
If .IsConnected <> 1 Then Exit Function
Else
Set g_oFunction = CreateObject("SAP.Functions")
Set g_oFunction.Connection = g_oConnection
End If
End With
Run "sapbex.xla!sapbexinitConnection" ‘ this will enable the connection you just created
logonToBW = True
End Function
Function 7 can be used to refresh queries in an active workbook. To refresh all queries, set the first parameter to True and use the following code:
If Run("sapbex.xla!SAPBEXrefresh", True) = 0 Then
Else
MsgBox " Error in Refresh"
To refresh a single query, reference a valid cell in the query (navigation or filter area or result area)
‘Set the values for Variables
Dim rngVar as Range
Set rngVar = YOUR_VARIABLE_SHEET.Range(“A2:H3”)
Run "SAPBEXsetVariables", rngVar
If Run("SAPBEX.xla!SAPBEXrefresh", False, ActiveSheet.Range("C7")) = 0 Then
Else
MsgBox "Error in Refresh”
End If
Function 8 and 9 allow you to change the drill down status in a report, either across or down, to hide certain areas while providing some basic functionality to users. The code below is to create a button for users to drill down or across (horizontal or vertical). Note the following values for myDrillState:
myDrillState = 0No drilldown”
myDrillState = 1Drilldown is vertical
myDrillState = 2Drilldown is horizontal
Coding for user button:
Sub btn_Customer_Click()
Dim myDrillState As Integer
Dim myFilterCell As Range
‘Set your filter cell
Set myFilterCell = ActiveSheet.Range(“C13”)
‘Now get the actual status
If Run( "SAPBEX.XLA!SAPBEXgetDrillState", myDrillState, myFilterCell) = 0 then
myState = Run("SAPBEX.XLA!SAPBEXgetDrillState_currentState")
‘ Depending on found ststus set the opposite ( toggle) state
If myState = 0 Then
If Run( "SAPBEX.XLA!SAPBEXsetDrillState", 1, myFilterCell) = 0 Then
Else
MsgBox “Error in Drill”
End If
Else
If Run ("SAPBEX.XLA!SAPBEXsetDrillState", 0, myFilterCell) = 0 Then
Else
MsgBox “Error in Drill”
End If
End If
End If
End Sub
Function 12 allows more complex commands to be executed than those available from the context menu. The code below sorts first by text ( SOAT) , then by characteristic by key (SOAK). To set the code up, first search your trace file for the OLAP function:
XLA: 13:31:28 calling OLAP function
XLA: - function code: SOAT
XLA: - array: Sheet1!$C$30:$EI$87
XLA: - Called AllowSetForegroundWindow, Result: True(<>0 is good)
...
...
XLA: 13:32:20 calling OLAP function
XLA: - function code: SOAK
Use the OLAP references to drill by a specific hierarchy level (HX03), in the case Level 3 (HX06 would be Hierarchy eXpand Level 06):
Function SetBexCommand()
'Function to change the hierarchy Drill Level as Example
Dim strCommand As String
Dim myCell As Range
strCommand = "HX03"
‘ Can be any valid ( Navigation Area or Data Area Range)
‘ I am setting the command to my customer in cel D11
Set myCell = Range(“D11”)
If Run("sapbex.xla!SAPBEXfireCommand", strCommand, ActiveSheet.Range(strMyCell)) = 0 Then
Else
MsgBox “Error in Hierarchy Command”
End If
End Function
Function 14 validates a function in a particular cell (Note: It is recommend that you use this function before the SAPBEXfireCommand to avoid errors in your code)
Function SetBexCommand()
Dim strCommand As String
Dim myCell As Range
strCommand = "HX03"
Set myCell = Range(“D11”)
If Run("sapbex.xla!SAPBEXCheckCommand", strCommand, ActiveSheet.Range(strMyCell)) = 0 Then
If Run("sapbex.xla!SAPBEXFireCommand", strCommand, ActiveSheet.Range(strMyCell)) = 0 Then
Else
MsgBox “Error in Hierarchy Command”
End If
End If
End Function
Function 15 turns on text information not implemented in an active workbook.
The following values can be used:
selectGroup = blank or "*": Show all text elements
selectGroup = "C": Show only general text elements (created by, changed on,...)
selectGroup = "F": Show filter only
selectGroup = "V": Show variables only
This example uses selectGroup = "C" to insert data into a footer in Excel
Function Get_text_Elem()
Dim selectGroup As String
Dim myRange As Range
selectGroup = "C"
Set myRange = ActiveSheet.Range("C23")
If Run("SAPBEXshowTextElements", selectGroup) = 0 Then
Else
MsgBox "Error in Textelements"
End If
End Function
Function 16 provides access to the Report Report Interface (RRI) to jump directly to another query.
View as Jump target
Private Sub CommandButton1_Click()
If Run("SAPBEX.XLA!SAPBEXjump", "v", "My jump view", ActiveSheet.Range("D19")) = 0 Then
Else
MsgBox "ERROR in Jump Target"
End If
End Sub
Query Jump target via RSBBS
Private Sub CommandButton1_Click()
If Run("SAPBEX.XLA!SAPBEXjump", "r", "QURY0001", ActiveSheet.Range("D19")) = 0 Then
Else
MsgBox "ERROR in Jump Target"
End If
End Sub
Function 18 automatically saves your workbooks.
Private Sub CommandButton1_Click()
If Run("SAPBEX.XLA!SAPBEXsaveWorkbook") = 0 Then
Else
MsgBox "ERROR WB save"
End If
End Sub
Function 19 opens workbooks without the BEx toolbar.
Private Sub CommandButton1_Click()
Dim strWBID As String
Dim strTmp As String
strWBID = "2A024RULBDK33U5BNZH60433U"
strTmp = Run("SAPBEX.XLA!SAPBEXreadWorkbook", strWBID)
If strTmp = "" Then
MsgBox "ERROR WB Read"
End If
End Sub
Function 20 translates the human friendly name to the GUID being stored on the BW server.
Private Sub CommandButton1_Click()
Dim strWBName As String
Dim strWBID As String
strWBName = "Testquery Jump"
strWBID = "2A024RULBDK33U5BNZH60433U"
strWBID = Run("SAPBEX.XLA!SAPBEXreadWorkbook", strWBName)
If strWBID = "" Then
MsgBox "ERROR get WBID"
End If
End Sub
Function 21 can be used to dynamically insert queries into an Excel workbook. There are two ways of using the function:
1.Boolean Value TRUE for the second parameter of that function, which will insert the query where you defined the active cell.
2.Leave the second function value blank, which open a new Workbook for a particular query.
Private Sub CommandButton1_Click()
Dim strQueryID As String
Dim strTmp As String
strQueryID = "85RFOO9I0FXTZOK5GP6X2UVNA"
ActiveWorkbook.Sheets("Sheet1").Range("A10").Select
strTmp = Run("SAPBEX.XLA!SAPBEXEmbedQuery", strQueryID)
If strTmp = "" Then
MsgBox "ERROR Insert Query"
End If
End Sub
Combine Functions 4, 5, and 10 to create multiple function calls. Function 3, 4, and 10 can be combined to first stop the automatism in BEX, then collect all function calls, and execute the functions in batch:
Run "sapbex.xla!SAPBEXpauseOn()" ‘This will stop all automatic refreshes by SAP
‘Set the values for Variable 1
If Run("SAPBEX.xla! SAPBEXSetFilterValue",YOUR_1_VARIABLE_VALUE,””, Sheets("Query_A").Range("B7")) = 0 Then
Else
MsgBox "Function failed"
End If
‘Set the values for Variable 2
If Run("SAPBEX.xla! SAPBEXSetFilterValue",YOUR_2_VARIABLE_VALUE,””, Sheets("Query_A").Range("B5")) = 0 Then
Else
MsgBox "Function failed"
End If
Run "sapbex.xla!SAPBEXpauseOn()"‘This will turn on all automatic refreshes by SAP and execute all functions since PauseOn
分享到:
相关推荐
【标题】"(Y33S-99CT_2010.3.3)畅想bex818.img" 提供的信息表明这可能是一个针对特定设备或系统的固件镜像文件。在这个标题中,“Y33S-99CT”可能是设备型号或者硬件版本的标识符,而“2010.3.3”则可能是固件的发布...
Installing business content and creating an R/3 source system in BW Loading data from SAP R/3 into SAP BW Data maintenance Performance tuning, including parallel query option and data packet ...
在进行SAP BW(Business Warehouse)与BO(BusinessObjects)集成的过程中,尤其是将BW的BEx查询与BO的Web Intelligence(Webi)集成时,需要注意以下关键知识点: 1. 在交付BEx查询前,必须确保查询选项中的“允许...
Nevrona Rave 5.1.2.BEX.Full.Sources.For.Delphi.BCB
在压缩包中,"rave_bex_5_1_3.exe"很可能是Rave Reports的安装程序,"RAVE5KG.EXE"可能是一个补丁或密钥生成器,用于激活软件。"Rave.Reports.v5.1.3.D4-7.CB4-6.FS.gif"是一个截图文件,可能展示了Rave Reports的...
BEX Analyzer,BEX与EXCEL的结合工具,可以查看BEX QUERY设计的报表并且自定义格式,上钻下溯等操作,功能强大,期待你的发现~
Nevrona Rave Reports BEX v6.0.2 是一个专为Delphi和BCB(Borland C++ Builder)设计的高级报表控件,它是Delphi 7自带报表组件的升级版本。这个控件集成了强大的报表设计功能,能够帮助开发者创建复杂的打印报表,...
【标题】"rave_bex_11_0_3.rar" 指的是一款名为 Rave BEX 的软件的版本号为 ...安装 "rave_bex_11_0_3.exe" 后,开发者可以将其集成到 Delphi 工程中,利用其提供的组件和API来构建报表功能,提升应用的业务分析能力。
SAP Basic Technology - SAPBW and BEx Suite
5. `BeX-desktop`:这个目录可能包含了BeX在桌面环境下的实现或版本,可能支持Windows、MacOS或Linux等操作系统,供开发者在非移动设备上进行游戏开发和测试。 综上所述,BeX是一个开源的软件项目,主要用于Android...
3.在Object Inspector中,设置DataSet的属性为一个已在你的应用程序中定义的dataset组件.使用Rave Visual Designer 4.去设计你的报表然后并创建一个report project文件(.rav file). 选择Tools|Rave Designer运行...
《Nevrona Rave Reports BEX v6.0.5 for Delphi & BCB 全源码解析》 Nevrona Rave Reports是一款在Delphi和BCB(Borland C++ Builder)开发环境中广泛使用的专业报表设计工具。其BEX(Business Extension)版本v...
本文档主要介绍了在SAP BW环境中如何利用用户出口(User Exit)来处理BEx报表中的复杂变量逻辑。这一过程涉及大量的ABAP编程工作,并且特别关注了如何使用特定的用户出口`EXIT_SAPLRRS0_001`来处理查询设计器中创建的...
ABAP in BW是SAP BW(商务仓库)系统中用于编程和增强后端功能的ABAP(高级企业应用编程)技术的专称。本知识点将从ABAP在BW中的应用、性能优化、增强机制以及数据处理等方面进行详细解读。 首先,ABAP in BW的学习...
【压缩包子文件的文件名称列表】: bex-master.zip 暗示着这个压缩包是项目的主分支或主线版本,"master"通常是Git版本控制系统中的默认分支,代表了项目的主要开发线。解压这个zip文件后,我们可能会找到项目的基本...
Rave Reports is an advanced suite of components for Delphi and C++Builder that allow the development of powerful and flexible database reporting. Features include: Rave Visual Report Designer ...
SAP Business Explorer(简称SAP BEx)是SAP Business Warehouse (SAP BW) 下的一个重要组件,旨在为企业用户提供一系列高效的数据分析、报告生成及Web应用程序开发工具。它不仅支持OLAP和企业级报告的需求,还能够...
本介绍部分首先对比了SAP BW 3.x版本的BEx Suite与SAP NetWeaver 2004s中的BI工具,并提出了一种分阶段的迁移策略。这种策略有助于最小化迁移过程中可能出现的复杂性问题,避免用户在短时间内被迫适应多种工具,同时...
### SAP BW文档 330 知识点详解 #### 一、SAP BW 概述 SAP BW(Business Warehouse)是SAP提供的一款强大的企业级数据仓库解决方案,它能够帮助企业从各种来源收集、整理并分析数据,从而支持业务决策。通过SAP BW...
Delonghi德龙ESAM3000.BEX1&ESAM3200.SEX1 咖啡机说明书.pdf