Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

As we mentioned in Dynamic Generation of Offline Adobe Interactive forms for SAP 4.6c and EP 7.0 without User Intervent... and Dynamic Generation of Offline Adobe Interactive forms for SAP 4.6c and EP 7.0 without User Intervent... of our blogs posted by Sankar Narayana Kalapatapu, Our requirement is to mail an offline adobe interactive form to the customer every time a new sales order quotation is created in R/3, with out any user interaction. In Part-I and Part-II, we have explained our thought process to reach to this solution, usage of KM Scheduler and explained how to dynamically generate Offline Adobe Interactive Form (at runtime) and send it to the customer as email attachment. 

Purpose of this Blog

 

Once after receiving the email, Customer would save the Offline Adobe Interactive form (Attachment in the mail) on to his desktop, open the adobe form and make the required changes and submits the form by clicking on submit button which in turn posts the changed order data to SAP. In Continuation to Part-II, in this 3rd part, I am going to discuss how to enable the customer to submit the Adobe Interactive Form (Offline) right from his desktop, which in turn updates SAP, with out logging into portal or without any execution environment. When I searched In SDN, I found that all the Offline Scenarios are being achieved by logging into portal, downloading the Form, editing the form and then uploading it back in portal, but our requirement demands that the customer should be able to submit the form, without logging into either SAP R/3 or Portal.

 

  
Solution

We learned that the only way to execute an action with out any execution platform is through Web Service. We realized that we could not make use of SAP R/3 capability to expose the RFC (that updates the form data), as a web service and call it from the form, as we are on R/3 4.6c. Hence only the option left for us is to use a Java Web Service which should act as an interface between the Adobe Form’s Submit button and the RFC that updates the form data in to R/3.

Creating Java Web Service

 

 This web service should accept the form data as input and send the same data to RFC for updating R/3. We have created a Java Project in Netweaver Developer Studio, Created an SAP Connectivity in it using SAP Enterprise Connector (to be able to use JCo Client, Interfaces and Proxies of the update RFC). New Class (UpdateSalesOrder) is added to the project which has logic to update sales data. After building the project, switch to Web Service Perspective and create a web service (WSSalesService) from the “UpdateSalesOrder.java”. Build ear file (SalesService.ear) and deploy to server.

Building the final WSDL through merging

Like the R/3 web service, the java web service is not generating the complete WSDL automatically. We should our self, build the WSDL from the 3 pieces generated by Netweaver Developer Studio. When you download the WSDL from this deployed Webservice, you will find 3 WSDL Files 1. main.wsdl (in root of the folder you have extracted), 2. Config1_document.wsdl (inside bindings folder), 3. Config1_ServiceNameVi_Document.wsdl (inside porttypes folder) and we have to merge these 3 into a single WSDL. There is an excellent Article by “Gilles Atlan, SAP NPI”  which helped us a lot. Please refer the following link. 

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/148ec26e-0c01-0010-e488-decaafae3...http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/148ec26e-0c01-0010-e488-decaafae3...

Passing Form Data to the Web Service

Now the question is “How to get the form data into this Web Service”? We can place a submit button (of type web service) in the Adobe Form by drag and dropping the web service method (after creating the data connection). On click of submit the WSDL of our service is called and the method is invoked. But we found that the values are passed (all the form parameters will become input parameters for the Web Service and can be accessed through the proxy classes generated) is only working fine for header data since the data values are passed as individual parameters.  Due to some reason, we could not capture the Table data (Line Items) with in the web service using the proxy classes. When we tried to use complex structures inside the web service, we could not expose the class as web service (got problem while creating web service from the .java file – procedure was explained above).

Solution

 

Schema Definition:

 

To be able to pass the form data in XML format to the web service and parse it with in the web service, we should create XSD file in which we will define the schema according to our Form Data and XSD Config file in which we will define the name spaces and packages.Then create a jar file using these 2 files and add the jar in our Project. Using the classes in this jar we can parse the xml string. 

XML Generation and Parsing:

