ALV Object Model Simple 2D Table Event Handling



Similar documents
Step by Step Guide for Language Translation Tool

ALV List with Radio Buttons

Table of Contents. Passing Data across Components through Component Controller between Two Value Nodes

Splitting the Custom Container & Display more than one ALV

Display Options in Transaction SE16

SAP List Viewer The New Programming Model in SAP NetWeaver 04

SAP CRM 7.0 for Newbies: (Part 1) Simple BOL Object Creation for CRM Webclient UI

Web Dynpro: Multiple ALV Grids and Layouts in ALV

Embedding Crystal Reports inside ECC ALV Reports

Restricting Search Operators in any Search View

SAP FI - Automatic Payment Program (Configuration and Run)

SAP BW - Excel Pivot Chart and Pivot Table report (Excel)

Step by Step guide of Report-to- Report Interface in BW Reporting

Tutorial - Creating Pop Up Window Using New Features in WebDynpro Java CE 7.1 Ehp1

Workflow Troubleshooting and Monitoring in SAP ECC 6.0

Mandatory Field Check in Web Dynpro- ABAP

Deleting the Requests from the PSA and Change Log Tables in Business Intelligence

Step by Step Guide How to Copy Flat File from Other Application Server to BI and Load through Info Package

Creating New Unit of Measure in SAP BW

Step by Step Procedure to Block and Debug a CIF Queue Flowing from R/3 to APO System

BW Performance Monitoring

Configuring HTTPs Connection in SAP PI 7.10

Web Dynpro ABAP: ALV and Table in Popup Window

How to Assign Transport Request for Language Translation?

Configuration of Enterprise Services using SICF and SOA Manager

Standard SAP Configuration of SMS through HTTP with Third Party SMS Gateway

Creating Content Using SO10 Objects and Text Symbols

Exposing RFC as Web Service and Consuming Web Service in Interactive Forms in ABAP

ABAP How To on SQL Trace Analysis

Creating Transaction and Screen Variants

Forgot or Lock "Administrator or J2EE_ADMIN" Password

Reverse Transport Mechanism in SAP BI

How to Modify, Create and Delete Table Entries from SE16

Understanding BEx Query Designer: Part-2 Structures, Selections and Formulas

This document applies to SAP ECC 6.0, SAP Netweaver 2004s. For more information, visit the Web Dynpro ABAP homepage.

LSMW: Upload Master Data using Batch Input Recording

Step by Step Guide to Extract Batch Master Data via Generic and Classification Datasource to BW

Deploying Crystal Reports on Top of a SAP BI Query

ALE Settings, for Communication between a BW System and an SAP System

Deploying JDBC drivers in PI 7.1x Systems

Deleting the User Personalization done on Enterprise Portal

SAP CRM System 6.0/7.0. For more information, visit the Customer Relationship Management homepage

Create Automatic Mail Notification/ Alert for Process Chain Monitoring

SPDD & SPAU Adjustments Handbook

Quick Viewer: SAP Report Generating Tool

SDN Community Contribution

ABAP Debugging Tips and Tricks

Web Application Designer for Beginners

Working with SAP BI 7.0 Data Transfer Process (DTP)

Understanding BW Non Cumulative Concept as Applicable in Inventory Management Data Model

Understanding OLAP Processor and RSRT

SAP CRM 7.0 E2C Setup: CRM via Toolset

Drag and Drop Functionality in Web Dynpro ABAP Application

Creating Web Service from Function Modules/BAPIs & Integrating with SAP Interactive Forms

Understanding DSO (DataStore Object) Part 1: Standard DSO

Compounding in Infoobject and Analyzing the Infoobject in a Query

First step to Understand a Payroll Schema

ABAP Proxy Interfacing

SAP CRM-BW Adapter an Overview

Merge PDF files in ABAP

How to Create an ecatt?

Data Flow from LBWQ/SMQ1 to RSA7 in ECC and Delta Extraction in BI

Step by Step Procedures to Load Master Data (Attribute and Text) from FlatFile in BI 7.0

Step by Step Guide to Archiving and Deleting of XML Messages in SAP NetWeaver PI

Data Extraction and Retraction in BPC-BI

How to Generate Stack Xml for Ehp4 and Above Upgrade

Order Split Usage in Production Orders

SAP NetWeaver Developer Studio 7.30 Installation Guide

Customer Exit Variables in SAP BW/BI Reports First day of the Current/Previous Month

XSLT Mapping in SAP PI 7.1

Multi Provider Creation Based on Sales and Planning Info Cubes

Extractor in R/3 and Delta Queue

Connecting to SAP BW with Microsoft Excel PivotTables and ODBO

Table of Content. SAP Query creation and transport Procedure in ECC6

