Application Development and Automation 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: 
Read only

Sapscript-PDF

Former Member
0 Likes
1,077

Hi Experts,

Iam trying to output one Sapscript to Pdf File.

Iam trying to convert the OTF recieved after close form and using the otf iam callind the FM CONVERT_OTF -> but the Fm is returning blank itab for LINES.

please suggest a solution

Regards

Sarath

9 REPLIES 9
Read only

Former Member
0 Likes
1,033

Hi,

Never tried this one but this may help FM CONVERT_OTFSPOOLJOB_2_PDF.. just give the spool you can get it in TSP01 table.

Also try these FMs

FPCOMP_CREATE_PDF_FROM_SPOOL

CONVERT_ABAPSPOOLJOB_2_PDF

Regards,

Leonard Chomi

Read only

Former Member
0 Likes
1,033

debug and check if ur getting ur otf data. before the call fm

Read only

0 Likes
1,033

I chacked.. iam getting the otf data.. Convert_OTF is executing sucessfully, and giving Sy-subrc = 0. but no data in itab For Lines

Read only

Former Member
0 Likes
1,033

Hi,

Is the OTF table properly filled and did you give the format properly

CALL FUNCTION 'CONVERT_OTF'
           EXPORTING
                format                = 'PDF'
           IMPORTING
                bin_filesize          = pdf_fsize
                bin_file              = pdf_xstring
           TABLES
                otf                   = otf_table
                lines                 = pdf_table
           EXCEPTIONS
                err_max_linewidth     = 1
                err_format            = 2
                err_conv_not_possible = 3
                OTHERS                = 4.

Regards

Read only

Former Member
0 Likes
1,033

HI,

If you want to convert your sapscript in to PDF Document then first generate spool request number

for that script after that use the below report:

RSTXPDFT4

through this you can convert your sapscript to PDF Document

Thanks,

Rajesh

Read only

Former Member
0 Likes
1,033

Hi,

Check the below link

Regards,

Ankki Reddy

Read only

Former Member
0 Likes
1,033

can u show us the code which u hv written.

кu03B1ятu03B9к

Read only

0 Likes
1,033

Hi Karthik,

i wrote like this

CALL FUNCTION 'CLOSE_FORM'

IMPORTING

RESULT = ITCPP

TABLES

OTFDATA = otfdata

EXCEPTIONS

UNOPENED = 3.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

  • MAX_LINEWIDTH = 132

IMPORTING

BIN_FILESIZE = DOC_SIZE

BIN_FILE = ld_binfile

TABLES

OTF = OTFDATA[]

LINES = PDFTAB[]

EXCEPTIONS

ERR_MAX_LINEWIDTH = 1

ERR_FORMAT = 2

ERR_CONV_NOT_POSSIBLE = 3

OTHERS = 4.

Read only

Former Member
0 Likes
1,033

Hi,

U have to first write code as in CLOSE_FORM.

CALL FUNCTION 'CLOSE_FORM'

IMPORTING

RESULT = RESULT

tables

otfdata = otf_data

*

exceptions

OTHERS = 1.

And MOST IMPORTANT THING IS **********************************

itcpo-tdnoprint = 'X'.

itcpo-tdimmed = ' '.

itcpo-tdgetotf = 'X'.

itcpo-tdnewid = 'X'.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

form = tnapr-fonam

OPTIONS = itcpo

EXCEPTIONS

canceled = 01

device = 02

OTHERS = 03.

IF sy-subrc NE 0.

ENDIF.

In OPEN_FORM U have to pass ITCPO as above. Then in that u have to set itcpo-tdgetotf = 'X'.

then only u get data in OTF format which u can convert in PDF Format.

DATA: t_pdf_data TYPE TABLE OF tline.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = pdf_file_size

TABLES

otf = otf_data

lines = t_pdf_data

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

OTHERS = 4.

DATA : p_xl TYPE rlgrap-filename.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

  • DYNPRO_NUMBER = SYST-DYNNR

field_name = 'p_xl'

IMPORTING

file_name = p_xl.

data : filename TYPE string.

concatenate p_xl ekko-ebeln '.pdf' into filename.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = pdf_file_size

filename = filename

filetype = 'BIN'

TABLES

data_tab = t_pdf_data

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.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1.

ENDIF.