cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to Create a Spool Request

former_member1193316
Participant
0 Kudos

Dear SDNers,

I want to display a smartform in PDF Format. To display in pdf format, I need to create a spool request. I wrote below code. But spool request is not creating.

I tried so many ways by chaing output options and control paramters as well. But not success. Please help me out regarding the same.

Here is the xode.

w_cparam-no_dialog = 'X'.
w_cparam-preview = 'X'. " Suppressing the dialog box for print preview
w_cparam-getotf = 'X'.
w_cparam-DEVICE = 'PRINTER'.
w_cparam-langu = sy-langu.
w_cparam-no_open = 'X'.
w_cparam-no_close = 'X'.

* Printer name to be used is provided in the export parameter
* OUTPUT_OPTIONS

w_outoptions-tdprinter = 'PDF1'.
w_outoptions-tddest = 'LP01'.
w_outoptions-tdnewid = 'X'.
w_outoptions-TDIMMED = 'X'.
w_outoptions-tdnoprint = 'X'."
w_outoptions-tdarmod = 1.
w_outoptions-tdcopies = 001.
w_outoptions-tdlifetime = 1.
w_outoptions-tddelete  = space.


CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    FORMNAME           = w_form_name
*   VARIANT            = ' '
*   DIRECT_CALL        = ' '
  IMPORTING
    FM_NAME            = w_fmodule
  EXCEPTIONS
    NO_FORM            = 1
    NO_FUNCTION_MODULE = 2
    OTHERS             = 3.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
data:t_otf_from_fm TYPE SSFCRESCL ,
      DOCUMENT_OUTPUT_INFO type SSFCRESPD,
      JOB_OUTPUT_OPTIONS type SSFCRESOP.

CALL FUNCTION w_fmodule"'/1BCDWB/SF00000004'
  EXPORTING
*    ARCHIVE_INDEX              =
*    ARCHIVE_INDEX_TAB          =
*    ARCHIVE_PARAMETERS         =
   CONTROL_PARAMETERS         = w_cparam
*    MAIL_APPL_OBJ              =
*    MAIL_RECIPIENT             =
*    MAIL_SENDER                =
   OUTPUT_OPTIONS             = w_outoptions
   USER_SETTINGS              = 'X'
    DOCU_NO                    = P_DOCUNO
    COMP_CD                    = P_COMPCD
    YEAR                       = P_YEAR
IMPORTING
    DOCUMENT_OUTPUT_INFO       = DOCUMENT_OUTPUT_INFO
   JOB_OUTPUT_INFO            = t_otf_from_fm
    JOB_OUTPUT_OPTIONS         = JOB_OUTPUT_OPTIONS
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.

Regards,

Venkat

Accepted Solutions (1)

Accepted Solutions (1)

former_member230486
Contributor
0 Kudos

Hi,

You just follow the code,

TABLES SFLIGHT.

SELECT-OPTIONS S_CARRID FOR SFLIGHT-CARRID.

DATA: it_otf      TYPE STANDARD TABLE OF itcoo,

          it_docs     TYPE STANDARD TABLE OF docs,

          it_lines    TYPE STANDARD TABLE OF tline.

* Declaration of local variables.

DATA:

      st_job_output_info            TYPE ssfcrescl,

      st_document_output_info  TYPE ssfcrespd,

      st_job_output_options      TYPE ssfcresop,

      st_output_options            TYPE ssfcompop,

      st_control_parameters     TYPE ssfctrlop,

      v_len_in                          TYPE so_obj_len,

      v_language                     TYPE sflangu VALUE 'E',

      v_e_devtype                   TYPE rspoptype,

      v_bin_filesize                 TYPE i,

      v_name                         TYPE string,

      v_path                           TYPE string,

      v_fullpath               TYPE string,

      v_filter                 TYPE string,

      v_uact                   TYPE i,

      v_guiobj                 TYPE REF TO cl_gui_frontend_services,

      v_filename               TYPE string,

      v_fm_name                TYPE rs38l_fnam.

CONSTANTS c_formname         TYPE tdsfname VALUE 'ZTEST'.

CALL FUNCTION 'SSF_GET_DEVICE_TYPE'

  EXPORTING

    i_language          = v_language

    i_application       = 'SAPDEFAULT'

  IMPORTING

    e_devtype           = v_e_devtype.

