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: 

sap data in pdf format

Former Member
0 Kudos
147

i need function module such that to convert sap format to pdf format....

if source code available attach it plz

1 ACCEPTED SOLUTION

Former Member
0 Kudos
113

call function 'CONVERT_OTF'

exporting

format = 'PDF'

max_linewidth = 132

importing

bin_filesize = v_len_in

tables

otf = i_otf

lines = i_tline

exceptions

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

others = 4.

  • Fehlerhandling

if sy-subrc <> 0.

endif.

use this function module

Regards

Anbu

7 REPLIES 7

Former Member
0 Kudos
113

Hi,

Chk the link :

http://help.sap.com/saphelp_nw04/helpdata/en/27/67443cc0063415e10000000a11405a/frameset.htm

Regards.

Edited by: Iyswarya Godi on Jun 26, 2008 10:42 AM

Edited by: Iyswarya Godi on Jun 26, 2008 10:42 AM

valter_oliveira
Active Contributor
0 Kudos
113

Hello.

Standard report RSTXPDFT4 converts spool content to a PDF file.

Regards.

Valter Oliveira.

Former Member
0 Kudos
113

Hi,

RSTXPDFT4 is a standard program which converts the spool generated into PDF format. Mayb its useful to u.

Nayan

Former Member
0 Kudos
114

call function 'CONVERT_OTF'

exporting

format = 'PDF'

max_linewidth = 132

importing

bin_filesize = v_len_in

tables

otf = i_otf

lines = i_tline

exceptions

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

others = 4.

  • Fehlerhandling

if sy-subrc <> 0.

endif.

use this function module

Regards

Anbu

Former Member
0 Kudos
113

Hi,

We have function module : CONVERT_ABAPSPOOLJOB_2_PDF to convert to PDF.

Below code will explain you for the same :

.

tables:
  tsp01.
*-- STRUCTURES
data:
  mstr_print_parms like pri_params,
  mc_valid(1)      type c,
  mi_bytecount     type i,
  mi_length        type i,
  mi_rqident       like tsp01-rqident.
*-- INTERNAL TABLES
data:
  mtab_pdf    like tline occurs 0 with header line,
  mc_filename like rlgrap-filename.
*-- SELECTION SCREEN
parameters:
  p_repid like sy-repid, " Report to execute
  p_linsz like sy-linsz default 132, " Line size
  p_paart like sy-paart default 'X_65_132'.  " Paper Format
start-of-selection.
concatenate 'c:\'
            p_repid
            '.pdf'
  into mc_filename.
*-- Setup the Print Parmaters
  call function 'GET_PRINT_PARAMETERS'
   exporting
     authority= space
     copies   = '1'
     cover_page                   = space
     data_set = space
     department                   = space
     destination                  = space
     expiration                   = '1'
     immediately                  = space
     in_archive_parameters        = space
     in_parameters                = space
     layout   = space
     mode     = space
     new_list_id                  = 'X'
     no_dialog= 'X'
     user     = sy-uname
   importing
     out_parameters               = mstr_print_parms
     valid    = mc_valid
   exceptions
     archive_info_not_found       = 1
     invalid_print_params         = 2
     invalid_archive_params       = 3
     others   = 4.
*-- Make sure that a printer destination has been set up
*-- If this is not done the PDF function module ABENDS
  if mstr_print_parms-pdest = space.
    mstr_print_parms-pdest = 'LOCL'.
  endif.
*-- Explicitly set line width, and output format so that
*-- the PDF conversion comes out OK
  mstr_print_parms-linsz = p_linsz.
  mstr_print_parms-paart = p_paart.
  submit (p_repid) to sap-spool without spool dynpro
                   spool parameters mstr_print_parms
                   via selection-screen
                   and return.
*-- Find out what the spool number is that was just created
  perform get_spool_number using sy-repid
             sy-uname
    changing mi_rqident.
*-- Convert Spool to PDF
  call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
    exporting
      src_spoolid= mi_rqident
      no_dialog  = space
      dst_device = mstr_print_parms-pdest
    importing
      pdf_bytecount                  = mi_bytecount
    tables
      pdf        = mtab_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
      others     = 12.
call function 'DOWNLOAD'
     exporting
          bin_filesize            = mi_bytecount
          filename                = mc_filename
          filetype                = 'BIN'
     importing
          act_filename            = mc_filename
     tables
          data_tab                = mtab_pdf.
*---------------------------------------------------------------------*
*       FORM get_spool_number *
*---------------------------------------------------------------------*
*       Get the most recent spool created by user/report              *
*---------------------------------------------------------------------*
*  -->  F_REPID               *
*  -->  F_UNAME               *
*  -->  F_RQIDENT             *
*---------------------------------------------------------------------*
form get_spool_number using f_repid
     f_uname
                changing f_rqident.
  data:
    lc_rq2name like tsp01-rq2name.
  concatenate f_repid+0(8)
              f_uname+0(3)
    into lc_rq2name separated by '_'.
  select * from tsp01 where  rq2name = lc_rq2name
  order by rqcretime descending.
    f_rqident = tsp01-rqident.
    exit.
  endselect.
  if sy-subrc ne 0.
    clear f_rqident.
  endif.
endform." get_spool_number

hope this helps you.

plz reward if useful.

thanks,

dhanashri.

Former Member
0 Kudos
113

hiiiii

use this FM

CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      format                = d_desired_type
    IMPORTING
      bin_filesize          = d_doc_size
    TABLES
      otf                   = t_itcoo
      lines                 = t_line
    EXCEPTIONS
      err_max_linewidth     = 1
      err_format            = 2
      err_conv_not_possible = 3
      OTHERS                = 4.

  IF sy-subrc > 0.
    RAISE otf_convert_failed.
  ENDIF.

regards

twinkal

Former Member
0 Kudos
113

Hi,

Try FM " CONVERT_ABAPSPOOLJOB_2_PDF "

Sample Report:

REPORT Z_TEXT_SPOOL_CONVERT.

TABLES: TSP01.

PARAMETERS: P_SPID LIKE TSP01-RQIDENT.

DATA: BEGIN OF ITAB OCCURS 0.

INCLUDE STRUCTURE TLINE.

DATA: END OF ITAB.

DATA: C_DIA TYPE C VALUE 'X',

C_DEVICE LIKE TSP03-PADEST,

C_BYTE_CNT TYPE I.

DATA: P_FILE TYPE STRING VALUE '
DWDFHOME02\C5103908$\My Documents'.

DATA: NUM(5) TYPE C.

DATA: pdfspoolid like tsp01-rqident,

jobname like tbtcjob-jobname,

jobcount like tbtcjob-jobcount.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

SRC_SPOOLID = P_SPID

NO_DIALOG = ''

  • DST_DEVICE = C_DEVICE

  • PDF_DESTINATION =

IMPORTING

PDF_BYTECOUNT = C_BYTE_CNT

PDF_SPOOLID = PDFSPOOLID

  • LIST_PAGECOUNT =

  • BTC_JOBNAME = JOBNAME

  • BTC_JOBCOUNT = JOBCOUNT

TABLES

PDF = ITAB

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

OTHERS = 12

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

IF SY-SUBRC = 0.

WRITE:/ 'PDF GENERATED'.

NUM = P_SPID.

CONCATENATE P_FILE '\' NUM '.PDF' INTO P_FILE.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = P_FILE

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'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = ITAB

  • 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.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ELSE.

WRITE:/ 'NOT'.

ENDIF.

Hope this helps you.

Regards,

Ruthra