cancel
Showing results for 
Search instead for 
Did you mean: 

Re: convert sapscript to pdf

Former Member
0 Kudos

HI friends ,

i am not getting my sapscript form in PDF eventhough i am using RSTXPDFT4 ,am getting PDF oly as No of record : 6

to Raguram :

u hav used 'SSF_FUNCTION_MODULE_NAME' but hope this will be only for SMARTFORMS,am i right?

shan

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

hi Durgaprasad,

but the FM 'SSF_FUNCTION_MODULE_NAME' u mentioned will work only for SMARTFORM ,am i right?.

shan

raguraman_c
Active Contributor
0 Kudos

Hi Siva,

Yes it is for SMARTFORM only. But not to blindly accept let me explain. Whenever you generate a smartform, a function module is created. This function module is the one that formats your layout, fetches data, and does everything. The function module <b>SSF_FUNCTION_MODULE_NAME</b> is used to call the smartform function module.

So there is no point that function module <b>SSF_FUNCTION_MODULE_NAME</b> can support SAPScript. And its not related to sapscript at all.

Hope I was clear.

As far as your problem of converting SAPScript to Pdf, did you try function module.

CONVERT_OTF

Feel free to revert back.

--Ragu

Message was edited by:

Raguraman C

Former Member
0 Kudos

hi raghuram,

hope we have FM called convert_OTF_2_PDF ,will it work for SAPSCRIPT?

thanks,

shan

raguraman_c
Active Contributor
0 Kudos

Hi,

That's right. But let me tell you,,, we have got one more option.

we either use '<b>SX_OBJECT_CONVERT_OTF_PDF</b>' or <b>CONVERT_OTF_2_PDF</b>.

Feel free to revret back.

--Ragu

Former Member
0 Kudos

thanks for the reply,

when we go for CONVERT_OTF_2_PDF we need JOBOUTPUT-OTFDATA[] to pass through OTF in TABLES, how wiil u know the value for this parameter,?

- shan

raguraman_c
Active Contributor
0 Kudos

Hi,

for SAPScript

CALL FUNCTION 'CLOSE_FORM'

TABLES

otfdata = te_otf_table

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

OTHERS = 3.

'te_otf_table' will have OTFDATA and you need to pass this.

Now to convert this Form output which is in OTF to PDF we either use 'SX_OBJECT_CONVERT_OTF_PDF' or CONVERT_OTF_2_PDF.

Have more here,

if you are using a Smartform, the FM has a IMport parameter 'job_output_info-otfdata' which will have the OTFData.

Feel free to revert back.

--Ragu

Former Member
0 Kudos

Hi Siva,

If you dont want to send the SAP Script to spool and capture it in PDF and dump it in a shared path you can do it as explained below.

In the close form function module, there is a tables parameter called OTFDATA. Create an internal table of type ITCOO and pass the internal table declared for parameter OTFDATA.

Afterthat, use the function module CONVERT_OTF_2_PDF and pass the above declared internal table to tables parameter OTF and take the PDF format output from tables parameter LINES.

Hope this helps in resolving your problem. Award points if this helps.

Thanks

Naresh

Former Member
0 Kudos

Thanks Raghuram ,

'te_otf_table' is of type ITCOO or SSFCRESCL.?

shan

raguraman_c
Active Contributor
0 Kudos

Hi,

Its of type ITCOO.

Feel free to revert back.

--Ragu

Hope this will solve your problem.

Former Member
0 Kudos

Hi shiva,

sorry for being late.hope u have solved ur problem and raghu has given the right solution.

ITCOO is the otf table

Former Member
0 Kudos

hi,

it seems that none of the value get passed thru 'te_otf_table' which is of type ITCOO.

i think it shld b of type SSFCRESCL.

this is how my codlooks like:

REPORT Z243_SSRIPT_PRACT.

TABLES : ZPURCHASEHEADER.

DATA: IT_TAB LIKE TABLE OF ZPURCHASEHEADER WITH HEADER LINE.

DATA: IT_PURCHASEDETAIL LIKE TABLE OF ZPURCHASEDETAILS WITH HEADER LINE.

DATA: BIN_SIZE TYPE I,

JOBOUTPUT TYPE SSFCRESCL,

  • it_result like table of itcoo,"JOBOUTPUT-OTFDATA

