Show TOC

Procedure documentationTutorial Part 8: Create BAdI Implementation

 

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:

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.

Prerequisites

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 Note

Ensure that you have already performed the previous steps, as described in Tutorial Part 8: Create Dashboard with Context App.

End of the note.

Procedure

Create the BAdI implementation as follows:

Create Implementation

In this section, you specify the technical name, short text, and object catalog entry of the enhancement and its BAdI implementation. Proceed as follows:

  1. Start the Object Navigator in transaction SE80.

  2. 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 Start of the navigation path AI_DSH_CORE Next navigation step Enhancements Next navigation step Enhancement Spot Next navigation step IF_DFWK_DASHBOARD_STARTUP End of the navigation path and choose this enhancement spot by double-clicking it.

  3. 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.

  4. A new screen lists the existing implementations of the enhancement spot. Choose Create Enhancement Implementation (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.

  5. Create the enhancement by choosing Enter (Enter) and confirming that the object is in the customer namespace.

  6. 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.

  7. 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 (Choose Selected Enhancement Implementation) pushbutton.

  8. 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 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.

    End of the note.
  9. 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 (Empty Class) pushbutton.

  10. Confirm that the object is in the customer namespace.

  11. On the Create Object Catalog Entry screen, choose Local Object.

Create Filter Value

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 Note

You create the dashboard in the Tutorial Part 8: Create Dashboard for Context App part of this tutorial.

End of the note.

To specify the filter value with which this BAdI implementation is called, proceed as follows:

  1. 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.

  2. 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.

  3. In the navigation bar, double-click Filter Values, go to change mode with Display<->Change (Display<->Change), and choose Create Filter Combination (Create Filter Combination).

  4. 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 (Change Filter Value).

  5. 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 (Continue) and Save (Save) pushbuttons.

Create Implementing Class Methods

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:

  1. 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.

  2. 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.

    .

  3. 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 (Display<->Change) and copy the following lines to the coding:

    Syntax Syntax

    1. method IF_DFWK_DASHBOARD_STARTUP~IS_EXEC_BOOTSTRAP_NEEDED.
    2.   DATA lt_apps TYPE dfwk_app_instance_t.
    3.   cv_dashboard->get_apps(
    4.     IMPORTING
    5.       e_apps = lt_apps    " App instance table
    6.   ).
    7.   IF lt_apps IS INITIAL. "-> bootstrapping
    8.     ev_bootstrap_needed = abap_true.
    9.   ELSE.
    10.     ev_bootstrap_needed = abap_false.
    11.   ENDIF.
    12. endmethod.
    End of the code.
  4. Save your entries and activate all objects in this implementation by selecting them and choosing Activate (Activate).

  5. Now create the implementation for the IF_DFWK_DASHBOARD_STARTUP~EXEC_BOOTSTRAP method by double-clicking the method. Answer the prompts appropriately.

  6. The coding of the method is displayed. Go to change mode with Display<->Change (Display<->Change) and copy the following lines to the coding:

    Syntax Syntax

    1. METHOD if_dfwk_dashboard_startup~exec_bootstrap.
    2.   DATA lt_apps TYPE dfwk_app_instance_t.
    3.   DATA wa_app LIKE LINE OF lt_apps.
    4.   DATA lo_ma_app TYPE REF TO if_dfwk_managing_app.
    5.   DATA l_type TYPE dsh_apptypename.
    6.   DATA l_name TYPE dsh_namespace.
    7.   cv_dashboard->get_apps(
    8.   IMPORTING
    9.     e_apps = lt_apps    " App instance table
    10. ).
    11.   IF lt_apps IS INITIAL.
    12.     wa_app ?= cl_dfwk_flash_wrapper=>create_app(
    13.         i_type      = 'Z_TUTORIAL_8_COSTS'
    14.         i_namespace = 'z_tutorial'
    15.         i_parent    = cv_dashboard
    16.         ).
    17.     cv_dashboard->add_app( wa_app ).
    18.     wa_app ?= cl_dfwk_flash_wrapper=>create_app(
    19.         i_type      = 'Z_TUTORIAL_8_DURATION'
    20.         i_namespace = 'z_tutorial'
    21.         i_parent    = cv_dashboard
    22.         ).
    23.     cv_dashboard->add_app( wa_app ).
    24.     wa_app ?= cl_dfwk_flash_wrapper=>create_app(
    25.        i_type      = 'Z_TUTORIAL_8_NUMBER'
    26.        i_namespace = 'z_tutorial'
    27.        i_parent    = cv_dashboard
    28.        ).
    29.     cv_dashboard->add_app( wa_app ).
    30.   ELSE.
    31.   ENDIF.
    32.   CLEAR lt_apps.
    33.   cv_dashboard->get_restriction_apps(
    34.     IMPORTING
    35.       e_apps = lt_apps    " App instance table
    36.   ).
    37.   IF lt_apps IS INITIAL.
    38.     lo_ma_app ?= cl_dfwk_flash_wrapper=>create_app(
    39.         i_type      = 'Z_TUTORIAL_8_CONTEXT'
    40.         i_namespace = 'z_tutorial'
    41.         i_parent    = cv_dashboard
    42.         ).
    43.     cv_dashboard->add_restriction_app( lo_ma_app ).
    44.   ENDIF.
    45. ENDMETHOD.
    End of the code.

    Note 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.

    End of the note.
  7. Save your entries and activate all objects in this implementation by selecting them and choosing Activate (Activate).

Result

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).