## 3.14.3  SAPExecuteCommand
You can use this API method as a generic command to execute the commands described below.
The system returns one of the following output parameters for each command execution:
- 0 = execution failed.
- 1 = execution successful.
## PlanDataTransfer
Use this command to recalculate entered planning data.
## PlanDataSave
Use this command to save entered planning data.

## PlanDataReset
Use this command to reset planning data entered since the last save of data.
## PlanDataClientReset
Use this command to reset planning data entered since the last successful recalculation of data.
## PlanDataToDisplayMode
Use this command to quit input-ready mode and switch to display mode while planning data.
## PlanDataToChangeMode
Use this command to switch to input-ready mode while planning data.
## PauseVariableSubmit
Use this command to pause the execution of variables using the parameter "On". To end the pausing, use the command with parameter "Off".
When PauseVariableSubmit is in mode "On", all Analysis formulas and most of the Analysis macros will not be executed. The following macros will be executed: SAPAddMessage, SAPSetVariable, PauseVariableSubmit "Off".
## Hide/Show
Use this command to hide and show Analysis UI components for a workbook. You can use the command for the types "Ribbon", "ContextMenu" and "TaskPane".
You can hide the complete ribbon ("All") and show it again ("Default"). For the context menu, you can hide the complete menu and show it again. For the design panel, you can hide the Analysis and the Components tab and show the complete design panel again.
The following commands are supported:
```
· Application.Run("SAPExecuteCommand", "Hide", "Ribbon", "All") · Application.Run("SAPExecuteCommand", "Show", "Ribbon", "Default")
```
```
· Application.Run("SAPExecuteCommand", "Hide", "ContextMenu", "All") · Application.Run("SAPExecuteCommand", "Show", "ContextMenu", "Default") · Application.Run("SAPExecuteCommand", "Hide", "TaskPane", "Analysis") · Application.Run("SAPExecuteCommand", "Hide", "TaskPane", "Components") · Application.Run("SAPExecuteCommand", "Show", "TaskPane", "Default")
```
## ShowPrompts
Use this command to display the prompts dialog. You can call the workbook or data source prompts dialaog. To call the dialog, the data source(s) need to be refeshed.
##  Example
Show prompts dialog for one data source
```
lResult= Application.Run("SAPExecuteCommand", "ShowPrompts", "DS_1")
```
If you execute this command, the prompts dialog for DS\_1 is displayed. This is only possible if the variables are not merged in the workbook.
##  Example
Show prompts dialog for all data sources
```
lResult= Application.Run("SAPExecuteCommand", "ShowPrompts", "ALL")
```
If you execute this command, the prompts dialog for all data sources in the workbook is displayed.
## Refresh
Use this command to initially refresh the data in the workbook. You can specify one data source or one planning object as a parameter that should be refreshed. If you do not enter a parameter or you enter the string 'ALL' as parameter, all data sources and planning objects will be refreshed. If you execute this command for a data source which is already refreshed, all corresponding crosstabs are redrawn.
Additionally, you can refresh a list of data sources.
##  Note
If a planning function 'PF\_X' has a filter assigned, you can include this filter with the alias 'PF\_X' into the list. However, the planning function itself wil not be refreshed and has to be refreshed with an own command.
```
 Example Refresh one data source Dim lResult As Long lResult= Application.Run("SAPExecuteCommand", "Refresh", "DS_1")
```
If you execute this command, the data for data source DS\_1 is refreshed.
##  Example
Refresh all data sources
Dim lResult As Long
```
lResult= Application.Run("SAPExecuteCommand", "Refresh")
```
If you execute this command, the data of all data sources is refreshed.
 Example
Refresh a list of data sources
Dim lResult As Long
```
lResult= Application.Run("SAPExecuteCommand", "Refresh", "DS_1;DS_2")
```
If you execute this command, the data of data source DS\_1 and DS\_2 is refreshed.
## RefreshData
Use this command to refresh the transaction data for all or defined data sources in the workbook. You can specify the data sources that should be refreshed. If you do not enter a parameter or you enter the string ' ALL' as parameter, all data sources will be refreshed. If you execute this command for a data source, the corresponding transaction data is updated from the server and the crosstabs are redrawn.
To use this command, the following prerequisites must be met:
- SAP BW 7.30 or higher
- The defined query read mode provides current data.
- Entered planning data was saved.
##  Example
Refresh two defined data sources
Dim lResult As Long
```
lResult= Application.Run("SAPExecuteCommand", "RefreshData", "DS_1;DS_3")
```
If you execute this command, the data for data source DS\_1 and DS\_3 is refreshed from the server.
## Restart
Use this command to technically restart all or defined data sources in the workbook. Technically restarting a data source has the same effect than deleting and reinserting it with keeping the current navigation state and the selected prompt values. The complete process of adding or initially refreshing a data source is executed.
After the restart, new data from the database will be included in the corresponding crosstabs. Before you can restart a data source, the data source has to be initially refreshed, for example with the command Refresh. If you do not enter a parameter or you enter the string 'ALL' as parameter, all data sources will be restarted. If you want to define a set of data sources that should be restarted, you can enter them as parameter with a semicolon separated list.

## AutoRefresh
Use this command to stop one or several data sources from redisplaying with parameter 'Off'. To reactivate the redisplaying, use the command with parameter 'On'. A data source can be set to off at any time. It can also be done in the callback Workbook\_SAP\_Initialize, for example. All parameters are mandatory and may not be blank.
If the command is used with parameter On, any crosstabs of the requested data sources that have pending updates, will be redisplayed automatically.
The configuration AutoRefresh of a data source is always independent of the 'Pause Refresh' of the workbook. A crosstab based on a data source is redisplayed if the workbook is not paused and the data source is not paused. The AutoRefresh value of a data source can be received with macro SAPGetProperty ("SAPGetProperty", "IsAutoRefresh","DS\_1").

## RegisterCallback
Use this command to register a callback. The following callbacks can be registered with SAPExecuteCommand: AfterRedisplay, BeforePlanDataSave, BeforePlanDataReset, BeforeMessageDisplay.
## UnregisterCallback
Use this command to unregister the callbacks listed above.

## SetFunctionalArea
Use this command to add a functional area (similar to a tag) to an Analysis workbook. It is limited to a length of 30 characters.
As it is typically called in the callback Workbook\_SAP\_Initialize, the functional area must be set before Analysis has established a connection to the BW system.
## NumberOfNewLines
Use this command to set the number of new lines for a crosstab.
If you enter a number less than 0, the number of new lines in the crosstab is set as defined in the file system setting NumberOfNewLines.
To get the number of new lines for a crosstab, you can use the API method SAPGetProperty with property NumberOfNewLines.

## Related Information
Using Callbacks [page 134] Hiding / Showing Analysis UI components [page 130] SAPSetVariable [page 120] Using BAdI information [page 132] SAPGetProperty [page 112]