OTF LIKE TABLE OF ITCOO,

DOC LIKE TABLE OF DOCS,

TLINES LIKE TABLE OF TLINE.

SELECTION-SCREEN : BEGIN OF SCREEN 9001.

PARAMETERS PUR_NO LIKE ZPURCHASEHEADER-PURCHASENO.

SELECTION-SCREEN : END OF SCREEN 9001.

CALL SELECTION-SCREEN 9001.

SELECT * FROM ZPURCHASEHEADER INTO IT_TAB

WHERE PURCHASENO = PUR_NO.

ENDSELECT.

SELECT * FROM ZPURCHASEDETAILS INTO IT_PURCHASEDETAIL

WHERE PURCHASENO = PUR_NO.

ENDSELECT.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

  • APPLICATION = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

  • DEVICE = 'PRINTER'

  • DIALOG = 'X'

FORM = 'Z243_SAPS_PRAC'.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'PUR_DET'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'MAIN'.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

  • ELEMENT = 'INFORMATION'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'WINDOW4'

  • IMPORTING

  • PENDING_LINES =

  • EXCEPTIONS

  • ELEMENT = 1

  • FUNCTION = 2

  • TYPE = 3

  • UNOPENED = 4

  • UNSTARTED = 5

  • WINDOW = 6.

CALL FUNCTION 'CLOSE_FORM'

TABLES

OTFDATA = OTF

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

BIN_FILESIZE = BIN_SIZE

TABLES

OTF = otf

DOCTAB_ARCHIVE = DOC

LINES = TLINES.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

BIN_FILESIZE = BIN_SIZE

FILENAME = 'C:\siva\SStest.pdf'

FILETYPE = 'BIN'

TABLES

DATA_TAB = TLINES.

  • * Open PDF

DATA: PROGRAM LIKE SOXPC-PATH.

CALL FUNCTION 'SO_PROGNAME_GET_WITH_PATH'

EXPORTING

DOCTYPE = 'PDF'

IMPORTING

PATHNAME = PROGRAM

EXCEPTIONS

PATH_NOT_FOUND = 1

PROGRAM_NOT_FOUND = 2

NO_BATCH = 3

X_ERROR = 4

OTHERS = 5.

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 'WS_EXECUTE'

EXPORTING

COMMANDLINE = 'C:\siva\SStest.pdf'

PROGRAM = PROGRAM

EXCEPTIONS

FRONTEND_ERROR = 1

NO_BATCH = 2

PROG_NOT_FOUND = 3

ILLEGAL_OPTION = 4

GUI_REFUSE_EXECUTE = 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.

pls help to solve this issue

shan

Message was edited by:

sivakumar palaniswamy

raguraman_c
Active Contributor
0 Kudos

Hi,

It is of type<b> ITCOO only</b>

but still you can achieve it this way.

job_info TYPE ssfcrescl

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

BIN_FILESIZE = BIN_SIZE

TABLES

OTF = <b>job_info-otfdata</b>

DOCTAB_ARCHIVE = DOC

LINES = TLINES.

Feel free to revert back.

--Ragu

raguraman_c
Active Contributor
0 Kudos

Hi,

If your problem is resolved, close the the thread.

--Ragu

Former Member
0 Kudos

Heloo to one and all..

u can refer the following code to covert the sap script (otf ) to PDF formate.

REPORT ZAAJ_OTF_TO_PDF . "

DATA: BIN_SIZE TYPE I,

JOBOUTPUT TYPE SSFCRESCL,

OTF LIKE TABLE OF ITCOO,

DOC LIKE TABLE OF DOCS,

TLINES LIKE TABLE OF TLINE.

DATA : I_ITCPO LIKE ITCPO .

I_ITCPO-TDGETOTF = 'X'.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

FORM = 'ZPDF1'

LANGUAGE = SY-LANGU

OPTIONS = I_ITCPO

.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'E'

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'.

CALL FUNCTION 'CLOSE_FORM'

TABLES

OTFDATA = OTF.

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

BIN_FILESIZE = BIN_SIZE

TABLES

OTF = otf

DOCTAB_ARCHIVE = DOC

LINES = TLINES.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

BIN_FILESIZE = BIN_SIZE

FILENAME = 'C:\anees\test.pdf'

FILETYPE = 'BIN'

TABLES

