Skip to Content
author's profile photo Former Member
Former Member

how to download smart forms to local file in pdf format

Hi All,

Please help me, i want to download my smartform to my local machine(windows) in PDF format.

THANKS,

Gaurav Mittal

Add comment
10|10000 characters needed characters exceeded

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 15, 2007 at 08:06 AM

    Hi,

    please go throuh the below procedure and sample Code, this might help you.

    Procedure

    When we activate the Smartform the system generates a Function Module. The function module name we can get from Smartfrom screen from menubar

    “Environment => Function Module_Name” . In a report we can get this Function module name by calling a Function Module standard SSF_FUNCTION_MODULE_NAME. This function module at runtime calls the FM generated by smartform, which in turn is then used to pass data from the report to Smartform. In the report given below the FM generated is “ /1BCDWB/SF00000152 ”. In this FM we can see CONTROL_PARAMETERS in import tab. This is of type SSFCTRLOP. We need to set the GETOTF of this to be ‘X’. Setting this field will activate the OTF field in smartform.

    In export tab of the FM generated by smartform we can see a parameter JOB_OUTPUT_INFO which is of type SSFCRESCL. The SSFCRESCL is a structure of having one of fields as OTFDATA. OTFDATA in turn is a table of type ITCOO. ITCOO has two fields TDPRINTCOM and TDPRINTPAR. TDPRINTCOM represents command line of OTF format data and TDPRINTPAR contains command parameters of OTF format data.

    In every Smartform output in OTF format, TDPRINTCOM begins and ends with ‘//’. ‘EP’ represents the end-of-page value for TDPRINTCOM field.

    In addition we need to set few fields at the place where we call this FM(generated by smartform) in our program. While calling this FM we should set control_parameters, output_options, user_settings and job_putput_info fields as shown in program.

    Once these settings are done we can call Function Module CONVERT_OTF to convert the OTF data of smartfrom output to PDF data format. Once these are done we can call method “cl_gui_fronted_services=>file_save_dialog” to specify the directory path where we want to save the output PDF file. After this we can call Function Module GUI_DOWNLOAD to download the PDF file on our local system.

    Here is a sample code of program to perform the function.

    
    SAMPLE CODE 
    
    
    *&---------------------------------------------------------------------*
    *& Report  ZAMIT_SMART_FORM_PDF                                        *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    *&                                                                     *
    *&                                                                     *
    *&---------------------------------------------------------------------*
     
    REPORT  ZAMIT_SMART_FORM_PDF                    .
     
    data: carr_id type sbook-carrid,
          cparam type ssfctrlop,
          outop type ssfcompop,
          fm_name type rs38l_fnam.
     
    DATA: tab_otf_data TYPE ssfcrescl,
          pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
          tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
          file_size TYPE i,
          bin_filesize TYPE i,
          FILE_NAME type string,
          File_path type string,
          FULL_PATH type string.
     
    parameter:      p_custid type scustom-id default 1.
    select-options: s_carrid for carr_id     default 'LH' to 'LH'.
    parameter:      p_form   type tdsfname   default 'ZAMIT_SMART_FORM'.
     
    data: customer    type scustom,
          bookings    type ty_bookings,
          connections type ty_connections.
     
    start-of-selection.
     
    ***************** suppressing the dialog box for print preview****************************
    outop-tddest = 'LP01'.
    cparam-no_dialog = 'X'.
    cparam-preview = SPACE.
    cparam-getotf = 'X'.
     
      select single * from scustom into customer where id = p_custid.
      check sy-subrc = 0.
     
     
      select * from sbook   into table bookings
               where customid = p_custid
               and   carrid in s_carrid
               order by primary key.
     
     
      select * from spfli into table connections
               for all entries in bookings
               where carrid = bookings-carrid
               and   connid = bookings-connid
               order by primary key.
     
     
     
      call function 'SSF_FUNCTION_MODULE_NAME'
           exporting  formname           = p_form
    *                 variant            = ' '
    *                 direct_call        = ' '
           importing  fm_name            = fm_name
           exceptions no_form            = 1
                      no_function_module = 2
                      others             = 3.
     
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        exit.
      endif.
     
     
     
    * calling the generated function module
      call function fm_name
           exporting
    *                 archive_index        =
    *                 archive_parameters   =
                     control_parameters   = cparam
    *                 mail_appl_obj        =
    *                 mail_recipient       =
    *                 mail_sender          =
                     output_options       =  outop
                     user_settings        = SPACE
                     bookings             = bookings
                      customer             = customer
                      connections          = connections
          importing
    *                 document_output_info =
                     job_output_info      = tab_otf_data
    *                 job_output_options   =
           exceptions formatting_error     = 1
                      internal_error       = 2
                      send_error           = 3
                      user_canceled        = 4
                      others               = 5.
     
      if sy-subrc <> 0.
    *   error handling
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
     
     
      tab_otf_final[] = tab_otf_data-otfdata[].
     
     
     
      CALL FUNCTION 'CONVERT_OTF'
     EXPORTING
       format                      = 'PDF'
       max_linewidth               = 132
    *   ARCHIVE_INDEX               = ' '
    *   COPYNUMBER                  = 0
    *   ASCII_BIDI_VIS2LOG          = ' '
     IMPORTING
       bin_filesize                = bin_filesize
    *   BIN_FILE                    =
      TABLES
        otf                         = tab_otf_final
        lines                       = pdf_tab
     EXCEPTIONS
       err_max_linewidth           = 1
       err_format                  = 2
       err_conv_not_possible       = 3
       err_bad_otf                 = 4
       OTHERS                      = 5
              .
    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 METHOD cl_gui_frontend_services=>file_save_dialog
    *  EXPORTING
    *    WINDOW_TITLE         =
    *    DEFAULT_EXTENSION    =
    *    DEFAULT_FILE_NAME    =
    *    FILE_FILTER          =
    *    INITIAL_DIRECTORY    =
    *    WITH_ENCODING        =
    *    PROMPT_ON_OVERWRITE  = 'X'
      CHANGING
        filename             = FILE_NAME
        path                 = FILE_PATH
        fullpath             = FULL_PATH
    *    USER_ACTION          =
    *    FILE_ENCODING        =
    *  EXCEPTIONS
    *    CNTL_ERROR           = 1
    *    ERROR_NO_GUI         = 2
    *    NOT_SUPPORTED_BY_GUI = 3
    *    others               = 4
            .
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
     
     
     
     
    *************downloading the converted PDF data to your local PC********
     
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
       bin_filesize                    = bin_filesize
       filename                        = FULL_PATH
       filetype                        = 'BIN'
    *   APPEND                          = ' '
    *   WRITE_FIELD_SEPARATOR           = ' '
    *   HEADER                          = '00'
    *   TRUNC_TRAILING_BLANKS           = ' '
    *   WRITE_LF                        = 'X'
    *   COL_SELECT                      = ' '
    *   COL_SELECT_MASK                 = ' '
    *   DAT_MODE                        = ' '
    *   CONFIRM_OVERWRITE               = ' '
    *   NO_AUTH_CHECK                   = ' '
    *   CODEPAGE                        = ' '
    *   IGNORE_CERR                     = ABAP_TRUE
    *   REPLACEMENT                     = '#'
    *   WRITE_BOM                       = ' '
    *   TRUNC_TRAILING_BLANKS_EOL       = 'X'
     IMPORTING
       filelength                      = file_size
      TABLES
        data_tab                        = pdf_tab
    *   FIELDNAMES                      =
     EXCEPTIONS
       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.
     
    ENDIF.
     
    
    
    
    Thanks and Regards,
    Vasanth
    

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      As per my understanding we do not need to pass any value in program but it takes the value when we provide local desktop path at the output..


      Regards.

  • author's profile photo Former Member
    Former Member
    Posted on Jun 15, 2007 at 08:05 AM

    Hi,

    Goto SMARTFORMS, then give the Smartform name then Utilities --> Download to Download the Smartform

    Regards

    Sudheer

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 15, 2007 at 08:10 AM

    Hi,

    This link may help you.

    http://www.saptechnical.com/Tutorials/Smartforms/OTF2PDF.htm

    Thanks,

    Anitha

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 15, 2007 at 09:26 AM

    hi

    good

    go through this code

    Code: -

    -


    Textpool :

    -

    -


    I001 CONVERT_OTFSPOOLJOB_2_PDF function successful

    I002 Not an OTF or ABAP spool request

    I003 Request does not exist I004 No authorization to read spool request

    I005 Error in CONVERT_OTFSPOOLJOB_2_PDF function

    I006 CONVERT_ABAPSPOOLJOB_2_PDF function successful

    I007 Error in CONVERT_ABAPSPOOLJOB_2_PDF function

    I009 CaractÈres dans

    R export SPOOLS to local files after PDF convertion

    S_CREDATE Date

    S_RQ2NAME Spool Name

    S_RQDEST Destination (printer)

    S_RQIDENT Spool Number

    S_RQOWNER Author

    -

    -


    Abap :

    -

    -


    *----

    -


    • The program select spools

    • and export then under PDF format.

    REPORT YYJPL14 "NO STANDARD PAGE HEADING

    LINE-SIZE 170

    LINE-COUNT 58

    MESSAGE-ID Y_LOCAL_FR22.

    *=----


    =*

    TABLES: TSP01, RSPOTYPE.

    *----


    *

    DATA: DEFDIR(256) VALUE 'C:SAP'

    ,_TSP01 LIKE TSP01 OCCURS 0 WITH HEADER LINE,

    AUTHORITY LIKE RSTSTYPE-AUTHCHECKD,

    CLIENT LIKE RSTSTYPE-CLIENT,

    NAME LIKE RSTSTYPE-NAME,

    PART LIKE TST01-DPART,

    CHARCO LIKE RSTSTYPE-CHARCO,

    CREATER LIKE RSTSTYPE-CREATER,

    CREDATE LIKE RSTSTYPE-CREDATE,

    DELDATE LIKE RSTSTYPE-DELDATE,

    MAX_CREDATE LIKE RSTSTYPE-CREDATE,

    MAX_DELDATE LIKE RSTSTYPE-DELDATE,

    NON_UNIQ LIKE RSTSTYPE-SEL_OK,

    NOOF_PARTS LIKE TST01-DNOPARTS,

    RECTYP LIKE RSTSTYPE-RECTYP,

    SIZE LIKE TST01-DSIZE,

    STOTYP LIKE TST01-DSTOTYP,

    TYPE LIKE RSTSTYPE-TYPE,

    OBJTYPE LIKE RSTSTYPE-TYPE,

    NUMBYTES TYPE I,

    PDFSPOOLID LIKE TSP01-RQIDENT,

    jobname like tbtcjob-jobname,

    JOBCOUNT LIKE TBTCJOB-JOBCOUNT,

    PDF LIKE TLINE OCCURS 0 WITH HEADER LINE,

    P_FILE LIKE RLGRAP-FILENAME VALUE 'C:tempfile.pdf'.

    RANGES: S_RQFIN FOR TSP01-RQFINAL.

    RANGES: _CRETIME FOR TSP01-RQCRETIME.

    *----


    *

    SELECT-OPTIONS:

    _RQIDENT FOR TSP01-RQIDENT,

    _RQOWNER FOR TSP01-RQOWNER,

    _CREDATE FOR RSPOTYPE-CREDATE,

    "_cretime FOR tsp01-rqcretime,

    _RQ2NAME FOR TSP01-RQ2NAME,

    _RQDEST FOR TSP01-RQDEST .

    PARAMETERS:

    DIR LIKE RLGRAP-FILENAME DEFAULT DEFDIR.

    *----


    *

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR DIR.

    *----


    *

    CALL FUNCTION 'WS_FILENAME_GET'

    EXPORTING

    DEF_FILENAME = '.'

    DEF_PATH = DEFDIR

    MASK = ',All files,..'

    MODE = 'O'

    TITLE = 'Get filename for directory'

    IMPORTING

    FILENAME = DIR

    EXCEPTIONS

    INV_WINSYS = 01

    NO_BATCH = 02

    SELECTION_CANCEL = 03

    SELECTION_ERROR = 04.

    IF SY-SUBRC <> 0.

    SY-SUBRC = SY-SUBRC + 0.

    ENDIF.

    DEFDIR = DIR.

    *=----


    =*

    START-OF-SELECTION.

    *=----


    =*

    *here inspiration comes from RSPOSP01 (transaction SP01)

    REFRESH S_RQFIN. " select all C & . required for index!!!

    S_RQFIN-LOW = 'C'.

    S_RQFIN-SIGN = 'I'.

    S_RQFIN-OPTION = 'EQ'.

    APPEND S_RQFIN.

    S_RQFIN-LOW = '.'.

    APPEND S_RQFIN.

    CLEAR _CRETIME.

    REFRESH _CRETIME.

    LOOP AT _CREDATE.

    _CRETIME-SIGN = _CREDATE-SIGN.

    _CRETIME-OPTION = _CREDATE-OPTION.

    IF _CREDATE-LOW IS INITIAL.

    CLEAR _CRETIME-LOW.

    ELSE.

    _CRETIME-LOW(8) = _CREDATE-LOW.

    _CRETIME-LOW+8(8) = '00000000'.

    ENDIF.

    IF _CREDATE-HIGH IS INITIAL.

    CLEAR _CRETIME-HIGH.

    ELSE.

    _CRETIME-HIGH(8) = _CREDATE-HIGH.

    _CRETIME-HIGH+8(8) = '23595900'.

    ENDIF.

    APPEND _CRETIME.

    ENDLOOP.

    *find the spool list

    SELECT * FROM TSP01

    INTO CORRESPONDING FIELDS OF TABLE _TSP01

    WHERE RQFINAL IN S_RQFIN AND

    RQIDENT IN _RQIDENT AND

    RQOWNER IN _RQOWNER AND

    RQCRETIME IN _CRETIME AND

    RQ2NAME IN _RQ2NAME AND

    RQDEST IN _RQDEST .

    LOOP AT _TSP01.

    MOVE-CORRESPONDING _TSP01 TO TSP01.

    *authority to work with spool

    CALL FUNCTION 'RSPO_CHECK_JOB_PERMISSION'

    EXPORTING

    ACCESS = 'BASE'

    SPOOLREQ = TSP01

    EXCEPTIONS

    NO_PERMISSION = 1

    OTHERS = 2.

    *check authority

    CHECK SY-SUBRC = 0.

    *here inspiration comes from RSTXPDFT4

    *retrieve spool attributes

    client = tsp01-rqclient.

    name = tsp01-rqo1name.

    CALL FUNCTION 'RSTS_GET_ATTRIBUTES'

    EXPORTING

    AUTHORITY = 'SP01'

    CLIENT = CLIENT

    NAME = NAME

    PART = 1

    IMPORTING

    CHARCO = CHARCO

    CREATER = CREATER

    CREDATE = CREDATE

    DELDATE = DELDATE

    MAX_CREDATE = MAX_CREDATE

    MAX_DELDATE = MAX_DELDATE

    NON_UNIQ = NON_UNIQ

    NOOF_PARTS = NOOF_PARTS

    RECTYP = RECTYP

    SIZE = SIZE

    STOTYP = STOTYP

    TYPE = TYPE

    OBJTYPE = OBJTYPE

    EXCEPTIONS

    FB_ERROR = 1

    FB_RSTS_OTHER = 2

    NO_OBJECT = 3

    NO_PERMISSION = 4

    OTHERS = 5.

    IF SY-SUBRC <> 0.

    MESSAGE E020 WITH SY-SUBRC CLIENT NAME.

    CONTINUE.

    ENDIF.

    *spool À traiter

    WRITE:/

    TSP01-RQIDENT ,

    TSP01-RQ0NAME ,

    TSP01-RQ1NAME ,

    TSP01-RQ2NAME ,

    TSP01-RQOWNER ,

    (19) TSP01-RQCRETIME USING EDIT MASK '____/__/__ __:__:__',

    TSP01-RQDEST ,

    TSP01-RQPAPER.

    " client ,

    " name ,

    " part ,

    " charco ,

    " creater ,

    " credate ,

    " deldate ,

    " max_credate ,

    " max_deldate ,

    " non_uniq ,

    " noof_parts ,

    " rectyp ,

    " size ,

    " stotyp ,

    " type ,

    " objtype .

    if objtype(3) = 'OTF'.

    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

    EXPORTING

    SRC_SPOOLID = TSP01-RQIDENT

    NO_DIALOG = ' '

    • DST_DEVICE =

    • PDF_DESTINATION =

    IMPORTING

    PDF_BYTECOUNT = numbytes

    PDF_SPOOLID = pdfspoolid

    • OTF_PAGECOUNT =

    BTC_JOBNAME = jobname

    BTC_JOBCOUNT = jobcount

    TABLES

    PDF = pdf

    EXCEPTIONS

    ERR_NO_OTF_SPOOLJOB = 1

    ERR_NO_SPOOLJOB = 2

    ERR_NO_PERMISSION = 3

    ERR_CONV_NOT_POSSIBLE = 4

    ERR_BAD_DSTDEVICE = 5

    USER_CANCELLED = 6

    ERR_SPOOLERROR = 7

    ERR_TEMSEERROR = 8

    ERR_BTCJOB_OPEN_FAILED = 9

    ERR_BTCJOB_SUBMIT_FAILED = 10

    ERR_BTCJOB_CLOSE_FAILED = 11.

    case sy-subrc.

    when 0.

    WRITE: / 'Funktion CONVERT_OTFSPOOLJOB_2_PDF erfolgreich'(001)

    COLOR COL_POSITIVE.

    when 1.

    WRITE: / 'Kein OTF- und kein ABAP-Spoolauftrag'(002)

    COLOR COL_negative.

    exit.

    when 2.

    WRITE: / 'Spoolauftrag existiert nicht'(003)

    COLOR COL_negative.

    exit.

    when 3.

    WRITE: / 'Keine Berechtigung zum Lesen Spoolauftrag'(004)

    COLOR COL_negative.

    exit.

    when others.

    WRITE: / 'Fehler bei Funktion CONVERT_OTFSPOOLJOB_2_PDF'(005)

    COLOR COL_negative.

    exit.

    endcase.

    else.

    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

    EXPORTING

    SRC_SPOOLID = TSP01-RQIDENT

    NO_DIALOG = ' '

    • DST_DEVICE =

    • PDF_DESTINATION =

    IMPORTING

    PDF_BYTECOUNT = numbytes

    PDF_SPOOLID = pdfspoolid

    • LIST_PAGECOUNT =

    BTC_JOBNAME = jobname

    BTC_JOBCOUNT = jobcount

    TABLES

    PDF = pdf

    EXCEPTIONS

    ERR_NO_ABAP_SPOOLJOB = 1

    ERR_NO_SPOOLJOB = 2

    ERR_NO_PERMISSION = 3

    ERR_CONV_NOT_POSSIBLE = 4

    ERR_BAD_DESTDEVICE = 5

    USER_CANCELLED = 6

    ERR_SPOOLERROR = 7

    ERR_TEMSEERROR = 8

    ERR_BTCJOB_OPEN_FAILED = 9

    ERR_BTCJOB_SUBMIT_FAILED = 10

    ERR_BTCJOB_CLOSE_FAILED = 11.

    case sy-subrc.

    when 0.

    WRITE: / 'Funktion CONVERT_ABAPSPOOLJOB_2_PDF erfolgreich'(006)

    COLOR COL_POSITIVE.

    when 1.

    WRITE: / 'Kein OTF- und kein ABAP-Spoolauftrag'(002)

    COLOR COL_negative.

    exit.

    when 2.

    WRITE: / 'Spoolauftrag existiert nicht'(003)

    COLOR COL_negative.

    exit.

    when 3.

    WRITE: / 'Keine Berechtigung zum Lesen Spoolauftrag'(004)

    COLOR COL_negative.

    exit.

    when others.

    WRITE: / 'Fehler bei Funktion CONVERT_ABAPSPOOLJOB_2_PDF'(007)

    COLOR COL_negative.

    exit.

    endcase.

    endif.

    • download PDF file

    TRANSLATE TSP01-RQ2NAME USING '/ : * < > | ? '' " '.

    CONDENSE TSP01-RQ2NAME NO-GAPS.

    CONCATENATE DIR '' TSP01-RQ2NAME '-' TSP01-RQCRETIME '.pdf'

    INTO P_FILE.

    CALL FUNCTION 'WS_DOWNLOAD'"or GUI_DOWNLOAD

    EXPORTING

    BIN_FILESIZE = NUMBYTES

    FILENAME = P_FILE

    FILETYPE = 'BIN'

    IMPORTING

    • act_filename = p_file

    FILELENGTH = NUMBYTES

    TABLES

    DATA_TAB = PDF.

    WRITE: / NUMBYTES, 'Bytes heruntergeladen in Datei'(009),

    (100) P_FILE.

    ULINE.

    ENDLOOP.

    thanks

    mrutyun^

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 14, 2015 at 04:43 AM

    Hi,

    Hope this Simple code would be useful to you.

    TABLES: kna1.



    *-----------------Interface options-----------------*

    SELECT-OPTIONS : s_kunnr FOR kna1-kunnr.

    *---------



    *-----------------Declarations----------------------*

    DATA: wa_control_parameters TYPE ssfctrlop.

    DATA: wa_output_options TYPE ssfcompop.

    DATA: wa_job_output_info TYPE ssfcrescl.

    DATA: fmname TYPE tdsfname.

    DATA: v_bin_filesize TYPE i.

    DATA: v_filename TYPE string. "VALUE 'formtest.pdf'.

    DATA: it_lines TYPE STANDARD TABLE OF tline.

    DATA: it_docs TYPE STANDARD TABLE OF docs.

    DATA: file_path TYPE string,

    full_path TYPE string.

    *---------

    *-----------------Getting the Form name-------------------*

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING

    formname = 'ZBM_DEMO_FORM'

    * VARIANT = ' '

    * DIRECT_CALL = ' '

    IMPORTING

    fm_name = fmname

    EXCEPTIONS

    no_form = 1

    no_function_module = 2

    OTHERS = 3.

    IF sy-subrc <> 0.

    * Implement suitable error handling here

    ENDIF.

    *----------



    *--------------Setting the output parameters for Form----------*

    wa_control_parameters-no_dialog = 'X'.

    wa_control_parameters-preview = 'X'.

    wa_control_parameters-getotf = 'X'.

    wa_output_options-tddest = 'LP01'.

    *-----------



    *--------------Calling the Form's FM----------------------------*

    CALL FUNCTION fmname

    EXPORTING

    control_parameters = wa_control_parameters

    output_options = wa_output_options

    kunnr_low = s_kunnr-low

    kunnr_high = s_kunnr-high

    IMPORTING

    job_output_info = wa_job_output_info

    EXCEPTIONS

    formatting_error = 1

    internal_error = 2

    send_error = 3

    user_canceled = 4

    OTHERS = 5.



    IF sy-subrc NE 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    STOP.

    ENDIF.

    *-------------



    *---------------Converting the OTF output into PDF---------------*

    CALL FUNCTION 'CONVERT_OTF_2_PDF'

    IMPORTING

    bin_filesize = v_bin_filesize

    TABLES

    otf = wa_job_output_info-otfdata

    doctab_archive = it_docs

    lines = it_lines

    EXCEPTIONS

    err_conv_not_possible = 1

    err_otf_mc_noendmarker = 2

    OTHERS = 3.



    IF sy-subrc NE 0.

    WRITE: / 'conversion error, RC:', sy-subrc.

    STOP.

    ENDIF.

    *----------





    *----------- THIS METHOD IS USED TO DISPLAY THE FILE SAVE DIALOG WINDOW-----------*

    CALL METHOD cl_gui_frontend_services=>file_save_dialog

    * EXPORTING

    * window_title =

    * default_extension =

    * default_file_name =

    * with_encoding =

    * file_filter =

    * initial_directory =

    * prompt_on_overwrite = 'X'

    CHANGING

    filename = v_filename

    path = file_path

    fullpath = full_path

    * user_action =

    * file_encoding =

    EXCEPTIONS

    cntl_error = 1

    error_no_gui = 2

    not_supported_by_gui = 3

    OTHERS = 4

    .

    IF sy-subrc <> 0.

    * Implement suitable error handling here

    ENDIF.

    *------------



    *--------------------Downloading the Form------------------*

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    bin_filesize = v_bin_filesize

    filename = v_filename

    filetype = 'BIN'

    TABLES

    data_tab = it_lines

    EXCEPTIONS

    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 NE 0.

    WRITE: / 'download error, RC:', sy-subrc.

    ENDIF.



    *-------------------

    Add comment
    10|10000 characters needed characters exceeded