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

hi all my friends

Former Member
0 Kudos
261

hi friend s help me.

1) how to convert script to pdf?

6 REPLIES 6
Read only

Former Member
0 Kudos
230

HI,

First, you must convert the file into xstring

then just add this code

DATA : file type xstring ,

content_length type xstring,

content_type type xstring ,

file_to_create type xstring

cached_response type ref to if_http_response ,

display_url type string .

file = file(file_to_create).

content_length = xstrlen( file ) .

content_type = 'application/pdf'.

create object cached_response type cl_http_response

exporting add_c_msg = 1.

cached_response->set_data( file ).

cached_response->set_header_field( name = if_http_header_field=>content_type

value = content_type ).

cached_response->server_cache_expire_rel( expires_rel = 180 ) .

concatenate runtime->application_url '/' namedoc '.pdf' into display_url.

cl_http_server=>server_cache_upload( url = display_url

response = cached_response )

navigation->goto_page( display_url ).

The generated file is store dor 180 seconds ( you can change this value ) in the ICM Cache ( we do this in order to solve problems links with explorer version or reverse proxy ) and then display in the window . After this user can save the document where they want.

PLEASE CHECK OUT THE LINK BELOW IT HELP YOU

http://www.go2pdf.com/ps-to-pdf.html

********PLEASE REWARD POINTS IF THE INFORMATION IS HELPFUL TO YOU************

Read only

Former Member
0 Kudos
230

Hi,

you need to create a print spool and then convert the spool by program RSTXPDFT4.

You can directlty use the fm CONVERT_OTFSPOOLJOB_2_PDF (see RSTXPDFT4)

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

Reward all helpful answers,

Regards,

Omkar.

Read only

Former Member
0 Kudos
230

Hi,

Use RSTXPDFT4

Reward if useful!

Read only

Former Member
0 Kudos
230

Hi,

Try this

Regards

Bala

Read only

Vijay
Active Contributor
0 Kudos
230

hi

Steps for your requirement:

1. Create a job and spool request from thet script.

2. Get the spool no.

3. Convert that spool no to Pdf

first u write Internal table to spool then u can convert the spool to pdf....see the below code.. hope it helps...

Please check this links also for sample codes.

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

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

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

<b>reward points if helpfull</b>

regards

vijay

DATA: BEGIN OF i_mara OCCURS 0,

matnr LIKE mara-matnr.

DATA: END OF i_mara.

DATA: v_dest LIKE tsp01-rqdest,

v_handle LIKE sy-tabix,

v_spool_id LIKE tsp01-rqident,

v_rc TYPE c,

v_errmessage(100) TYPE c,

v_text(70) TYPE c.

START-OF-SELECTION.

SELECT matnr FROM mara INTO TABLE i_mara.

CALL FUNCTION 'RSPO_OPEN_SPOOLREQUEST'

EXPORTING

dest = 'LOCL'

  • LAYOUT =

  • NAME =

  • SUFFIX1 =

  • SUFFIX2 =

  • COPIES =

  • PRIO =

  • IMMEDIATE_PRINT =

  • AUTO_DELETE =

  • TITLELINE =

  • RECEIVER =

  • DIVISION =

  • AUTHORITY =

  • POSNAME =

  • ACTTIME =

  • LIFETIME = '8'

  • APPEND =

  • COVERPAGE =

  • CODEPAGE =

  • DOCTYPE =

IMPORTING

handle = v_handle

spoolid = gd_spool_nr

rc = v_rc

errmessage = v_errmessage.

LOOP AT i_mara.

v_text = i_mara-matnr.

CALL FUNCTION 'RSPO_WRITE_SPOOLREQUEST'

EXPORTING

handle = v_handle

text = v_text

  • LENGTH =

  • CODEPAGE =

  • TRUNCATE =

IMPORTING

rc = v_rc

errmessage = v_errmessage

EXCEPTIONS

handle_not_valid = 1

OTHERS = 2.

IF sy-subrc <> 0.

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

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

ENDIF.

ENDLOOP.

CALL FUNCTION 'RSPO_CLOSE_SPOOLREQUEST'

EXPORTING

handle = v_handle

IMPORTING

