Vous êtes sur la page 1sur 13

How to Use Confirmation Popups in Web Dynpro for ABAP

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

Summary
If you are familiar with using the function module POPUP_TO_CONFIRM in your ABAP applications, you may have wondered how to use confirmation popups in Web Dynpro for ABAP. This article will show you how. Author: Christine Arundell
st

Company: SAP Created on: 1 November 2011

Author Bio
Christine Arundell is a Senior Education Consultant with SAP UK. She teaches courses across the entire ABAP curriculum.

SAP COMMUNITY NETWORK 2011 SAP AG

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

How to Use Confirmation Popups in Web Dynpro for ABAP

Table of Contents
Using Confirmation Popups in Web Dynpro for ABAP ....................................................................................... 3 Related Content ................................................................................................................................................ 12 Copyright........................................................................................................................................................... 13

SAP COMMUNITY NETWORK 2011 SAP AG

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

How to Use Confirmation Popups in Web Dynpro for ABAP

Using Confirmation Popups in Web Dynpro for ABAP


Create a new Web Dynpro Component called ZNET310_POPUP_CONFIRM_##

When prompted, assign it to your package and change request as usual. In the Context of the Component Controller, create a node called PAY, cardinality of 1:1:

Now right-click on the new node to add an attribute SALARY, type I.

SAP COMMUNITY NETWORK 2011 SAP AG

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

How to Use Confirmation Popups in Web Dynpro for ABAP

Map the Component Controller context to the context of your view:

In the Layout of your view, add a Label UI element with the text Please enter your current salary, and create an InputField, bound to the PAY attribute just created:

Next create a button, with the text INCREASE SALARY, and an ACTION called INCREASE.

SAP COMMUNITY NETWORK 2011 SAP AG

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

How to Use Confirmation Popups in Web Dynpro for ABAP

Go to the Event Handler method for the action, and put your cursor in the appropriate place:

Use the Web Dynpro Code Wizard and choose the appropriate radiobutton

SAP COMMUNITY NETWORK 2011 SAP AG

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

How to Use Confirmation Popups in Web Dynpro for ABAP

Result:

We want all of this code except for the CREATE_WINDOW method instead we are going to call the CREATE_POPUP_TO_CONFIRM method to produce the confirmation popup box. Remove the CREATE_WINDOW method:

Where the CREATE_WINDOW method was, we are going to add a different method we can use the PATTERN functionality to do this, first ensure your cursor is positioned where you want the new method to be added, then hit the PATTERN pushbutton:

Choose ABAP Objects Patterns, then hit the green tick to continue:

Populate as shown below, then choose the green tick to insert the code:

SAP COMMUNITY NETWORK 2011 SAP AG

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

How to Use Confirmation Popups in Web Dynpro for ABAP

Result:

Set values of parameters as shown below:

If you activate everything and create an application for your Web Dynpro Component and run it now, you should see your popup working:

SAP COMMUNITY NETWORK 2011 SAP AG

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

How to Use Confirmation Popups in Web Dynpro for ABAP

To react to the user pressing either of the buttons, we need to proceed as follows. Go back to the method where you implemented the popup. BEFORE the OPEN method at the end, we need to assign an action to each of the buttons, which we can then program the logic for. Firstly, use the Web Dynpro Code Wizard and populate as follows:

SAP COMMUNITY NETWORK 2011 SAP AG

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

How to Use Confirmation Popups in Web Dynpro for ABAP

Result:

Now use the PATTERN button again (as described above) to add the following method call:

Populate the parameters of the method as shown below the ACTION_NAME is an action which we will create in our view in just a moment:

SAP COMMUNITY NETWORK 2011 SAP AG

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

How to Use Confirmation Popups in Web Dynpro for ABAP

We now need to create the action which we have assigned to the YES button, and program the event handler method. Switch to the ACTIONS tab in your view and create the action as shown below:

Now switch to the METHODS tab and you should see the event handler has been created for you:

Double-click on the method to implement it. We will just issue a simple message to prove that we know the user has pressed the YES button. Position your cursor between the METHOD..ENDMETHOD:

Use the WIZARD:

SAP COMMUNITY NETWORK 2011 SAP AG

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

How to Use Confirmation Popups in Web Dynpro for ABAP

Populate the parameters of the resulting method call as shown below:

Activate your changes and test:

You can now repeat as above to apply the logic for the NO pushbutton.

SAP COMMUNITY NETWORK 2011 SAP AG

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

How to Use Confirmation Popups in Web Dynpro for ABAP

Related Content
For more information, visit the ABAP homepage

SAP COMMUNITY NETWORK 2011 SAP AG

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

How to Use Confirmation Popups in Web Dynpro for ABAP

Copyright
Copyright 2011 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 Server, 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 Oracle Corporation. JavaScript is a registered trademark of Oracle Corporation, 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, Xcelsius, 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 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.

SAP COMMUNITY NETWORK 2011 SAP AG

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

Vous aimerez peut-être aussi