Application Development 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: 

Spool conversion to PDF and download

gautam_totekar
Active Participant
0 Kudos

I am converting ABAP Spool to PDF download and downloading the same into PDF. But the PDF output downlaoded is in A4 layout only and not in A3 even after creating a new destination device for A3

1 ACCEPTED SOLUTION

former_member209120
Active Contributor
0 Kudos

Hi Gautam Totekar,

Try like this

TYPES: BEGIN OF ty_pdf,
fld1(
20) TYPE c,
fld2(
20) TYPE c,
fld3(
20) TYPE c,
END OF ty_pdf.

DATA  : g_val      TYPE c,
w_pripar 
TYPE pri_params,
w_arcpar 
TYPE arc_params,
spool_no 
LIKE tsp01-rqident,
it_pdf   
TYPE TABLE OF tline WITH HEADER LINE,
file_tab 
TYPE STANDARD TABLE OF solisti1,
bytecount
TYPE i.

DATA: it_t001 TYPE TABLE OF t001.
DATA: wa_t001 TYPE t001.
DATA: it_FINAL TYPE TABLE OF ty_pdf.
DATA: wa_FINAL TYPE ty_pdf.



START-
OF-SELECTION.
PERFORM get_data.
PERFORM print_data CHANGING spool_no.
PERFORM convert_spool_2_pdf.
PERFORM download_pdf_file.



*&---------------------------------------------------------------------*
*&    Form  get_data

*&---------------------------------------------------------------------*

FORM get_data .

SELECT * INTO TABLE it_t001 FROM t001 up to 10 rows.

wa_final-fld1 =
'Field 1'.
wa_final-fld2 =
'Field 2'.
wa_final-fld3 =
'Field 3'.
APPEND wa_final TO it_final.

LOOP AT it_t001 INTO wa_t001.
wa_final-fld1 = wa_t001-bukrs.
wa_final-fld2 = wa_t001-butxt.
wa_final-fld3 = wa_t001-ort01.
APPEND wa_final TO it_final.
ENDLOOP.

ENDFORM.                  " get_data

*&---------------------------------------------------------------------*
*&    Form  print_data

*&---------------------------------------------------------------------*

FORM print_data  CHANGING spool_no.

CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
in_archive_parameters  = w_arcpar
in_parameters          = w_pripar
layout                 =
'X_65_132'
line_count             =
65
line_size              =
132
no_dialog              =
'X'
IMPORTING
out_archive_parameters = w_arcpar
out_parameters         = w_pripar
valid                  = g_val.

IF g_val  NE space AND sy-subrc = 0.
w_pripar-prrel = space.
w_pripar-primm = space.
NEW-PAGE PRINT ON NEW-SECTION PARAMETERS w_pripar ARCHIVE PARAMETERS w_arcpar NO DIALOG.

LOOP AT it_final into wa_final.
WRITE😕 wa_final.
ENDLOOP.
NEW-PAGE PRINT OFF.
CALL FUNCTION 'ABAP4_COMMIT_WORK'.

ENDIF.

IF NOT sy-spono IS INITIAL.
spool_no = sy-spono.

ENDIF.
ENDFORM.                  " print_data

*&---------------------------------------------------------------------*
*&    Form  convert_spool_2_pdf
*&---------------------------------------------------------------------*

FORM convert_spool_2_pdf .

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid   = spool_no
no_dialog     = space
IMPORTING
pdf_bytecount = bytecount
TABLES
pdf           = it_pdf.

CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_src =
134
line_width_dst =
255
TABLES
content_in     = it_pdf
content_out    = file_tab.


ENDFORM.                  " convert_spool_2_pdf

*&---------------------------------------------------------------------*
*&    Form  download_PDF_file

*&---------------------------------------------------------------------*

FORM download_pdf_file .

CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize          = bytecount
filename              =
'D:/test.pdf'
filetype              =
'BIN'
CHANGING
data_tab              = file_tab.

ENDFORM.                  " download_PDF_file

 

25 REPLIES 25

tolga_polat
Active Participant
0 Kudos

Hi Gautam,

this question anwsered many times. pls use search...

http://lmgtfy.com/?q=sap+spool+to+pdf

