Wednesday, July 30, 2008

Inserting Existing PDF Forms (MIME Objects) Web Dynpro ABAP Integrating Forms

Use

Forms that are stored in systems as MIME objects in the MIME repository with MIME type application/pdf can be integrated and displayed in a Web Dynpro application.

To do this, bind the pdfSource property to a context attribute of type XSTRING. In this case therefore, neither the templateSource nor the dataSource are set.

In scenarios where only the pdfSource is set, the properties enabled and readOnly are ignored. The form can then be displayed for printing (and is displayed without the ADS or the ACF).

Using the method call described below, the PDF document can be made ready for input, but there is no context binding. Instead, the changed document is retrieved from the pdfSource and processed in the specific application.

Prerequisites

You need to store your form in the MIME repository. The simplest way to do this is to import the form to your Web Dynpro component by choosing Create ® MIME Object ® Import.

The imported PDF appears in your component’s object list under MIMEs.

Example:

This graphic is explained in the accompanying text

Procedure

...

1. In the Web Dynpro explorer, create a view for your component or select a view to which to add the form.

2. In the view context, create the context attribute that will be bound to the form later, and select XSTRING.

3. In the view, drag the InteractiveForm UI element from the integration category to the Layout Designer.

4. Go to the methods for your view and change WDDOINNIT by adding coding to the method, such as the coding below:

method WDDOINIT .

data:

Elem_Context type ref to If_Wd_Context_Element,

Stru_Context type If_View=>Element_Context ,

Item_STATIC_PDF like Stru_Context-STATIC_PDF.

* get element via lead selection

Elem_Context = wd_Context->get_Element( ).

DATA: mr TYPE REF TO if_mr_api,

lurl TYPE string.

* get name of component

data: l_component type ref to if_wd_component,

l_component_info type ref to if_wd_rr_component,

l_name type string.

l_component = wd_comp_controller->wd_get_api( ).

l_component_info = l_component->get_component_info( ).

l_name = l_component_info->get_name( ).

* get mime object

mr = cl_mime_repository_api=>get_api( ).

call method CL_WD_UTILITIES=>CONSTRUCT_WD_URL( exporting APPLICATION_NAME = l_name

importing OUT_LOCAL_URL = lurl ).

concatenate lurl '/' 'popup.pdf' into lurl.

mr->get( EXPORTING i_url = lurl

IMPORTING e_content = Item_Static_Pdf ).

Elem_Context->set_Attribute(

exporting

Name = `STATIC_PDF`

Value = Item_Static_Pdf ).

endmethod.

Here, you only need to specify the name of your MIME object, popup.pdf in this example.

You can also receive the MIME object by inserting the path manually:

DATA: mr TYPE REF TO if_mr_api,

content TYPE xstring.

mr = cl_mime_repository_api=>get_api( ).

mr->get( EXPORTING i_url = 'sap/bc/webdynpro/sap/zhvg_adobe2/popup.pdf'

IMPORTING e_content = content ).

5. In the properties table for InteractiveForm, bind the pdfSource to the context attribute created in step two.

6. After filling the created context structure – for example using a suitable supply function – and inserting it into the window navigation, you can activate and test an application.

No comments:

Archive