Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
JyotiD
Active Participant

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-fe7af7945...


Create Project and Entity Type


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

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_outputparams-nodialog = abap_true.


     ls_outputparams-getpdf   = 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 sy-subrc <> 0.


* Implement suitable error handling here


     ENDIF.



     ls_docparams-langu = sy-langu.


     ls_docparams-country = '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 sy-subrc <> 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 sy-subrc <> 0. " Subrc Check is not required, so we are not handling any exception here


     ENDIF.


     " Converting the PDF to XString


     ls_stream-value = ls_formoutput-pdf.


     ls_stream-mime_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

Labels in this area