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: 

regarding background job pdf conversion

Former Member
0 Kudos

hi

this report runs in background and accordingly spool id is generated but after conversion to pdf i cant see any data in lt_pdf_output table .

I am can see the report in fore ground wen i dont have to mail it.

but wen i try to mail it it doesnt show me any data in pdf format in the debuggar and i get the attachment as blank pdf file..

plz help

LOOP AT t_smartcode WHERE count <> 0 .

  • WRITE: /5 t_smartcode-smart_code, 30 t_smartcode-count .

*{ ENTCR 8127: D&S Report - Smartcode value retrieval start of changes

WRITE: /5 t_smartcode-smart_code, 30 t_smartcode-formkey ,

50 t_smartcode-count

g_spono = sy-spono .

FORM send_mail USING p_email l_obj_name l_obj_descr .

DATA: t_reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE ,

l_docdata LIKE sodocchgi1 ,

t_objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE ,

t_attach LIKE solisti1 OCCURS 10 WITH HEADER LINE , "RD1K953969

t_objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,

l_tab_lines TYPE i ,

l_buffer TYPE string , "RD1K953969

l_spoolid TYPE tsp01-rqident . "RD1K953969

*{RD1K953969

DATA: BEGIN OF lt_pdf_output OCCURS 0 .

INCLUDE STRUCTURE tline .

DATA: END OF lt_pdf_output .

l_spoolid = g_spono .

*Convert Spool to PDF

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = l_spoolid

no_dialog = 'X'

  • DST_DEVICE =

  • PDF_DESTINATION =

  • IMPORTING

  • PDF_BYTECOUNT =

  • PDF_SPOOLID =

  • LIST_PAGECOUNT =

  • BTC_JOBNAME =

  • BTC_JOBCOUNT =

TABLES

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

IF sy-subrc <> 0.

ENDIF.

    • Transform 134 byte string to 255 byte.

CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'

EXPORTING

line_width_src = 134

line_width_dst = 255

TABLES

content_in = lt_pdf_output

content_out = t_attach

EXCEPTIONS

err_line_width_src_too_long = 1

err_line_width_dst_too_long = 2

err_conv_failed = 3

OTHERS = 4.

IF sy-subrc <> 0.

CONCATENATE text-016 g_spono INTO t_objtxt SEPARATED BY space .

APPEND t_objtxt .

ENDIF.

*}RD1K953969

*Create Receiver List

t_reclist-receiver = p_email .

*{RD1K953969

t_reclist-rec_type = 'B'. "Login name

*{ ENTCR 8127: D&S Report - Smartcode value retrieval start of changes

  • t_reclist-rec_type = 'U'. "Internet address

*} ENTCR 8127: D&S Report - Smartcode value retrieval end of changes

  • t_reclist-com_type = 'INT'.

*}RD1K953969

APPEND t_reclist.

  • Create Message Body

**Title and Description

l_docdata-obj_name = l_obj_name .

l_docdata-obj_descr = l_obj_descr .

*{RD1K953969

    • Commented. The report is sent as PDF attachment

***Main Text

  • LOOP AT t_smartcode .

  • MOVE t_smartcode TO t_objtxt .

  • APPEND t_objtxt .

  • CLEAR t_objtxt .

  • ENDLOOP .

  • Create email body

t_objtxt = text-013 .

APPEND t_objtxt .

CONCATENATE text-014 sy-datum INTO t_objtxt SEPARATED BY space .

APPEND t_objtxt .

CONCATENATE text-015 sy-uzeit INTO t_objtxt SEPARATED BY space .

APPEND t_objtxt .

**Write Packing List (Main)

  • DESCRIBE TABLE t_objtxt LINES l_tab_lines.

*

  • READ TABLE t_objtxt INDEX l_tab_lines.

  • l_docdata-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( t_objtxt ).

DESCRIBE TABLE t_attach LINES l_tab_lines.

READ TABLE t_attach INDEX l_tab_lines.

l_docdata-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( t_attach ).

*}RD1K953969

CLEAR t_objpack-transf_bin.

t_objpack-head_start = 1.

t_objpack-head_num = 0.

t_objpack-body_start = 1.

  • t_objpack-body_num = l_tab_lines.

DESCRIBE TABLE t_objtxt LINES t_objpack-body_num .

t_objpack-doc_type = 'RAW'.

APPEND t_objpack.

*{RD1K953969

  • Create attachment notification

t_objpack-transf_bin = 'X'.

t_objpack-head_start = 1.

t_objpack-head_num = 1.

t_objpack-body_start = 1.

t_objpack-body_num = l_tab_lines .

t_objpack-doc_type = 'PDF' .

t_objpack-obj_descr = 'Dunning & Stub Report'.

t_objpack-obj_name = 'DnS Report.pdf'.

t_objpack-doc_size = t_objpack-body_num * 255.

APPEND t_objpack.

*}RD1K953969

*Send Mail

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = l_docdata

  • put_in_outbox = 'X' "RD1K953969

TABLES

packing_list = t_objpack

contents_bin = t_attach "RD1K953969

contents_txt = t_objtxt

receivers = t_reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

IF sy-subrc <> 0.

MESSAGE ID 'SO' TYPE 'S' NUMBER '023'

WITH l_docdata-obj_name.

ENDIF.

ENDFORM. " send_mail

1 ACCEPTED SOLUTION

former_member223537
Active Contributor
0 Kudos

Hi,

Please refer sample program:

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

Best regards,

Prashant

2 REPLIES 2

former_member223537
Active Contributor
0 Kudos

Hi,

Please refer sample program:

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

Best regards,

Prashant

0 Kudos

hi prashant

thx for the reply...

i think my code is same on the line of link that is given

here in my code i am generating spool-id

but still i could not figure out y i am not getting the pdf ouput..

if any one can help..

regards

vivek