一、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 小板
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 ...
Nevrona Rave 5.1.2.BEX.Full.Sources.For.Delphi.BCB
Nevrona.Rave.Reports.BEX.v6.0.5.for.Delphi.BCB.Full.Source删除了为认为多于的东西!
D7开始Borland公司自带的报表组件包,适用于Delphi4-7和C++Builder4-6,包含了可视化编辑器和基于报表库的代码,当前版本v5.1.3,此压缩包包含站长提供的汉化文件。
BEX Analyzer,BEX与EXCEL的结合工具,可以查看BEX QUERY设计的报表并且自定义格式,上钻下溯等操作,功能强大,期待你的发现~
SAP Basic Technology - SAPBW and BEx Suite
就是delphi7自带的报表控件的新版
3.在Object Inspector中,设置DataSet的属性为一个已在你的应用程序中定义的dataset组件.使用Rave Visual Designer 4.去设计你的报表然后并创建一个report project文件(.rav file). 选择Tools|Rave Designer运行...
rave_bex_11_0_3.rar
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 ...
Delonghi德龙ESAM3000.BEX1&ESAM3200.SEX1 咖啡机说明书.pdf
Be.X开放源代码与Newton Lee所著的“请先阅读我:适用于儿童和成人的Android游戏开发”(ISBN 978-0-9889810-2-7和ISBN 978-1489580344)一起使用。
贝克斯 bex.world官方源代码存储库
Rave BEX reports can be compiled into Delphi and C++Builder applications or stored externally on disk or in a database. An optional End User Designer license provides for the distribution of the Rave...
介绍在SAP bw的报表中如何通过出口更改变量值及自动填充变量值。
新的客户信息API取代了旧的BEX API,该API已在。 客户详细信息在其他BaufiSmart API(Vorgaenge-API或Request-API)中也称为记录数据。 文件资料 欢迎将有关该模型的反馈和问题作为。 API的用例 根据潜在客户应用...
Data Transformation in SAP BW 241 Architecture and Data Flow 241 Persistency Considerations 242 Multilevel Staging Considerations 243 Transfer Rules 245 Conversion Exits 246 InfoObject Assignment ...
这篇文档是根据自己的摸索总结出来的比较详尽的BEx Analyzer使用方面的资料 文档中附有图片 操作步骤等 清晰明了 是关于SAP BW方面的资料。
点击“添加到Chrome”,即表示我接受并同意安装“货币转换”扩展程序,并将“ Chrome:trade_mark:新标签页”设置为该服务以及隐私权(bex-digital.com/privacy-policy)和使用条款(bex -digital....