“Hi Raj, How r u???”
Her Requirement was ::
DEPTNO, DNAME and LOC.To start with the Tutorial:
Create a Webdynpro ABAP component ZTEST_RAJ_OFFLINE using se80.
(You can give any name )
To create a PDF interactive form:
Create a Interactive form named INT_DEPT_FORM by going to the Main view of your Webdynpro component
Upload (Button) which is of type Button.
Step 4 :
When Katherine upload the form from her local Computer, a data node of type XTRING is needed to hold the Form details
We will declare a Element which is of type XSTRING which would store the form
To store the FORM data like Dept No, Dept name and Location we also need respective attributes to be created.
Finally your context will look like :
Step 5:
Now it’s time to map the data with layout.
Go back to your layout tab, Double click on the FILE_UP_LOAD Element.
Go to Property data and Bind it with the PDF_SOURCE of your context.
Step 6:
Now Double click on the element INT_DEPT_FORM.and enter the name ZINT_DEPTFORM in the template source .Hit Enter.
It will prompt you to specify the interface name. Give any name say : ZINT_DEPTFORM_INTF
(it is good practice to use the context of your view while creating the FORM
Select your Dept_data node and click enter.
Step 7:
It will take you to Adobe Form Designer.
Select the data DATA View from the left panel where you can see yours Dept_data Node.
Drag it to the Right side part on design view. Work on the Alignment part.
Also put one Submit Button from the Object Library (Palettes Object Library).From Webdynpro Native.
Finally your layout of adobe form will look like:
Step 8 :
ZCI Layout (called as Zero client installation layout).
Again come back to the Layout tab and follow the menu path:
Utilities -> Insert the Webdynpro Script .
Save and activate the FORM+interface.
Step 9 : Go back to your Webdynpro Component:
Two things are yet to be completed for the required development:
- Code to read and save the data from the FORM when user submit the form ONLINE.
- Code to read the PDF file when user upload it and save the data into database table ZTEST_DEPT.
Go to the Properties section by double clicking on the Element INT_DEPT_FORM and set the
Width as 100%
Check the Check box Active.
Step:10.
When a User submit the FORM by clicking the SUBMIT Button .. It will trigger the Event.
This will Internally Generate a method called ONACTIONSUBMIT.
(The method’s naming convention which gets created is ONACTION<Action name>.)You can see this
data : wa_dept type ztest_dept.lv_node = wd_context->get_child_node( NAME = ‘DEPT_DATA’ ).
lv_node->get_attribute( EXPORTING name = ‘DEPTNO’ IMPORTING value = wa_dept-deptno ). lv_node->get_attribute( exporting name = ‘DNAME’ IMPORTING value = wa_dept-dname ). lv_node->get_attribute( exporting name = ‘LOC’ IMPORTING value = wa_dept-loc ). wa_dept-mandt = sy-mandt. insert ztest_dept from wa_dept.
Step 11:
When user upload the offline Pdf form , we need code which would read the data from the file and save it into database table ZTEST_DEPT.
Double click on the Upload Button element. Go to its Properties and click on the Create Icon to create an Action.
Similar to Submit this will also Create one method named ONACTIONUPLOAD.Put the below code inside this Method:
Explanation: This code reads the PDF file which is Uploaded by the user and extract the Dept name , Dept No and location from it and save it into the database table Ztest_dept.
DATA: w_pdf_source TYPE xstring,
w_dob TYPE char10.
* Get a reference to the form Processing class
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_pdf_source LIKE ls_context-pdf_source.
* get element via lead selection
lo_el_context = wd_context->get_element( ).* get single attribute
lo_el_context->get_attribute(
EXPORTING
name = `PDF_SOURCE`
IMPORTING
value = lv_pdf_source ).
DATA: l_fp TYPE REF TO if_fp.
l_fp = cl_fp=>get_reference( ).
* Get reference to the Pdf Object Class
DATA:l_pdfobj TYPE REF TO if_fp_pdf_object.
TRY.
l_pdfobj = l_fp->create_pdf_object( ).
CATCH cx_fp_runtime_internal.
CATCH cx_fp_runtime_usage.
CATCH cx_fp_runtime_system.
ENDTRY.
* Set your Pdf In the Pdf object created
TRY .
l_pdfobj->set_document( pdfdata = lv_pdf_source ).
* Extract data from pdf object
l_pdfobj->set_extractdata( ).
CATCH cx_fp_runtime_usage.
ENDTRY.
TRY.
* Call Adobe Document Service
l_pdfobj->execute( ).
CATCH cx_fp_runtime_usage.
CATCH cx_fp_runtime_system.
CATCH cx_fp_runtime_internal.
ENDTRY.
* Get the pdf Data to a Xstring Variable
DATA: pdf_form_data TYPE xstring.
l_pdfobj->get_data( IMPORTING formdata = pdf_form_data ).
* Call method to convert xstring to string.
DATA: converter TYPE REF TO cl_abap_conv_in_ce,
formxml TYPE string.
converter = cl_abap_conv_in_ce=>create( input = pdf_form_data ).
converter->read( IMPORTING data = formxml ).
* Get the ixm type group Into Our prorgram DATA: l_ixml TYPE REF TO if_ixml.
l_ixml = cl_ixml=>create( ).
* Get istream Object from Stream Factory
DATA: streamfactory TYPE REF TO if_ixml_stream_factory,
istream TYPE REF TO if_ixml_istream.
streamfactory = l_ixml->create_stream_factory( ).
istream = streamfactory->create_istream_string( formxml ).
* Get xml document Class to process XML DATA: document TYPE REF TO if_ixml_document.
document = l_ixml->create_document( ).
* Get an Interface to Parse the XML
DATA: parser TYPE REF TO if_ixml_parser.
parser = l_ixml->create_parser( stream_factory = streamfactory
istream = istream
document = document ).
* Start parsing theDocument with parsing interface referenced. parser->parse( ).
DATA: node TYPE REF TO if_ixml_node,
fs_dept TYPE ZTEST_DEPT.
node = document->find_from_name(’DEPTNO’).
IF node IS NOT INITIAL.
fs_dept-DEPTNO = node->get_value( ).
ENDIF.
node = document->find_from_name(’DNAME’).
IF node IS NOT INITIAL.
fs_dept-DNAME = node->get_value( ).
ENDIF.
node = document->find_from_name(’LOC’).
IF node IS NOT INITIAL.
fs_dept-LOC = node->get_value( ).
ENDIF.
IF fs_dept IS NOT INITIAL.
fs_dept-mandt = sy-mandt.
INSERT into ztest_dept VALUES fs_dept.
ENDIF.
Step 12:
Save and activate your Webdynpro component.
- Create a Webdynpro application.
- Now the form is ready to be tested By beautiful Katherine.
(Note : if you can’t see the Adobe forms just “change your advance internet setting to default” from internet options)
You should see the one entry created in the ZTEST_DEPT table via SE16.
This is what ADOBE FORM has delivered out off the BOX functionality. You can’t achieve this using any HTML Forms.












Arun.P
Hi Raj
I tried with two buttons in AIF but still having problems, It will be good to have a sample application with more than one buttons in AIF and based upon that the action should take place.
Regards
Arun.P
Raj
Hi Arun,
We will surely try to provide one article based on this.
i have conveyed this to our ignite team.
Thanks.
SAP Ignite
Betcy
Hi Raj ,
Nice article …
Can you please post some more good examples on Formcalc based scipting .
Best Regards ,
Betcy Yohannan
Caiden
This site is like a clasrsoom, except I don’t hate it. lol