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

Problem in Spool to PDF conversion

Former Member
0 Likes
1,989

Hi,

Iam using FM 'RSPO_SX_OUTPUT_TEXTDATA' to genarete a spool. then iam using FM 'CONVERT_ABAPSPOOLJOB_2_PDF' to conver to PDF.

Iam able to generate spool as wel pdf file, but when try to open pdf file, its thrwing an error ''There was an error opening this document. the file is damaged and could not be repair'

pls help me to solve this...

Srinivas

Hi,

Iam using FM 'RSPO_SX_OUTPUT_TEXTDATA' to genarete a spool. then iam using FM 'CONVERT_ABAPSPOOLJOB_2_PDF' to conver to PDF.

Iam able to generate spool as wel pdf file, but when try to open pdf file, its thrwing an error ''There was an error opening this document. the file is damaged and could not be repair'

pls help me to solve this...

Srinivas

5 REPLIES 5
Read only

Sharadha1
Active Contributor
0 Likes
1,255

Hi Srinivas,

I am also facing the same problem. Any soultion??

Regards,

Sharadha

Read only

former_member404244
Active Contributor
0 Likes
1,255

Hi,

After calling the fm'CONVERT_ABAPSPOOLJOB_2_PDF' u need to call the subroutine.Please have a look at the below piece of code.

  • Declaration of local variables

DATA : lv_bytecount TYPE i,

lv_cancel(1) TYPE c,

lv_filename1 LIKE rlgrap-filename. "File name

  • Declaration of local constants

CONSTANTS: lc_pdf(4) TYPE c VALUE '.PDF'.

CONCATENATE c_c

sy-repid

lc_pdf

INTO lv_filename1.

  • Convert Spool to PDF

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = v_rqident

no_dialog = c_x

dst_device = v_print_parms-pdest

IMPORTING

pdf_bytecount = lv_bytecount

TABLES

pdf = i_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.

IF sy-subrc NE 0.

REFRESH : i_pdf.

ENDIF.

IF p_pdf IS NOT INITIAL.

  • To Download to PDF format

PERFORM download_w_ext(rstxpdft) TABLES i_pdf

USING lv_filename1

lc_pdf

'BIN'

lv_bytecount

lv_cancel.

ENDIF.

Reward points if u find useful

Regards,

Nagaraj

Read only

Former Member
0 Likes
1,255

Hi Srinias,

here a short example how to conver a spool in PDF.

Try to change as you like:

TABLES: TSP01.

  • Spoolnummer

PARAMETERS: P_SPOOL LIKE TSP01-RQIDENT.

*

  • Länge der PDF-Datei in Byte

DATA: FILESIZE TYPE I.

  • PDF Ausgabetabelle

DATA: BEGIN OF PDF_OUTPUT OCCURS 0.

INCLUDE STRUCTURE TLINE.

DATA: END OF PDF_OUTPUT.

*

DATA: DATEI TYPE STRING.

************************************************************************

START-OF-SELECTION.

*

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_DESKTOP_DIRECTORY

CHANGING

DESKTOP_DIRECTORY = DATEI.

*

CALL METHOD CL_GUI_CFW=>FLUSH.

*

CONCATENATE DATEI 'TEST.PDF' INTO DATEI.

*

SELECT SINGLE * FROM TSP01 WHERE RQIDENT = P_SPOOL.

IF SY-SUBRC <> 0. EXIT. ENDIF.

*

IF TSP01-RQDOCTYPE = 'OTF'.

*

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

SRC_SPOOLID = P_SPOOL

IMPORTING

PDF_BYTECOUNT = FILESIZE

TABLES

PDF = PDF_OUTPUT.

*

ELSE.

*

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

SRC_SPOOLID = P_SPOOL

IMPORTING

PDF_BYTECOUNT = FILESIZE

TABLES

PDF = PDF_OUTPUT.

*

ENDIF.

  • Download der Spools

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD

EXPORTING

BIN_FILESIZE = FILESIZE

FILENAME = DATEI

FILETYPE = 'BIN'

CHANGING

DATA_TAB = PDF_OUTPUT[].

*

CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE

EXPORTING

DOCUMENT = DATEI.

*

END-OF-SELECTION.

Hope it helps

Regards, Dieter

Read only

Former Member
0 Likes
1,255

Srinivias,

Hope this helps.

There is a STANDARD routine that convert spool data into PDF files.

You can acces and run this program in SE38. It's name is RSTXPDFT4.

If you need to do this conversion in the middle of a program, you can call this routine, or copy the code and change it to fill your program code.

Reward point if helpful please.

Regards.

Read only

Former Member
0 Likes
1,255

Hi,

i tried it with RSPO_SX_OUTPUT_TEXTDATA. I get the same Error.

I think the Problem is the spool is in RAW-Format.

In stead of RSPO_SX_OUTPUT_TEXTDATA use this:

...

DATA: PARAMS LIKE PRI_PARAMS.

...

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

DESTINATION = 'LOCA'

LINE_SIZE = 080

IMMEDIATELY = ' '

NO_DIALOG = 'X'

IMPORTING

OUT_PARAMETERS = PARAMS

VALID = VALID.

*

CHECK VALID <> SPACE.

*

NEW-PAGE PRINT ON PARAMETERS PARAMS NO DIALOG NO-TITLE NO-HEADING.

*

LOOP AT ITAB.

WRITE:/ ITAB.

ENDLOOP.

*

NEW-PAGE PRINT OFF.

  • Spoolnummer besorgen

SPOOL_NR = SY-SPONO.

After this you can delete the spool via

CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ

Hope it helps.

Regards, Dieter