Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata


 The scenario is to get approval for leave application which is in smartform format and after getting the approval a PDF leave report is to be generated.

Steps: in SWDD

1.) Create a USER DECISION step for accepting or rejecting the leave request and in the workflow container create an element FORNAME to accept form name from the user.

2.) If the request is accepted create an ACTIVITY task, where u shall provide a task to convert the leave request from smartform to PDF format, if the leave request is rejected than generate a rejection mail and send it to the user.

3.) If approved, create a Business Object in SWO1 and create methods like  SSF_COVERT_TO_PDF and DISPLAY_PO .

 for method SSF_COVERT_TO_PDF declare one parameter FORNAME  of type STXFADM. 


begin_method ssf_covert_to_pdf changing container.
      itab_otf type table of itcoo,
      itab_tline type table of tline,
      fs_tline like line of itab_tline,
      it_line type table of ztline,
      fs_line like ztline,
      formname type stxfadm-formname,
      w_control type ssfctrlop,
      w_result type ssfcrescl,
      fm_name type rs38l_fnam.
  swc_get_element container 'FormName' formname.
     formname                 = formname
    fm_name                  = fm_name
    no_form                  = 1
    no_function_module       = 2
if sy-subrc eq 0.
w_control-no_dialog = 'X'.
w_control-getotf = 'X'.
w_control-preview = 'X'.
call function fm_name
 control_parameters        = w_control
 job_output_info            = w_result
   formatting_error           = 1
   internal_error             = 2 .
 itab_otf[] = w_result-otfdata[].
 call function 'CONVERT_OTF'
   format                      = 'PDF'
   max_linewidth               = 132
    otf                         = itab_otf
    lines                       = itab_tline
   err_max_linewidth           = 1
   err_format                  = 2 
 err_conv_not_possible       = 3
  err_bad_otf                 = 4 .
t_line[] = itab_tline[].
insert ztline from table it_line accepting duplicate keys.

coming back to SWDD

4.) In the activity step create a task and in the task container create fields to accept the forname from workflow and returning table from the method.

5.) Establish a Mapping between the Task and the Workflow.

6.) Establish the binding between workflow & task.

7.) now create another user desicion for printing and downloading the PDF file on to your local system.

8.) If the decision is YES than create an ACTIVITY and again provide the Object and the method  DISPLAY and give the following code in display method.

 begin_method display_po changing container.
      tline like ztline,
      table_tline type table of ztline.
  swc_get_element container 'tline' tline.
select * from ztline into table table_tline.
 delete ztline from table table_tline.
call function 'GUI_DOWNLOAD'
    filename                        = 'C:\TEMP\SMRTPDF.PDF'
    filetype                        = 'BIN'
    confirm_overwrite               = 'X'
    data_tab                        =  table_tline
   file_write_error                = 1
   no_batch                        = 2
   gui_refuse_filetransfer         = 3
   invalid_type                    = 4
   no_authority                    = 5
   unknown_error                   = 6
   header_not_allowed              = 7
   separator_not_allowed           = 8
   filesize_not_allowed            = 9
   header_too_long                 = 10
   dp_error_create                 = 11
   dp_error_send                   = 12
   dp_error_write                  = 13
   unknown_dp_error                = 14
   access_denied                   = 15
   dp_out_of_memory                = 16
   disk_full                       = 17
   dp_timeout                      = 18
   file_not_found                  = 19
   dataprovider_exception          = 20
   control_flush_error             = 21
   others                          = 22
if sy-subrc <> 0.
 message id sy-msgid type sy-msgty number sy-msgno
         with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
declare paremeters for the method DISPLAY

in the task container give the following element.

create binding between task & method , also binding between Workflow and Task.

 save and activate the workflow.

now test the workflow by providing the SMARTFORM name in FORNAME element,

but the form should not have any input interface parameters.

  • No labels