st_output_options-tdprinter = v_e_devtype.

st_control_parameters-no_dialog = 'X'.

st_control_parameters-getotf = 'X'.

*.................GET SMARTFORM FUNCTION MODULE NAME.................*

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

  EXPORTING

    formname = c_formname

  IMPORTING

    fm_name  = v_fm_name

  EXCEPTIONS

    no_form  = 1

   no_function_module = 2

    OTHERS   = 3.

*...........................CALL SMARTFORM............................*

CALL FUNCTION v_fm_name

  EXPORTING

    control_parameters = st_control_parameters

    output_options     = st_output_options

  IMPORTING

    document_output_info  = st_document_output_info

    job_output_info       = st_job_output_info

    job_output_options    = st_job_output_options

  TABLES

    so_carrid             = S_CARRID

  EXCEPTIONS

    formatting_error = 1

    internal_error   = 2

    send_error       = 3

    user_canceled    = 4

    OTHERS           = 5.

*.........................CONVERT TO OTF TO PDF.......................*

  CALL FUNCTION 'CONVERT_OTF_2_PDF'

    IMPORTING

      bin_filesize   = v_bin_filesize

    TABLES

      otf            = st_job_output_info-otfdata

      doctab_archive = it_docs

      lines          = it_lines

    EXCEPTIONS

      err_conv_not_possible  = 1

      err_otf_mc_noendmarker = 2

      OTHERS                            = 3.

  CONCATENATE 'smrt' '.pdf' INTO v_name.

  CREATE OBJECT v_guiobj.

  CALL METHOD v_guiobj->file_save_dialog

    EXPORTING

      default_extension  = 'pdf'

      default_file_name  = v_name

      file_filter        = v_filter

    CHANGING

      filename           = v_name

      path               = v_path

      fullpath           = v_fullpath

      user_action        = v_uact.

  IF v_uact = v_guiobj->action_cancel.

    EXIT.

  ENDIF.

*..................................DOWNLOAD AS FILE....................*

  MOVE v_fullpath TO v_filename.

  CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

      bin_filesize     = v_bin_filesize

      filename         = v_filename

      filetype         = 'BIN'

    TABLES

      data_tab         = it_lines.

former_member1193316
Participant
0 Kudos

I dont want download option. I want to display the spool request in pdf format at SAP Screen itself. is it possible?

Former Member
0 Kudos

Hi,

You can check the below link:

http://wiki.sdn.sap.com/wiki/display/ABAP/PDF+Downlaod+By+Creating+Spool+Request

Hope it serves useful to you.

former_member230486
Contributor
0 Kudos

Try using this code,

tables sflight.
select-options s_carrid for sflight-carrid.
DATA:w_form_name  type tdsfname,             "Smartform name
          r_options    type ssfcompop,            "Print option
           r_control    type ssfctrlop,            "Print control
          w_function type rs38l_fnam.


r_options-tddest    = 'LOCL'.             "Spool: Output device
    r_options-tdimmed   = 'X'.               "Print Immediately
    r_options-tddelete  = space.            "Delete After Printing
    r_options-tdnewid   = 'X'.                 "New Spool Request
    r_control-device    = 'PRINTER'.
    r_control-no_dialog = 'X'.
    r_control-langu     = sy-langu.
 
   call function 'SSF_FUNCTION_MODULE_NAME'
     exporting
       formname           = 'ZADEV_FLIGHT_DETAILS'
     importing
       fm_name            = w_function.
 
   if sy-subrc <> 0.
      message id sy-msgid type sy-msgty number sy-msgno
              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
 
call function w_function
      exporting
        control_parameters = r_control
        output_options     = r_options
        user_settings      = ' '
   TABLES
     so_carrid                  = s_carrid.
       if sy-subrc <> 0.
      message id sy-msgid type sy-msgty number sy-msgno
              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.

Answers (2)

Answers (2)

former_member386202
Active Contributor
0 Kudos

Hi ,

Change your medium  NAST-NACHA = 1.

Regards,

Prashant    

Former Member
0 Kudos

Check this two threads.It will be helpful for u

Karthik.R