Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how call FM otf to pdf in a report

Former Member
0 Kudos

Hi,

I am working on a code of a sapscript and i am facing the problem when i execute it does not shows the line in it and i want to use the FM converting OTF TO PDF. i know there is a system program RSTXPDFT4 which performs the same functionality but i have to assign a seperate tcode for it and tell the user how to generate the spool request for it and then download it. Thats why i want to use the FM for it so that the user can able to have the proper print out of it.

plzz provide me guidelines for solving this problem.

13 REPLIES 13

Former Member
0 Kudos

This message was moderated.

0 Kudos

hi anusha,

should i call this FM as it is where the sapscript has been called in the program.

0 Kudos

sorry for writing the same msgs 2 times.

Edited by: ricx .s on May 19, 2009 8:11 AM

0 Kudos

hi anusha,

should i use as it is in the program and place it in the code after the sapscript open form or closed form?

0 Kudos

you should use it after open _ form....

not after close_form...

0 Kudos

you should use it after open _ form....

not after close_form...

0 Kudos

you should use it after open _ form....

not after close_form...

0 Kudos

hi,

io had tried as you had said but it is not working,even though i read from the tutorial mentioned in the above post but it is still not giving the functionality of it,plzz provide me guidlines to solve this problem.

0 Kudos

You need to submit your print program in background to generate a Spool No using SUBMIT statement.

Then select the respective spool no. from table TSP01. Now using this spool no. submit the program RSTXPDFT4. I hope Now you know how to write the code.

0 Kudos

hi,

i am usig the code for converting the otf to pdf in my code. but i don't know how to make exact functionlity of it as i execute in the normal way . Here's the code:-



FORM close_form .

  CALL FUNCTION 'CLOSE_FORM'
 TABLES
   OTFDATA                        = DATAB
   EXCEPTIONS
     unopened                       = 1
     bad_pageformat_for_print       = 2
     send_error                     = 3
     spool_error                    = 4
     codepage                       = 5
     OTHERS                         = 6
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

ENDFORM.                    " CLOSE_FORM

FORM PDF.
  CALL FUNCTION 'CONVERT_OTF'
   EXPORTING
     FORMAT                      = 'PDF'
   IMPORTING
     BIN_FILESIZE                = BINFILESIZE
    TABLES
      OTF                         = DAtab[]
      LINES                       = PDFtab[].

  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
CHANGING
filename = FILE_NAME
path = FILE_PATH
fullpath = FULL_PATH.
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 = binfilesize
FILENAME = full_path
FILETYPE = 'BIN'
tables
  data_tab = PDFTAB[]
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.
ENDIF.
ENDFORM.

please provide me guidelines to solve this problem .

Edited by: ricx .s on May 22, 2009 5:19 AM

Edited by: ricx .s on May 22, 2009 10:17 AM

GauthamV
Active Contributor
0 Kudos

Use these FM.

CONVERT_OTF

CONVERT_OTF_2_PDF

SX_OBJECT_CONVERT_OTF_PDF .

Former Member
0 Kudos

Hi ricx,

[Converting SAP Script outputs to PDF file|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/49e15474-0e01-0010-9cba-e62df8244556]

Regards,

Sravanthi

Former Member
0 Kudos

CALL FUNCTION "CONVERT_OTF"

EXPORTING

FORMAT = "PDF"

IMPORTING

BIN_FILESIZE = FILE_LEN

TABLES

OTF = OTFDATA

LINES = PDFDATA

Check this code

u can use 'SX_OBJECT_CONVERT_OTF_PDF' this FM also