The below post shows the gateway project data model to get the PDF file data by implementing the GET_STREAM method. The aim is to pass the Smartform Name as an attribute of the entity set and get the PDF file.
Below structure to be sued as the source of our project data model.

Below are two different smartforms- Very simple forms for the same of demo.

Another Smartform.

The gateway project-

Create data model- by importing from DDIC structure. Provide the structure and entity type name.

Choose only one attribute to be used as the key input(smartform name).

Finish-

Enable the Media flag for the entity type.

Generate the artifacts and register the service in the gateway service builder.

The Runtime artifacts are-

As we already registered the service( /IWFND/MAINT_SERVICE) ,Now test the service in the gateway client(Tx- /IWFND/GW_CLIENT ). The status looks good.

Lets provide the entity set name and pass the smartform name as the key and use addition- $value. As we can see it goes to the GET_STREAM method but it is not yet implemented.

If we see the DPC ent class – Types

Here we have a media source type and then navigate to the declaration to see it components.

So we have to fill two fields like the mime type and the XSTING value of the PDF inside the GET_STREAM method.

Let’s implement the code inside the GET_STREAM method.




code
METHOD /iwbep/if_mgw_appl_srv_runtime~get_stream.
DATA: lv_fm_name TYPE rs38l_fnam.
DATA: ls_cparam TYPE ssfctrlop.
DATA: ls_op_options TYPE ssfcompop.
DATA: ls_job_op_info TYPE ssfcrescl.
DATA: lt_lines TYPE TABLE OF tline.
DATA: lv_file TYPE xstring.
DATA: ls_stream TYPE ty_s_media_resource.
IF iv_entity_set_name = 'ety_pfileSet'.
IF it_key_tab IS NOT INITIAL.
DATA(lv_sf_name) = conv TDSFNAME( it_key_tab[ name = 'Fname' ]-value ).
- Get the smartform FM name
CALL FUNCTION ‘SSF_FUNCTION_MODULE_NAME’
EXPORTING
formname = lv_sf_name ” ‘ZZTEST_FORM1’
IMPORTING
fm_name = lv_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
RETURN.
ENDIF.ls_cparam-no_dialog = 'X'. ls_cparam-preview = ' '. ls_cparam-getotf = 'X'. ls_op_options-tddest = 'LP01'.
- call smartform fucntion mdoule
CALL FUNCTION lv_fm_name
EXPORTING
control_parameters = ls_cparam
output_options = ls_op_options
IMPORTING
job_output_info = ls_job_op_info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
RETURN.
ENDIF.DATA(lt_otf) = ls_job_op_info-otfdata[].
- Convert OTF data to PDF –
CALL FUNCTION ‘CONVERT_OTF’
EXPORTING
format = ‘PDF’
IMPORTING
bin_file = lv_file
TABLES
otf = lt_otf
lines = lt_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc <> 0.
RETURN.
ENDIF.ls_stream-mime_type = 'application/pdf'. ls_stream-value = lv_file. me->copy_data_to_ref( EXPORTING is_data = ls_stream CHANGING cr_data = er_stream ).
ENDIF.
ENDIF.
ENDMETHOD.
Test-1 Provide the Smartform name and execute

Test-2 Provide another Smartform name and execute

We get the different PDFs based on the smartform input.
One comment