DATA_TAB = TLINES.

Former Member
0 Kudos

hi siva,

i donno wat procedure u r following plz use the following code

Here is how you can achieve it

DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,

i_tline TYPE TABLE OF tline WITH HEADER LINE,

i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,

i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,

i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,

i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,

i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,

i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,

wa_objhead TYPE soli_tab,

w_ctrlop TYPE ssfctrlop,

w_compop TYPE ssfcompop,

w_return TYPE ssfcrescl,

wa_doc_chng typE sodocchgi1,

w_data TYPE sodocchgi1,

wa_buffer TYPE string,"To convert from 132 to 255

v_form_name TYPE rs38l_fnam,

v_len_in LIKE sood-objlen,

v_len_out LIKE sood-objlen,

v_len_outn TYPE i,

v_lines_txt TYPE i,

v_lines_bin TYPE i.

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

formname = 'ZZZ_TEST1'

importing

fm_name = v_form_name

exceptions

no_form = 1

no_function_module = 2

others = 3.

IF sy-subrc <> 0.

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

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

w_ctrlop-getotf = 'X'.

w_ctrlop-no_dialog = 'X'.

w_compop-tdnoprev = 'X'.

CALL FUNCTION v_form_name

EXPORTING

control_parameters = w_ctrlop

output_options = w_compop

user_settings = 'X'

IMPORTING

job_output_info = w_return

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

IF sy-subrc <> 0.

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

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

i_otf[] = w_return-otfdata[].

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.

if sy-subrc <> 0.

endif.

loop at i_tline.

translate i_tline using '~'.

concatenate wa_buffer i_tline into wa_buffer.

endloop.

translate wa_buffer using '~'.

do.

i_record = wa_buffer.

append i_record.

shift wa_buffer left by 255 places.

if wa_buffer is initial.

exit.

endif.

enddo.

  • Attachment

refresh:

i_reclist,

i_objtxt,

i_objbin,

i_objpack.

clear wa_objhead.

i_objbin[] = i_record[].

              • Create Message Body

        • Title and Description

i_objtxt = 'test with pdf-Attachment!'.

append i_objtxt.

describe table i_objtxt lines v_lines_txt.

read table i_objtxt index v_lines_txt.

wa_doc_chng-obj_name = 'smartform'.

wa_doc_chng-expiry_dat = sy-datum + 10.

wa_doc_chng-obj_descr = 'smartform'.

wa_doc_chng-sensitivty = 'F'.

wa_doc_chng-doc_size = v_lines_txt * 255.

        • Main Text

  • wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )

*.

clear i_objpack-transf_bin.

i_objpack-head_start = 1.

i_objpack-head_num = 0.

i_objpack-body_start = 1.

i_objpack-body_num = v_lines_txt.

i_objpack-doc_type = 'RAW'.

append i_objpack.

        • Attachment

  • (pdf-Attachment)

i_objpack-transf_bin = 'X'.

i_objpack-head_start = 1.

i_objpack-head_num = 0.

i_objpack-body_start = 1.

  • Länge des Attachment ermitteln

describe table i_objbin lines v_lines_bin.

read table i_objbin index v_lines_bin.

i_objpack-doc_size = v_lines_bin * 255 .

i_objpack-body_num = v_lines_bin.

i_objpack-doc_type = 'PDF'.

i_objpack-obj_name = 'smart'.

i_objpack-obj_descr = 'test'.

append i_objpack.

clear i_reclist.

i_reclist-receiver = give ur mail id

i_reclist-rec_type = 'U'.

append i_reclist.

call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = wa_doc_chng

put_in_outbox = 'X'

TABLES

packing_list = i_objpack

object_header = wa_objhead

CONTENTS_BIN = i_objbin

contents_txt = i_objtxt

receivers = i_reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

others = 8.

Feel Free to revert back.

anversha_s
Active Contributor
0 Kudos

hi,

chk this.

Visit this link for SAMple code of SAPSCRIPT to PDF.:

http://www.sapgenie.com/abap/pdf_creation.htm

and check the following weblog for code samples.

/people/sap.user72/blog/2004/11/10/bsphowto-generate-pdf-output-from-a-bsp

chk this one

http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm

some function modules useful would be

CONVERT_OTF

plzz refer to this link..it will solve ur problem

rgds

Anver