SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
Using the VBA API in SAP BusinessObjects
Analysis Office 1.1
Tobias Kaufmann
SAP Customer Solution Adoption
Legal disclaimer


This presentation is not subject to your license agreement or any other agreement
with SAP. SAP has no obligation to pursue any course of business outlined in this
presentation or to develop or release any functionality mentioned in this
presentation. This presentation and SAP's strategy and possible future
developments are subject to change and may be changed by SAP at any time for
any reason without notice. This document is provided without a warranty of any
kind, either express or implied, including but not limited to, the implied warranties of
merchantability, fitness for a particular purpose, or non-infringement. SAP assumes
no responsibility for errors or omissions in this document, except if such damages
were caused by SAP intentionally or grossly negligent.




© 2011 SAP AG. All rights reserved.                                                    2
Agenda
API              Samples
 Introduction    Enable Analysis Office Add-In
                  Refresh
                  Drilldown with Button
                  Set Filter
                  Dynamic Grid
Introduction
Documentation


Use the online help in Analysis Office as reference for the API




© 2011 SAP AG. All rights reserved.                               4
Introduction
API – What for?


Building sophisticated BI workbooks
Using formulas
 Call formulas within cell
 Get and show information like filter values, meta data, and data
 Set filter component
Using macros
 Used in VBA editor (e.g. behind some developer items like buttons, check box etc.)
 Execute planning functions/sequences, set dimensions in grid, set filter, read cell context
  etc.
 Typically using application.run (“”….)




© 2011 SAP AG. All rights reserved.                                                             5
Agenda
API              Samples
 Introduction    Enable Analysis Office Add-In
                  Refresh
                  Drilldown with Button
                  Set Filter
                  Dynamic Grid
Enable Analysis Office Add-In


Scenario
 Ensure that the Analysis Office Add-In is loaded
 Before the workbook macros are executed




© 2011 SAP AG. All rights reserved.                  7
Enable Analysis Office Add-In


Implement Workbook_Open in ThisWorkbook
  Loop all COMAddIns
  Set Connect to True for Analysis Office



Option Explicit
Private Sub Workbook_Open()
     Call EnableAnalysisOffice
End Sub
Private Sub EnableAnalysisOffice()
     Dim addin As COMAddIn
     For Each addin In Application.COMAddIns
            If addin.progID = "SBOP.AdvancedAnalysis.Addin.1" Then
                   If addin.Connect = False Then addin.Connect = True
            End If
     Next
End Sub


© 2011 SAP AG. All rights reserved.                                     8
Agenda
API              Samples
 Introduction    Enable Analysis Office Add-In
                  Refresh
                  Drilldown with Button
                  Set Filter
                  Dynamic Grid
Refresh


Scenario
 Ensure data is refreshed if needed
 Before calling own functions or SAP function
 Use error handling for refresh




© 2011 SAP AG. All rights reserved.              10
Refresh


Use SAPExecuteCommand with Refresh
  Refresh on error handling

Public Function MyGetData() As String
     Dim lCellContent As String
     On Error GoTo refresh
     lCellContent = Application.Run("SAPGetData", "DS_1", "4J97S26KX1BYBQ4GGQJNZGD9T", "0D_PH1=DS20")
     MyGetData = lCellContent
     Exit Function
