You are on page 1of 27

UP361

Adding Dynamic Features to your SAP Interactive Forms by Adobe

Marc Chan, SAP NetWeaver RIG APJ Boris Magocsi, SAP NetWeaver RIG Americas Peter McNulty, SAP NetWeaver PMO Daniel Yackel, SAP NetWeaver RIG Americas

Disclaimer

This presentation outlines our general product direction and should not be relied on in making a purchase decision. This presentation is not subject to your license agreement or any other agreement with SAP. SAP has no obligation to pursue any course of business outlined in this presentation or to develop or release any functionality mentioned in this presentation. This presentation and SAP's strategy and possible future developments are subject to change and may be changed by SAP at any time for any reason without notice. This document is provided 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 assumes no responsibility for errors or omissions in this document, except if such damages were caused by SAP intentionally or grossly negligent.

SAP 2008 / SAP TechEd 08 / UP361 Page 2

Agenda

1. Using form scripting on the PDF


1.1 1.2 1.3 1.4 Introducing form scripting Controlling the presence of UI elements Adding rows to a table interactively Calculating summation

2. Making use of the PDF Document API

SAP 2008 / SAP TechEd 08 / UP361 Page 3

Introduction to Form Scripting on PDF

Adobe LiveCycle Designer enables a form developer to build intelligent forms using only the options provided in the Adobe LiveCycle Designer graphical interface. By scripting against the XML Form Object Model, the form developer may further manipulate all aspects of the form, extending the functionality of the form beyond what is available through the LiveCycle Designer interface. Scripting is supported in two languages: FormCalc, a calculation language created by Adobe, and JavaScript, a powerful and popular scripting language. Detail of the XML Form Object Model can be found from:
http://partners.adobe.com/public/developer/en/xml/Adobe_XML_Form_Object_Model_Reference.pdf

SAP 2008 / SAP TechEd 08 / UP361 Page 4

Basics of Form Scripting

Specify the action for triggering the script.

Specify whether you script with FormCalc or Java Script

Specify script to be ran at client or server side.

Use the Script Editor to write scripts for a form design The scripts written will be embeded in the XML Source. Use the PDF Preview tab to view and test a form design as a PDF form

Use the Hierarchy palette to select and manipulate objects, and to locate an object in the form hierarchy.

SAP 2008 / SAP TechEd 08 / UP361 Page 5

Before You Start Scripting

Make sure Dynamic XML Form is set to enable script execution on the form during runtime. In the Adobe LiveCycle Designer, go to Edit -> Form Properties -> Defaults. Configure the XDP Preview Format in the Preview section and PDF Render Format in the Server section.

SAP 2008 / SAP TechEd 08 / UP361 Page 6

Controlling the Visibility of an UI Element

The visibility of an UI element is controlled by setting the presence properties to visible or invisible. In the same way, you can control the visibility of a subform so you can toggle the presence of all the UI elements inside.
Example 1: Setting a field to be visible or invisible // If a field is visible, make it invisible and vice versa. if(Field1.presence == "visible){ Field1.presence = "invisible"; } else { Field1.presence = "visible"; } Example 2: Setting a subform to be visible when a checkbox is checked // If the checkbox is checked, set the subform to be visible and vice versa if (CheckBox1.rawValue == 0) { Subform1.presence = "invisible"; } else { Subform1.presence = "visible"; }

SAP 2008 / SAP TechEd 08 / UP361 Page 7

Adding Rows to a Table Dynamically

A table row is basically a subform. Inserting a row in the table actually means adding an instance of the subform on the table. Make use of the instanceManger of the subform to insert or remove instance of the table row.

SAP 2008 / SAP TechEd 08 / UP361 Page 8

Dynamic Table Rows in Web Dynpro Runtime