We tried for a work around for this limitation of using table data, in many ways and finally could able to achieve this by auto generating XML String using String Concatenation approach. With in the Adobe Form, using the Adobe Script, we have generated an XML String (data values with field names as delimiters/tags) with all the header data and line items of the form, and stored it in a hidden field on the form itself. On click of Submit button we passed this string as input parameter to the custom method of our web service -  updateSales (refer above). Then captured the XML string in this method and using the XML parsing technique, we can extract data from this string.

 

Updating the Parsed Data of the Form in R/3

 

Once we captured both the header data and line items from the XML String (by parsing), we have passed this data to the RFC that updates the Sales Order in R/3, using the JCo Client middle layer. In order to use the JCo Client you need to place sapjco.dll file in the path x:windows32 of the portal server. Also add sapjco.jar to our project. There after we should give a reference to this sapjco.jar in “application-j2ee-engine.xml” file (com.sap.mw.jcofor ReferenceTarget and Weak for ReferenceType). Then we can use the proxy classes to invoke the RFC through JCo middle layer.

 

import com.sap.mw.jco.IFunctionTemplate;

import com.sap.mw.jco.JCO;
JCO.Client r3connection;
JCO.Repository r3Repository;
IFunctionTemplate ft = null;
JCO.Function function = null;
JCO.ParameterList inputParameters  = null;
JCO.ParameterList outputParameters  = null;
//Connecting to R/3 Client
r3connection = JCO.createClient("Client#","testuser","testpwd","EN","Host","SysID");
r3connection.connect();
r3Repository = new JCO.Repository("MyRepository", r3connection);
//Accessing the RFC
ft = r3repository.getFunctionTemplate("Name_Of_Update_RFC");
function = ft.getFunction();
//Getting the input parameters
inputParameters = function.getImportParameterList();
//Passing Values—Param1 is local variable and Param2 is RFC Field
inputParameters.setValue(quotenumber,"Q_NUM");
//and so on for all the parameters……...
//Exectuing the RFC for Sales Updation
r3connection.execute(function);
//Getting the response i.e message from RFC
outputParameters = function.getExportParameterList();
output = outputParameters.getValue("MESSAGE").toString();
 
Incorporating this web service into the Adobe Form

 

After ensuring that the web service is parsing the data from the input XML String  and updating R/3 through JCo Client (Test it from WS Navigator, Providing the XML String as input in the text box), We have incorporated the web service in our Adobe Interactive Form. To connect the web service to the Form, Open the Form in Adobe Live Cycle Designer and place a Submit button of type Web Service on the form.

Actually, this Web Service Incorporated form only should be used as XDP template in Adobe Document API Code and also in Mail API Code for sending the email attachment (explained in Part-II).

 

Tips & Tricks
  
1. Please ensure that all the following Jars are added to the Project:

C:Program FilesSAPIDEIDE70eclipsepluginscom.sap.ide.jcb.core_2.0.0lib aii_proxy_rt.jar

C:Program FilesSAPIDEIDE70eclipsepluginscom.sap.ide.jcb.core_2.0.0lib aii_proxy_gen.jar

C:Program FilesSAPIDEIDE70eclipsepluginscom.sap.ide.jcb.core_2.0.0lib aii_util_misc.jar

C:Program FilesSAPIDEIDE70eclipsepluginscom.sap.mw.jco_2.0.0lib sapjco.jar 

2. To ensure that the XML String we are generating is correct, use this trick:

Open the Form in Designer, Place a “Submit by Email” button on it and click on this button. You can capture the XML generated now and try to construct our XML String similarly, using the Adobe Script.

Other Related Links
The specified item was not found.

Purely Offline Adobe Scenario for BAPI call

 

Conclusion:

 

We are done with the Offline Adobe Interactive Form Submission to R/3 via web service. The customer can save the Form on to his desktop from the mail  (explained in Part-I and Part-II), Open the Form, Enter data or do modifications and then click on Submit. This will trigger our web service running on top of J2EE Engine by passing the XML String as Input. The Web Service will parse the data from XML String and Pass it further to the RFC using JCo which in turn Updates the R/3 database. 

 

Please let me know if there are any comments on this blog.I will appreatiate your valuable inputs and comments.