Register Login

Smart form OTF to PDF conversion

Updated May 18, 2018

Hi,

I had a query regarding OTF to PDF conversion of Smartform output. I have attached my source code below. I am taking the customer number on a selection screen and then based on that customer number i am extracting the order information of the customer. The problem is if the data has only one page, then the PDF file extracted is perfect. However, if it spans more than one page, iam only getting the data on the last page of PDF file. In the remaining pages all i get is empty table (The structure of the table is fine with borders and shading, but no data).

Please help me out guys.  

Regards,     

*&---------------------------------------------------------------------*

*& Report ZSCRIPT8

*&

*&---------------------------------------------------------------------*

*&   AUTHOR - REKHA

*&

*&---------------------------------------------------------------------*

REPORT zscript8.

* These 2 are needed for function 'CONVERT_OTF_2_PDF'

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

DATA : it_docs TYPE STANDARD TABLE OF docs,

it_lines TYPE STANDARD TABLE OF tline,

* Standard parameters for smartform

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

my_job_output_info TYPE ssfcrescl,

my_output_options TYPE ssfcompop,

my_control_parameters TYPE ssfctrlop,

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

dev_name TYPE rspoptype, " For device name for PDF output

v_bin_filesize TYPE i, "Specifying the file size for functions

                       "Convert_otf_2_pdf and Gui_download

f_name TYPE rs38l_fnam. "To store the form function module name

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

DATA   w_kna1 TYPE kna1. "For Customer information

DATA t_vbak TYPE vbak OCCURS 1. "For order information

PARAMETERS p_custno TYPE kna1-kunnr.

* To print the customer number and the name at the top of the order

* table output

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

SELECT * FROM kna1 INTO w_kna1 WHERE kunnr = p_custno.

ENDSELECT.

* Selecting the order data of the selected customer.

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

SELECT vbeln

       erdat

       ernam

       netwr

       INTO CORRESPONDING FIELDS OF TABLE t_vbak

       FROM vbak WHERE kunnr = p_custno.

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

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

  EXPORTING

    formname = 'ZSMARTFORM4'

  IMPORTING

    fm_name  = f_name.

*.................GET DEVICE NAME FOR PDF OUTPUT.....................*

CALL FUNCTION 'SSF_GET_DEVICE_TYPE'

  EXPORTING

    i_language    = sy-langu

    i_application = 'SAPDEFAULT'

  IMPORTING

    e_devtype     = dev_name.

*............SETTING STANDARD PARAMETERS FOR SMART FORM INTERFACE.....*

my_output_options-tdprinter = dev_name.

my_control_parameters-no_dialog = 'X'. "SUPPRESS SPOOL DIALOG MODULE

my_control_parameters-getotf = 'X'.    "TO GET OTF DATA WITHOUT PRINTING

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

CALL FUNCTION f_name

  EXPORTING

    control_parameters = my_control_parameters

    output_options     = my_output_options

    w_kna1             = w_kna1

  IMPORTING

    job_output_info    = my_job_output_info

  TABLES

    t_vbak             = t_vbak.

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

CALL FUNCTION 'CONVERT_OTF_2_PDF'

  IMPORTING

    bin_filesize   = v_bin_filesize "This is must, if not

  TABLES

    otf = my_job_output_info-otfdata  " given getting run err

    doctab_archive = it_docs

    lines = it_lines.

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

CALL FUNCTION 'GUI_DOWNLOAD'

  EXPORTING

    bin_filesize = v_bin_filesize "Must give else run error

    filename     = 'C:MYPDF.PDF'

    filetype     = 'BIN' "This is also must else run error

  TABLES

    data_tab     = it_lines.


