Value help

Page 1

Value Help in Web Dynpro ABAP Tutorial.

Applies to: Web Dynpro for ABAP, For more information, visit the Web Dynpro ABAP homepage.

Summary In this tutorial I want to explain how to set value help for UI elements of your Web Dynpro ABAP application. Author:

Patrick Johann

Company: SAP Created on: 12. March 2009

Author Bio Patrick Johann is in the first year of Vocational Training as an IT Specialist – Application Development at SAP. At the moment he is working in a SAP Net Weaver Product Management User Interaction Team and is doing Web Dynpro for ABAP.

SAP COMMUNITY NETWORK © 2008 SAP AG

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


Value Help in Web Dynpro ABAP - Tutorial.

Table of Content Exercise Objectives: ...........................................................................................................................................3 Know and use the different kinds of value helps ............................................................................................3 Process at runtime: .........................................................................................................................................3 Procedure: ..........................................................................................................................................................3 READ_CARRID: .............................................................................................................................................3 VALUESET_CARRID:.....................................................................................................................................4 Related Contents ................................................................................................................................................5 Copyright.............................................................................................................................................................6

SAP COMMUNITY NETWORK Š 2009 SAP AG

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


Value Help in Web Dynpro ABAP - Tutorial.

Exercise Objectives: Know and use the different kinds of value helps •

Create a DropDownByKey UI-element and define the value help dynamically

Process at runtime: The user looks at a view which offers a drop down input field and three regular input fields. They don’t have an effect but every element has its own value help.

Procedure: 1.

Start the Object Navigator (transaction code SE80). Create a new Web Dynpro component (suggested name: ‘Z##_VALUE_HELP’), one window and one view (suggested names: ‘MAIN_WINDOW’ and ‘MAIN_VIEW’). Embed the view in the window if it hasn’t been done automatically.

2.

Navigate to COMPONENTCONTROLLER. Create a context node named FLIGHTINFO (cardinality 1:1) with the type of the dictionary structure SFLIGHT, and with the attributes CARRID, CONNID, FLDATE und PRICE.

3.

Click on the attribute CARRID. With the click the attribute properties appear below. Look at the Input Help Mode property and change it to automatically if it isn’t set already to it. Do the same with the FLDATE attribute. For CONNID choose Dictionary Search Help, and for PRICE deactivate the help mode, because we don’t want a value help for this input. The automatic help mode will be defined at Web Dynpro runtime. It uses an already defined value help from the dictionary element you use. The Dictionary Search Help property allows the developer to choose a dictionary defined value help.

4.

Now we want to set an individual value set for the CARRID attribute. This has to been done dynamically in the view controller, but first we have to write a few lines of code to get the data from the dictionary. Create a new method in the component controller (suggested name: ‘READ_CARRID’). Define an exporting parameter of type WDY_KEY_VALUE_TABLE in the signature of your created method. To get the data from the dictionary you only have to code an array fetch on the table SCARR into your itab. Select the fields Carrid and Carrname. Then order the itab by carrid.

READ_CARRID: METHOD read_carrid. SELECT carrid carrname FROM scarr INTO TABLE e_carrier_vs ORDER BY carrid. ENDMETHOD.

SAP COMMUNITY NETWORK © 2009 SAP AG

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


Value Help in Web Dynpro ABAP - Tutorial.

5.

Now navigate to the view controller and add a new method (suggested name: ‘VALUESET_CARRID’). Use the code wizard to call the created method in your component controller. Moreover declare two local objects with reference to IF_WD_CONTEXT_NODE and IF_WD_CONTEXT_NODE_INFO. Navigate from the context to FLIGHTINFO with the context method get_child_node( ). After that, call the method get_node_info( ). To set the new value set, call the method set_attribute_value_set( ) of your local node info.

VALUESET_CARRID: METHOD valueset_carrid. DATA DATA DATA DATA

lo_nd_flightinfo lo_nd_info_flightinfo lt_value_set lo_componentcontroller

TYPE REF TO if_wd_context_node. TYPE REF TO if_wd_context_node_info. TYPE wdy_key_value_table. TYPE REF TO ig_componentcontroller .

lo_nd_flightinfo = wd_context->get_child_node( name = 'FLIGHTINFO' ). lo_nd_info_flightinfo = lo_nd_flightinfo->get_node_info( ). lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).

lo_componentcontroller->read_carrid( IMPORTING e_carrier_vs = lt_value_set ).

lo_nd_info_flightinfo->set_attribute_value_set( name = 'CARRID' value_set = lt_value_set ). ENDMETHOD. 6.

Open the hook method WDDOINIT of the view and implement the method that you created in the previous step to get the value set BEFORE the view is displayed.

7.

Now we go back to the COMPONENTCONTROLLER and have a look at the node attribute CONNID. In step three we chose the dictionary search as the help mode. You get another input field called Dictionary search help. Enter ‘ZSHG_H_SPFLI_CONNID’. This value help shows more details to the connection than the regular help for the CONNID field.

8.

Map the Context from your controller to the context of the view and implement a form on the layout with the code wizard and display all node attributes.

9.

Finally delete the generated Input Field for Carrid and replace it by a DropDownByKey UI element. Bind the necessary selectedKey property to Carrid and correct the generated label.

SAP COMMUNITY NETWORK © 2009 SAP AG

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


Value Help in Web Dynpro ABAP - Tutorial.

Related Contents For more information, visit the Web Dynpro ABAP homepage. For more information, visit the User Interface Technology homepage.

SAP COMMUNITY NETWORK Š 2009 SAP AG

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


Value Help in Web Dynpro ABAP - Tutorial.

Copyright © 2009 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, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, System i, System i5, System p, System p5, System x, System z, System z9, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix, i5/OS, POWER, POWER5, POWER5+, OpenPower and PowerPC are trademarks or registered trademarks of IBM Corporation. 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. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, 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 in several other countries all over the world. 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 for 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 constituting an additional warranty. These materials are provided “as is” without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages. Any software coding and/or code lines/strings (“Code”) included in this documentation are only examples and are not intended to be used in a productive system environment. The Code is only intended better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, except if such damages were caused by SAP intentionally or grossly negligent.

SAP COMMUNITY NETWORK © 2009 SAP AG

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


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