Creating a WebDynpro ALV Application in 30 easy steps

...Previous

Step 20: Now in the similar way create a view called ‘MAIN’. In this view create two elements of the type ViewContainerUIelement. As shown in the picture below. 

 

Step 21: Click on the ROOTELEMENTCONTAINER of the MAIN view and change the layout property to MATRIX LAYOUT.  

Step 22: Also click on each ViewConatinerUIElement and change the layout to MATRIX HEAD DATA. You will get the layout like this. 

Step 23: Navigate to the CONTEXT tab. And MAP both the nodes created in the component controller. (For mapping refer to Step 12). 

 

Step 24: Save MAIN view and double click on the Component name (ZSAM_TEST). 

Go to Properties tab of the component and declare the ALV component in it as shown below: 

Here ALV_TEST now stands for the ALV component that we are going to use in the application.  

Step 25: Now go to ‘Component usages’ in the left side tree and expand ALV_TEST and double click on the INTERFACECONTROLLER_USAGE.

 

 

 

Step 26: You will see the screen as in the given picture, click on the CONTROLLER USAGE Button.

 

 

Now the component controller will open in the right side panel as shown above. Drag and drop the NODE_ALV into the DATA node of the Interface Controller. This will declare a mapping. Meaning we have just declared which node is going to be displayed in the ALV.

 

Step 27: SAVE everything. Double click the link, WINDOWS > ZSAM_TEST. Drag and drop MAIN view onto the Window. Now click on the arrow next to MAIN, you will see the two View containers, Right click on container 1 (CONT1) and click on EMBED VIEW. Embed the Input View in the first container. Similarly right click on the second container and say Embed View. Press F4 on the ‘View To Be Embedded’ input box and enter the TABLE view of the ALV_TEST component. Refer to the screen shots below.

  

( After F4 )

Step 27: The Window will now look like this.

 

Step 28: Now save everything and right click on the Component (ZSAM_TEST).

Click the link Create > Application. Enter the following details.

 

 

Step 29: Now this is the most important step of all. CODING J

For coding, go to the Input View and click on METHODS, which is the last tab.

There you will find a method ONACTIONACTION_FIND already created. This is the event handler method of the action FIND.

  

Double click on the method name; on the editor write the following code:

 

METHOD onactionaction_find .

 

  DATA: node_node_vbak           TYPE REF TO if_wd_context_node,

    elem_node_vbak                      TYPE REF TO if_wd_context_element,

    stru_node_vbak                        TYPE if_input_view=>element_node_vbak .

 

* navigate from <CONTEXT> to <NODE_VBAK> via lead selection

  node_node_vbak = wd_context->get_child_node( name = if_input_view=>wdctx_node_vbak ).

 

* get element via lead selection

  elem_node_vbak = node_node_vbak->get_element(  ).

 

* get all declared attributes

  elem_node_vbak->get_static_attributes(

    IMPORTING

      static_attributes = stru_node_vbak ).

 

 

  DATA: ls_where(72) TYPE c,

        lt_where LIKE TABLE OF ls_where,

        lt_vbak TYPE STANDARD TABLE OF zstr_vbak.

 

* create where condition

  IF NOT stru_node_vbak-vbeln EQ ''.

    CONCATENATE 'VBELN = ''' stru_node_vbak-vbeln '''' INTO ls_where.

    APPEND ls_where TO lt_where.

  ENDIF.

  IF NOT stru_node_vbak-erdat EQ '00000000'.

    CONCATENATE 'ERDAT = ''' stru_node_vbak-erdat '''' INTO ls_where.

    IF stru_node_vbak-vbeln NE ''.

      CONCATENATE 'AND' ls_where INTO ls_where SEPARATED BY space.

    ENDIF.

    APPEND ls_where TO lt_where.

  ENDIF.

 

  SELECT VBELN ERDAT ERZET ERNAM ANGDT BNDDT AUDAT VBTYP TRVOG AUART

         AUGRU GWLDT SUBMI LIFSK FAKSK NETWR WAERK VKORG VTWEG SPART

         VKGRP VKBUR GSBER GSKST GUEBG GUEEN KNUMV

  FROM vbak INTO TABLE lt_vbak WHERE (lt_where).

 

 

  DATA:

    node_node_alv                       TYPE REF TO if_wd_context_node,

    stru_node_alv                       TYPE if_input_view=>element_node_alv .

 

* navigate from <CONTEXT> to <NODE_ALV> via lead selection

  node_node_alv = wd_context->get_child_node( name = if_input_view=>wdctx_node_alv ).

 

 

* get all declared attributes

  node_node_alv->bind_table( lt_vbak ).

 

ENDMETHOD

 

Step 30: SAVE the application and activate the Component. 

 

Now run the application. Here’s the output J

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image