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,269

Hi all,

I need to create a pdf file from the sap script. can anyone please tell me how to go about it?

i have used the following functions in my se38 editor.

open_form,

write_form,

close_form.

Till here it works and i get the output in the sapscript.i need to copy this output into a pdf file and save it to my local directory.

I used the function

SX_OBJECT_CONVERT_OTF_PDF,GUI_DOWNLOAD.

but its giving me a dump error when i execute the program

Can anyone pls explain me how to proceed, what all parameters needs to be passed inside these functions.

Also note that i shud not get a printout of the output.

Many thanks in advance,

sinthu

10 REPLIES 10
Read only

Former Member
0 Likes
1,154

complete refer..

Read only

Former Member
0 Likes
1,154

Check the below code......

Get the OTF from CLOSE_FORM (otf_data)

  • Convert OTF to PDF

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

IMPORTING

bin_filesize = pdf_size

TABLES

otf = otf_data

lines = it_pdf.

  • Make each line 255 characters

CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'

TABLES

content_in = it_pdf

content_out = it_pdfout.

  • Create the PDF File

CLEAR it_pdfdata.

REFRESH it_pdfdata.

LOOP AT it_pdfout.

MOVE it_pdfout-tline TO it_pdfdata-line.

APPEND it_pdfdata.

CLEAR it_pdfdata.

ENDLOOP.

Use GUI_DOWNLOAD to to downlaod it_pdfdata file.

Enjoy Coding,

Thomas.

Read only

Former Member
0 Likes
1,154

hi sinthu,

SAP has created a standard program <b>RSTXPDFT4</b> to convert your Sapscripts spools into a PDF format.

Specify the spool number and you will be able to download the sapscripts spool into your local harddisk.

It look exactly like what you see during a spool display....

Please note that it is not restricted to sapsciprts spool only.. Any reports in the spool can be converted using the program 'RSTXPDFT4'. ..

regards

satesh

Read only

0 Likes
1,154

Hi satish,

Thanks, but from where will i get the spool no? this pgm will be executed in background.

-sinthu

Read only

0 Likes
1,154

Hi sinthu,

1. spool number is not required.

2. when we use CLOSE_FORM

we can pass the optional tables parameters

<b>OTFDATA LIKE ITCOO</b>

(where we will get the sapscript outpt in OTF format)

<b>(also while using OPEN_FORM

pass this prameter in OPTIONS

OPTIONS-TDGETOTF = 'X'.</b>

3. then we can convert this into pdf.

4. just see this below small code for getting the idea.

(then u can use OPEN DATASET , TRANSFER,CLOSE DATASET

to save the PDF File, bcos u are running the program

in background(

CALL FUNCTION 'CLOSE_FORM'

IMPORTING

RESULT = w_res

TABLES

otfdata = i_otf

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.

  • Converting OTF data to single line

LOOP AT i_otf INTO w_otf.

CONCATENATE w_otf-tdprintcom w_otf-tdprintpar

INTO w_pdf.

APPEND w_pdf TO i_content_txt.

ENDLOOP.

  • Converting to PDF Format

CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'

EXPORTING

format_src = c_otf

format_dst = c_pdf

devtype = c_printer

CHANGING

transfer_bin = w_transfer_bin

content_txt = i_content_txt

content_bin = i_content_bin

objhead = i_objhead

len = v_len_in

EXCEPTIONS

err_conv_failed = 1

OTHERS = 2.

v_size = v_len_in.

  • Downloading the PDF File

*----


for front-end only

*----


for application server, use DATASET

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = v_size

filename = c_name

filetype = c_bin

TABLES

data_tab = i_content_bin.

regards,

amit m.

Read only

0 Likes
1,154

Hi Sindhu,

u can chk out in SP01 all the spool requests created..or else in SM36 u ll get the status of ur Background jobs( and also the spool no.)...

put ur spool no. in the program RSTXPDFT4 n execute...

Read only

Former Member
0 Likes
1,154

Hi Sinthu,

You can execute the SAPScript and create a spool request for that... Now execute the program RSTXPDFT4 and in that give the spool number and the path of the pdf file(say D:\SP\file.pdf).

Regards,

SP.

Read only

Former Member
0 Likes
1,154
Read only

Former Member
0 Likes
1,154

Hi,

this code will give u the last spool number:

DATA : lv_spool_no TYPE TSP01-RQIDENT .

SELECT RQIDENT into lv_spool_no

UP TO 1 ROWS

FROM TSP01

  • WHERE "Put some restriction ..like last 5 days, to improve performance

ORDER BY RQCRETIME DESCENDING.

ENDSELECT.

<b>RSPO_ISELECT_SPOOLREQS</b> will get you all the spool request

rgds,

latheesh

Read only

Former Member
0 Likes
1,154

hi sinthu,

to create a spool number for the script ..

just execute it and uncheck print immediately..

then give a printer name..

and give print..

it creates a spool request..

the number can be viewed in sp01.

just give that number and execute the program..

regards

satesh