Skip to Content
0
Former Member
Jan 17, 2008 at 09:44 AM

how to display the data in PDF format : problem is splitting into 2 lines

38 Views

Hi ,

I developed one report which downloads the data into PDF format and saved in C drive but my problem is

in my program : Line size of the report is 255 in PDF it is splitting into 2 lines. it has to show in a single line. how to do it. how to reduce the width of the output? i am sending my code below. anybody can suggest me how to do it. if possible please send me the code.

my code:

report zmaheedhar.

  • maheedhar-start

TABLES : vbak.

parameters : p_vbeln type vbak-vbeln.

data : begin of itab occurs 0,

vbeln type vbak-vbeln,

ERDAT type vbak-erdat,

ERZET type vbak-erzet,

ERNAM type vbak-ernam,

ANGDT type vbak-angdt,

BNDDT type vbak-bnddt,

AUDAT type vbak-audat,

VBTYP type vbak-vbtyp,

TRVOG type vbak-trvog,

AUART type vbak-auart,

AUGRU type vbak-augru,

GWLDT type vbak-gwldt,

SUBMI type vbak-submi,

LIFSK type vbak-lifsk,

FAKSK type vbak-faksk,

NETWR type vbak-netwr,

WAERK type vbak-waerk,

VKORG type vbak-vkorg,

end of itab.

  • maheedhar-end

DATA: pripar TYPE pri_params,

arcpar TYPE arc_params,

lay TYPE pri_params-paart,

lines TYPE pri_params-linct,

rows TYPE pri_params-linsz.

DATA: val(1), val1(1).

*---> Local Printer Name defined in SAP, Change NHREMOTE to your local printer

DATA: dest TYPE pri_params-pdest VALUE 'ZNUL'.

DATA: name TYPE pri_params-plist VALUE 'Testing'.

DATA: i_pdf TYPE STANDARD TABLE OF tline.

DATA: spono TYPE tsp01-rqident.

  • maheedhar-start

top-of-page.

write: 'Sales Document' , 'C Date', 'Entry time', 'Created By','Quotation date',

'Date','Document Date','SD document category','Transaction group','Sales Document Type',

'Order reason'.

start-OF-SELECTION.

select vbeln ERDAT ERZET ERNAM ANGDT BNDDT AUDAT

VBTYP TRVOG AUART AUGRU GWLDT SUBMI LIFSK

FAKSK NETWR WAERK VKORG from vbak

into table itab

where vbeln = p_vbeln.

  • maheedhar-end

--- Retreive local printer details

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

destination = dest

no_dialog = 'X'

immediately = ' '

IMPORTING

out_archive_parameters = arcpar

out_parameters = pripar

valid = val

valid_for_spool_creation = val1

EXCEPTIONS

archive_info_not_found = 1

invalid_print_params = 2

invalid_archive_params = 3

OTHERS = 4.

IF sy-subrc NE 0.

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

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

ENDIF.

*-- Set Spool printer details w.r.t local printer

pripar-prdsn = 'DSN'.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

in_archive_parameters = arcpar

in_parameters = pripar

no_dialog = 'X'

list_name = name

IMPORTING

out_archive_parameters = arcpar

out_parameters = pripar

valid = val

valid_for_spool_creation = val1

EXCEPTIONS

archive_info_not_found = 1

invalid_print_params = 2

invalid_archive_params = 3

OTHERS = 4.

IF sy-subrc EQ 0.

  • ---> Triggers the spool creation in the sense all the write statements from hereon will be written to spool instead of screen

NEW-PAGE PRINT ON

NEW-SECTION

PARAMETERS pripar

ARCHIVE PARAMETERS arcpar

NO DIALOG.

ELSE.

WRITE:/ 'Unable to create spool'.

ENDIF.

*--- Output statements

*WRITE:/ 'First Line', 'mahee','lklk','kikik','lokiuj','fffff','kijuyh','fgfgfgfg','gtgtgtgtgtgtgtgtggggggggggggggggggggggggggggggg'.

*WRITE:/ 'Second Line'.

LOOP at itab.

write: itab-vbeln,

itab-ERDAT,

itab-ERZET,

itab-ERNAM,

itab-ANGDT,

itab-BNDDT,

itab-AUDAT,

itab-VBTYP.

ENDLOOP.

"---> Close spool

NEW-PAGE PRINT OFF.

spono = sy-spono.

  • Convert ABAP Spool to PDF

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = spono

no_dialog = 'X'

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.

  • Download PDF contents to presentation server

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'c:\test.pdf'

filetype = 'BIN'

TABLES

data_tab = i_pdf

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22.

thanks,

maheedhar