## 3.14.21  Using BAdI information
Using macros in a workbook offers a great option to improve the user experience and to expose functionality in an easy consumable manner. As long as the macros only require information that is available in Analysis already (e.g. filter values), the implementation is straightforward.
For situations, where additional information from the BW back-end is required, Analysis offers the possibility to retrieve information from the BW system, and use it in the Analysis API. In the BW system, the information that can be retrieved, is provided by a Business Add-In (BAdI).
You can use the back-end information in variable scenarios, for example:
- Showing/hiding a ribbon or component based on the user configuration.
- Checking if new versions are available and as consequence, ask the user to update the software.
- Invoking a web page where the URL is system dependent.
The request to the BW system for retrieving the information, is sent once when a connection is established to the BW system. If a workbook is connected to several BW systems, each system can be asked for back-end information. The transfer format is string. This means whatever information should be transferred, it requires an encoding to string format in the BW system and a decoding from string in Analysis.
You need to implement the BAdI RSAO\_GET\_INITIAL\_APPL\_CONTEXT in the BW system. To call the BAdI from Analysis, execute the following steps:
1. Define a functional area in BAdI RSAO\_GET\_INITIAL\_APPL\_CONTEXT in the BW system. The functional area is a BAdI filter of type FUNCTIONAL\_AREA.
2. Add the functional area to the Analysis workbook.
The functional area is added with API method SAPExecuteCommand and the command SetFunctionalArea.
It must be set before Analysis is connected to the BW system. Therefore it is typically called in callback Workbook\_SAP\_Initialize.
You can add one functional area per BW system to a workbook.
3. Use the information retrieved from the BAdI in an Analysis macro.
2. The information is transferred to Analysis upon connecting to the BW system. The information can be accessed with the Analysis function SAPListOf and parameter CUSTOMAPPLCONTEXT. The formula returns a list with three columns (SystemID, RowCount and Content).
## Example: Hiding the Analysis ribbon
The following example shows the coding in Analysis.
1. Add the functional area to the Analysis workbook:
```
Public Sub Workbook_SAP_Initialize() Dim result result = Application.Run("SAPExecuteCommand", "SetFunctionalArea", "FA_Ribbon") End Sub
```
The functional area FA\_Ribbon is added to the workbook.
2. After connecting to the BW system, the result of the BAdI implementation that corresponds to the functional area FA\_Ribbon is transferred to Analysis:
The information is encoded to string format to be transferred.
3. You can retrieve the BAdI information with formula SAPListOf and use the result to hide the Analysis ribbon:
```
Dim result As String result = application.run("SAPListOf","CUSTOMAPPLCONTEXT")(3) 'The formula returns in column 3 as result the content: "hideRibbon=X" Dim hideRibbon As Boolean Dim parameters() As String parameters() = Split(result, "=") If parameters(0) = "hideRibbon" and parameters(1) = "X" Then hideRibbon = True Else hideRibbon = False End If
```
```
If hideRibbon = True Application.run("SAPExecuteCommand","Hide","Ribbon") End If
```
The result "hideRibbon=X" is the encoded string provided by the BW system.
The BAdI information is decoded from string and used to hide the Analysis ribbon with API method SAPExecuteCommand.
## Related Information
SAPListOf [page 89]
SAPExecuteCommand [page 104]