Generating Self-Defined Functions for ALV in Web Dynpro for ABAP

Similar documents
Working with the Roadmap UI Element in Web Dynpro ABAP

WDA Tutorial II: Using Select Options in a WDA Application

Working with Tabstrip in Webdynpro for ABAP

ALV with Dynamic Structure in Web DynPro

Working with Dynamic Tables in Interactive Adobe Forms and WebDynpro ABAP

Table Popins and Business Graphics in Web Dynpro ABAP

Using Drop Down By Index in Table UI Element in WebDynpro ABAP

How to Integrate Web Dynpro ABAP in Portal and Capture Portal Logon User Name

Table Row Popup in Web Dynpro Component

Web Dynpro ABAP: Changing ALV Contents and Saving in Database

How to Create Top of List and End of List of the ALV Output in Web Dynpro for ABAP

Sales Order Creation using Web Dynpro ABAP

SDN Community Contribution

How to pass data from ABAP to Web Dynpro ABAP - Part 1

Web Dynpro ABAP: Dynamic Table

Freely Programmed Help- Web Dynpro

A Simple Web Dynpro Application to Locate Employee s Location into Google Map

Integration of Web Dynpro for ABAP Application in Microsoft Share Point Portal

POWL: Infoset Generation with Web Dynpro ABAP

ALV Object Model Hierarchical Sequential List The Basics

Easy Lookup in Process Integration 7.1

How to Create Business Graphics in Web Dynpro for ABAP

Dialog Windows in WebDynpro ABAP Applications

Web Dynpro: Coloring Table Conditionally

Dynamic Context Menus in Web Dynpro ABAP.

Using Radio Buttons in Web Template

Table Properties and Table Popin

Dynamically Enable / Disable Fields in Table Maintenance Generator

Value Help in Web Dynpro ABAP - Tutorial.

This article explains the steps to create a Move-in letter using Print Workbench and SAPScripts.

How to Reference External JAR Files in Web Dynpro DC in SAP NW Portal 7.3

Displaying SAP Transaction as Internet Application in Portal

How to Use New Select-Options WD_SELECT_OPTIONS_20.

Add /Remove Links on ESS Home Page in Business Package 1.5

SDN Community Contribution

Working with Select Options in Web Dynpro for ABAP

Integrating POWL with WebDynpro ABAP

Upload Image file from system in Web dynpro view

Template Designer: Create Automatic PDF Documents for Attachment or Print Purpose

BAPI Execution in offline Adobe Form

How to Default Variant Created for Report Developed In Report Painter/Writer

MDM Import Manager - Taxonomy Data (Attribute Text Values) Part 3

SUP: Personalization Keys and Synchronize Parameter

Graphical Mapping Technique in SAP NetWeaver Process Integration

Open Text DocuLink Configuration - To Access Documents which are Archived using SAP

DB Connect with Delta Mechanism

Creation of Sets in SAP-ABAP, How to Read them INI SAP-ABAP Reports

Material Master Archiving in Simple Method

E-Sourcing System Copy [System refresh from Production to existing Development]

Internationalization in WebDynpro ABAP Applications

Creating Rules in Process Composer and using them in Process

MDM Syndicator: Custom Items Tab

Creation of Key Figures with Higher Decimal Place Precision

SMT (Service Mapping Tool)

Limitation in BAPI Scheduling Agreement (SA) Create or Change

ABAP HR: Standard Info Type Enhancement

SAP BW Copy Existing DTP for Data Targets

Reporting Duplicate Entries

Custom Process types Remote Trigger and End Time

Fetching User Details from the Portal and Displaying it in Web Dynpro with Authentication in the Portal

Developing Crystal Reports on SAP BW

Triggering the Process Chains at Particular Date using Events

Creation of Alert Data Service VC model for the BI query exception using Information Broadcasting

Information Broadcasting Part 3 Scheduling the First Report

Creating Custom SU01 Transaction Code with Display and Password Reset Buttons

Open Hub Destination - Make use of Navigational Attributes

Linking Documents with Web Templates

Download SAP Query Output to Local/ Network Folders in Background

Exception Handling in Web Services exposed from an R/3 System

How to Integrate SAP xmii Services with Web Dynpro Java

Custom Password Reset Tool in SAP Enterprise Portal Using Web Dynpro for Java

Validity Table in SAP BW/BI

Customizing Characteristic Relationships in BW-BPS with Function Modules

Extracting Missing Fields of Data Source Which Are Present In Their Extract Structure

