SlideShare a Scribd company logo
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

More Related Content

What's hot

SQL Server 2008 New Features
SQL Server 2008 New FeaturesSQL Server 2008 New Features
SQL Server 2008 New Features
Dan 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
 
Cool features 7.4
Cool features 7.4Cool features 7.4
Cool features 7.4
Mahesh Someshetty
 
Business Intelligence Technology Presentation
Business Intelligence Technology PresentationBusiness Intelligence Technology Presentation
Business Intelligence Technology Presentation
John 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 Roadmap
Kenneth Li
 
New dimensions for_reporting
New dimensions for_reportingNew dimensions for_reporting
New dimensions for_reporting
Rahul 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 1
Amit Sharma
 
Hyperion Planning Overview
Hyperion Planning OverviewHyperion Planning Overview
Hyperion Planning Overview
Anthony Yuan , PMP
 
320 2009
320 2009320 2009
320 2009
Ajay Ohri
 
Whats new 2011
Whats new 2011Whats new 2011
Whats new 2011
kingkong7702
 
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
James Jara
 
Cognos framework manager
Cognos framework managerCognos framework manager
Cognos framework manager
maxonlinetr
 
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
Maria 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 2008
Klaudiia Jacome
 
Planning learn step by step
Planning learn step by stepPlanning learn step by step
Planning learn step by step
ksrajakumar
 
Obiee interview questions and answers faq
Obiee interview questions and answers faqObiee interview questions and answers faq
Obiee interview questions and answers faq
maheshboggula
 
MSBI-SQL Server Reporting Services
MSBI-SQL Server Reporting ServicesMSBI-SQL Server Reporting Services
MSBI-SQL Server Reporting Services
Thejaswi shasthri
 
Analysis edition for olap
Analysis edition for olapAnalysis edition for olap
Analysis edition for olap
Software Engineer
 
SAP BW connect db
SAP BW connect dbSAP BW connect db
SAP BW connect db
Guang Ying Yuan
 

What's hot (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
 

Similar to Bo analusis macros

Debugger & Profiler in NetBeans
Debugger & Profiler in NetBeansDebugger & Profiler in NetBeans
Debugger & Profiler in NetBeans
Huu 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 .pdf
ssuser878ec2
 
Sap enhancement packages
Sap enhancement packagesSap enhancement packages
Sap enhancement packages
Joyce 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 Tutorial
Sam Garforth
 
Lecture07 abap on line
Lecture07 abap on lineLecture07 abap on line
Lecture07 abap on line
Milind Patil
 
EA261_2015_Exercises
EA261_2015_ExercisesEA261_2015_Exercises
EA261_2015_Exercises
Luc Vanrobays
 
Gephi Plugin Developer Workshop
Gephi Plugin Developer WorkshopGephi Plugin Developer Workshop
Gephi Plugin Developer Workshop
Gephi 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.docx
keturahhazelhurst
 
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
guest38bf
 
How to create_an_ecatt
How to create_an_ecattHow to create_an_ecatt
How to create_an_ecatt
Mohammed 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_brfplus
Rivalino Pereira
 
sap
sap sap
Essbase Today - MindStream Analytics
Essbase Today - MindStream AnalyticsEssbase Today - MindStream Analytics
Essbase Today - MindStream Analytics
mindstremanalysis
 
ab-initio-training basics and architecture
ab-initio-training basics and architectureab-initio-training basics and architecture
ab-initio-training basics and architecture
saipriyacoool
 
Summer ‘14 Release Training by Astrea
Summer ‘14 Release Training by AstreaSummer ‘14 Release Training by Astrea
Summer ‘14 Release Training by Astrea
priyanshi_astrea
 
How to create generic delta
How to create generic deltaHow to create generic delta
How to create generic delta
Jacques Kalees
 
Diving into VS 2015 Day5
Diving into VS 2015 Day5Diving into VS 2015 Day5
Diving into VS 2015 Day5
Akhil Mittal
 
Adapters db-104-informixstoredprocedure
Adapters db-104-informixstoredprocedureAdapters db-104-informixstoredprocedure
Adapters db-104-informixstoredprocedure
prathap kumar
 

Similar to 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
 
ab-initio-training basics and architecture
ab-initio-training basics and architectureab-initio-training basics and architecture
ab-initio-training basics and architecture
 
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
 

Recently uploaded

Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
Edge AI and Vision Alliance
 

Recently uploaded (20)

Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Artificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic WarfareArtificial Intelligence and Electronic Warfare
Artificial Intelligence and Electronic Warfare
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
 

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