In Web Dynpro environment, the number of table rows to be displayed is controlled by the number of instance of the Web Dynpro context node the table row binds to. For example, if you have 5 instances of the context node during runtime, the table on the PDF generated will have 5 table rows by default. To allow the PDF only display 1 table row by default but allow users to add more rows dynamically, the followings have to be done: Remove the subform instances created by Web Dynpro runtime during initialization. This can be done by a simple for-loop script in the initialize action of the Table subform. The number of instances of Web Dynpro context nodes should be treated as the max number of rows you can have in the table. You should configure this as the max number of row for the Table row. Clicking on the Add Row button will just insert an instance of the subform just like before.

SAP 2008 / SAP TechEd 08 / UP361 Page 9

Calculating Summation in a Table

Supposed you want to sum up the prices in a table for the total every time a user enters the amount. This can be easily done by using the FormCalc script on the exit event on the field where the user enters the amount.

SAP 2008 / SAP TechEd 08 / UP361 Page 10

Ex. 1 Scripting on SAP Interactive Forms by Adobe


SAP 2008 / SAP TechEd 08 / <Session ID> Page 11

Agenda

1. Using form scripting on the PDF


1.1 1.2 1.3 1.4 Introducing form scripting Controlling the presence of UI elements Adding rows to a table interactively Calculating summation

2. Making use of the PDF Document API

SAP 2008 / SAP TechEd 08 / UP361 Page 12

Overview of the IWDPDFDocument API

IWDPDFDocument API allows dynamic construction and manipulation of new or existing PDF document objects. You can:

Create documents using a template (layout) and data. Template + data = PDF. Add attachments to documents Change the document appearance (hide menu bars, magnification) Digitally sign the document using a private key Change the dynamic mode of the document Extract data in XML form from an existing document

Functionality is found in the following packages:


com.sap.tc.webdynpro.clientserver.adobe.api com.sap.tc.webdynpro.clientserver.adobe.pdfdocument.api Older classes in com.sap.tc.webdynpro.pdfobject.api package are deprecated!

SAP 2008 / SAP TechEd 08 / UP361 Page 13

Usage Scenario for Dynamic Creation of Interactive Forms

Static PDF download by users. Everyone gets the same copy.

Generate a new PDF through the PDF Document API.

Form template in XDP format

User downloads a PDF with personalized data

Personalized data wrapped in XML

SAP 2008 / SAP TechEd 08 / UP361 Page 14

Templates in XDP

XML Data Package (XDP) allows PDF content to be packaged within an XML container. XDP can contain template information to build the UI: drop downs, text fields, etc. <field name="DestinationCity" y="127mm" x="19.05mm" w="101.6mm" h="9mm"> <ui> <textEdit> <border> <edge stroke="lowered"/> </border> <margin/> </textEdit> </ui> ... <bind match="dataRef" ref="$record.TravelData[*].DestinationCity"/> </field>

SAP 2008 / SAP TechEd 08 / UP361 Page 15

XML Data

XML data is raw XML containing only the data values.


<TravelData> <ArrvialDate>2008-04-28</ArrvialDate> <DepartureDate>2008-04-30</DepartureDate> <DestinationCity>San Diego</DestinationCity> </TravelData>

SAP 2008 / SAP TechEd 08 / UP361 Page 16

Dynamic Creation of a PDF: IWDPDFDocumentCreationContext


IWDPDFDocumentHandler hndlr= WDPDFDocumentFactory.getDocumentHandler(); IWDPDFDocumentCreationContext cxt = hndlr.getDocumentCreationContext(); // byte [] containing raw XML data cxt.setData( rawXMLAsByteArray ); // byte [] containing XDP template cxt.setTemplate( rawXDLAsByteArray ); IWDPDFDocument document = context.execute();

SAP 2008 / SAP TechEd 08 / UP361 Page 17

Working with an Existing PDF: IWDPDFDocumentAccessibleContext


IWDPDFDocumentHandler hdlr = WDPDFDocumentFactory.getDocumentHandler(); IWDPDFDocumentCreationContext cxt = hdlr.getDocumentAccessibleContext(); // myPDFByteArray is a byte [] containing // the raw PDF data ctx.setPDF( myPDFByteArray ); IWDPDFDocument theDocument = ctx.execute();

SAP 2008 / SAP TechEd 08 / UP361 Page 18