refresh:
     Dim lResult As Long
     MsgBox "Refresh“
     lResult = Application.Run("SAPSetRefreshBehaviour", "Off")
     lResult = Application.Run("SAPExecuteCommand", "Refresh")
     lResult = Application.Run("SAPSetRefreshBehaviour", "On“)
     lCellContent = Application.Run("SAPGetData", "DS_1", "4J97S26KX1BYBQ4GGQJNZGD9T", "0D_PH1=DS20“)
     MyGetData = lCellContent
End Function


© 2011 SAP AG. All rights reserved.                                                                11
Refresh


Tip
  In case you are implementing your own formula (public function)
  Which is refreshing the data
  You should change the refresh behavior before and after this call

  Or use the Refresh Workbook on Opening option

Dim lResult as long

lResult = Application.Run("SAPSetRefreshBehaviour", "Off")

lResult = Application.Run("SAPExecuteCommand", "Refresh")

lResult = Application.Run("SAPSetRefreshBehaviour", "On")




© 2011 SAP AG. All rights reserved.                                    12
Agenda
API              Samples
 Introduction    Enable Analysis Office Add-In
                  Refresh
                  Drilldown with Button
                  Set Filter
                  Dynamic Grid
Drilldown with Button
Define Button with some actions


Scenario
 Read current cell information for current dimension
 Place new dimension “year” before the current dimension




© 2011 SAP AG. All rights reserved.                         14
Drilldown with Button
Step 1: Insert Button and Create Macro


Insert Button
 Use “developer” tab
  (in case you don’t see it,
  you might need to activate it in your Excel settings)




Create macro (that executes on click)



© 2011 SAP AG. All rights reserved.                       15
Drilldown with Button
Step 2: Get Cell Context


Use SAPGetCellInfo
     IResult = Application.Run("SAPGetCellInfo", ActiveCell, "DIMENSION")
     Reads context of cell that the cursor is placed on (ActiveCell)
     Requests dimension information
     lResult(1) will contain the data source alias
     Iresult(2) will contain the dimension key


Option Explicit

Sub Button1_Click()

      Dim lResult

      On Error GoTo leave

      lResult = Application.Run("SAPGetCellInfo", ActiveCell, "DIMENSION")

...




© 2011 SAP AG. All rights reserved.                                          16
Drilldown with Button
Step 3: Define drilldown


Use SAPMoveDimension
  OkCode = Application.Run("SAPMoveDimension", IResult(1), "0CALYEAR", "BEFORE",
   IResult(2))
  Inserts dimension “0CALYEAR” in currently chosen data source before (“BEFORE”) the
   dimension that the cursor is placed on

Option Explicit

Sub Button1_Click()

     Dim lResult
     Dim OkCode

     On Error GoTo leave

     lResult = Application.Run("SAPGetCellInfo", ActiveCell, "DIMENSION")

     OkCode = Application.Run("SAPMoveDimension", lResult(1), "0CALYEAR", "BEFORE", lResult(2))

leave:

End Sub



© 2011 SAP AG. All rights reserved.                                                               17
Drilldown with Button
Result




© 2011 SAP AG. All rights reserved.   18
Drilldown with Button


Tip
  Improve error handling by combining…
    1.     Enable Analysis Office Add-In (see other slide)
    2.     Refresh
    3.     Drilldown with Button
Option Explicit
Sub Button1_Click()
    Dim lResult
    On Error GoTo leave
    lResult = Application.Run("SAPGetCellInfo", ActiveCell, "DIMENSION")
    lResult = Application.Run("SAPMoveDimension", lResult(1), "0CALYEAR", "BEFORE", lResult(2))
    Exit Sub
leave:
    lResult = Application.Run("SAPSetRefreshBehaviour", "Off")
    lResult = Application.Run("SAPExecuteCommand", "Refresh")
    lResult = Application.Run("SAPSetRefreshBehaviour", "On“)
    lResult = Application.Run("SAPGetCellInfo", ActiveCell, "DIMENSION")
    If IsError(lResult) = True Then
        MsgBox "No dimension selected."
    Else
        lResult = Application.Run("SAPMoveDimension", lResult(1), "0CALYEAR", "BEFORE", lResult(2))
    End If
End Sub



© 2011 SAP AG. All rights reserved.                                                               19
Agenda
API              Samples
 Introduction    Enable Analysis Office Add-In
                  Refresh
                  Drilldown with Button
                  Set Filter
                  Dynamic Grid
Set Filter


Scenario
 Use function SAPSetFilter to set a filter
 Use parameter Member Format for selecting single or multiple values
 Use combo boxes for choosing parameter and values




© 2011 SAP AG. All rights reserved.                                     21
Set Filter


Insert Combobox



Format Control




Define Input range (values in dropdown)
and Cell Link (selected index)




© 2011 SAP AG. All rights reserved.       22
Set Filter


Use second sheet for values
(Input range)



And selected index
(Cell link)



Transform selected index into
value for SAPSetFilter
using formula INDEX




© 2011 SAP AG. All rights reserved.   23
Set Filter


Assign macro to control

Option Explicit

Sub DropDown2_Change()
    Dim selectedType As String
    Dim selectedValue As String
    Dim dimension As String
    Dim formulaAlias As String
    Dim r

    selectedType = Worksheets("Sheet2").Range("C1").Value
    selectedValue = Worksheets("Sheet2").Range("C7").Value
    dimension = "0D_PH2"
    formulaAlias = "DS_1"
    r = Application.Run("SAPSetFilter", formulaAlias, dimension, selectedValue, selectedType)
End Sub




© 2011 SAP AG. All rights reserved.                                                             24
Agenda
API              Samples
 Introduction    Enable Analysis Office Add-In
                  Refresh
                  Drilldown with Button
                  Set Filter
                  Dynamic Grid
Dynamic Grid


Scenario
 Use event Workbook_SheetChange to react on changes



                                                 Press Delete Key


                                           Type dimension
                                           and press return




                                      F4

© 2011 SAP AG. All rights reserved.                                 26
Summary
Download


All samples are available via the following link

https://sapmats-de.sap-
ag.de/download/download.cgi?id=SZMBCX9HYNLGEPDM4GWXZ865CWSHX4
YXWNN8BILFYW38Y7HMHX

If the link is invalid, please contact tobias.kaufmann@sap.com




© 2011 SAP AG. All rights reserved.                              28
Thank You!


Contact information:

Tobias Kaufmann
RIG Expert
tobias.kaufmann@sap.com

Weitere ähnliche Inhalte

Was ist angesagt?

SQL Server 2008 New Features
SQL Server 2008 New FeaturesSQL Server 2008 New Features
SQL Server 2008 New FeaturesDan English
 
Mss new object_data_provider_(oadp)
Mss new object_data_provider_(oadp)Mss new object_data_provider_(oadp)
Mss new object_data_provider_(oadp)Juanfe1978
 
Business Intelligence Technology Presentation
Business Intelligence Technology PresentationBusiness Intelligence Technology Presentation
Business Intelligence Technology PresentationJohn Paredes
 
Step by step procedure for loading of data from the flat file to the master d...
Step by step procedure for loading of data from the flat file to the master d...Step by step procedure for loading of data from the flat file to the master d...
Step by step procedure for loading of data from the flat file to the master d...Prashant Tyagi
 
SAP Crystal Reports & SAP HANA - Integration and Roadmap
SAP Crystal Reports & SAP HANA - Integration and RoadmapSAP Crystal Reports & SAP HANA - Integration and Roadmap
SAP Crystal Reports & SAP HANA - Integration and RoadmapKenneth Li
 
New dimensions for_reporting
New dimensions for_reportingNew dimensions for_reporting
New dimensions for_reportingRahul Mahajan
 
Essbase beginner's guide olap fundamental chapter 1
Essbase beginner's guide olap fundamental chapter 1Essbase beginner's guide olap fundamental chapter 1
Essbase beginner's guide olap fundamental chapter 1Amit Sharma
 
James Jara Portfolio 2014 - Enterprise datagrid - Part 3
James Jara Portfolio 2014  - Enterprise datagrid - Part 3James Jara Portfolio 2014  - Enterprise datagrid - Part 3
James Jara Portfolio 2014 - Enterprise datagrid - Part 3James Jara
 
Cognos framework manager
Cognos framework managerCognos framework manager
Cognos framework managermaxonlinetr
 
Part2 Best Practices for Managing Optimizer Statistics
Part2 Best Practices for Managing Optimizer StatisticsPart2 Best Practices for Managing Optimizer Statistics
Part2 Best Practices for Managing Optimizer StatisticsMaria Colgan
 
An introduction to new data warehouse scalability features in sql server 2008
An introduction to new data warehouse scalability features in sql server 2008An introduction to new data warehouse scalability features in sql server 2008
An introduction to new data warehouse scalability features in sql server 2008Klaudiia Jacome
 
Planning learn step by step
Planning learn step by stepPlanning learn step by step
Planning learn step by stepksrajakumar
 
Obiee interview questions and answers faq
Obiee interview questions and answers faqObiee interview questions and answers faq
Obiee interview questions and answers faqmaheshboggula
 
MSBI-SQL Server Reporting Services
MSBI-SQL Server Reporting ServicesMSBI-SQL Server Reporting Services
MSBI-SQL Server Reporting ServicesThejaswi shasthri
 

Was ist angesagt? (20)

SQL Server 2008 New Features
SQL Server 2008 New FeaturesSQL Server 2008 New Features
SQL Server 2008 New Features
 
Mss new object_data_provider_(oadp)
Mss new object_data_provider_(oadp)Mss new object_data_provider_(oadp)
Mss new object_data_provider_(oadp)
 
Cool features 7.4
Cool features 7.4Cool features 7.4
Cool features 7.4
 
Business Intelligence Technology Presentation
Business Intelligence Technology PresentationBusiness Intelligence Technology Presentation
Business Intelligence Technology Presentation
 
Step by step procedure for loading of data from the flat file to the master d...
Step by step procedure for loading of data from the flat file to the master d...Step by step procedure for loading of data from the flat file to the master d...
Step by step procedure for loading of data from the flat file to the master d...
 
SAP Crystal Reports & SAP HANA - Integration and Roadmap
SAP Crystal Reports & SAP HANA - Integration and RoadmapSAP Crystal Reports & SAP HANA - Integration and Roadmap
SAP Crystal Reports & SAP HANA - Integration and Roadmap
 
New dimensions for_reporting
New dimensions for_reportingNew dimensions for_reporting
New dimensions for_reporting
 
Essbase beginner's guide olap fundamental chapter 1
Essbase beginner's guide olap fundamental chapter 1Essbase beginner's guide olap fundamental chapter 1
Essbase beginner's guide olap fundamental chapter 1
 
Hyperion Planning Overview
Hyperion Planning OverviewHyperion Planning Overview
Hyperion Planning Overview
 
320 2009
320 2009320 2009
320 2009
 
Whats new 2011
Whats new 2011Whats new 2011
Whats new 2011
 
James Jara Portfolio 2014 - Enterprise datagrid - Part 3
James Jara Portfolio 2014  - Enterprise datagrid - Part 3James Jara Portfolio 2014  - Enterprise datagrid - Part 3
James Jara Portfolio 2014 - Enterprise datagrid - Part 3
 
Cognos framework manager
Cognos framework managerCognos framework manager
Cognos framework manager
 
Part2 Best Practices for Managing Optimizer Statistics
Part2 Best Practices for Managing Optimizer StatisticsPart2 Best Practices for Managing Optimizer Statistics
Part2 Best Practices for Managing Optimizer Statistics
 
An introduction to new data warehouse scalability features in sql server 2008
An introduction to new data warehouse scalability features in sql server 2008An introduction to new data warehouse scalability features in sql server 2008
An introduction to new data warehouse scalability features in sql server 2008
 
Planning learn step by step
Planning learn step by stepPlanning learn step by step
Planning learn step by step
 
Obiee interview questions and answers faq
Obiee interview questions and answers faqObiee interview questions and answers faq
Obiee interview questions and answers faq
 
MSBI-SQL Server Reporting Services
MSBI-SQL Server Reporting ServicesMSBI-SQL Server Reporting Services
MSBI-SQL Server Reporting Services
 
Analysis edition for olap
Analysis edition for olapAnalysis edition for olap
Analysis edition for olap
 
SAP BW connect db
SAP BW connect dbSAP BW connect db
SAP BW connect db
 

Ähnlich wie Bo analusis macros

Debugger & Profiler in NetBeans
Debugger & Profiler in NetBeansDebugger & Profiler in NetBeans
Debugger & Profiler in NetBeansHuu Bang Le Phan
 
CO_TM_Controlling_co-om Master Data .pdf
CO_TM_Controlling_co-om Master Data .pdfCO_TM_Controlling_co-om Master Data .pdf
CO_TM_Controlling_co-om Master Data .pdfssuser878ec2
 
Sap enhancement packages
Sap enhancement packagesSap enhancement packages
Sap enhancement packagesJoyce Maina
 
Getting Started with Nastel AutoPilot Business Views and Policies - a Tutorial
Getting Started with Nastel AutoPilot Business Views and Policies - a TutorialGetting Started with Nastel AutoPilot Business Views and Policies - a Tutorial
Getting Started with Nastel AutoPilot Business Views and Policies - a TutorialSam Garforth
 
Lecture07 abap on line
Lecture07 abap on lineLecture07 abap on line
Lecture07 abap on lineMilind Patil
 
EA261_2015_Exercises
EA261_2015_ExercisesEA261_2015_Exercises
EA261_2015_ExercisesLuc Vanrobays
 
Gephi Plugin Developer Workshop
Gephi Plugin Developer WorkshopGephi Plugin Developer Workshop
Gephi Plugin Developer WorkshopGephi Consortium
 
Fi enhancement technique how-to-guide on the usage of business transaction ...
Fi enhancement technique   how-to-guide on the usage of business transaction ...Fi enhancement technique   how-to-guide on the usage of business transaction ...
Fi enhancement technique how-to-guide on the usage of business transaction ...Kranthi Kumar
 
Fi enhancement technique how-to-guide on the usage of business transaction ...
Fi enhancement technique   how-to-guide on the usage of business transaction ...Fi enhancement technique   how-to-guide on the usage of business transaction ...
Fi enhancement technique how-to-guide on the usage of business transaction ...Rajeev Kumar
 
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docxCASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docxketurahhazelhurst
 
AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1guest38bf
 
How to create_an_ecatt
How to create_an_ecattHow to create_an_ecatt
How to create_an_ecattMohammed Azhad
 
0801 sap business_workflow_and_business_rules_framework_plus_brfplus
0801 sap business_workflow_and_business_rules_framework_plus_brfplus0801 sap business_workflow_and_business_rules_framework_plus_brfplus
0801 sap business_workflow_and_business_rules_framework_plus_brfplusRivalino Pereira
 
Essbase Today - MindStream Analytics
Essbase Today - MindStream AnalyticsEssbase Today - MindStream Analytics
Essbase Today - MindStream Analyticsmindstremanalysis
 
Summer ‘14 Release Training by Astrea
Summer ‘14 Release Training by AstreaSummer ‘14 Release Training by Astrea
Summer ‘14 Release Training by Astreapriyanshi_astrea
 
How to create generic delta
How to create generic deltaHow to create generic delta
How to create generic deltaJacques Kalees
 
Diving into VS 2015 Day5
Diving into VS 2015 Day5Diving into VS 2015 Day5
Diving into VS 2015 Day5Akhil Mittal
 
Adapters db-104-informixstoredprocedure
Adapters db-104-informixstoredprocedureAdapters db-104-informixstoredprocedure
Adapters db-104-informixstoredprocedureprathap kumar
 
Performance tuning in sap bi 7.0
Performance tuning in sap bi 7.0Performance tuning in sap bi 7.0
Performance tuning in sap bi 7.0gireesho
 

Ähnlich wie Bo analusis macros (20)

Debugger & Profiler in NetBeans
Debugger & Profiler in NetBeansDebugger & Profiler in NetBeans
Debugger & Profiler in NetBeans
 
CO_TM_Controlling_co-om Master Data .pdf
CO_TM_Controlling_co-om Master Data .pdfCO_TM_Controlling_co-om Master Data .pdf
CO_TM_Controlling_co-om Master Data .pdf
 
Sap enhancement packages
Sap enhancement packagesSap enhancement packages
Sap enhancement packages
 
Getting Started with Nastel AutoPilot Business Views and Policies - a Tutorial
Getting Started with Nastel AutoPilot Business Views and Policies - a TutorialGetting Started with Nastel AutoPilot Business Views and Policies - a Tutorial
Getting Started with Nastel AutoPilot Business Views and Policies - a Tutorial
 
Lecture07 abap on line
Lecture07 abap on lineLecture07 abap on line
Lecture07 abap on line
 
EA261_2015_Exercises
EA261_2015_ExercisesEA261_2015_Exercises
EA261_2015_Exercises
 
Gephi Plugin Developer Workshop
Gephi Plugin Developer WorkshopGephi Plugin Developer Workshop
Gephi Plugin Developer Workshop
 
Fi enhancement technique how-to-guide on the usage of business transaction ...
Fi enhancement technique   how-to-guide on the usage of business transaction ...Fi enhancement technique   how-to-guide on the usage of business transaction ...
Fi enhancement technique how-to-guide on the usage of business transaction ...
 
Fi enhancement technique how-to-guide on the usage of business transaction ...
Fi enhancement technique   how-to-guide on the usage of business transaction ...Fi enhancement technique   how-to-guide on the usage of business transaction ...
Fi enhancement technique how-to-guide on the usage of business transaction ...
 
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docxCASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
 
AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1
 
How to create_an_ecatt
How to create_an_ecattHow to create_an_ecatt
How to create_an_ecatt
 
0801 sap business_workflow_and_business_rules_framework_plus_brfplus
0801 sap business_workflow_and_business_rules_framework_plus_brfplus0801 sap business_workflow_and_business_rules_framework_plus_brfplus
0801 sap business_workflow_and_business_rules_framework_plus_brfplus
 
sap
sap sap
sap
 
Essbase Today - MindStream Analytics
Essbase Today - MindStream AnalyticsEssbase Today - MindStream Analytics
Essbase Today - MindStream Analytics
 
Summer ‘14 Release Training by Astrea
Summer ‘14 Release Training by AstreaSummer ‘14 Release Training by Astrea
Summer ‘14 Release Training by Astrea
 
How to create generic delta
How to create generic deltaHow to create generic delta
How to create generic delta
 
Diving into VS 2015 Day5
Diving into VS 2015 Day5Diving into VS 2015 Day5
Diving into VS 2015 Day5
 
Adapters db-104-informixstoredprocedure
Adapters db-104-informixstoredprocedureAdapters db-104-informixstoredprocedure
Adapters db-104-informixstoredprocedure
 
Performance tuning in sap bi 7.0
Performance tuning in sap bi 7.0Performance tuning in sap bi 7.0
Performance tuning in sap bi 7.0
 

Kürzlich hochgeladen

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 

Kürzlich hochgeladen (20)

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 

Bo analusis macros

  • 1. Using the VBA API in SAP BusinessObjects Analysis Office 1.1 Tobias Kaufmann SAP Customer Solution Adoption
  • 2. Legal disclaimer This presentation is not subject to your license agreement or any other agreement with SAP. SAP has no obligation to pursue any course of business outlined in this presentation or to develop or release any functionality mentioned in this presentation. This presentation and SAP's strategy and possible future developments are subject to change and may be changed by SAP at any time for any reason without notice. This document is provided without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP assumes no responsibility for errors or omissions in this document, except if such damages were caused by SAP intentionally or grossly negligent. © 2011 SAP AG. All rights reserved. 2
  • 3. Agenda API Samples  Introduction  Enable Analysis Office Add-In  Refresh  Drilldown with Button  Set Filter  Dynamic Grid
  • 4. Introduction Documentation Use the online help in Analysis Office as reference for the API © 2011 SAP AG. All rights reserved. 4
  • 5. Introduction API – What for? Building sophisticated BI workbooks Using formulas  Call formulas within cell  Get and show information like filter values, meta data, and data  Set filter component Using macros  Used in VBA editor (e.g. behind some developer items like buttons, check box etc.)  Execute planning functions/sequences, set dimensions in grid, set filter, read cell context etc.  Typically using application.run (“”….) © 2011 SAP AG. All rights reserved. 5
  • 6. Agenda API Samples  Introduction  Enable Analysis Office Add-In  Refresh  Drilldown with Button  Set Filter  Dynamic Grid
  • 7. Enable Analysis Office Add-In Scenario  Ensure that the Analysis Office Add-In is loaded  Before the workbook macros are executed © 2011 SAP AG. All rights reserved. 7
  • 8. Enable Analysis Office Add-In Implement Workbook_Open in ThisWorkbook  Loop all COMAddIns  Set Connect to True for Analysis Office Option Explicit Private Sub Workbook_Open() Call EnableAnalysisOffice End Sub Private Sub EnableAnalysisOffice() Dim addin As COMAddIn For Each addin In Application.COMAddIns If addin.progID = "SBOP.AdvancedAnalysis.Addin.1" Then If addin.Connect = False Then addin.Connect = True End If Next End Sub © 2011 SAP AG. All rights reserved. 8
  • 9. Agenda API Samples  Introduction  Enable Analysis Office Add-In  Refresh  Drilldown with Button  Set Filter  Dynamic Grid
  • 10. Refresh Scenario  Ensure data is refreshed if needed  Before calling own functions or SAP function  Use error handling for refresh © 2011 SAP AG. All rights reserved. 10
  • 11. Refresh Use SAPExecuteCommand with Refresh  Refresh on error handling Public Function MyGetData() As String Dim lCellContent As String On Error GoTo refresh lCellContent = Application.Run("SAPGetData", "DS_1", "4J97S26KX1BYBQ4GGQJNZGD9T", "0D_PH1=DS20") MyGetData = lCellContent Exit Function refresh: Dim lResult As Long MsgBox "Refresh“ lResult = Application.Run("SAPSetRefreshBehaviour", "Off") lResult = Application.Run("SAPExecuteCommand", "Refresh") lResult = Application.Run("SAPSetRefreshBehaviour", "On“) lCellContent = Application.Run("SAPGetData", "DS_1", "4J97S26KX1BYBQ4GGQJNZGD9T", "0D_PH1=DS20“) MyGetData = lCellContent End Function © 2011 SAP AG. All rights reserved. 11
  • 12. Refresh Tip  In case you are implementing your own formula (public function)  Which is refreshing the data  You should change the refresh behavior before and after this call  Or use the Refresh Workbook on Opening option Dim lResult as long lResult = Application.Run("SAPSetRefreshBehaviour", "Off") lResult = Application.Run("SAPExecuteCommand", "Refresh") lResult = Application.Run("SAPSetRefreshBehaviour", "On") © 2011 SAP AG. All rights reserved. 12
  • 13. Agenda API Samples  Introduction  Enable Analysis Office Add-In  Refresh  Drilldown with Button  Set Filter  Dynamic Grid
  • 14. Drilldown with Button Define Button with some actions Scenario  Read current cell information for current dimension  Place new dimension “year” before the current dimension © 2011 SAP AG. All rights reserved. 14
  • 15. Drilldown with Button Step 1: Insert Button and Create Macro Insert Button  Use “developer” tab (in case you don’t see it, you might need to activate it in your Excel settings) Create macro (that executes on click) © 2011 SAP AG. All rights reserved. 15
  • 16. Drilldown with Button Step 2: Get Cell Context Use SAPGetCellInfo  IResult = Application.Run("SAPGetCellInfo", ActiveCell, "DIMENSION")  Reads context of cell that the cursor is placed on (ActiveCell)  Requests dimension information  lResult(1) will contain the data source alias  Iresult(2) will contain the dimension key Option Explicit Sub Button1_Click() Dim lResult On Error GoTo leave lResult = Application.Run("SAPGetCellInfo", ActiveCell, "DIMENSION") ... © 2011 SAP AG. All rights reserved. 16
  • 17. Drilldown with Button Step 3: Define drilldown Use SAPMoveDimension  OkCode = Application.Run("SAPMoveDimension", IResult(1), "0CALYEAR", "BEFORE", IResult(2))  Inserts dimension “0CALYEAR” in currently chosen data source before (“BEFORE”) the dimension that the cursor is placed on Option Explicit Sub Button1_Click() Dim lResult Dim OkCode On Error GoTo leave lResult = Application.Run("SAPGetCellInfo", ActiveCell, "DIMENSION") OkCode = Application.Run("SAPMoveDimension", lResult(1), "0CALYEAR", "BEFORE", lResult(2)) leave: End Sub © 2011 SAP AG. All rights reserved. 17
  • 18. Drilldown with Button Result © 2011 SAP AG. All rights reserved. 18
  • 19. Drilldown with Button Tip  Improve error handling by combining… 1. Enable Analysis Office Add-In (see other slide) 2. Refresh 3. Drilldown with Button Option Explicit Sub Button1_Click() Dim lResult On Error GoTo leave lResult = Application.Run("SAPGetCellInfo", ActiveCell, "DIMENSION") lResult = Application.Run("SAPMoveDimension", lResult(1), "0CALYEAR", "BEFORE", lResult(2)) Exit Sub leave: lResult = Application.Run("SAPSetRefreshBehaviour", "Off") lResult = Application.Run("SAPExecuteCommand", "Refresh") lResult = Application.Run("SAPSetRefreshBehaviour", "On“) lResult = Application.Run("SAPGetCellInfo", ActiveCell, "DIMENSION") If IsError(lResult) = True Then MsgBox "No dimension selected." Else lResult = Application.Run("SAPMoveDimension", lResult(1), "0CALYEAR", "BEFORE", lResult(2)) End If End Sub © 2011 SAP AG. All rights reserved. 19
  • 20. Agenda API Samples  Introduction  Enable Analysis Office Add-In  Refresh  Drilldown with Button  Set Filter  Dynamic Grid
  • 21. Set Filter Scenario  Use function SAPSetFilter to set a filter  Use parameter Member Format for selecting single or multiple values  Use combo boxes for choosing parameter and values © 2011 SAP AG. All rights reserved. 21
  • 22. Set Filter Insert Combobox Format Control Define Input range (values in dropdown) and Cell Link (selected index) © 2011 SAP AG. All rights reserved. 22
  • 23. Set Filter Use second sheet for values (Input range) And selected index (Cell link) Transform selected index into value for SAPSetFilter using formula INDEX © 2011 SAP AG. All rights reserved. 23
  • 24. Set Filter Assign macro to control Option Explicit Sub DropDown2_Change() Dim selectedType As String Dim selectedValue As String Dim dimension As String Dim formulaAlias As String Dim r selectedType = Worksheets("Sheet2").Range("C1").Value selectedValue = Worksheets("Sheet2").Range("C7").Value dimension = "0D_PH2" formulaAlias = "DS_1" r = Application.Run("SAPSetFilter", formulaAlias, dimension, selectedValue, selectedType) End Sub © 2011 SAP AG. All rights reserved. 24
  • 25. Agenda API Samples  Introduction  Enable Analysis Office Add-In  Refresh  Drilldown with Button  Set Filter  Dynamic Grid
  • 26. Dynamic Grid Scenario  Use event Workbook_SheetChange to react on changes Press Delete Key Type dimension and press return F4 © 2011 SAP AG. All rights reserved. 26
  • 28. Download All samples are available via the following link https://sapmats-de.sap- ag.de/download/download.cgi?id=SZMBCX9HYNLGEPDM4GWXZ865CWSHX4 YXWNN8BILFYW38Y7HMHX If the link is invalid, please contact tobias.kaufmann@sap.com © 2011 SAP AG. All rights reserved. 28
  • 29. Thank You! Contact information: Tobias Kaufmann RIG Expert tobias.kaufmann@sap.com