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

Hello Friends...

We had a scenario of Claim Maintenance . Our clients has a requirement where they have online and offline PDF claim forms.

1.Offline :The Customers can directly fill in the Claim form and submit ,to send a mail to sales agent. The sales agent saves the PDF on his desktop and runs the dynpro application which will have all the data from that PDF.

2. Online : Here the SalesAgent fill the PDF form within the WD application directly.

Here i m going to deal with the offline scenario.I seached for two days to finally get this done.Here it is for all those ,who are interested in Adobe interacting with WD.

Procedure :

1> Create a WD Component and design the View as required.

2>Create context elements to be mapped to the view elements.Create a context attribute(PDFOBJ) of type "XSTRING" to be bound to data property of FileUpload view element.

3>Create a element of type FileUpload in the view layout. This will be used to brouse the PDF from the desktop. Bind the Data Property to the XSTRING context attribute (PDFObj).

!https://weblogs.sdn.sap.com/weblogs/images/251735287/1.JPG|height=345|alt=image|width=579|src=https:...!"

4> Now we need a button ,on click of which the PDF will get upload.Create a button in the view layout and set properties as below.

!https://weblogs.sdn.sap.com/weblogs/images/251735287/2.JPG|height=355|alt=image|width=558|src=https:...!"

5>DoubleClick the UPLOAD function attached to the button and code to read the data of PDF .

5.1> The data uploaded will be in format of XSTRING/Binary . We first need to convert this data into string.

5.2> Then iXML classes are used to parse it to XML document, which is then retrieved to WD Context.

code:

********code to retrieve data from PDF to context node

*get ref to form processing class

++DATA: l_fp TYPE REF TO if_fp.++ 

l_fp = cl_fp=>get_reference( ).++ +

+* Set ref to pdf object class++ 

DATA: l_pdfobj TYPE REF TO if_fp_pdf_object.++ 

l_pdfobj = l_fp->create_pdf_object( ).+

+ ++* Set pdf in pdfobject++ 

l_pdfobj->set_document( pdfdata = item_pdfobj ).++ +

+*  Set pdfobj to extract form data++ 

l_pdfobj->set_extractdata( ).++ +

+*  execute call to ADS++ 

l_pdfobj->execute( ).++ +

+*  Get the pdf form data++ 

DATA: pdf_form_data TYPE xstring.++ 

l_pdfobj->get_data( IMPORTING formdata = pdf_form_data ).++ +

+*  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 ).+

+ ++*  Pull in iXML type gp.

++  TYPE-POOLS: ixml.+

+* Get ref to ixmlobj

++DATA: l_ixml TYPE REF TO if_ixml.

++l_ixml = cl_ixml=>create( ).+

+* Get istream obj 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 ).+

+* Create XML doc class to process xml

++DATA: document TYPE REF TO if_ixml_document.

++document = l_ixml->create_document( ).+

+* Create Parser Class

++DATA: parser TYPE REF TO if_ixml_parser.

++parser = l_ixml->create_parser(++stream_factory = streamfactory

                                        + +istream = istream

                                         ++document = document ).+

+* Parse XML

++parser->parse( ).+

+* Define XML type node obj

++DATA: node TYPE REF TO if_ixml_node.+

+* Retrieve data

+node = document->find_from_name('CMC_SALES_ORDER_ID').

+IF NOT node IS INITIAL.

+so = node->get_value( ).<br />ENDIF.

________________________________-

<CMC_SALES_ORDER_ID >: The tag that store the salesoreder_id.<br />This value is stored in variable "so"  and can be saved into the required context attribute :)<br />Plz debug the "document" to see the XML and then use proper tag to get the value required.

Thats it. Now we can retrieve all the offline PDF data and use in WD Applications.

Result :

Below is the offline PDF with data that has to be uploaded into WD Appl.

After clicking on upload, the Application will load the broused PDF data and related data as below :

!https://weblogs.sdn.sap.com/weblogs/images/251735287/SA.JPG|height=392|alt=image|width=578|src=https...!</body>

14 Comments