Skip to Content

One of the coolest features in the New ABAP WebDynpro is the ALV Grid with rich set of functionalities. Just reading through the Web Dynpro for ABAP documentation. I just happened to read a

very cool feature. You can display data in ALV plus represent the same as a business graphics just using a few additional lines of code.

Here is a simple application which displays the ALV data and Business Graphics at the same time. The necessary steps required are explained in the below steps. I belive they are

very much self explanatory and hence I am just providing the steps and the relavent screen shots.

Create a context node in the Component Controller

Attribute

Data Type

YEAR

STRING

PROFIT

I

image

Add the ALV Component Usage

image

Map the Controller Component Context Node to the Interface Controller Usage

image

Embed the ALV Table view into the Window

!https://weblogs.sdn.sap.com/weblogs/images/31132/4.JPG|height=193|alt=image|width=450|src=https://weblogs.sdn.sap.com/weblogs/images/31132/4.JPG|border=0!

image

Add the following code in the COMPONENTCONTROLLER WDDOINIT method

  • Declarations

  DATA: node_profit TYPE REF TO if_wd_context_node.

  TYPES: BEGIN OF t_profit,

          year TYPE string,

          profit TYPE i,

         END OF t_profit.

  DATA: i_profit TYPE TABLE OF t_profit,

        w_profit TYPE t_profit.

  • Populating the Data

  CLEAR w_profit.

  w_profit-year = ‘2001’.

  w_profit-profit = 2000.

  APPEND w_profit TO i_profit.

  CLEAR w_profit.

  w_profit-year = ‘2002’.

  w_profit-profit = 2200.

  APPEND w_profit TO i_profit.

  CLEAR w_profit.

  w_profit-year = ‘2003’.

  w_profit-profit = 2500.

  APPEND w_profit TO i_profit.

  CLEAR w_profit.

  w_profit-year = ‘2004’.

  w_profit-profit = 2400.

  APPEND w_profit TO i_profit.

  CLEAR w_profit.

  w_profit-year = ‘2005’.

  w_profit-profit = 2500.

  APPEND w_profit TO i_profit.

  •   navigate from <CONTEXT> to <PROFIT> via lead selection

  node_profit = wd_context->get_child_node(

                name = if_componentcontroller=>wdctx_profit ).

  • Fill the context Node

  node_profit->bind_table( i_profit ).

  • Create a Component Controller Usage

  DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.

  l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).

  IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.

    l_ref_cmp_usage->create_component( ).

  ENDIF.

  • Get the ALV Modal and make the config changes

  DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .

  l_ref_interfacecontroller =   wd_this->wd_cpifc_alv( ).

  DATA:

    l_value TYPE REF TO cl_salv_wd_config_table.

  l_value = l_ref_interfacecontroller->get_model(

  ).

  • Set Visible Row Count as 5

  l_value->if_salv_wd_table_settings~set_visible_row_count( ‘5’ ).

  • The Config Table Setting to Display Table & Business Graphics

  DATA: l_ref_config_table TYPE REF TO if_salv_wd_table_settings,

        l_display_as TYPE salv_wd_constant VALUE ’02’.

  l_ref_config_table ?= l_value.

  l_ref_config_table->set_display_as(

                      value = l_display_as ).

The Result

image

Many people would prefer the data to be displayed as business graphics than tables. How about a mix of both, no one will say no for that I believe.

To report this post you need to login first.

11 Comments

You must be Logged on to comment or reply to a post.

  1. Kathirvel Balakrishnan Post author
    Hi Rich

    Thanks for your comments.

    I knew this article before. What I have posted is a simple method to generate Business Graphics and ALV Grid together using the Web Dynpro ALV grid classes.

    The code sample posed by Velu Pillai explains the usage of IGS Business Graphics in Web Dynpro.

    Regards
    Kathirvel

    (0) 
  2. Trevor Zhang
    Web-Dynpro-Comp. / Intf. Z_TREVOR_WEB_DYNRPO_ALV,Web-Dynpro-Component-Controller COMPONENTCONTROLLER
    Method WDDOINIT
    Die Methode “WD_CPUSE_ALV” ist unbekannt bzw. PROTECTED oder PRIVATE.
    Web-Dynpro-Comp. / Intf. Z_TREVOR_WEB_DYNRPO_ALV,Web-Dynpro-Component-Controller COMPONENTCONTROLLER
    Method WDDOINIT
    Die Methode “WD_CPIFC_ALV” ist unbekannt bzw. PROTECTED oder PRIVATE.
    Web-Dynpro-Comp. / Intf. Z_TREVOR_WEB_DYNRPO_ALV,Web-Dynpro-Component-Controller COMPONENTCONTROLLER
    Method WDDOINIT
    The type of “L_REF_INTERFACECONTROLLER” cannot be converted to the type
    of “L_VALUE”.
    Web-Dynpro-Comp. / Intf. Z_TREVOR_WEB_DYNRPO_ALV,Web-Dynpro-Component-Controller COMPONENTCONTROLLER
    Method WDDOINIT
    The type of “L_REF_CMP_USAGE” cannot be converted to the type of
    “L_REF_INTERFACECONTROLLER”.

    Regards
    Trevor

    (0) 
    1. Kathirvel Balakrishnan Post author
      Hi Trevor,

      Just after this code

      * Fill the context Node
        node_profit->bind_table( i_profit ).

      I just use the Code Wizard to
      1) Instantiate Used Conponent i.e. ALV
      2) Then called the GET_MODEL method using Method Call in the Used Controller.

      Then I went with the following code,
      * Set Visible Row Count as 5
        l_value->if_salv_wd_table_settings~set_visible_row_count( ‘5’ ).

      * The Config Table Setting to Display Table & Business Graphics
        DATA: l_ref_config_table TYPE REF TO if_salv_wd_table_settings,
              l_display_as TYPE salv_wd_constant VALUE ’02’.

        l_ref_config_table ?= l_value.
        l_ref_config_table->set_display_as(
                            value = l_display_as ).

      It works fine for me. I am not getting the picture of your problem.

      Regards
      Kathirvel

      (0) 
  3. Ian Stubbings
    This method is not avaiable in SP5.

    I have used ‘set_display_type’ as an alternative but no graphic is displayed.  Is this ALV feature only present in later SPs?

    Regards
    Ian

    (0) 
    1. Kathirvel Balakrishnan Post author
      Hi Ian,

      I am on NW2004S SPS8 and I am not sure about the features in previous SP’s,

      Using IF_SALV_WD_TABLE_SETTINGS~SET_DISPLAY_TYPE you can set the display as Table, Hierarchy only.

      But using the IF_SALV_WD_TABLE_SETTINGS~SET_DISPLAY_AS you can set the following types of display,

      DISPLAY_AS_EXCEL
      DISPLAY_AS_GRAPHIC
      DISPLAY_AS_TABLE
      DISPLAY_AS_TABLE_GRAPHIC

      Regards
      Kathirvel

      (0) 
  4. Steffen Weber
    Hi,
    very helpful Blog which leads me to the expected results!

    But is there also a way to change the chart format (i.e. to Time Scatter) or the grouping and displayed data like you do with a standard, non-ALV Business Graphic?

    Unfortunately I can’t find any information on that.

    Best regards, Steffen

    (0) 

Leave a Reply