How to Integrate CRM 2007 WebClient UI with SAP NetWeaver Portal

A Step-by-Step guide on SMTP Configuration and File to Mail Scenario Using Process Integration Scenario in PI 7.1

How to Get Work Items from Workflow in your Outlook Inbox

Query OLAP Cache Optimization in SAP BW

SAP Workflow in Plain English

Business Scenario Using GP/Web Dynpro with Back and Forth 3 Level Process and Dynamic Approvers in a Loop

Business Intelligence Overview. BW/BI Security. BW/BI Architecture. Business Explorer (BEx) BW/BI BEx Tools Overview. What is BEx?

Currency Conversion using Variables in SAP BI -Reporting

SAP CRM Campaign Automation

Different Types of Alerts for Process Chains. Table of Content

Inventory Management (0IC_C03) Part - 3

How to Develop Programs for SAP Mobile RF

SDN Contribution Beginners guide to CRM Interaction Center (IC) Winclient setup

Consuming Services in SOA Manager

Process Controlled Workflow SRM 7.0 (Using BRF)

Upload Data in Web Dynpro Table from a Text File with Delimiters

How to Load Data from Flat Files into BW PSA

SAP MM: Purchase Requisition with Classification and Workflow Approval

Online Store order process within SAP 2 nd December 2013

SAP BI Generic Extraction Using a Function Module

Step By Step Procedure to Create Logical File Path and Logical File Name

Creation and Configuration of Business Partners in SAP CRM

Sending an Image File Through XI in a File-to-Mail Scenario

SAP BW 7.3: Exploring Semantic Partitioning

Invoice Collaboration: Self Billing Invoice

Transcription:

ALV Object Model Simple 2D Table Event Handling Applies to: Netweaver 2004 and Netweaver 2004s Summary This tutorial will show how to implement event handling when using the new ALV object model. For more examples, see any program which begins with SALV* in your Netweaver ABAP System. Author(s): Rich Heilman Company: Yorktowne Cabinetry Created on: 28 September 2006 Rich Heilman is an ABAP/J2EE Software Engineer/Analyst for Yorktowne Cabinetry, Inc. based in Red Lion, Pennsylvania, USA. He has a total of nine years experience in the IT industry. He has spent the past five years studying ABAP and Java. SAP DEVELOPER NETWORK sdn.sap.com 2006 SAP AG 1

Table of Contents Applies to:... 1 Summary... 1 The Basic Program... 3 Set the Gui Status... 4 Event Handlers - Event ADDED_FUNCTION... 5 Event Handlers - Event DOUBLE_CLICK... 8 Related Content... 11 Disclaimer and Liability Notice... 12 2006 SAP AG 2

The Basic Program Starting with the program below, we will add coding to handle some events for the ALV Grid. In this example the events DOUBLE_CLICK and ADDED_FUNCTION will be handled. report zalvom_demo3. data: ispfli type table of spfli. data: xspfli type spfli. data: gr_table type ref to cl_salv_table. data: gr_selections type ref to cl_salv_selections. start-of-selection. select * into corresponding fields of table ispfli from spfli up to 100 rows. call method cl_salv_table=>factory importing r_salv_table = gr_table changing t_table = ispfli. * Set up selections. gr_selections = gr_table->get_selections( ). gr_selections->set_selection_mode( 1 ). "Single * Display gr_table->display( ). 2006 SAP AG 3

Set the Gui Status Next, go to function group SALV_METADATA_STATUS and copy the gui status SALV_TABLE_STANDARD into the ZALVOM_DEMO3 program. This is the standard gui status for the 2 Dimensional Table ALV grid. Once you have copied the status, set the screen status using the appropriate method of the object GR_TABLE. Go to the gui status and add a new button on the application toolbar and name it as MYFUNCTION. report zalvom_demo3. data: ispfli type table of spfli. data: xspfli type spfli. data: gr_table type ref to cl_salv_table. data: gr_selections type ref to cl_salv_selections. start-of-selection. select * into corresponding fields of table ispfli from spfli up to 100 rows. call method cl_salv_table=>factory importing r_salv_table = gr_table changing t_table = ispfli. gr_table->set_screen_status( pfstatus = 'SALV_TABLE_STANDARD' report = sy-repid set_functions = gr_table->c_functions_all ). * Set up selections. gr_selections = gr_table->get_selections( ). gr_selections->set_selection_mode( 1 ). "Single * Display gr_table->display( ). 2006 SAP AG 4