Comments

  • 28 Oct 2010 6:52 am rekha
    Try This-

     

    *&---------------------------------------------------------------------*

    *& Report  ZSF_AGREEMENT_PDF_USR                                       *

    *&                                                                     *

    *&---------------------------------------------------------------------*

    *& AUTHOR :                                              *

    *&                                                                     *

    *&---------------------------------------------------------------------*

     

    REPORT  ZSF_AGREEMENT_PDF_USR.

     

    DATA : ANS(6) TYPE C.

    DATA : WS_UCOMM LIKE SY-UCOMM,

           FORM_NAME TYPE RS38L_FNAM,

           WA_CTRLOP TYPE SSFCTRLOP,

           WA_OUTOPT TYPE SSFCOMPOP.

    DATA : T_OTFDATA TYPE SSFCRESCL,

           T_PDF_TAB LIKE TLINE OCCURS 0 WITH HEADER LINE.

    DATA : T_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE.

    DATA : W_FILESIZE TYPE I.

    DATA : W_BIN_FILESIZE TYPE I.

     

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

      EXPORTING

        FORMNAME           = 'ZSF_AGREEMENT'

      IMPORTING

        FM_NAME            = FORM_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.

    ENDIF.

     

    WA_CTRLOP-PREVIEW = 'X'.

    WA_CTRLOP-NO_DIALOG = 'X'.

    WA_OUTOPT-TDNOPREV = 'X'.

     

     

    CALL FUNCTION FORM_NAME

     EXPORTING

       CONTROL_PARAMETERS         = WA_CTRLOP

       OUTPUT_OPTIONS             = WA_OUTOPT

       USER_SETTINGS              = 'X'

     IMPORTING

       JOB_OUTPUT_INFO            = T_OTFDATA

     EXCEPTIONS

       FORMATTING_ERROR           = 1

       INTERNAL_ERROR             = 2

       SEND_ERROR                 = 3

       USER_CANCELED              = 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 FUNCTION 'POPUP_TO_CONFIRM_STEP'

      EXPORTING

       DEFAULTOPTION        = 'Y'

       TEXTLINE1            = 'DO YOU TO DOWNLOAD PREVIEW TO PDF FILE ?'

       TEXTLINE2            = 'PRESS YES TO DOWNLOAD AND NO OR CANCEL TO EXIT !'

       TITEL                = 'DOWNLOAD TO PDF FILE ON PRESENTATION SERVER'

       CANCEL_DISPLAY       = 'X'

     IMPORTING

       ANSWER               = ANS.

     

     

    CASE ANS.

      WHEN 'J'.

        PERFORM DWTOPDF.

      WHEN 'N'.

        BACK.

      WHEN OTHERS.

        LEAVE PROGRAM.

    ENDCASE.

     

    *&---------------------------------------------------------------------*

    *&      Form  DWTOPDF

    *&---------------------------------------------------------------------*

    *       text

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

    *  -->  p1        text

    *  <--  p2        text

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

    FORM DWTOPDF .

    WA_CTRLOP-GETOTF = 'X'.

    WA_CTRLOP-PREVIEW = ' '.

     

    CALL FUNCTION FORM_NAME

     EXPORTING

       CONTROL_PARAMETERS         = WA_CTRLOP

       OUTPUT_OPTIONS             = WA_OUTOPT

       USER_SETTINGS              = 'X'

     IMPORTING

       JOB_OUTPUT_INFO            = T_OTFDATA

     EXCEPTIONS

       FORMATTING_ERROR           = 1

       INTERNAL_ERROR             = 2

       SEND_ERROR                 = 3

       USER_CANCELED              = 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.

     

     

    T_OTF[] = T_OTFDATA-OTFDATA[].

     

     

      CALL FUNCTION 'CONVERT_OTF'

      EXPORTING

        FORMAT = 'PDF'

        MAX_LINEWIDTH = 132

      IMPORTING

        BIN_FILESIZE = W_BIN_FILESIZE

      TABLES

         OTF = T_OTF

         LINES = T_PDF_TAB

      EXCEPTIONS

          ERR_MAX_LINEWIDTH = 1

          ERR_FORMAT = 2

          ERR_CONV_NOT_POSSIBLE = 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.

     

      CALL FUNCTION 'GUI_DOWNLOAD'

      EXPORTING

        BIN_FILESIZE = W_BIN_FILESIZE

        FILENAME = 'd: est.PDF'

        FILETYPE = 'BIN'

      IMPORTING

        FILELENGTH = W_FILESIZE

      TABLES

        DATA_TAB = T_PDF_TAB

      EXCEPTIONS

        FILE_OPEN_ERROR = 1

        FILE_WRITE_ERROR = 2

        INVALID_FILESIZE = 3

        INVALID_TYPE = 4

        NO_BATCH = 5

        UNKNOWN_ERROR = 6

        INVALID_TABLE_WIDTH = 7

        GUI_REFUSE_FILETRANSFER = 8

        CUSTOMER_ERROR = 9

        OTHERS = 10.

     

      IF SY-SUBRC <> 0.

        MESSAGE 'File not downloaded succesfully' TYPE 'A'.

      ELSE.

        MESSAGE 'File Test.pdf downloaded succesfully under D drive' TYPE 'I'.

      ENDIF.

     

    ENDFORM.                    " DWTOPDF
  • 10 Nov 2010 11:27 am Guest
    type pdf! in print preview screen .. form will be in pdf format...

×