WTF Solution

Display Smart form in PDF Format Using SSFCOMP_PDF_PREVIEW in SAP ABAP

Here we will see how to display smart form in PDF format using SSFCOMP_PDF_PREVIEW function module on SAP GUI system.

In SAP ABAP, When you can execute the smart form, pop up screen will open and ask, put the output device name or number and show print preview & print button. If you click print preview, Then we can see the output. But this output is not PDF format output, this is standard form output screen. If you want to display, smart form output is PDF formatted. Then follow the below example.

Display Smart form in PDF Format

Steps for display Smart form in PDF Format:

For Example: We want to show only one text in smart form and output of this form show in PDF format.

Step: 1

First write your required select query and loop table or read table statement. In this example can not required any select query and read table, Only required one text field. So, We write only text field. 

DATA : DISPLAY_TEXT type char200.

DISPLAY_TEXT = 'Show smart form in pdf format.'.

Explanation: DISPLAY_TEXT is variable, that store the output text.

Step: 2

After all data are coming, you can call SSF_FUNCTION_MODULE_NAME function module. This function module convert smartform name to smartform function module.

DATA: LV_FM_NAME TYPE RS38L_FNAM.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
 EXPORTING
  FORMNAME   = 'ZR_PDF'
 IMPORTING
  FM_NAME      = LV_FM_NAME
 EXCEPTIONS
  NO_FORM                            =   1
  NO_FUNCTION_MODULE   =   2
OTHERS                                  =   3.

IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

Explanation:

ZR_PDF is the form name. LV_FM_NAME is the variable, that store the smart form function module name. After call SSF_FUNCTION_MODULE_NAME function module, get the data in LV_FM_NAME field.

Step: 3

Call smart form using the smart form function module name. After call, remove or comment this function module name ( /BCDWB/SF00000045 ) and instead of this function module name use SSF_FUNCTION_MODULE_NAME  importing parameter FM_NAMEpassing variable ( LV_FM_NAME ). In this function module, put exporting CONTROL_PARAMETERS and put other exporting parameter as per your required and get importing parameter JOB_OUTPUT_INFO.

DATA: JOB_OUTPUT_INFO TYPE SSFCRESCL,
           CONTROL_PARAMETERS TYPE SSFCTRLOP.

CONTROL_PARAMETERS-GETOTF         =  'X'.
CONTROL_PARAMETERS-NO_DIALOG =  'X'.

CALL FUNCTION  LV_FM_NAME   ""   '/BCDWB/SF00000045'

 EXPORTING

   CONTROL_PARAMETERS =   CONTROL_PARAMETERS
   display_text                     =    DISPLAY_TEXT
 IMPORTING
   JOB_OUTPUT_INFO       = JOB_OUTPUT_INFO
 EXCEPTIONS 
   FORMATTING_ERROR    =   1
   INTERNAL_ERROR         =   2
   SEND_ERROR                 =   3
   USER_CANCELED           =   4
 OTHERS                            =   5.

IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

Step: 4

After call smart form function module name, call another function module that name is SSFCOMP_PDF_PREVIEW. This function module use toconvert normal smart form print view to pdf view.

CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'
EXPORTING
   I_OTF            =  JOB_OUTPUT_INFO-OTFDATA
 EXCEPTIONS
   CONVERT_OTF_TO_PDF_ERROR  =   1
   CNTL_ERROR                                =   2
 OTHERS                                          =   3.

IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

Explanation:

In this function module, use importing parameter field JOB_OUTPUT_INFO of smart form function module and this field put into the exporting parameter  I_OTF field of SSFCOMP_PDF_PREVIEW .

If you have a any query then comment that or contact me through the contact page.

Read More blog post:
List of Commonly Used Function Modules in SAP ABAP in 2025
Learn with SAP

Thank you .

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top