Event Handlers - Event ADDED_FUNCTION Next, create a local class which will act as the event handler, define the event handler method for the ADDED_FUNCTION event. Define an object reference variable for the local class. Retrieve the events object from the GR_TABLE, create the event handler object and set the handler method for the event. Finally, add the implementation for the ON_USER_COMMAND event handler method. report zalvom_demo3. data: ispfli type table of spfli. data: xspfli type spfli. data: gr_table type ref to cl_salv_table. data: gr_events type ref to cl_salv_events_table. data: gr_selections type ref to cl_salv_selections. * CLASS lcl_handle_events DEFINITION * class lcl_handle_events definition. public section. methods: on_user_command for event added_function of cl_salv_events importing e_salv_function, endclass. "lcl_handle_events DEFINITION data: event_handler type ref to lcl_handle_events. start-of-selection. select * into corresponding fields of table ispfli from spfli up to 100 rows. call method cl_salv_table=>factory importing r_salv_table = gr_table changing t_table = ispfli. gr_table->set_screen_status( pfstatus = 'SALV_TABLE_STANDARD' report = sy-repid set_functions = gr_table->c_functions_all ). gr_events = gr_table->get_event( ). create object event_handler. set handler event_handler->on_user_command for gr_events. * Set up selections. 2006 SAP AG 5

gr_selections = gr_table->get_selections( ). gr_selections->set_selection_mode( 1 ). "Single * Display gr_table->display( ). * CLASS lcl_handle_events IMPLEMENTATION * class lcl_handle_events implementation. method on_user_command. * Get the selection rows data: lr_selections type ref to cl_salv_selections. data: lt_rows type salv_t_row. data: ls_rows type i. data: message type string. case e_salv_function. when 'MYFUNCTION'. lr_selections = gr_table->get_selections( ). lt_rows = lr_selections->get_selected_rows( ). read table lt_rows into ls_rows index 1. read table ispfli into xspfli index ls_rows. concatenate xspfli-carrid xspfli-connid xspfli-cityfrom xspfli-cityto into message separated by space. message i001(00) with 'You pushed the button!' message. endcase. endmethod. endclass. "on_user_command "lcl_handle_events IMPLEMENTATION 2006 SAP AG 6

Run the program, select a row by single clicking on it and click the icon for the new function that you added. Notice that some of the data in the row that was clicked is now showing in the message. 2006 SAP AG 7

Event Handlers - Event DOUBLE_CLICK Define the event handler method for DOUBLE_CLICK event and add the implementation for the ON_DOUBLE_CLICK event handler method. Remember to set the handler for the event. report zalvom_demo3. data: ispfli type table of spfli. data: xspfli type spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions_list. data: gr_events type ref to cl_salv_events_table. data: gr_selections type ref to cl_salv_selections. * CLASS lcl_handle_events DEFINITION * class lcl_handle_events definition. public section. methods: on_user_command for event added_function of cl_salv_events importing e_salv_function, on_double_click for event double_click of cl_salv_events_table importing row column. endclass. "lcl_handle_events DEFINITION data: event_handler type ref to lcl_handle_events. start-of-selection. select * into corresponding fields of table ispfli from spfli up to 100 rows. call method cl_salv_table=>factory importing r_salv_table = gr_table changing t_table = ispfli. gr_table->set_screen_status( pfstatus = 'SALV_TABLE_STANDARD' report = sy-repid set_functions = gr_table->c_functions_all ). gr_events = gr_table->get_event( ). create object event_handler. set handler event_handler->on_user_command for gr_events. 2006 SAP AG 8

set handler event_handler->on_double_click for gr_events. * Set up selections. gr_selections = gr_table->get_selections( ). gr_selections->set_selection_mode( 1 ). "Single * Display gr_table->display( ). * CLASS lcl_handle_events IMPLEMENTATION * class lcl_handle_events implementation. method on_user_command. * Get the selection rows data: lr_selections type ref to cl_salv_selections. data: lt_rows type salv_t_row. data: ls_rows type i. data: message type string. case e_salv_function. when 'MYFUNCTION'. lr_selections = gr_table->get_selections( ). lt_rows = lr_selections->get_selected_rows( ). read table lt_rows into ls_rows index 1. read table ispfli into xspfli index ls_rows. concatenate xspfli-carrid xspfli-connid xspfli-cityfrom xspfli-cityto into message separated by space. message i001(00) with 'You pushed the button!' message. endcase. endmethod. "on_user_command method on_double_click. data: message type string. data: row_c(4) type c. row_c = row. concatenate 'Row' row_c 'Column' column into message separated by space. message i001(00) with 'You double-clicked on ' message. endmethod. endclass. "on_double_click "lcl_handle_events IMPLEMENTATION 2006 SAP AG 9

Run the program, double click on the fifth row in the Depart. City column, notice the information message contains the row number and column name of the cell which you double clicked. 2006 SAP AG 10

Related Content Help - ALV Object Model Utilizing the New ALV Object Model SDN ABAP Forum 2006 SAP AG 11

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 12