Working with IWDResource Objects

Use WDResourceFactory to create IWDResource objects from byte arrays, InputStreams, or context attributes. Example of loading a resource from deployment unit:
String resultPDFPath = WDURLGenerator.getResourcePath( wdComponentAPI.getDeployableObjectPart(), example.pdf"); FileInputStream in = new FileInputStream(resultPDFPath); IWDResource resource = WDResourceFactory. createResource(in, "result.pdf", WDWebResourceType.PDF, false);

SAP 2008 / SAP TechEd 08 / UP361 Page 19

Extracting the Data from an IWDPDFDocument

Once you have the IWDPDFDocument of the pdf, you can apply the getData() method to retrieve the data from it. Below is a sample custom method for doing so.
private String getPDFData( IWDPDFDocument document ) { try { InputStream ins = document.getData(); StringWriter sw = new StringWriter(); while ( ins.available() > 0 ) { sw.write(ins.read()); } return sw.toString(); } catch ( IOException e ) { throw new WDRuntimeException("Can not read PDF data: " + e); } }

SAP 2008 / SAP TechEd 08 / UP361 Page 20

Ex. 2 Generating an Interactive Form using the PDF Document API


SAP 2008 / SAP TechEd 08 / <Session ID> Page 21

Building Your Business with SDN Subscriptions SDN Subscriptions offers developers and consultants like you, an annual license to the complete SAP NetWeaver platform software, related services, and educational content, to keep you at the top of your profession.
SDN Software Subscriptions: (currently available in U.S. and Germany)
A

one year low cost, development, test, and commercialization license to the complete SAP NetWeaver software platform Automatic notification for patches and updates Continuous learning presentations and demos to build expertise in each of the SAP NetWeaver platform components A personal SAP namespace

SAP NetWeaver Content Subscription: (available globally)


An

online library of continuous learning content to help build skills.

Starter Kit

To learn more or to get your own SDN Subscription, visit us at the Community Clubhouse or at www.sdn.sap.com/irj/sdn/subscriptions
SAP 2008 / SAP TechEd 08 / UP361 Page 22

Fuel your Career with SAP Certification

What the industry is saying

Teams with certified architects and developers deliver projects on specification, on time, and on budget more often than other teams.
2008 IDC Certification Analysis

82% of hiring managers use certification as a hiring criteria.


2008 SAP Client Survey

SAP Certified Application Professional status is proof of quality, and thats what matters most to customers.*
Conny Dahlgren, SAP Certified Professional

Take advantage of the enhanced, expanded and multi tier certifications from SAP today!

Further Information

SAP Public Web:


SAP Developer Network (SDN): www.sdn.sap.com IFbA section in SDN: https://www.sdn.sap.com/irj/sdn/adobe Business Process Expert (BPX) Community: www.bpx.sap.com

Related SAP Education and Certification Opportunities


http://www.sap.com/education/

Related Workshops/Lectures at SAP TechEd 2008


UP361, Adding Dynamic Features to your SAP Interactive Forms by Adobe UP266, Bring Your Existing Business Workflow into a new dimension by Utilizing IFbA SIM266, Security aspects in SAP Interactive Forms by Adobe

SAP 2008 / SAP TechEd 08 / UP361 Page 24

Thank you!

SAP 2008 / SAP TechEd 08 / <Session ID> Page 25

Feedback Please complete your session evaluation.


Be courteous deposit your trash, and do not take the handouts for the following session.

Thank You !
SAP 2008 / SAP TechEd 08 / UP361 Page 26

Copyright 2008 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. SAP, R/3, xApps, xApp, SAP NetWeaver, Duet, SAP Business ByDesign, ByDesign, PartnerEdge 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 and associated logos displayed are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. The information in this document is proprietary to SAP. No part of this document may be reproduced, copied, or transmitted in any form or for any purpose without the express prior written permission of SAP AG. This document is a preliminary version and not subject to your license agreement or any other agreement with SAP. This document contains only intended strategies, developments, and functionalities of the SAP product and is not intended to be binding upon SAP to any particular course of business, product strategy, and/or development. Please note that this document is subject to change and may be changed by SAP at any time without notice. SAP assumes no responsibility for errors or omissions in this document. SAP does not warrant the accuracy or completeness of the information, text, graphics, links, or other items contained within this material. This document is provided 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 have no liability for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. This limitation shall not apply in cases of intent or gross negligence. The statutory liability for personal injury and defective products is not affected. 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.

Weitergabe und Vervielfltigung dieser Publikation oder von Teilen daraus sind, zu welchem Zweck und in welcher Form auch immer, ohne die ausdrckliche schriftliche Genehmigung durch SAP AG nicht gestattet. In dieser Publikation enthaltene Informationen knnen ohne vorherige Ankndigung gendert werden. Einige von der SAP AG und deren Vertriebspartnern vertriebene Softwareprodukte knnen Softwarekomponenten umfassen, die Eigentum anderer Softwarehersteller sind. SAP, R/3, xApps, xApp, SAP NetWeaver, Duet, SAP Business ByDesign, ByDesign, PartnerEdge und andere in diesem Dokument erwhnte SAP-Produkte und Services sowie die dazugehrigen Logos sind Marken oder eingetragene Marken der SAP AG in Deutschland und in mehreren anderen Lndern weltweit. Alle anderen in diesem Dokument erwhnten Namen von Produkten und Services sowie die damit verbundenen Firmenlogos sind Marken der jeweiligen Unternehmen. Die Angaben im Text sind unverbindlich und dienen lediglich zu Informationszwecken. Produkte knnen lnderspezifische Unterschiede aufweisen. Die in dieser Publikation enthaltene Information ist Eigentum der SAP. Weitergabe und Vervielfltigung dieser Publikation oder von Teilen daraus sind, zu welchem Zweck und in welcher Form auch immer, nur mit ausdrcklicher schriftlicher Genehmigung durch SAP AG gestattet. Bei dieser Publikation handelt es sich um eine vorlufige Version, die nicht Ihrem gltigen Lizenzvertrag oder anderen Vereinbarungen mit SAP unterliegt. Diese Publikation enthlt nur vorgesehene Strategien, Entwicklungen und Funktionen des SAP-Produkts. SAP entsteht aus dieser Publikation keine Verpflichtung zu einer bestimmten Geschfts- oder Produktstrategie und/oder bestimmten Entwicklungen. Diese Publikation kann von SAP jederzeit ohne vorherige Ankndigung gendert werden. SAP bernimmt keine Haftung fr Fehler oder Auslassungen in dieser Publikation. Des Weiteren bernimmt SAP keine Garantie fr die Exaktheit oder Vollstndigkeit der Informationen, Texte, Grafiken, Links und sonstigen in dieser Publikation enthaltenen Elementen. Diese Publikation wird ohne jegliche Gewhr, weder ausdrcklich noch stillschweigend, bereitgestellt. Dies gilt u. a., aber nicht ausschlielich, hinsichtlich der Gewhrleistung der Marktgngigkeit und der Eignung fr einen bestimmten Zweck sowie fr die Gewhrleistung der Nichtverletzung geltenden Rechts. SAP haftet nicht fr entstandene Schden. Dies gilt u. a. und uneingeschrnkt fr konkrete, besondere und mittelbare Schden oder Folgeschden, die aus der Nutzung dieser Materialien entstehen knnen. Diese Einschrnkung gilt nicht bei Vorsatz oder grober Fahrlssigkeit. Die gesetzliche Haftung bei Personenschden oder Produkthaftung bleibt unberhrt. Die Informationen, auf die Sie mglicherweise ber die in diesem Material enthaltenen Hotlinks zugreifen, unterliegen nicht dem Einfluss von SAP, und SAP untersttzt nicht die Nutzung von Internetseiten Dritter durch Sie und gibt keinerlei Gewhrleistungen oder Zusagen ber Internetseiten Dritter ab. Alle Rechte vorbehalten.
SAP 2008 / SAP TechEd 08 / UP361 Page 27