In Continuation to my previous blog, in this Second part I am going to discuss and demonstrate how we technically developed this solution.
The purpose of this blog is you can create an Adobe Interactive Form (AIF) at run time without Webdynpro Java, without logging into Portal and with out user intervention using SAP R/3 4.6c. As I discussed in my previous blog (Part-I) we have scenario to have a java service which runs at regular intervals of 5 minutes, picks the Quotations created in the last 5 minutes span in R/3, Generate AIF on the fly by merging the XDP template with the data from RFC and send it as mail attachment to customers automatically. This AIF (Offline) also contains a WebService to enable the customer submit the form back directly from the desk top without logging into portal
h5. How to Implement this Solution
We have implemented this Solution by dividing it into 5 Steps.
> Creating XDP file
> Connecting to SAP and getting data
> Generating XML Data String at runtime.
> Using PDFDocument API for Dynamic Generation of Adobe Interactive Form
> Send the Generated AIF as mail Attachment using Mail API
> Scheduling the Entire Project Using KM Scheduler
Netweaver Developer Studio: 7.0.15
Adobe Reader 9.0
Adobe Live Cycle Designer 8.0
SAP Enterprise Portal 7.0 SP15 with Adobe Document Services Configured
h5. Creating XDP file
We have designed the Adobe Interactive Form using Adobe Live Cycle Designer 8.0 and placed the resultant XDP file in a shared folder on the Portal Server. Every UI Element is bound to an attribute (The attribute name is very important, as we are going to use the same name while generating the XML Data). Since the entire process has to happen in the background, we are not going to include this as part of any webdynpro application.
Connecting to SAP and getting data
Since only the .par files can be exposed as KM Scheduler Tasks, we have chosen “Portal Application Project” in Netweaver Developer Studio, for our purpose. While implementing the AIF dynamic generation functionality (in run method) we need to fetch the data that should be populated in the XDP template from RFCs (R/3) and for this we are using JCO client middle layer. Hence we are creating this SAP Connectivity to enable the NWDS generate the proxy classes for us and we are using these proxy classes to pass input parameters, get output parameters and execute the RFC. Also ensure that SAPJCorfc.DLL and sapjco.jar should be present at c:\windows\system32 on Portal Server and we need to restart the server once after placing these files.
Generating XML Data String at runtime
To be able to Schedule KM Scheduler and enable it to call our Java Application (Portal Application), application should follow Repository Framework. Usually RF is used for extending or customizing the standard delivered KM functionality by SAP (like implementing Repository Filters, Customizing Resource Renderers, Collection Renderers in KM etc..). The same RF can also be used to schedule and call any Job developed as Java Application. Technically this means our class should implement the ISchedulerTask Interface. Within our Portal Application Project, we have to create a Repository Framework and choose “Scheduler Task Wizard”. In the Scheduler Task Wizard’s screen provide a Class name, Package and Eclipse project Name and click finish.
NWDS Auto generates the skeleton for the implementation of the interface ISchedulerTask:
* *In your java class (example.java) you will find the following template already created by NWDS. We have to write the entire code that is to be called by the KM scheduler in the run method
import com.sapportals.wcm.service.;</p><p>import com.sapportals.wcm.service.scheduler.;//Written in the Custom Method getExampleDetailRFC
sb = new StringBuffer(0); for(