ALV with Dynamic Structure in Web DynPro

Similar documents
Web Dynpro ABAP: Dynamic Table

Working with the Roadmap UI Element in Web Dynpro ABAP

Table Row Popup in Web Dynpro Component

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

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

Working with Tabstrip in Webdynpro for ABAP

Working with Dynamic Tables in Interactive Adobe Forms and WebDynpro ABAP

Table Popins and Business Graphics in Web Dynpro ABAP

WDA Tutorial II: Using Select Options in a WDA Application

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

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

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

POWL: Infoset Generation with Web Dynpro ABAP

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

Web Dynpro ABAP: Changing ALV Contents and Saving in Database

SMT (Service Mapping Tool)

Integrating POWL with WebDynpro ABAP

Dialog Windows in WebDynpro ABAP Applications

Easy Lookup in Process Integration 7.1

Using Radio Buttons in Web Template

Freely Programmed Help- Web Dynpro

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

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

SDN Community Contribution

How to Create Business Graphics in Web Dynpro for ABAP

SDN Community Contribution

BAPI Execution in offline Adobe Form

Sales Order Creation using Web Dynpro ABAP

Internationalization in WebDynpro ABAP Applications

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

Dynamically Enable / Disable Fields in Table Maintenance Generator

DB Connect with Delta Mechanism

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

Linking Documents with Web Templates

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

Step by Step Procedure for DSO Creation

Standalone BW System Refresh

ALV Object Model Hierarchical Sequential List The Basics

Value Help in Web Dynpro ABAP - Tutorial.

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

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

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

Step by Step Guide on How to Use Cell Definition in BEx Query

Displaying HR Organizational Tree Structure in Web Dynpro

Reporting Duplicate Entries

Creation of Key Figures with Higher Decimal Place Precision

Maintaining Roles and Authorizations in BI7.0 - RSECADMIN

MDM Syndicator: Custom Items Tab

Web Dynpro: Coloring Table Conditionally

Implying Security on Business Object XI 3.1 Universe having SAP BW as Source

Displaying SAP Transaction as Internet Application in Portal

SAP BW Copy Existing DTP for Data Targets

How to Create View on Different Tables and Load Data through Generic Datasource based on that View

Upload Image file from system in Web dynpro view

Recreating BIA Indexes to Address the Growth of Fact Index Table

Using Query Extract to Export Data from Business warehouse, With Pros and Cons Analyzed

ABAP HR: Standard Info Type Enhancement

Transfer Material Attributes (Material Type) from R/3 to SAP GRC Global Trade Services (GTS)

Download SAP Query Output to Local/ Network Folders in Background

About ITAB Duplicate_Key (SAP lrsaods) Runtime Error

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

Developing Crystal Reports on SAP BW

Creating Rules in Process Composer and using them in Process

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

Process Chain Log Deletion

Database Statistics During ODS Activation

Common Queries/Errors while working with Adobe Print PDF Forms

Data Extraction & DS Enhancement in SAP BI Step by Step

Step by Step Method for File Archival in BW

Limitation in BAPI Scheduling Agreement (SA) Create or Change

Customized Transaction to Trigger Process Chain from Failed Step

Triggering the Process Chains at Particular Date using Events

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

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

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

Material Master Archiving in Simple Method

Financial Statement Version into PDF Reader

Graphical Mapping Technique in SAP NetWeaver Process Integration

Information Broadcasting Part 3 Scheduling the First Report

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

Procedure to Trigger Events in Remote System Using an ABAP Program

Step By Step: the Process of Selective Deletion from a DSO

Replacement Path: Explained with an Illustrated Example

Changing the Source System Assignments in SAP BW Objects without Affecting the Data Modeling

Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

List of Values in BusinessObjects Web Intelligence Prompts

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

Custom Process types Remote Trigger and End Time

Table Properties and Table Popin

Custom BADI Using Function Module UJQ_RUN_AXIS_QUERY

Material Master Extension for New Plant

Totals in Adobe forms

Currency Translation in SAP BI Step by step Guide

How to Create and Schedule Publications from Crystal Reports

Material Listing and Exclusion

Reading Enhanced DataSource fields for the Remote Cube

How to Configure User Status in mysap SRM

Explore to the Update Tab of Data Transfer Process in SAP BI 7.0

A Step-by-Step Guide on IDoc-ALE between Two SAP Servers

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

Transcription:

ALV with Dynamic Structure in Web DynPro Applies to: Web DynPro ABAP. For more information, visit the Web Dynpro ABAP homepage. Summary Though it s always better to give all the design to your WDC before running it, sometimes dynamic creation of ALV and the layout can be a good idea. It saves the effort that d go into creating nodes and modifying the attributes time and again. This manual guides you through the creation of an ALV WebdynPro Component that builds itself up even as it runs. Author: Pushpraj Singh Company: Infosys technologies Limited Created on: 09 December 2009 Author Bio Pushpraj Singh is currently placed as a senior ABAP consultant at Infosys. He has worked on a few Web DynPro developments and find the field very interesting. 2009 SAP AG 1

Table of Contents Pre requisite Skills... 3 Steps to create a dynamically structured ALV WebdynPro Application... 3 Related Content... 15 Disclaimer and Liability Notice... 16 2009 SAP AG 2