Step by Step Procedure for DSO Creation

Displaying HR Organizational Tree Structure in Web Dynpro

SDN Community Contribution

Applies To:...1. Summary...1. Table of Contents...1. Procedure..2. Code... Error! Bookmark not defined.0

Customized Transaction to Trigger Process Chain from Failed Step

Data Mining: Scoring (Linear Regression)

Creating, Configuring and Testing a Web Service Based on a Function Module

Standalone BW System Refresh

Adding Files as Attachments to SAP Interactive Forms in the Java Environment

How to use Boolean Operations in the Formula as Subsidiary for IF Condition

Currency Translation in SAP BI Step by step Guide

Federated Portal for Composite Environment 7.1

Creating Multiple Methods/Operations and Exposing BAPI as a Webservice

Step by Step Guide for PI Server Start and Stop Procedure

Step by Step Guide How to Use BI Queries in Visual Composer

Financial Statement Version into PDF Reader

Database Statistics During ODS Activation

Steps to Activate ALE Delta for Custom Master Datasource Created on ZTable

Programmatical Approach to User Management in Enterprise Portal

Procedure to Trigger Events in Remote System Using an ABAP Program

List of Values in BusinessObjects Web Intelligence Prompts

About ITAB Duplicate_Key (SAP lrsaods) Runtime Error

Common Queries/Errors while working with Adobe Print PDF Forms

How to Attach Documents to Any Custom Program Using Generic Object Services

Solution to the Challenges in Pivoting

Federated Portal Network Remote Role Assignment Step-by- Step Configuration

Transcription:

Generating Self-Defined Functions for ALV in Web Dynpro for ABAP Applies to: SAP NetWeaver 2004s Web Dynpro for ABAP. Summary This tutorial explains how to generate custom defined functions in ALV. It also explains how to associate UI elements with the defined functions and thereby embedding UI elements in ALV. This tutorial assumes that you have completed WDA Tutorial Programming the ALV configuration Model. Author(s): Rakesh Company: Cognizant Technology Solutions Created on: 20 November 2006 Author Bio Rakesh is a SAP Netweaver Consultant, working with Cognizant Technology Solutions in applications based on Web Dynpro and BSP. He has knowledge in ABAP programming and Java based technologies. Currently he is working on Web Dynpro ABAP. 2006 SAP AG 1

Table of Contents Applies to:... 1 Summary... 1 Author Bio... 1 Step 1 Create a New Web Dynpro Component with ALV Configuration model... 3 Create a New Web Dynpro Component... 3 Create Context element in Component Controller for storing the Search Criteria... 3 Create a Context element in Component Controller for storing the Flight list... 3 Create method for filling the Flight list... 4 Define Component Usage... 5 Creating View for Displaying ALV Table... 6 Define component usage SALV_WD_TABLE in FlightView... 6 Set data to ALV for Display... 6 Set Functional Elements to ALV for linking functions... 7 Step - 2 Generating Self-Defined Functions for ALV... 7 Instantiate ALV component and get configuration model... 7 Set the ALV header... 8 Generate Toolbar elements... 8 Specify properties for the Toolbar elements... 8 Generating Objects for Self-Defined Functions and assigning Toolbar elements... 9 Capturing Events triggered by Toolbar elements... 9 Related Content... 10 Disclaimer and Liability Notice... 11 2006 SAP AG 2

Step 1 Create a New Web Dynpro Component with ALV Configuration model First a web Dynpro component with ALV usage has to be created using the ALV configuration model. A view with component usage definition has to be created. Create a New Web Dynpro Component Start ABAP Workbench ( SE80 ) and create the new Web Dynpro component ZWDT_FLIGHTLIST_FUNCTIONS. Assign a window name. Create Context element in Component Controller for storing the Search Criteria Create context node FUNCTION_ATTRIBUTES based on the dictionary structure SFLIGHT. Click on the button Add Attribute from Structure and choose fields CARRID and CONNID. Create a Context element in Component Controller for storing the Flight list Create context node NODE_SFLIGHT based on the dictionary structure SFLIGHT. Set Cardinality to 0..N. Click on button Add Attribute from Structure and choose fields CARRID, CONNID, FLDATE, PRICE, CURRENCY, PLANETYPE, SEATSMAX, SEATSOCC and PAYMENTSUM. 2006 SAP AG 3

