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: 

PDF Conversion Truncated

Former Member
0 Kudos

Hello, I have an issue when performing the Spool to PDF conversion. I am using FM CONVERT_ABAPSPOOLJOB_2_PDF to convert an ALV list to a PDF file. When I run my report in the foreground, everything works correctly, the PDF file is attached and then emailed to the appropriate recipient. When I schedule the job to run in the background, the contents of the attachment that is created is truncated on the right side cutting off half of the report (the font is also larger). I am out of ideas on how to solve this issue. Any help would be appreciated.

4 REPLIES 4

Former Member
0 Kudos

hi matt,

for time being after executing report in background.go to transaction SP01

and check the type of newly created spool..it will show you the actual output

generated by spool req.

or u probably have to write 3 lines of code after write statement i.e.

new-page.

commit work.

new-page print off.

u can also refer link for the same.

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

regards

vivek

0 Kudos

In response to Vivek's response:

Hi Vivek, thanks for your quick reply. When looking at the spool in SP01 the output looks correct which leads me to believe the issue has something to do with the PDF conversion as opposed to the actual creation of the spool ( I could be wrong about this). I did try adding the 3 lines of code as you listed and it did not work. The link you provided is what I based my code on from the start.

Thanks for your help but the problem is still unresolved.

Former Member
0 Kudos

Hi,

Use this code this work for you

Please reward me if you find this answer is helpful

&----


*& Report YSEND_MAIL_ATTACH

*&

&----


*&

*&

&----


REPORT ysend_mail_attach NO STANDARD PAGE HEADING LINE-COUNT 65(2)

LINE-SIZE 120.

----


*TABLES/ DATA DECLARATION

----


TABLES: tsp01,

kna1.

DATA: int_email_receivers LIKE zelift_user_3 OCCURS 0 WITH HEADER LINE.

DATA: int_to_receivers TYPE zeinterface_mail-z_email_to OCCURS 0.

DATA: wa_to_receivers TYPE zeinterface_mail-z_email_to.

DATA: int_mailsend TYPE soos1 OCCURS 0 WITH HEADER LINE.

DATA: printer LIKE pri_params,

mc_valid(1) TYPE c,

p_linsz LIKE sy-linsz VALUE 100,

p_paart LIKE sy-paart VALUE 'X_65_132',

mi_rqident LIKE tsp01-rqident,

mi_bytecount TYPE i,

prg_name LIKE sy-repid,

user_name LIKE sy-uname,

mtab_pdf LIKE tline OCCURS 0 WITH HEADER LINE,

mc_filename LIKE rlgrap-filename,

req_no LIKE tsp01_sp0r-rqid_char,

req_rc LIKE sy-subrc,

nom_char(20),

g_drc_diff.

  • sending email stuff

DATA: object_hd_change TYPE sood1,

object_type TYPE sood-objtp,

objcont TYPE soli OCCURS 0 WITH HEADER LINE,

objhead TYPE soli OCCURS 0 WITH HEADER LINE,

att_cont TYPE soli OCCURS 0 WITH HEADER LINE,

att_head TYPE soli OCCURS 0 WITH HEADER LINE,

packing_list TYPE soxpl OCCURS 0 WITH HEADER LINE,

receivers TYPE soos1 OCCURS 0 WITH HEADER LINE,

  • receivers TYPE somlreci1 OCCURS 0 WITH HEADER LINE,

free_recc TYPE soos1 OCCURS 0 WITH HEADER LINE,

object_id_new TYPE soodk,

sent_to_all TYPE sonv-flag,

all_binding_done TYPE sonv-flag,

office_object_key TYPE swotobjid-objkey,

originator_id TYPE soudk,

objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,

objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,

reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,

doc_chng LIKE sodocchgi1,

tab_lines LIKE sy-tabix,

paylist LIKE bapi7004_rl OCCURS 0 WITH HEADER LINE,

p_info LIKE pc407,

pdf_table LIKE tline OCCURS 0 WITH HEADER LINE,

pdf_fsize TYPE i,

pdf_line(134),

spoolid TYPE tsp01-rqident.

***data declaration for sending the mail.

***data declaration for output display.

DATA:BEGIN OF int_kna1 OCCURS 0,

kunnr LIKE kna1-kunnr,

land1 LIKE kna1-land1,

name1 LIKE kna1-name1,

END OF int_kna1.

