cancel
Showing results for 
Search instead for 
Did you mean: 

Smart form print preview in PDF format

Former Member
0 Kudos

Hi ABAP Experts,

I have 2 requirements

1) I want to print preview of a smartform in pdf format

2) I also want to attach a local pdf file to the smartform which is displaying in the pdf print preview format

or to rephrase:

I want a pdf attached to a smartform which i want to open in the pdf print preview format.

Regards,

Niloufer

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Use following function modules:

Please see the below code to download a PDF file on to your computer.

PERFORM F_CONVERT_OTF.

FORM F_CONVERT_OTF .
PERFORM F_CALL_SMARTFORM. " Call the smartform to get data in I_OTF_FINAL

**appending the otf data into the final table & save the pdf file.

  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      FORMAT                = C_PDF_U      "Value is 'PDF'
    IMPORTING
      BIN_FILESIZE          = L_BIN_FILESIZE         "L_BIN_FILESIZE TYPE I,
    TABLES
      OTF                   = I_OTF_FINAL
      LINES                 = I_PDF_TAB    "It is of type TLINE
    EXCEPTIONS
      ERR_MAX_LINEWIDTH     = 1
      ERR_FORMAT            = 2
      ERR_CONV_NOT_POSSIBLE = 3
      ERR_BAD_OTF           = 4
      OTHERS                = 5.


* Check if the file is already existing.
  CALL FUNCTION 'TMP_GUI_GET_FILE_EXIST'
    EXPORTING
      FNAME                = L_FILE1   " Path where file is saved
   IMPORTING
     EXIST                = L_RESULT
*   ISDIR                =
*   FILESIZE             =
   EXCEPTIONS
     FILEINFO_ERROR       = 1
     OTHERS               = 2
            .
PERFORM F_GUI_DOWNLOAD USING L_FILE.
ENDFORM.

FORM F_GUI_DOWNLOAD  USING P_FILE TYPE STRING.

CONSTANTS: C_BIN(10)       TYPE C VALUE 'BIN'.


  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      FILENAME                = P_FILE     "same as L_FILE
      FILETYPE                = C_BIN
      CONFIRM_OVERWRITE       = C_X   "value 'X'
    TABLES
      DATA_TAB                = I_PDF_TAB
    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.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ELSE.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

<removed by moderator>

Edited by: vishalmurgai58 on Mar 6, 2012 1:43 PM

Edited by: Thomas Zloch on Mar 6, 2012 - please do not ask for ...

Answers (6)

Answers (6)

Former Member
0 Kudos

Actually your requirement is not clear " Attaching a pdf to a smartform.

What do you basically want to do?

1. Do you want to upload a pdf from your desktop and display it in pdf viewer through SAP?

2. Do you need to send a pdf as an attachment with a mail?

Please clarify.

For the 1st case:

1.) Use FM GUI_UPLOAD to upload a pdf & store its data in an internal table.

2.) Check the program 'SAP_PDF_VIEWER_DEMO' to print this data in a pdf viewer.

Hope this helps.

Edited by: vishalmurgai58 on Mar 7, 2012 10:56 AM

Former Member
0 Kudos

Hi All!!!

Thanks for your valuable replies, I want to attach a PDF and open the same in the print preview of the smartform which is in the PDF format.

Regards,

Niloufer

Former Member
0 Kudos

HI,

For Print Preview try this function module

SSFCOMP_PDF_PREVIEW

For attachment try this link

https://wiki.sdn.sap.com/wiki/display/ABAP/SmartformSendvia+Email

Harsh_Bansal
Contributor
0 Kudos

Hi,

But you can see the preview in !pdf format using this method. Why specifically program?

Regards,

Harsh Bansal

Former Member
0 Kudos

Hi,

Thank you!! But i was looking for a program which does tha.

Regards,

Niloufer

Harsh_Bansal
Contributor
0 Kudos

Hi,

To print preview in PDF,

Print preview smartform in normal way. Then in command box type - !PDF

Regards,

Harsh Bansal