Skip to Content
Author's profile photo Tarun Sharma

Download Adobe Form Using SAP NW Gateway

Steps-

Create Adobe Form

First, Develop Adobe Form using Tcode SFP ZF_AdobeForm, which will have input as docparams and will export formoutput.

You can follow step to create Adobe Form as per requirement

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40553f25-08d1-2c10-3e8f-fe7af794566e?QuickLink=index&overridelayout=true&46158013817331


Create Project and Entity Type


Now develop GW service which will help us to expose Form. Create simple GW service ZFORM as displayed below.

/wp-content/uploads/2015/12/image_859238.png

We have Entity Form (Media Type) and Entity Set Forms.

Generate run-time artifacts.

Redefine Define method marking Mime Type

Now we need to redefine DEFINE Method in MPC_EXT class as below.

METHOD define.

  DATA:

lo_entity   TYPE REF TO /iwbep/if_mgw_odata_entity_typ,

lo_property TYPE REF TO /iwbep/if_mgw_odata_property.

super->define( ).

lo_entity = model->get_entity_type( iv_entity_name = ‘pdf’ ).

  IF lo_entity IS BOUND.

lo_property = lo_entity->get_property( iv_property_name = ‘mime_type’ ).

lo_property->set_as_content_type( ).

  ENDIF.


ENDMETHOD.



Redefine GET_STREAM


Redefine method /iwbep/if_mgw_appl_srv_runtime~get_stream in DPC_EXT as below.

METHOD /iwbep/if_mgw_appl_srv_runtime~get_stream.

     DATA: lv_funcname     TYPE funcname,

           ls_outputparams TYPE sfpoutputparams,

           ls_docparams    TYPE sfpdocparams,

           ls_formoutput   TYPE fpformoutput.

     DATA: ls_stream   TYPE ty_s_media_resource.

     ” Getting the Function Module Name for the Adobe Form

     TRY.

         CALL FUNCTION ‘FP_FUNCTION_MODULE_NAME’

           EXPORTING

             i_name     = ‘ZF_AdobeForm’     “Adobeform name

           IMPORTING

             e_funcname = lv_funcname.

         “Handle Exceptions with Try – catch

     ENDTRY.

     ” Opening the Job

     ls_outputparamsnodialog = abap_true.

     ls_outputparamsgetpdf   = abap_true.

     CALL FUNCTION ‘FP_JOB_OPEN’

       CHANGING

         ie_outputparams = ls_outputparams

       EXCEPTIONS

         cancel          = 1

         usage_error     = 2

         system_error    = 3

         internal_error  = 4

         OTHERS          = 5.

     IF sysubrc <> 0.

* Implement suitable error handling here

     ENDIF.

     ls_docparamslangu = sylangu.

     ls_docparamscountry = ‘US’.

     CALL FUNCTION lv_funcname

       EXPORTING

         /1bcdwb/docparams  = ls_docparams

       IMPORTING

         /1bcdwb/formoutput = ls_formoutput

       EXCEPTIONS

         usage_error        = 1

         system_error       = 2

         internal_error     = 3

         OTHERS             = 4.

     IF sysubrc <> 0.

* Implement suitable error handling here

     ENDIF.

     ” Closing the Job

     CALL FUNCTION ‘FP_JOB_CLOSE’

       EXCEPTIONS

         usage_error    = 1

         system_error   = 2

         internal_error = 3

         OTHERS         = 4.

     IF sysubrc <> 0. ” Subrc Check is not required, so we are not handling any exception here

     ENDIF.

     ” Converting the PDF to XString

     ls_streamvalue = ls_formoutputpdf.

     ls_streammime_type = ‘PDF’.

     copy_data_to_ref( EXPORTING is_data = ls_stream CHANGING  cr_data = er_stream ).

ENDMETHOD.

Testing the Service


Register GW service, and we are ready for testing.


To read document a GET containing the keys with $value to read stream can be requested:

/sap/opu/odata/sap/ZFORM_SRV/Form(‘key value value’)/$value

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.