PARAMETERS p_kunnr LIKE kna1-kunnr.

*start-of-selection

START-OF-SELECTION.

perform display.

*pdf conversion.

PERFORM pdf_conversion.

END-OF-SELECTION.

----


  • FORM get_spool_number *

----


  • Get the most recent spool created by user/report *

----


  • --> F_REPID *

  • --> F_UNAME *

  • --> F_RQIDENT *

----


FORM get_spool_number USING f_repid

f_uname

CHANGING f_rqident.

DATA:

lc_rq2name LIKE tsp01-rq2name.

CONCATENATE f_repid+0(9)

f_uname+0(3)

INTO lc_rq2name.

CONDENSE lc_rq2name.

SELECT * FROM tsp01 WHERE rq2name = lc_rq2name

ORDER BY rqcretime DESCENDING.

f_rqident = tsp01-rqident.

EXIT.

ENDSELECT.

IF sy-subrc NE 0.

CLEAR f_rqident.

ENDIF.

ENDFORM. " get_spool_number

*---getting the spool created by user/report

&----


*& Form PDF_CONVERSION

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM pdf_conversion.

*-- Setup the Print Parmaters

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

  • authority = space

  • copies = '1'

  • cover_page = space

  • data_set = space

  • department = space

  • destination = space

  • expiration = '1'

  • immediately = space

  • in_archive_parameters = space

  • in_parameters = space

  • layout = space

  • mode = space

  • new_list_id = 'X'

no_dialog = 'X'

user = sy-uname

IMPORTING

out_parameters = printer

valid = mc_valid

EXCEPTIONS

archive_info_not_found = 1

invalid_print_params = 2

invalid_archive_params = 3

OTHERS = 4.

*-- Make sure that a printer destination has been set up

*-- If this is not done the PDF function module ABENDS

IF printer-pdest = space.

printer-pdest = 'LOCL'.

ENDIF.

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

*-- the PDF conversion comes out OK

printer-linsz = p_linsz.

printer-linct = sy-linct.

printer-paart = p_paart.

printer-prrel = ' '.

prg_name = 'YSEND_MAIL_ATTACH'.

user_name = sy-uname.

SUBMIT yidoc12 TO SAP-SPOOL WITHOUT SPOOL DYNPRO

SPOOL PARAMETERS printer

WITH p_kunnr = p_kunnr

AND RETURN.

PERFORM get_spool_number USING prg_name user_name

CHANGING mi_rqident.

IF sy-subrc = 0.

  • IF sendmail = 'X'.

req_no = mi_rqident.

PERFORM spool_pdf_conversion.

PERFORM sendmail.

  • ENDIF.

ENDIF.

req_no = mi_rqident.

CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'

EXPORTING

spoolid = req_no

IMPORTING

  • RC = req_rc

status = req_rc.

  • IF req_rc <> 0.

IF req_rc = 0.

LEAVE PROGRAM.

ENDIF.

ENDFORM. " PDF_CONVERSION

*****pdf conversion----


&----


*& Form SPOOL_PDF_CONVERSION

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM spool_pdf_conversion.

spoolid = req_no.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = spoolid

no_dialog = space

dst_device = printer-pdest

IMPORTING

pdf_bytecount = pdf_fsize

TABLES

pdf = pdf_table

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.

ENDFORM. " FILE_UPLOAD

********converting the spool job to pdf******************************

*sending the mail as an attachment using the fm

&----


*& Form SENDMAIL

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM sendmail.

DATA : BEGIN OF lt_pdflns OCCURS 0.

INCLUDE STRUCTURE solisti1.

DATA : END OF lt_pdflns.

DATA: l_ind,

l_nom_key_o LIKE oijnomi-nomtk.

  • General header data.

MOVE: sy-langu TO object_hd_change-objla,

'Ext.email' TO object_hd_change-objnam,

'C' TO object_hd_change-objsns,

'TXT' TO object_hd_change-file_ext,

'REQUIRED OUTPUT' TO object_hd_change-objdes.

  • Body of the message itself (255).

MOVE ' REPORT TESTING' TO objcont-line.

APPEND objcont.

CONCATENATE 'Time: ' sy-uzeit0(2) ':' sy-uzeit2(2) ':' sy-uzeit+4(2)

INTO objcont-line.

APPEND objcont.

MOVE: 'RAW' TO object_type.

LOOP AT pdf_table.

lt_pdflns = pdf_table.