Clear the DICTIONARY STRUCTURE attribute of NODE_SFLIGHT to avoid display of all fields that are available in dictionary, in ALV. Create method for filling the Flight list Create method FILL_SFLIGHTS in the component controller to fill the node NODE_SFLIGHT using the attributes CONNID, CARRID from the node FUNCTION_ATTRIBUTES. method FILL_SFLIGHTS. data: node_function_attributes type ref to if_wd_context_node, elem_function_attributes type ref to if_wd_context_element, stru_function_attributes type if_componentcontroller=>element_function_attributes, item_carrid like stru_function_attributes-carrid, item_connid like stru_function_attributes-connid, ls_where(72) TYPE c, lt_where LIKE TABLE OF ls_where, lt_flights TYPE TABLE OF sflight. data: node_node_sflight type ref to if_wd_context_node, elem_node_sflight type ref to if_wd_context_element, stru_node_sflight type if_componentcontroller=>element_node_sflight. * navigate from <CONTEXT> to <NODE_SFLIGHT> via lead selection node_node_sflight = wd_context->get_child_node( name = `NODE_SFLIGHT` ). * navigate from <CONTEXT> to <FUNCTION_ATTRIBUTES> via lead selection node_function_attributes = wd_context->get_child_node( name = `FUNCTION_ATTRIBUTES` ). * get element via lead selection elem_function_attributes = node_function_attributes->get_element( ). 2006 SAP AG 4