rc = v_rc

errmessage = v_errmessage

EXCEPTIONS

handle_not_valid = 1

OTHERS = 2.

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

EXPORTING

src_spoolid = gd_spool_nr

no_dialog = c_no

dst_device = c_device

IMPORTING

pdf_bytecount = gd_bytecount

TABLES

pdf = it_pdf_output

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.

CHECK sy-subrc = 0.

get the spool number

  • Declaration of local variables.

DATA:

LV_RQ2NAME LIKE TSP01-RQ2NAME.

CONCATENATE SY-REPID+0(8)

SY-UNAME+0(3)

INTO LV_RQ2NAME SEPARATED BY '_'.

  • Get the spool number.

SELECT * FROM TSP01 WHERE RQ2NAME = LV_RQ2NAME

ORDER BY RQCRETIME DESCENDING.

V_RQIDENT = TSP01-RQIDENT.

EXIT.

ENDSELECT.

IF SY-SUBRC NE 0.

CLEAR V_RQIDENT.

ENDIF

Read only

Former Member
0 Kudos
230

Hi,

SAP have created a standard program RSTXPDFT4 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'.

DATA: wa_itcpp LIKE itcpp.
DATA: wa_itcpo LIKE itcpo.
DATA: doc LIKE TABLE OF docs.
DATA: tlines LIKE TABLE OF tline.
DATA: bin_filesize TYPE i.
 
DATA: it_otf LIKE TABLE OF itcoo.
 
 
wa_itcpo-tdgetotf = 'X'.
CALL FUNCTION 'OPEN_FORM'
 EXPORTING
*   APPLICATION                       = 'TX'
*   ARCHIVE_INDEX                     =
*   ARCHIVE_PARAMS                    =
   device                            = 'PRINTER'
   dialog                            = 'X'
   form                              = 'ZSCRIPT_BOX_PS'
   language                          = sy-langu
   OPTIONS                           = wa_itcpo
*   MAIL_SENDER                       =
*   MAIL_RECIPIENT                    =
*   MAIL_APPL_OBJECT                  =
*   RAW_DATA_INTERFACE                = '*'
*   SPONUMIV                          =
 IMPORTING
*   LANGUAGE                          =
*   NEW_ARCHIVE_PARAMS                =
   RESULT                            = wa_itcpp
 EXCEPTIONS
   canceled                          = 1
   device                            = 2
   form                              = 3
   OPTIONS                           = 4
   unclosed                          = 5
   mail_options                      = 6
   archive_error                     = 7
   invalid_fax_number                = 8
   more_params_needed_in_batch       = 9
   spool_error                       = 10
   codepage                          = 11
   OTHERS                            = 12
          .
 
CALL FUNCTION 'WRITE_FORM'
   EXPORTING
     element                        = 'ELE1'
     function                       = 'SET'
     type                           = 'BODY'
     window                         = 'MAIN'
* IMPORTING
*   PENDING_LINES                  =
   EXCEPTIONS
     element                        = 1
     function                       = 2
     type                           = 3
     unopened                       = 4
     unstarted                      = 5
     window                         = 6
     bad_pageformat_for_print       = 7
     spool_error                    = 8
     codepage                       = 9
     OTHERS                         = 10
            .
 
 
CALL FUNCTION 'CLOSE_FORM'
* IMPORTING
*   RESULT                         =
*   RDI_RESULT                     =
 TABLES
   otfdata                        = it_otf
 EXCEPTIONS
   unopened                       = 1
   bad_pageformat_for_print       = 2
   send_error                     = 3
   spool_error                    = 4
   codepage                       = 5
   OTHERS                         = 6
          .
 
 
CALL FUNCTION 'CONVERT_OTF_2_PDF'
  IMPORTING
    bin_filesize   = bin_filesize
  TABLES
    otf            = it_otf
    doctab_archive = doc
    lines          = tlines.
 
BREAK-POINT.
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    bin_filesize = bin_filesize
    filename     = 'D:New FolderTESTPDF.PDF'
    filetype     = 'BIN'
  TABLES
    data_tab     = tlines.

Pls verify the link it has simple code for the same:

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

Pls reward all helpful points.

Regards,

Ameet