APPEND lt_pdflns.

CLEAR lt_pdflns.

ENDLOOP.

CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'

EXPORTING

line_width_src = 134

line_width_dst = 255

TABLES

content_in = lt_pdflns

content_out = objbin

EXCEPTIONS

err_line_width_src_too_long = 1 "content_out

err_line_width_dst_too_long = 2

err_conv_failed = 3

OTHERS = 4.

  • DESCRIBE TABLE objbin LINES tab_lines.

*get the mail ids for sending the emails.

  • Fill email receivers

IF int_email_receivers[] IS INITIAL.

CALL FUNCTION 'ZEI_GET_INTERFACE_MAILIDS'

EXPORTING

program_name = 'ZER02230_TSPPRA'

interface = 'TS_TMJ_REJ'

key = 'NOMTK'

value = 'FAILURE_RECEIVERS'

  • DIRECTION =

  • NOTES =

IMPORTING

to_mail_recivers = int_to_receivers

  • CC_MAIL_RECIVERS = int_cc_receivers

EXCEPTIONS

no_data_found = 1

OTHERS = 2

.

  • Appending Email addresses if found.

IF NOT int_to_receivers[] IS INITIAL.

LOOP AT int_to_receivers INTO wa_to_receivers.

MOVE wa_to_receivers TO int_mailsend-recextnam .

int_mailsend-recesc = 'U'.

int_mailsend-sndart = 'INT'.

int_mailsend-sndpri = '1'.

APPEND int_mailsend.

ENDLOOP.

ENDIF.

ELSE.

LOOP AT int_email_receivers.

CONCATENATE int_email_receivers '@exchange.aramco.com.sa' INTO

int_mailsend-recextnam.

int_mailsend-recesc = 'U'.

int_mailsend-sndart = 'INT'.

int_mailsend-sndpri = '1'..

APPEND int_mailsend.

ENDLOOP.

ENDIF.

**************end of the getting emails for sending the mails

DESCRIBE TABLE objbin LINES tab_lines.

MOVE: "'X' TO packing_list-TRANSF_BIN,

'1' TO packing_list-head_start,

'1' TO packing_list-head_num,

'1' TO packing_list-body_start,

tab_lines TO packing_list-body_num,

'RAW' TO packing_list-objtp,

'Attachment' TO packing_list-objnam,

'PDF' TO packing_list-file_ext.

packing_list-objlen = tab_lines * 255.

CONCATENATE 'REPORT TESTING' '--'

sy-datum4(2) '/' sy-datum6(2) '/' sy-datum+0(4)

'--'

sy-uzeit0(2) ':' sy-uzeit2(2) ':' sy-uzeit+4(2)

INTO packing_list-objdes.

APPEND packing_list.

objhead = 'testing the email for pdf'.

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

object_hd_change = object_hd_change

object_type = object_type

IMPORTING

object_id_new = object_id_new

sent_to_all = sent_to_all

all_binding_done = all_binding_done

office_object_key = office_object_key

originator_id = originator_id

TABLES

objcont = objcont

objhead = objhead

receivers = int_mailsend

packing_list = packing_list

att_cont = objbin

att_head = att_head

EXCEPTIONS

active_user_not_exist = 1

communication_failure = 2

component_not_available = 3

folder_not_exist = 4

folder_no_authorization = 5

forwarder_not_exist = 6

note_not_exist = 7

object_not_exist = 8

object_not_sent = 9

object_no_authorization = 10

object_type_not_exist = 11

operation_no_authorization = 12

owner_not_exist = 13

parameter_error = 14

substitute_not_active = 15

substitute_not_defined = 16

system_failure = 17

too_much_receivers = 18

user_not_exist = 19

originator_not_exist = 20

x_error = 21

OTHERS = 22.

IF sy-subrc EQ 0.

COMMIT WORK.

ELSE.

MESSAGE i014(ze9) WITH 'Email was not sent to the Recipients'.

ENDIF.

ENDFORM. " SENDMAIL

************sending mail as an attachment

*for displaying

form display.

endform.

*for displaying

Former Member
0 Kudos

Thank you both for your responses, but it turns out that the issue has to do with the min and max linesize that is specified when calling the FM "REUSE_ALV_BLOCK_LIST_APPEND" when creating an ALV report. It does not make sense to me that changing these parameters affects the PDF conversion and not the actual spool, but it worked.