Skip to Content
Author's profile photo Kanishak Gupta

Call Smart form present in different server into SAP ECC and display the same in ECC

Note: All the screenshots, code, data and documentations are made dummy for elaboration of this functionality.

Prepared by:

Kanishak Gupta

Target readers:

SAP Technical Consultants

Disclaimer: The screen shots shown in the document are taken in ECC 6.0 and GTS. The screens may differ in different versions of SAP.


I hereby declare that this document is based on my work experience and to the best of my knowledge this document does not contain any material that infringes the copyrights of any other individual or organization.


This document contains several steps to call the smart form present in other SAP server say SAP GTS and display it in SAP ECC. This process will be explained with the help of an example shown in the document.


There is an Invoice report in SAP ECC which displays the various invoices in ALV. On clicking the line item in ALV, the program should be able to get the smart from present in SAP GTS for the billing document in the line item of ALV. This is done to validate and display some special invoices like pro-forma invoices, replicated in SAP GTS, in SAP ECC system.

Steps to follow:

  • Create a custom Invoice report which displays the billing documents in ALV format. On double clicking the line item in ALV, the program calls below mentioned Remote call function module to display the smart form.
  • Create a RFC function module in SAP GTS or server where the smart form is present which will have the input as the reference number (Number replicated in SAP GTS for Billing document) and the output as Smart form OTF data and the table for handling error messages.
  • First let’s create a RFC function module in SAP GTS or server where the smart form is present.

    Important Note: Different systems might use different function modules to display the smart form data. So our primary aim is to debug the system where the smart form is present and find out the steps by which the system displays that particular smart form.

    The following example is only for fetching the invoice related smart form from SAP GTS for the billing document.

  • Creation of wrapper function module :-
  • Create a RFC Function module with the import parameter as G_REF_NO type /SAPSLL/REFNO (field which stores the billing document number in SAP GTS).

    The FM also contains two parameters as TABLES.W_JOB_OUTPUT_INFO as OTF output data and I_BAPIRET2 to store the error messages if there are any.

  • Steps in the FM (These steps are related to SAP GTS only):-
  • Once the reference number is got, get the primary GUID from table /SAPSLL/CORREF. If the primary GUID is not fetched, update I_BAPIRET2 with message ‘Invoice could not be found in GTS’. If the primary GUID is fetched from table /SAPSLL/CORREF ,get the data OS_GUID (GUID) from table PPFTTRIGG .If the OS_GUID is not found, update I_BAPIRET2 with message ‘Invoice could not be found in GTS’; else set parameter TRIGGERGUID with OS_GUID value from PPFTTRIGG.
  • Create message interface for activity message for which the smart form is to be called and upload it in memory by calling FM /SAPSLL/CUHD_PPF_MEM_UPD_TRANS.
  • Initialize the application log by calling FM /SAPSLL/APPLOG_INIT.
  • Get the printing device type by calling FM SF_GET_DEVICE_TYPE.
  • In the end, call FM /SAPSLL/PRN_FORM_PROCESS to get the OTF data. The input parameter to the FM is Primary GUID, Form name as ‘the name of the smart form in GTS, application log handle fetched above, control parameters and output parameters. Update I_BAPIRET2 with message ‘Invoice could not be displayed’ if there are errors while fetching the data from above mentioned function modules. In the control parameters, set GETOTF as X and NO_DIALOG as X so as to get the OTF data and to have no dialog output.
  • Creation of report in ECC :-
  • An invoice report is created in ECC which displays the billing documents (VBRK-VBELN) in ALV format.Once the line item in ALV is double clicked; program picks the billing document present in the line item  and then finds the respective GTS server connected to ECC with the help of Function module “/SAPSLL/CD_ALE_RECEIVER_GET_R3”. Then the program calls the RFC created above which provides us the smart form data as OTF data. The OTF data is displayed as a smart form in ECC through FM “SSFDISPLAY_OTF”.

    Important terms used:-

    OTF – The Output Text Format (OTF) is the established SAP output format for printing forms. It consists of a number of simple, device-independent commands, thus allowing output to be directed to different output devices such as line printers and laser printers, or as an on-screen print preview. OTF is an explicit output format, which means that once SAP Smart Forms has generated an OTF output, no modifications can be made.

    GTS – SAP Global Trade Services automates global trade processes and enables us to manage large numbers of business partners, and high volumes of documents while also helping us to comply with changing legal regulations. It facilitates global trade by providing us with the tools we require to respond to governments modernizing their systems and to customs authorities communicating electronically with businesses. SAP GTS also helps you to avoid costly delays in your import and export processes and allows you to respond quickly to global business opportunities while mitigating financial risks.

    RFC – Remote Function Call (RFC) is the standard SAP interface for communication between SAP systems or with non SAP systems. RFC calls a function to be executed in a remote system.

    Attached code for reference:-

    a) Wrapper RFC function module

    FUNCTION zgotc_comminvoice_formdata.
    *”*”Local Interface:
    *” TABLES

    * Get the Reference number in internal format
    PERFORM sub_convert_ref_no CHANGING g_ref_no.

    * Fetch the GUID’s and then the OTF data
    PERFORM sub_fetch_guids USING g_ref_no CHANGING i_job_output_info []
      i_bapiret2 [].



    *&      Form SUB_CONVERT_REF_NO
    *       Get the reference number in internal format
    *      <–FP_G_REF_NO  Reference number
    FORM sub_convert_ref_no  CHANGING fp_g_ref_no TYPE /SAPSLL/REFNO.

    * FM to convert the reference number into internal form
    input = fp_g_ref_no
    output = fp_g_ref_no.

    *&      Form SUB_FETCH_GUIDS
    *       Fetch GUID’s and then OTF data
    *      –>FP_G_REF_NO     Reference number
    *      <–FP_I_BAPIRET2   Return parameter
    FORM sub_fetch_guids  USING    fp_g_ref_no          type /SAPSLL/REFNO
    CHANGING fp_i_job_output_info TYPE tsfotf
      fp_i_bapiret2        TYPE ty_t_bapiret2.

    *Local data declarations
    DATA : l_guid_pobj              TYPE /sapsll/pobj_guid_16,“Primary Key of Preceding Object
    l_guid_trigg             TYPE os_guid,        “Globally Unique Identifier
    l_guid_trigger           TYPE char40,           “GUID trigger
    l_appl_log_handle        TYPE balloghndl,       “Application Log: Log
    li_mes                   TYPE /sapsll/msg_if_t, “Message Interface
    lw_bapiret2              TYPE bapiret2,         “Return parameter
    l_devtype                TYPE rspopty           “Spool: Device type name

    *Get the primary GUID for the reference number from ECC
    FROM /sapsll/corref
    INTO l_guid_pobj
    WHERE refno EQ fp_g_ref_no.                          

    IF sysubrc EQ 0.
    *    Get Application GUID from PPFTTRIGG
    FROM ppfttrigg
    INTO l_guid_trigg
    WHERE appl_oid EQ l_guid_pobj
    AND ttype EQ c_ttype.

    IF sysubrc EQ 0.
    *     Set Trigger GUID
    l_guid_trigger = l_guid_trigg.

    *     Create Message interface to trigger the activity messages
    PERFORM sub_create_message_interface USING l_guid_trigger
    CHANGING li_mes.

    *     Initialize the application log
    PERFORM sub_initialize_applog CHANGING l_appl_log_handle

    *     Get the device type
    PERFORM sub_get_device_type CHANGING l_devtype

    *     Get OTF data
    PERFORM sub_get_otf_data USING l_devtype
    CHANGING fp_i_job_output_info []

    *     Update BAPIRET2 structure if data from PPFTTRIGG is not found
    MOVE: c_type TO lw_bapiret2type,
    c_id   TO lw_bapiret2id,
    c_num2 TO lw_bapiret2number.
    APPEND lw_bapiret2 TO fp_i_bapiret2.
    CLEAR lw_bapiret2.
    * Update BAPIRET2 structure if data from /sapsll/corref is not found
    MOVE: c_type TO lw_bapiret2type,
    c_id   TO lw_bapiret2id,
    c_num2 TO lw_bapiret2number.
    APPEND lw_bapiret2 TO fp_i_bapiret2.
    CLEAR lw_bapiret2.

    *    Creates message interface for activity messages
    *      –>FP_G_GUID_TRIGGER  Trigger GUID
    *      <–FP_I_MES           Table for message interface
    FORM sub_create_message_interface  USING    fp_l_guid_trigger type char40
    CHANGING fp_li_mes         TYPE /sapsll/msg_if_t

    * Local data declarations
    DATA: lw_mes TYPE /sapsll/msg_if_s. “Message Interface – Reduced

    *Create Message interface to trigger the activity message for Z0999
    lw_mesprosn = c_prosn.
    lw_mesprocs = c_procs.
    lw_mespross = c_pross.
    lw_mesprosa = c_prosa.
    lw_mesttype = c_ttype.
    lw_meslgreg = c_lgreg.
    lw_mesguid_ppf_trigg = fp_l_guid_trigger.
    APPEND lw_mes TO fp_li_mes.
    CLEAR lw_mes.

    *FM to upload FP_I_MESS into the memory so that the program gets the activity message
    it_msg_if = fp_li_mes.

    *       Initialize the application log
    *      <–FP_G_APPL_LOG_HANDLE  Application log handle
    *      <–FP_I_BAPIRET2  text Return parameter
    FORM sub_initialize_applog  CHANGING fp_l_appl_log_handle TYPE balloghndl
      fp_i_bapiret2        TYPE ty_t_bapiret2.

    * Local data declarations
    DATA: l_extnumber              TYPE balnrext,    “Application Log: External ID
    l_modno (20)              TYPE c,          “Index of External Session
    lw_bapiret2              TYPE bapiret2.    “Return parameter

    * Build external id
    l_extnumber = syuname.
    l_modno     = symodno.
    CONCATENATE l_extnumber l_modno INTO l_extnumber.

    * FM to initialize the application log
    iv_extnumber            = l_extnumber
    iv_delete_mess          = c_x
    iv_default_set          = c_x
    iv_skip_search          = space
    cv_handle               = fp_l_appl_log_handle
    invalid_call            = 1
    log_header_inconsistent = 2
    internal_error          = 3
    OTHERS                  = 4.
    IF sysubrc <> 0.
    * Update BAPIRET2 structure if FM fails
    MOVE: c_type TO lw_bapiret2type,
    c_id   TO lw_bapiret2id,
    c_num1 TO lw_bapiret2number.
    APPEND lw_bapiret2 TO fp_i_bapiret2.
    CLEAR lw_bapiret2.

    *&      Form SUB_GET_DEVICE_TYPE
    *       Get the device type
    *      <–FP_G_DEVTYPE   Device type
    *      <–FP_I_BAPIRET2  Return parameter
    FORM sub_get_device_type  CHANGING fp_l_devtype  TYPE rspoptype
      fp_i_bapiret2 TYPE ty_t_bapiret2.

    * Local data declarations
    DATA:      lw_bapiret2               TYPE bapiret2.     “Return parameter

    * FM to get the device type
    i_language             = sylangu
    i_application          = c_app
    e_devtype              = fp_l_devtype
    no_language            = 1
    language_not_installed = 2
    no_devtype_found       = 3
    system_error           = 4
    OTHERS                 = 5.
    IF sysubrc <> 0.
    * Update BAPIRET2 structure if FM fails
    MOVE: c_type TO lw_bapiret2type,
    c_id   TO lw_bapiret2id,
    c_num1 TO lw_bapiret2number.
    APPEND lw_bapiret2 TO fp_i_bapiret2.
    CLEAR lw_bapiret2.

    *&      Form SUB_GET_OTF_DATA
    *       Get OTF data
    *      <–FP_W_JOB_OUTPUT_INFO  OTF data
    *      <–FP_I_BAPIRET2  text Return parameter
    FORM sub_get_otf_data  USING fp_l_devtype         TYPE rspoptype
      fp_l_guid_pobj       TYPE /sapsll/pobj_guid_16
      fp_l_appl_log_handle TYPE balloghndl
    CHANGING fp_w_job_output_info TYPE tsfotf
      fp_i_bapiret2        TYPE ty_t_bapiret2.

    *Local data declarations
    DATA l_guid                 TYPE /sapsll/guid_16,“Primary Key as GUID in “RAW” Format
    lw_bapiret2            TYPE bapiret2,   “Return parameter
    lw_output_options      TYPE ssfcompop“SAP Smart Forms: Smart Composer (transfer) options
    lw_control_parameters  TYPE ssfctrlop“Smart Forms: Control structure
    lw_job_output_info     TYPE ssfcrescl“Smart Forms: Return value at end of form printing
    lw_job_output_options  TYPE ssfcresop, “Smart Forms: Return value at start of form printing
    lw_document_output_info TYPE ssfcrespd, “Smart Forms: Return Document
    li_error_tab           TYPE tsferror . “SAP Smart Forms: Runtime Error

    * Maintain the output structure
    lw_output_optionstdprinter = fp_l_devtype.

    * Maintain the control structure
    lw_control_parametersno_dialog = c_x.
    lw_control_parametersgetotf = c_x.

    * Update variable L_GUID for input in below FM
    l_guid = fp_l_guid_pobj.

    * FM to get the OTF data
    iv_guid_cuhd            = l_guid
    iv_formname             = c_form
    iv_appl_log_handle      = fp_l_appl_log_handle
    is_control_parameters   = lw_control_parameters
    is_output_options       = lw_output_options
    es_document_output_info = lw_document_output_info
    es_job_output_info      = lw_job_output_info
    es_job_output_options   = lw_job_output_options
    et_form_error_tab       = li_error_tab
    output_canceled         = 1
    OTHERS                  = 2.
    IF sysubrc <> 0.
    * Update BAPIRET2 structure if FM fails
    MOVE: c_type TO lw_bapiret2type,
    c_id   TO lw_bapiret2id,
    c_num1 TO lw_bapiret2number.
    APPEND lw_bapiret2 TO fp_i_bapiret2.
    CLEAR lw_bapiret2.
    * Move the OTF data
    fp_w_job_output_info [] = lw_job_output_infootfdata [].


  • Report program in ECC:-
  • It is a test program which is created to show only the linkage of the program with the RFC and to show the steps to display the smart form.

    Report ztest MESSAGE-ID ztest.
    Tables: vbrk.
    Types: ty_t_bapiret2 type table of bapiret2.“Return parameter

    data: i_otf      type tsfotf,
    i_bapiret2 type ty_t_bapiret2,
    w_bapiret2 type bapiret2,
    l_dest type rfcdest.

    PARAMETERS: s_ref type vbrkvbeln.

    *     Get the corresponding GTS server
    call function ‘/SAPSLL/CD_ALE_RECEIVER_GET_R3’
    ev_rfc_dest                   = l_dest
    no_rfc_destination_maintained = 1
    customs_server_not_unique     = 2
    others = 3.
    If sysubrc <> 0.
    message id symsgid type symsgty number symsgno
    with symsgv1 symsgv2 symsgv3 symsgv4.

    *    Call RFC FM to fetch the smart form OTF data
    call function ‘ZGOTC_COMMINVOICE_FORMDATA’ destination l_dest
    g_ref_no          = s_ref
    i_job_output_info = i_otf
    i_bapiret2        = i_bapiret2.

    If i_bapiret2 is initial.” No error found
    if i_otf is not initial.” OTF table is filled
    *        Call FM for OTF display
    call function ‘SSFDISPLAY_OTF’
    otf    = i_otf
    error  = 1
    others = 2.
    if sysubrc <> 0.
    message i276.” invoice could not be displayed
    endif.” I_OTF
    *     Loop at all the messages for display
    loop at i_bapiret2 into w_bapiret2.
    *        Display the messages

             message id w_bapiret2id type w_bapiret2type number w_bapiret2number.

    Assigned Tags

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