7 – Column Coloring in ALV

Page 1

Web Dynpro: Column Coloring in ALV

Applies to: SAP ECC 6.0

Summary The article aims to help the professionals who have only ABAP knowledge and passion to develop their Web Dynpro knowledge in ABAP. This article provides the knowledge for understanding ALV in Web dynpro and coloring a column in ALV. Author(s): J.Jayanthi Company: Siemens Information Processing Services Pvt. Ltd. Created on: 07 July 2010

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

SAP COMMUNITY NETWORK Š 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 1


Web Dynpro: Column Coloring in ALV

Table of Contents ALV in Web Dynpro ABAP ............................................................................................................................ 3 Prerequisites ................................................................................................................................................. 3 Creating Web Dynpro ................................................................................................................................ 3 Component Controller................................................................................................................................ 4 Designing View.......................................................................................................................................... 5 Embedding View...................................................................................................................................... 10 Component Usages ................................................................................................................................. 10 Creating Web Dynpro Application ............................................................................................................ 11 Code ....................................................................................................................................................... 12 Output ....................................................................................................................................................... 13 Related Content .......................................................................................................................................... 13 Copyright .................................................................................................................................................... 14

SAP COMMUNITY NETWORK Š 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 2


Web Dynpro: Column Coloring in ALV

ALV in Web Dynpro ABAP ABAP Consultants are generally familiar in SAP List Viewer (ALV) and aware of the ways to play with ALV by coloring a row, coloring a column, F4 help for a cell, displaying cell as button, coloring a cell, etc., Being an ABAP consultant, we are going to see how to approach the ALV in Web Dynpro and color a column in ALV.

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.

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

Mention the Component Use as ALV and Component as SALV_WD_TABLE in the Used Components tab in Web Dynpro (ZZZ_JAYTEST3).

SAP COMMUNITY NETWORK Š 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 3


Web Dynpro: Column Coloring in ALV

This will create a Component Usages by name ALV.

Component Controller Go to Component Controller and Right click the context. Then select Create Node.

Then select the fields from the structure.

SAP COMMUNITY NETWORK Š 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 4


Web Dynpro: Column Coloring in ALV

Double click the node Mara and then remove the dictionary structure, change the cardinality to 0:n. Uncheck the Initialization Lead selection.

Designing View Go to the layout in view and right click the ROOTUIELEMENTCONTAINER and then choose Insert element.Fill the ID and choose the Typ as ViewContainerUIElement.

SAP COMMUNITY NETWORK Š 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 5


Web Dynpro: Column Coloring in ALV

After doing the same, the layout will appear as below.

In context tab, drag and drop the context which appears under component controller to view(Main is the view name).

After drag and drop, the context will appear as below.

In the properties, define as below.

SAP COMMUNITY NETWORK Š 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 6


Web Dynpro: Column Coloring in ALV

Select the method WDDOINIT in methods tab.

Use Web Dynpro code wizard to generate code automatically. Choose the radio button Read context and then press F4 to select the context Mara.

Keep the below generated code and delete the rest which is not required.

Again use Code Wizard as below.

This will generate the below code.

Then use Method call in Used controller as below in Code Wizard.

SAP COMMUNITY NETWORK Š 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 7


Web Dynpro: Column Coloring in ALV

Then our aim is to change the Column color. To do that, we need to know the class and the method which is needed. if_salv_wd_column_settings~get_columns is the required method which is available in the class cl_salv_wd_config_table.

To change the MATNR column color, we need to use SET_CELL_DESIGN method in class cl_salv_wd_column. To generate the code, use Pattern as shown below and pass the value.

SAP COMMUNITY NETWORK Š 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 8


Web Dynpro: Column Coloring in ALV

Click the squared arrow as above to get the different values that can be passed.

SAP COMMUNITY NETWORK Š 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 9


Web Dynpro: Column Coloring in ALV

We can pass different values instead of e_cell_design-one to view different colors.

Embedding View Embed the view by right clicking the Material in the window.

Component Usages Right click the component Usage (here with name ALV) and Create controller Usage. Drag and drop the node(MARA in right side) from Component Controller context to Data(in left side) in Controller Usage Context.

SAP COMMUNITY NETWORK Š 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 10


Web Dynpro: Column Coloring in ALV

Creating Web Dynpro Application Create Web Dynpro Application by right clicking the Webdynpro(ZZZ_JAYTEST3).

Right click the Web Dynpro component and activate.

SAP COMMUNITY NETWORK Š 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 11


Web Dynpro: Column Coloring in ALV

Code

SAP COMMUNITY NETWORK © 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 12


Web Dynpro: Column Coloring in ALV

Output

1st column appears with different color.

Related Content Please include at least three references to SDN documents or web pages. Reference 1 Reference 2

SAP COMMUNITY NETWORK Š 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 13


Web Dynpro: Column Coloring in ALV

Copyright © Copyright 2010 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Serv er, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries. Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsi us, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable fo r errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituti ng an additional warranty.

SAP COMMUNITY NETWORK © 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 14


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.