web dynpro abap: toolbar in alv nbsp;· web dynpro abap: toolbar in alv applies to: sap ecc 6.0. for...

Download Web Dynpro ABAP: Toolbar in ALV nbsp;· Web Dynpro ABAP: Toolbar in ALV Applies to: SAP ECC 6.0. For more information, visit the Web Dynpro ABAP homepage. Summary The

Post on 30-Jan-2018

229 views

Category:

Documents

4 download

Embed Size (px)

TRANSCRIPT

  • SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 1

    Web Dynpro ABAP: Toolbar in ALV

    Applies to:

    SAP ECC 6.0. For more information, visit the Web Dynpro ABAP homepage.

    Summary

    The article elaborates the use of button in ALV toolbar. Functionality of the button in toolbar is to display the details in popup window based on selected line.

    Author: J.Jayanthi

    Company: Siemens IT Solutions and Services Pvt. Ltd.

    Created on: 03 November 2010

    Author Bio

    J.Jayanthi is a Certified ABAP consultant with HR ABAP knowledge.

    https://www.sdn.sap.com/irj/sdn/nw-wdabap

  • Web Dynpro ABAP: Toolbar in ALV

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 2

    Table of Contents

    ALV in Web Dynpro ABAP .................................................................................................................................. 3

    Prerequisites ....................................................................................................................................................... 3

    Goal. ..................................................................................................................................................... 3

    Creating Web Dynpro ...................................................................................................................................... 3

    Component Controller ..................................................................................................................................... 4

    View.. ............................................................................................................................................ 6

    Step 1: ........................................................................................................................................................... 10

    Step 2: ........................................................................................................................................................... 10

    Step 3: ........................................................................................................................................................... 10

    Step 4: ........................................................................................................................................................... 10

    Step 5: ........................................................................................................................................................... 11

    Step 6: ........................................................................................................................................................... 11

    Step 7: ........................................................................................................................................................... 11

    Component Usages ...................................................................................................................................... 11

    Embedding View ........................................................................................................................................... 12

    Handling the Button Action ........................................................................................................................... 13

    Creating Web Dynpro Application ................................................................................................................. 14

    Code. ............................................................................................................................................................. 14

    Output ................................................................................................................................................. 16

    Related Content ................................................................................................................................................ 17

    Disclaimer and Liability Notice .......................................................................................................................... 18

  • Web Dynpro ABAP: Toolbar in ALV

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 3

    ALV in Web Dynpro ABAP

    Normally ABAP Consultants will create the toolbar button in ALV programmatically. We are going to see how to display button in ALV toolbar using Webdynpro ABAP and how and where to write the functionality of the button.

    Prerequisites

    Component The component is the central, reusable unit of the application project. You can create any number of views in a component and arrange them in any number of windows. Component Usages Web Dynpro components can be nested. This means that you can integrate any number of other, already existing components into a component. View The view is the smallest unit of a Web Dynpro application visible for the user. The layout elements and dialog elements - for example, tables, text fields, or buttons - required for the application are arranged in a view. The view contains a controller and a controller context in which the application data to be processed is stored in a hierarchical structure. This allows the linking of the graphical elements with the application data. Window

    A window is used to group multiple views and to specify the navigation between the views. A view can only displayed by the browser if the view is embedded in a window. Singleton

    The property "Singleton" specifies the number of instances that can exist in a dependent context node (that does not belong directly to the root node). If the property "Singleton" is set, exactly one instance of the node exists. Its content changes when the lead selection of the parent node changes. If the property "Singleton" is not set, one instance per parent instance exists. The content of the instances does not change when the lead selection of the parent changes.

    Supply Function

    We can specify the name of a method which we can use to fill the context node at runtime in supply function.

    Goal

    In this article, Sales order details will be displayed initially in the main window and based on selected sales document, toolbar button will display the Sales order item details in popup window.

    We are going to use two views one for initial Sales Document display and another one for Popup Window. We need to use Component SALV_WD_TABLE for ALV display. In POPUP window, table will be used for diaplying vbeln and posnr. Since we need the item details of the sales order only when the particular sales document is clicked, we will use supply function.

    Creating Web Dynpro

    Go to SE80 and select Web Dynpro Comp./Intf. and provide the name(say ZZZ_JAYTEST9) to create. Then enter the description and choose the type as Web Dynpro Component.

    Enter the ALV for component use with component type SALV_WD_TABLE as below in the properties of the webdynpro ZZZ_JAYTEST9. This will create the component usages by name ALV.

  • Web Dynpro ABAP: Toolbar in ALV

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 4

    Component Controller

    Go to Component Controller and Right click the context. Then select Create Node VBAK with dictionary structure as VBAK. Then select the fields required for display from VBAK table using ADD ATTRIBUTE FROM STRUCTURE button. In this example, we are selecting VBELN, VKORG, VTWEG and SPART.

    Then remove the dictionary structure VBAK from the node VBAK and set other properties of the node VBAK as below.

  • Web Dynpro ABAP: Toolbar in ALV

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 5

    Create a node VBAP inside the node VBAK and add the attributes VBELN and POSNR from VBAP.

    Then set the property of VBAP as below. Create a supply function GET_ITEM.

    Here Singleton property is set in VBAP node.

    Uncomment the code which appears automatically and keep additionally only the logic for data selection.

  • Web Dynpro ABAP: Toolbar in ALV

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 6

    View

    In Layout of the Main view, create ViewContianerUIElement using Insert element by right clicking the ROOTUIELEMENTCONTAINER.

    In properties tab, design the properties as below.

    Now in Context, drag and drop VBAK from right side to Left side. Delete the child node VBAP which we dont

    require in Main view. symbol shows it is mapped.

  • Web Dynpro ABAP: Toolbar in ALV

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 7

    Create another view say POPUP.

    In the context tab, Drag and Drop only the child node VBAP to the view from component controller.

    In the layout tab of POPUP view, Insert an element(say T1) Table. Set the datasource property as below.

  • Web Dynpro ABAP: Toolbar in ALV

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 8

    Then right click T1 and select Create Binding.

  • Web Dynpro ABAP: Toolbar in ALV

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com |