0 Kudos

cool site (http://lmgtfy.com).

Former Member
0 Kudos

Hi,

Ask your Basis consultant (or) you  can also check in Transaction SPAD

what is the default set for out put basically it is A4 .. there you

change it to A3 format.

Regards

Khaleel

former_member215424
Active Participant
0 Kudos

Hi,

Try to change the Page format used in smartforms to A3 width and height.

Former Member
0 Kudos

Hi Gautam,

The new destination device and printer should have DEFAULT page format as A3.

Regards

0 Kudos

where to providethese settings to the new destination device and printer ? the basis have provided one device. But I doubt its configuration. I checked SPAD.. I could see page format in tray selection .. could nto find default settings

0 Kudos

In SPAD got to outpu devices of the ouput type you are using in print parameters

Check the "Tray Info" tab here you can specify hardcoded DINA3 and use this only for your case.

Regards

former_member209120
Active Contributor
0 Kudos

Hi Gautam Totekar,

Try like this

TYPES: BEGIN OF ty_pdf,
fld1(
20) TYPE c,
fld2(
20) TYPE c,
fld3(
20) TYPE c,
END OF ty_pdf.

DATA  : g_val      TYPE c,
w_pripar 
TYPE pri_params,
w_arcpar 
TYPE arc_params,
spool_no 
LIKE tsp01-rqident,
it_pdf   
TYPE TABLE OF tline WITH HEADER LINE,
file_tab 
TYPE STANDARD TABLE OF solisti1,
bytecount
TYPE i.

DATA: it_t001 TYPE TABLE OF t001.
DATA: wa_t001 TYPE t001.
DATA: it_FINAL TYPE TABLE OF ty_pdf.
DATA: wa_FINAL TYPE ty_pdf.



START-
OF-SELECTION.
PERFORM get_data.
PERFORM print_data CHANGING spool_no.
PERFORM convert_spool_2_pdf.
PERFORM download_pdf_file.



*&---------------------------------------------------------------------*
*&    Form  get_data

*&---------------------------------------------------------------------*

FORM get_data .

SELECT * INTO TABLE it_t001 FROM t001 up to 10 rows.

wa_final-fld1 =
'Field 1'.
wa_final-fld2 =
'Field 2'.
wa_final-fld3 =
'Field 3'.
APPEND wa_final TO it_final.

LOOP AT it_t001 INTO wa_t001.
wa_final-fld1 = wa_t001-bukrs.
wa_final-fld2 = wa_t001-butxt.
wa_final-fld3 = wa_t001-ort01.
APPEND wa_final TO it_final.
ENDLOOP.

ENDFORM.                  " get_data

*&---------------------------------------------------------------------*
*&    Form  print_data

*&---------------------------------------------------------------------*

FORM print_data  CHANGING spool_no.

CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
in_archive_parameters  = w_arcpar
in_parameters          = w_pripar
layout                 =
'X_65_132'
line_count             =
65
line_size              =
132
no_dialog              =
'X'
IMPORTING
out_archive_parameters = w_arcpar
out_parameters         = w_pripar
valid                  = g_val.

IF g_val  NE space AND sy-subrc = 0.
w_pripar-prrel = space.
w_pripar-primm = space.
NEW-PAGE PRINT ON NEW-SECTION PARAMETERS w_pripar ARCHIVE PARAMETERS w_arcpar NO DIALOG.

LOOP AT it_final into wa_final.
WRITE😕 wa_final.
ENDLOOP.
NEW-PAGE PRINT OFF.
CALL FUNCTION 'ABAP4_COMMIT_WORK'.

ENDIF.

IF NOT sy-spono IS INITIAL.
spool_no = sy-spono.

ENDIF.
ENDFORM.                  " print_data

*&---------------------------------------------------------------------*
*&    Form  convert_spool_2_pdf
*&---------------------------------------------------------------------*

FORM convert_spool_2_pdf .

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid   = spool_no
no_dialog     = space
IMPORTING
pdf_bytecount = bytecount
TABLES
pdf           = it_pdf.

CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_src =
134
line_width_dst =
255
TABLES
content_in     = it_pdf
content_out    = file_tab.


ENDFORM.                  " convert_spool_2_pdf

*&---------------------------------------------------------------------*
*&    Form  download_PDF_file

*&---------------------------------------------------------------------*

FORM download_pdf_file .

CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize          = bytecount
filename              =
'D:/test.pdf'
filetype              =
'BIN'
CHANGING
data_tab              = file_tab.

ENDFORM.                  " download_PDF_file

 

0 Kudos

we tried with a new printer configured as A3 layout default but still the contents are not readable. and fonts are very small

0 Kudos

Hi Gautam Totekar,

See this link for solution http://scn.sap.com/thread/1675947

0 Kudos

what is the original size? Lets say, if its a SF, is it designed to fit A4 page and not A3 page? If yes, then you will have to first make it fit for A3 size display, manually. And then you will have proper A3 print.

Regards,

KS

0 Kudos

It is a normal list output of report..

On a nutton. I am printing the same output to spool.

using Get_print_parameters,

CONVERT_ABAPSPOOLJOB_2_PDF

and downloading

0 Kudos

Hi Gautam Totkar,

Develop smartform and convert it to PDF your requirement will fulfill.

See this link to know how to download smartform as PDF

http://wiki.sdn.sap.com/wiki/display/Snippets/Convert+Smartform+to+PDF+format

0 Kudos

We have 4-5 reports with similar problem

X_65_255 gives proper output with all teh columns but the font sieze is not readable which is why we are moving to layout A3.

We cannot convert it to smartform output currently

0 Kudos

Hi Gautam,

Have a look for generic A3 Printing with issue similar to yours.

How can I print A3 format in SAP

Regards

0 Kudos

Hi,

Since it is a normal report its printing format will completely depend on it SPAD settings:

This link explains:

http://www.saptechies.org/how-can-i-print-a3-format-in-sap/

Regards,

KS

0 Kudos

As suugested we created a new page format Z_A3 and mentioned DINA3 and lines 65 columns 255 for it.

And maintained the same against the printer under Tray.

But although sp01 shows complete output the PDF generated with following FM is blank

GET_PRINT_PARAMETERS

***Write list and generate spool***

CONVERT_ABAPSPOOLJOB_2_PDF

GUI_DOWNLOAD

0 Kudos

What is the device type of your new output device? Is it "PDF1"?

0 Kudos

No the device type I am using is HPLJIIID:HP lserjet 3 series PCL5.

As I am generating a spool number first and then sending it to download using FMs

CONVERT_ABAPSPOOLJOB_2_PDF

GUI_DOWNLOAD.

PDF1 is used for automatic conversion of spool to PDF i feel.

Creating a device of this type will it help ?

because we have  a device of this type used it as well.

http://www.erpgreat.com/bc037.htm

0 Kudos

Then for this kind of print use the existing device with device type "PDF1" and check.

0 Kudos

you would also need to first set output width and size manually.

check:

http://wiki.sdn.sap.com/wiki/display/ABAP/PDF+Download+By+Creating+Spool+Request

From this link, check this piece of code:

*-- Explicitly set line width, and output format so that

*-- the PDF conversion comes out OK

  mstr_print_parms-linsz = p_linsz.

  mstr_print_parms-paart = p_paart.

and then call CONVERT_ABAPSPOOLJOB_2_PDF, as shown there.

BR,

KS


Former Member
0 Kudos

Is your issue solved?

0 Kudos

yes..Thanks for your inputs.

 

  1. Created a custom
    Page Format ZPDINA3 for DINA3. for DINA3 with lines 65 columns 255
  2. Created a custom
    Format Type ZFDINA3 for DINA3.
  3. Assigned the new format to existing printer PDFP

printed using PDFP.

0 Kudos

now its a good idea to close the thread.

0 Kudos

HI,

GO TO TCODE SPAD

CLICK ON FULL ADMIN. BUTTON

CHOOSE THE TAB <DEVICE TYPES>

THERE YOU CLICK ON <DISPLAY> BUTTON AGAINST - PAGE FORMATS

CREATE A NEW PAGE FORMAT OF YOUR INTEREST

AND THEN ASSIGN IT TO A DEVICE TYPE .