Skip to Content

There is a good blog about how to get PDF preview in CRM web client UI. However several development are invovled in that solution. You have to implement your own ICF node to make PDF displayed in UI, and you have to generate the binary code of PDF by yourself.

There is just another approach to achieve the same result but with much less coding by leveraging the standard control “Adobe Interactive form” in ABAP webdynpro. In this way no ICF node implementation, no manual PDF binary code generation, just a few model task.

1. Create an form interface in tcode SFP.

/wp-content/uploads/2013/12/clipboard1_344949.png

Choose interface type as ABAP Dictionary-Based Interface.

/wp-content/uploads/2013/12/clipboard2_344950.png

Just create two parameter NAME and SCORE. Activate the interface.

/wp-content/uploads/2013/12/clipboard3_344999.png

2. Create a new form template via tcode SFP.

/wp-content/uploads/2013/12/clipboard4_345000.png

Click “Context”tab, drag the two parameters from Interface to the right part Context ZPF_EXAMPLE and drop there.

/wp-content/uploads/2013/12/clipboard5_345001.png

Click tab Layout, design your form layout. Here I create a caption and two text fields. Bind the data source of the two fields to your form context parameter. Here text field NAME is bound to ZPF_EXAMPLE.NAME and Score field bound to ZPF_EXAMPLE.SCORE.

/wp-content/uploads/2013/12/clipboard6_345002.png

3. Create a new ABAP webdynpro in SE80. A view MAIN will be created by workbench automatically.

Just put a new Adobe Interactive form control into the empty view. You can choose “Insert Element” from context menu and choose “Interactive form”

/wp-content/uploads/2013/12/clipboard7_345003.png

/wp-content/uploads/2013/12/clipboard8_345004.png

Specify the form template name ZPF_EXAMPLE to property “templateSource” created in step2.

/wp-content/uploads/2013/12/clipboard9_345008.png

After that the property “dataSource” is also determined automatically.

/wp-content/uploads/2013/12/clipboard10_345009.png

Click tab “Context”, now you should see the two parameters defined in form interface is also displayed in context node of view MAIN.

/wp-content/uploads/2013/12/clipboard11_345010.png

4. Create a new Webdynpro application and assign two parameter NAME and SCORE to it.

/wp-content/uploads/2013/12/clipboard12_345011.png

5. Double click WDDOINIT to implement:

/wp-content/uploads/2013/12/clipboard13_345012.png

The init method will retrieve name and score from application parameter included in url. The url will be populated from CRM webclient UI side.

Till now the development of ABAP webdynpro is finished. You don’t care about the PDF generation and display, it will be handled by ABAP webdynpro framework.

method WDDOINIT .
  data(lo_node) = wd_context->get_child_node( 'ZPF_EXAMPLE' ).
  DATA: lv_name type string,
        lv_score type int4.
  lv_name = cl_wd_runtime_services=>get_url_parameter( name = 'NAME' ).
  lv_score = cl_wd_runtime_services=>get_url_parameter( name = 'SCORE' ).
  lo_node->set_attribute( name = 'NAME' value = lv_name ).
  lo_node->set_attribute( name = 'SCORE' value = lv_score ).
endmethod.

6. The left task would be quite easy for a CRM UI developer:

I create a simple view with two input fields for Name and Score, and one hyperlink.

/wp-content/uploads/2013/12/clipboard14_345013.png

The event handler for hyperlink click:

DATA: lr_popup    TYPE REF TO if_bsp_wd_popup,
        lr_cn       TYPE REF TO cl_bsp_wd_context_node,
        lr_obj      TYPE REF TO if_bol_bo_property_access,
        lt_parameters TYPE tihttpnvp,
        ls_params   TYPE crmt_gsurlpopup_params.
  data(lo_data) = me->typed_context->data->collection_wrapper->get_current( ).
  DATA(ls_line) = VALUE ihttpnvp( name = 'NAME' value = lo_data->get_property_as_string( 'NAME' ) ).
  APPEND ls_line TO lt_parameters.
  ls_line = VALUE ihttpnvp( name = 'SCORE' value = lo_data->get_property_as_string( 'VALUE' ) ).
  APPEND ls_line TO lt_parameters.
  cl_wd_utilities=>construct_wd_url(
      EXPORTING
        application_name = 'ZADOBEFORM'
        in_parameters    = lt_parameters
      IMPORTING
        out_absolute_url = mv_url ).
  lr_popup =  me->comp_controller->window_manager->create_popup(  iv_interface_view_name = 'GSURLPOPUP/MainWindow'
                                                                  iv_usage_name          = 'GSURLPOPUP'
                                                                  iv_title               = 'Adobe Interactive Form Control' ).
  lr_cn = lr_popup->get_context_node( 'PARAMS' ).           "#EC NOTEXT
  lr_obj = lr_cn->collection_wrapper->get_current( ).
  ls_params-url = mv_url.
  ls_params-height = '700'.                                 "#EC NOTEXT
  lr_obj->set_properties( ls_params ).
  lr_popup->set_display_mode( if_bsp_wd_popup=>c_display_mode_plain ).
  lr_popup->set_window_width( 700 ).
  lr_popup->set_window_height( 700 ).
  lr_popup->open( ).

Of course you need to add component GSURLPOPUP via component usage.

In the runtime after name and score fields are maintained in CRM UI and hyperlink is clicked, the corresponding PDF will be generated and displayed by ABAP Webdynpro framework.

/wp-content/uploads/2013/12/clipboard15_345014.png

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Ravi S Verma

    Good one, Can you tell me how do I customize this to have sold to and material details with quantity populated into sales order ?

    Also where is the print option to it ?

    (0) 
  2. Angxiao Lu

    Works fine, but there is a problem in Chrome. If I close the popup window, the busy indicator is still loading and never stop.

    This doesn’t exist in IE. Do you know what to do ?

    (0) 

Leave a Reply