Pre requisite Skills You should know the ABCs of Web DynPros : node, attribute, view, application, etc are. Having created a static ALV WDC before would be really recommended. Steps to create a dynamically structured ALV WebdynPro Application 1. Go to the transaction SE80 and choose Web Dynpro Comp. / Intf. In the list. Give a name and press Enter. 2. You d be asked to enter a description. Enter and press enter. 2009 SAP AG 3

3. Go to the WDC (WebdynPro Component) you just created and add the usage of the ALV component (Component SALV_WD_TABLE) 2009 SAP AG 4

4. Now go to the MAIN view and to the Properties tab. (In case your SAPGUI doesn t create the MAIN view automatically create it manually) Click on the Create Controller Usage button and choose both the ALV component usages from the pop up. 2009 SAP AG 5

5. Go to the Layout tab of the view and create a group. In this group add a View Container UI Element with the id view_cont. 2009 SAP AG 6

6. Now go to the Methods tab of the view and write the following code in the method WDDOMODIFYVIEW (Method for Modifying the View Before Rendering). METHOD wddomodifyview. "this check avoids the creation of the node 'ALV' again on "any ALV event and thus prevents dump IF first_time EQ abap_true. TYPES : lst_sflight TYPE STANDARD TABLE OF sflight. DATA : li_sflight TYPE lst_sflight, lw_sflight TYPE sflight. "add the fields to be used as ALV columns DATA : li_comp TYPE cl_abap_structdescr=>component_table. ********************************************************************** "this is the portion of the code where we can add or remove fields "to or from the ALV wd_this->fill_comp( EXPORTING fv_name = 'CARRID' " this would be the name of the attribute unde 2009 SAP AG 7

r the node 'ALV' fv_data_element = 'S_CARR_ID' " data element IMPORTING fi_comp = li_comp " cl_abap_structdescr=>component_table ). wd_this->fill_comp( EXPORTING fv_name = 'CONNID' " this would be the name of the attribute unde r the node 'ALV' fv_data_element = 'S_CONN_ID' " data element IMPORTING fi_comp = li_comp " cl_abap_structdescr=>component_table ). wd_this->fill_comp( EXPORTING fv_name = 'FLDATE' " this would be the name of the attribute unde r the node 'ALV' fv_data_element = 'S_DATE' " data element IMPORTING fi_comp = li_comp " cl_abap_structdescr=>component_table ). wd_this->fill_comp( EXPORTING fv_name = 'PRICE' " this would be the name of the attribute under the node 'ALV' fv_data_element = 'S_PRICE' " data element IMPORTING fi_comp = li_comp " cl_abap_structdescr=>component_table ). ********************************************************************** "create the desired structure and assign it to a new dynamic context node DATA: lo_root_info TYPE REF TO if_wd_context_node_info, lo_node_info TYPE REF TO if_wd_context_node_info, lo_structdescr TYPE REF TO cl_abap_structdescr. CALL METHOD cl_abap_structdescr=>create EXPORTING p_components = li_comp RECEIVING p_result = lo_structdescr. * Get context node info lo_root_info = wd_context->get_node_info( ). * Generate new node 'ALV' with the dynamic structure CALL METHOD lo_root_info->add_new_child_node EXPORTING name = 'ALV' is_initialize_lead_selection = abap_false static_element_rtti = lo_structdescr is_static = abap_false RECEIVING child_node_info = lo_node_info. 2009 SAP AG 8

* get instance of new node DATA : lo_dyn_node TYPE REF TO if_wd_context_node. lo_dyn_node = wd_context->get_child_node( name = 'ALV' ). "Populate the internal table SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE li_sflight UP TO 38 ROWS. "transfer the contents of the internal table to the node lo_dyn_node->bind_table( li_sflight ). *Get reference to model DATA : lo_interfacecontroller TYPE REF TO iwci_salv_wd_table. lo_interfacecontroller = wd_this->wd_cpifc_alv( ). lo_interfacecontroller->set_data( lo_dyn_node ). ENDIF. ENDMETHOD. Go to the method List of the View and add a method fill_comp. 2009 SAP AG 9

METHOD fill_comp. DATA : lw_comp TYPE cl_abap_structdescr=>component, lv_type TYPE REF TO cl_abap_datadescr. lw_comp-name = fv_name. lv_type?= cl_abap_typedescr=>describe_by_name( p_name = fv_data_element ). lw_comp-type = lv_type. APPEND lw_comp TO fi_comp. ENDMETHOD. 7. In order to show the ALV inside the View, we must embed the Table View of the SALV_WD_TABLE component. Go to the Window and select the View Container UI Element (view_cont) that was created earlier. Right click on it. 2009 SAP AG 10

8. Choose TABLE of the ALV component. 2009 SAP AG 11

9. Right Click on the component and create a WebdynPro Application. 2009 SAP AG 12

10. Activate everything. 11. Execute the WDA. 2009 SAP AG 13

As we can see, without having to create (or change) the context we can get any structure we want by simply doing a few changes to the code written in the method WDDOMODIFYVIEW. 2009 SAP AG 14

Related Content http://www.sdn.sap.com/irj/scn/elearn?rid=/library/uuid/201ddd3b-b4ce-2b10-8883-880ae8147f89 http://www.saptechnical.com/tutorials/webdynproabap/dynamicalv/demo.htm?blog=/pub/wlg/2888 For more information, visit the Web Dynpro ABAP homepage. 2009 SAP AG 15

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. 2009 SAP AG 16