* get single attribute elem_function_attributes->get_attribute( exporting name = `CARRID` importing value = item_carrid ). * get single attribute elem_function_attributes->get_attribute( exporting name = `CONNID` importing value = item_connid ). * get element via lead selection elem_node_sflight = node_node_sflight->get_element( ). * create where condition if not item_carrid eq ''. concatenate 'CARRID = ''' item_carrid '''' INTO ls_where. append ls_where TO lt_where. endif. if not item_connid eq '0000'. concatenate 'CONNID = ''' item_connid '''' INTO ls_where. if item_carrid ne ''. concatenate 'AND' ls_where into ls_where separated by space. endif. append ls_where to lt_where. endif. * read data from SFLIGHT select * from sflight into table lt_flights WHERE (lt_where). * navigate from <CONTEXT> to <NODE_FLIGHT> via lead selection node_node_sflight = wd_context->get_child_node( name = `NODE_SFLIGHT` ). * fill context node node_node_sflight->bind_table( lt_flights ). endmethod. Define Component Usage If you want to see the data within a Web Dynpro ALV, you have to define the Web Dynpro component for ALV, SALV_WD_TABLE as a usage component of your Web Dynpro component. 2006 SAP AG 5

Creating View for Displaying ALV Table Create View FLIGHTVIEW. In the layout of the view FLIGHTVIEW, create a ViewContainerUIElement called CONTAINER. Define component usage SALV_WD_TABLE in FlightView To display ALV inside the view RESULTVIEW, it is necessary to define the component usage of SALV_WD_TABLE in the view. Go to the properties of view RESULTVIEW and press button Create Controller Usage and choose the following entry from the list on the popup: Embed the view, FLIGHTVIEW in the window. Embed ALV table in the View container, CONTAINER. Set data to ALV for Display The selected flights will be inside the context node NODE_SFLIGHT. To display them in the ALV, map the context node NODE_SFLIGHT to the context node DATA of the ALV interface controller. Go to Web Dynpro component s node Component Usages -> ALV -> INTERFACECONTROLLER_USAGE. Click on the Controller Usage button. The component controller of your Web Dynpro component appears on the right side of the screen. Map the context node NODE_SFLIGHT of your Web Dynpro component to the context node DATA of the interface controller of the ALV component. 2006 SAP AG 6

Set Functional Elements to ALV for linking functions Self-defined functions like input field, that you can insert into the toolbar cause data to change when the user triggers them. For accessing the functions data and to change them, you should map these functions to a context element of your application. Map the context node FUNCTION_ATTRIBUTES of your Web Dynpro component to the context node FUNCTION_ELEMENTS of the interface controller of the ALV component. Step - 2 Generating Self-Defined Functions for ALV For self-defined functions, you generate a function object with each function. Any of the possible UI Elements is specified for each function. You can generate as many function objects as you want and arrange them in the toolbar. For generating self defined functions, use WDOINIT method of the view, FLIGHTVIEW. Instantiate ALV component and get configuration model Instantiate the ALV component. You can use code wizard for the purpose. 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. 2006 SAP AG 7

Call the interface controller s method GET_MODEL. 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 the ALV header Configure the ALV s header by using GET_HEADER method of the interface class If_salv_wd_table_settings. *set header for the table data: lr_table_settings type ref to if_salv_wd_table_settings. data: lr_header type ref to CL_SALV_WD_HEADER. lr_table_settings?= l_value. lr_header = lr_table_settings->get_header( ). lr_header->set_text( 'FLIGHT LIST SEARCH' ). Generate Toolbar elements Generate toolbar elements for inserting into ALV toolbar. Define the toolbar elements of the appropriate UI element type. Create Input field elements for getting CARRID and CONNID, using CREATE OBJECT. Bind the input field values with the context attributes by specifying context attributes name in the EXPORT parameter, VALUE_ELEMENTNAME. Create toolbar elements for button and separators ( To provide visual separation between UI elements ). Note : The context attributes specified in the VALUE_ELEMENTNAME parameter are mapped to FUNCTION_ELEMENTS of the interface controller of the ALV component from the component controller. DATA lr_buttonui type REF TO CL_SALV_WD_FE_BUTTON. DATA lr_inputui1 type REF TO CL_SALV_WD_FE_INPUT_FIELD. DATA lr_inputui2 type REF TO CL_SALV_WD_FE_INPUT_FIELD. DATA lr_seperator1 type REF TO CL_SALV_WD_FE_SEPARATOR. DATA lr_seperator2 type REF TO CL_SALV_WD_FE_SEPARATOR. CREATE OBJECT lr_inputui1 EXPORTING VALUE_ELEMENTNAME = 'CARRID'. CREATE OBJECT lr_inputui2 EXPORTING VALUE_ELEMENTNAME = 'CONNID'. CREATE OBJECT lr_buttonui. CREATE OBJECT lr_seperator1. CREATE OBJECT lr_seperator2. Specify properties for the Toolbar elements Set text for the button toolbar element. Set labels for the input field elements. 2006 SAP AG 8

lr_buttonui->set_text( 'Search Flights' ). lr_inputui1->set_label_text( ' AIRLINE :' ). lr_inputui2->set_label_text( ' FLIGHT NO :' ). Generating Objects for Self-Defined Functions and assigning Toolbar elements for the objects Generate a function object of class CL_SALV_WD_FUNCTION for each function you create. When you generate a self-defined function, specify a unique ID, for addressing the function. Function objects are created using CREATE_FUNCTION method of the interface class IF_SALV_WD_FUNCTION_SETTINGS. Specify the toolbar element for the functions by using the method SET_EDITOR. DATA input1 TYPE REF TO CL_SALV_WD_FUNCTION. input1 = l_value->if_salv_wd_function_settings~create_function( id = 'LINPUT1' ). input1->set_editor( lr_inputui1 ). DATA seperator1 TYPE REF TO CL_SALV_WD_FUNCTION. seperator1 = l_value->if_salv_wd_function_settings~create_function( id = 'LS' ). seperator1->set_editor( lr_seperator1 ). DATA input2 TYPE REF TO CL_SALV_WD_FUNCTION. input2 = l_value->if_salv_wd_function_settings~create_function( id = 'LINPUT2' ). input2->set_editor( lr_inputui2 ). DATA seperator2 TYPE REF TO CL_SALV_WD_FUNCTION. seperator2 = l_value->if_salv_wd_function_settings~create_function( id = 'LS2' ). seperator2->set_editor( lr_seperator2 ). DATA button1 TYPE REF TO CL_SALV_WD_FUNCTION. button1 = l_value->if_salv_wd_function_settings~create_function( id = 'LBUTTON' ). button1->set_editor( lr_buttonui ). Capturing Events triggered by Toolbar elements Create a event handler method ON_SEARCH in the view, RESULTVIEW. Specify event, ON_FUNCTION of the interface controller of ALV for the event handler method. The importing parameter r_param of the method contains unique ID of the function for which the toolbar element is assigned. method ON_SEARCH. DATA: temp TYPE string. temp = r_param->id. IF temp = 'LBUTTON'. wd_comp_controller->fill_sflights( ). ENDIF. endmethod. 2006 SAP AG 9

Create an application and save the component. Activate and test the component. The search criteria and the display for the Flight application will be present inside the ALV itself. Related Content Please include at least three references to SDN documents or web pages. WDA Tutorial - Simple Example for Using ALV WDA Tutorial Programming the ALV configuration Model WDA Official Documentation 2006 SAP AG 10

Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document. 2006 SAP AG 11