This tutorial is part of a course that explains how to create and register apps for the Dashboard Framework. In this step, you will create a simple BAdI implementation that ensures that a specific dashboard is filled with the apps you require.
You need to create this BAdI implementation because you want to create a dashboard containing the following apps as part of this tutorial:
Three apps that display various metrics (see Tutorial Part 8: Create Apps with Xcelsius)
A context app that you use to choose the period for all apps for which the data is displayed (see Tutorial Part 8: Create Context App with Xcelsius)
The first time a dashboard is called up, it is empty. To ensure that it contains the apps you need, however, you specify in Dashboard Management (see Creating and Editing Dashboards) that an initialization BAdI is called when the dashboard is started. If a dashboard does not contain any apps (which is usually the case the first time it is started), this BAdI ensures that it is filled with the intended apps.
This procedure is part of a comprehensive tutorial about Creating and Registering Dashboard Apps. During this tutorial, you create and register apps and their data sources.
You create this BAdI implementation in the eighth part of the tutorial.
Note
Ensure that you have already performed the previous steps, as described in Tutorial Part 8: Create Dashboard with Context App.
Create the BAdI implementation as follows:
In this section, you specify the technical name, short text, and object catalog entry of the enhancement and its BAdI implementation. Proceed as follows:
Start the Object Navigator
in transaction SE80.
Go to the package AI_DSH_CORE
. This package contains the enhancement spot DFWK_DASHBOARD_STARTUP
, in which you create the enhancement implementation.
Expand the navigation bar along
and choose this enhancement spot by double-clicking it.Go to the Enh. Spot Element Definition
on the right of the enhancement spot. Create a new implementation by choosing Create BAdI Implementation
from the context menu of the BAdI definition IF_DFWK_DASHBOARD_STARTUP_DEF
.
A new screen lists the existing implementations of the enhancement spot. Choose (Create Enhancement Implementation
) . Enter the following data for your implementation:
In the Enhancement Implementation
input field, enter the technical name Z_TUTORIAL8_FILL_DASHBOARD.
In the Short Text
input field, enter the description Initial Fill of the Tutorial Dashboard.
Leave the Compound Enhancement Implementation
field empty.
Create the enhancement by choosing (Enter
) and confirming that the object is in the customer namespace.
Enter the required information in the Create Object Catalog Entry
screen, depending on whether you want to transport the implementation. In this tutorial, you do not transport the object, so choose Local Object
, and confirm that the enhancement implementation was created in a package that is not assigned a switch.
Make sure that the row containing your new enhancement implementation is selected and proceed to the next step by choosing the (Choose Selected Enhancement Implementation
) pushbutton.
You go to a screen in which you create BAdI Implementation
. Enter the following data:
In the BAdI Implementation
input field, enter the technical name Z_TUTORIAL8_FILL_DASHBOARD.
In the Short Text
input field, enter the description Initial Fill of the Tutorial Dashboard.
In the Implementing Class
input field, enter the class name Z_TUTORIAL8_IMPL_CLASS.
Note
Create two objects, because the Enhancement Implementation
is a container for the BAdI Implementation
. Because there is one object in this container for this tutorial, you have assigned the same name. For more information, see Implementing BAdIs.
On the next screen, the system informs you that sample implementation classes already exist. Since you do not need them in this tutorial, choose the (Empty Class
) pushbutton.
Confirm that the object is in the customer namespace.
On the Create Object Catalog Entry
screen, choose Local Object
.
In the previous section, you created the implementation. Now specify a filter value for the implementation. The filter value is the technical name of the dashboard (ALIAS
) for which this BAdI implementation is to be called when it is started.
Note
You create the dashboard in the Tutorial Part 8: Create Dashboard for Context App part of this tutorial.
To specify the filter value with which this BAdI implementation is called, proceed as follows:
In the Object Navigator
, the system shows the enhancement implementation Z_TUTORIAL8_FILL_DASHBOARD
, which you created in the previous section, under the enhancement spot IF_DFWK_DASHBOARD_STARTUP
. Choose this enhancement implementation by double-clicking it.
Choose the Enhancement Implementation Elements
tab on the right-hand side and expand the BAdI Implementation Z_TUTORIAL8_FILL_DASHBOARD
in the subscreen navigation bar.
In the navigation bar, double-click Filter Values
, go to change mode with (Display<->Change
), and choose (Create Filter Combination
).
The system has created a filter combination with the default name Combination 1
. To set a filter value for this combination, in the table Filter Values
, select the lower, indented row of the combination, and choose (Change Filter Value
).
You go to the Change Filter Value
screen. Enter the following data:
In the Value 1
input field, enter the technical name of the dashboard that you will create in the next part of the tutorial. In this tutorial, this is Z_TUTORIAL8.
In the Comparison 1
dropdown box, choose =
.
Save the filter value by choosing the (Continue
) and (Save
) pushbuttons.
The filter value specifies the dashboard from which the BAdI implementation is called. This section specifies the apps that will fill the dashboard. It has the following two methods:
IS_EXEC_BOOTSTRAP_NEEDED
This method checks whether the EXEC_BOOTSTRAP
method below must be called. In this tutorial, this should be the case if the dashboard is still empty, that is, if it does not contain any apps.
EXEC_BOOTSTRAP
This method fills the empty dashboard with the required apps. In this tutorial, these are the three apps that you registered in Tutorial Part 8: Register Apps and the associated context app from Tutorial Part 8: Register Context App.
To create the methods for the implementation, proceed as follows:
You are in the Object Navigator
, in the enhancement implementation Z_TUTORIAL8_FILL_DASHBOARD
and the Enhancement Implementation Elements
tab. You have expanded the BAdI implementation Z_TUTORIAL8_FILL_DASHBOARD
in the navigation bar of the right-hand subscreen.
Double-click Implementing Class
in this navigation bar. The Implementing Class
group box contains entries for the IF_DFWK_DASHBOARD_STARTUP~EXEC_BOOTSTRAP
and IF_DFWK_DASHBOARD_STARTUP~IS_EXEC_BOOTSTRAP_NEEDED
methods.
.
First create the implementation for the IF_DFWK_DASHBOARD_STARTUP~IS_EXEC_BOOTSTRAP_NEEDED
method.
To do so, double-click the method and confirm that you want to create the implementation and that this object is in the customer namespace.
The empty coding of the method is displayed. Go to change mode with (Display<->Change
) and copy the following lines to the coding:
Syntax
method IF_DFWK_DASHBOARD_STARTUP~IS_EXEC_BOOTSTRAP_NEEDED.
DATA lt_apps TYPE dfwk_app_instance_t.
cv_dashboard->get_apps(
IMPORTING
e_apps = lt_apps " App instance table
).
IF lt_apps IS INITIAL. "-> bootstrapping
ev_bootstrap_needed = abap_true.
ELSE.
ev_bootstrap_needed = abap_false.
ENDIF.
endmethod.
Save your entries and activate all objects in this implementation by selecting them and choosing (Activate
).
Now create the implementation for the IF_DFWK_DASHBOARD_STARTUP~EXEC_BOOTSTRAP
method by double-clicking the method. Answer the prompts appropriately.
The coding of the method is displayed. Go to change mode with (Display<->Change
) and copy the following lines to the coding:
Syntax
METHOD if_dfwk_dashboard_startup~exec_bootstrap.
DATA lt_apps TYPE dfwk_app_instance_t.
DATA wa_app LIKE LINE OF lt_apps.
DATA lo_ma_app TYPE REF TO if_dfwk_managing_app.
DATA l_type TYPE dsh_apptypename.
DATA l_name TYPE dsh_namespace.
cv_dashboard->get_apps(
IMPORTING
e_apps = lt_apps " App instance table
).
IF lt_apps IS INITIAL.
wa_app ?= cl_dfwk_flash_wrapper=>create_app(
i_type = 'Z_TUTORIAL_8_COSTS'
i_namespace = 'z_tutorial'
i_parent = cv_dashboard
).
cv_dashboard->add_app( wa_app ).
wa_app ?= cl_dfwk_flash_wrapper=>create_app(
i_type = 'Z_TUTORIAL_8_DURATION'
i_namespace = 'z_tutorial'
i_parent = cv_dashboard
).
cv_dashboard->add_app( wa_app ).
wa_app ?= cl_dfwk_flash_wrapper=>create_app(
i_type = 'Z_TUTORIAL_8_NUMBER'
i_namespace = 'z_tutorial'
i_parent = cv_dashboard
).
cv_dashboard->add_app( wa_app ).
ELSE.
ENDIF.
CLEAR lt_apps.
cv_dashboard->get_restriction_apps(
IMPORTING
e_apps = lt_apps " App instance table
).
IF lt_apps IS INITIAL.
lo_ma_app ?= cl_dfwk_flash_wrapper=>create_app(
i_type = 'Z_TUTORIAL_8_CONTEXT'
i_namespace = 'z_tutorial'
i_parent = cv_dashboard
).
cv_dashboard->add_restriction_app( lo_ma_app ).
ENDIF.
ENDMETHOD.
Note
If you want to use this coding as a template for your own BAdI implementation, enter the technical names of your apps and the namespaces under which they are registered as values for i_type
and i_namespace
.
Save your entries and activate all objects in this implementation by selecting them and choosing (Activate
).
You have created a BAdI implementation that ensures that a dashboard with the alias TUTORIAL8
is filled with the required apps and context app. In the next step, you have to create this dashboard and make sure that it is assigned this BAdI implementation. You will do this in the next and final part of this tutorial (see Tutorial Part 8: Create Dashboard for Context App).