Skip to Content
Technical Articles
Author's profile photo Anusha Kotagiri

Display the Adobe form in the PDF format through Gateway Service


This blog post is about to display the Adobe form in the PDF format through the Gateway Service.

In this blog post you can see the steps for how to display the Adobe form in the form of PDF through Gate way Service.


Display the PDF Format of Adobe form using the Gate Service. Whenever execute the URL from the Gateway system, it needs to display the adobe form in the form of PDF Format.


Steps to Required:

Step1: Need to create a ODATA Project.

  • Go to the Transaction SEGW and click and on Create Button to create a project.
  • Create a Project as ZPPM_PDF_AAR, and Package details as shown in the below screen.

  •  Expand the Project which we have created just now then need to  create entity type to define the Properties.
  • Expand the Data Model, under that Right click on the Entity types then click on create as show in below.


  • Enter the Entity Name as required and click on ok.



  • After that will get the below screen. Here we need to check the check box for Media type as in the below screen shot.

          Note: Don’t forgot to check the Media type for the Entity Type, If not we did not get the image                       in the Service output.


  • To define the Properties, expand the Entity type and double click on the Properties then click on the Append row button to add the properties as shown in the below screen.

  • Then define the properties as required. For the AAR Adobe form I have defined the below properties and check the Key box for the Key fields as shown in the below screen.


  • Once done with the above steps click on the Generate Runtime Artifacts as below.
  • It will help us to create the Classes to define custom Code. It will navigate to the next screen as show in the below and click on ok button.


  • To define the Code, go to the Runtime Artifacts of the Project and double click on the DPC_EXT as shown in the below.


Step2:  Implement the Code to Download the Adobe form

Redefine Define method marking Mime Type and the GET_STREAM

  • Now we need to redefine DEFINE Method in MPC_EXT class as below.
  • In this class we can define the type of media. Like as per requirement we need to PDF so I have defined as pdf .

  • Need to maintain the below piece of code in the Define Method.

METHOD define.


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( ).



In DPC_EXT Class:

  • Redefine the Get stream method and as in the DPC_EXT as below.
  • Get Stream mainly useful for the Upload or download  the files.


  • Maintain the below Piece of code in the GET_STREAM Method.

METHOD /iwbep/if_mgw_appl_srv_runtime~get_stream.

**– Data Declarations

DATA: lv_funcname TYPE funcname,

ls_outputparams TYPE sfpoutputparams,

ls_docparams TYPE sfpdocparams,

ls_formoutput TYPE fpformoutput,

ls_stream TYPE ty_s_media_resource,

lv_pia TYPE char32,

lv_proj TYPE char32.

**– Constants

CONSTANTS: lc_pia TYPE char32 VALUE ‘PIAGuid’,

lc_proj TYPE char32 VALUE ‘ProjGuid’,

lc_name TYPE fpname VALUE ‘ZPPM_AAR_FORM’,

lc_us TYPE land1 VALUE ‘US’.

***__ Read key data.
LOOP AT it_key_tab INTO DATA(ls_data)   ##INTO_OK.

CASE ls_data-name.

WHEN lc_pia.

lv_pia = ls_data-value.

WHEN lc_proj.

lv_proj = ls_data-value.



**–Call the Function Module Name for the Adobe Form




i_name = lc_name


e_funcname = lv_funcname.


**–Handle Exceptions with Try – catch


**–Opening the Job

ls_outputparams-nodialog = abap_true.

ls_outputparams-preview = abap_true.

ls_outputparams-getpdf = abap_true.



ie_outputparams = ls_outputparams


cancel = 1

usage_error = 2

system_error = 3

internal_error = 4


ls_docparams-langu = sy-langu.

ls_docparams-country = lc_us.

**– Function to get the Form

CALL FUNCTION lv_funcname


/1bcdwb/docparams = ls_docparams

iv_proj_guid = lv_proj “‘005056B056C91ED89DA0FA3E3E1BE0DC’

iv_pia_guid = lv_pia “‘0A14860E3D8A1EE98691CCF06AF99B66’


/1bcdwb/formoutput = ls_formoutput


usage_error = 1

system_error = 2

internal_error = 3


**–Closing the Job



usage_error = 1

system_error = 2

internal_error = 3


**–Converting the PDF to XString

ls_stream-value = ls_formoutput-pdf.

ls_stream-mime_type = TEXT-001. “application/pdf”

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


Step3: Testing the Service

Register GW service, and we are ready for testing.





Note: In the above URL, $value refers to the Stream method.

Output Screen:

After Execution of above URL:


Downloaded Adobe Form:



By following above steps we can download or view the adobe form through the Gate way Service or we can download the smart form also but there is a small difference between these two. The difference is function modules what ever we are using  in the DPC_EXT class but the remaining Steps are same.


Hope this is useful.

Thanks in Advance !!

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Philippe Addor
      Philippe Addor

      Hi Anusha

      Thank you for your effort to blog this. Just a suggestion from my side: Code should always be inserted by the "insert/edit code sample" button (the last button to the right at the top of the post editor). That would make your post look even better!

      Like so:

      // There is supposed to be some code here. You can even choose the programming lanugage in which it is formated. 

      Maybe you could correct it using the edit function.

      Thank you,


      Author's profile photo neha singhal
      neha singhal

      Hi Anusha,

      I have a similar requirement and I followed the steps mentioned in your blog. However, when I run the service, the form is getting downloaded automatically. I am unable to preview it. Could you please let me know if I am missing something. I am using Hana 1909 version

      Author's profile photo Sina Rahemi
      Sina Rahemi

      when i write this code in method define i got error "Data object 'PDF' not found"

            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( ).


      Author's profile photo Robin Thakral
      Robin Thakral

      Have you overcome this issue?
      as following the post, I have landed over the same issue and am not sure what is missing or declared wrong!!

      just now I have commented the pdf declaration and rest of code worked, the print was visible in the Gateway Service.