cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Screen(spool) to PDF file sending mail with attach file

Former Member
0 Kudos

Hi :

I'd like convert spool list to pdf and sending file...

so, I read thread about spool convert to PDF before,

and know how to convert Spool to PDF file and send mail with attach file.

but I have a problem.

my solution as:

step 1. Call function: "CONVERT_ABAPSPOOLJOB_2_PDF"

step 2. Call function: "SO_NEW_DOCUMENT_ATT_SEND_API1"

then, I got a mail with attached PDF file, but the PDF file display limited 255 line.( SO_NEW_DOCUMENT_ATT_SEND_API1 limited)

I want to showing word is wider that 255.

and then I find a manual method as:

After program finished.

Function Menu -> system -> List -> Send

use Prog: "Create Document and Send"

I use this prog sending mail and attached file ,

PDF file do <b>NOT</b> have 255 word limit !

finally. my question is, If I want sending mail as Prog: "Create Document and Send", how to do?

which Function I have to use?...

Please help me, Thanks!

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Check this sample code of sending spool as attachment to an email address..

  • Parameters.

PARAMETERS: p_email(50) LOWER CASE.

PARAMETERS: p_spool LIKE tsp01-rqident.

  • Data declarations.

DATA: plist LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.

DATA: document_data LIKE sodocchgi1.

DATA: so_ali LIKE soli OCCURS 100 WITH HEADER LINE.

DATA: real_type LIKE soodk-objtp.

DATA: sp_lang LIKE tst01-dlang.

DATA: line_size TYPE i VALUE 255.

DATA: v_name LIKE soextreci1-receiver.

DATA rec_tab LIKE somlreci1 OCCURS 1 WITH HEADER LINE.

  • Get the spool data.

CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'

EXPORTING

rqident = p_spool

first_line = 1

last_line = 0

desired_type = ' '

IMPORTING

real_type = real_type

sp_lang = sp_lang

TABLES

buffer = so_ali

EXCEPTIONS

no_such_job = 1

job_contains_no_data = 2

selection_empty = 3

no_permission = 4

can_not_access = 5

read_error = 6

type_no_match = 7

OTHERS = 8.

IF sy-subrc <> 0.

MESSAGE s208(00) WITH 'Error'.

LEAVE LIST-PROCESSING.

ENDIF.

  • Prepare the data.

plist-transf_bin = 'X'.

plist-head_start = 0.

plist-head_num = 0.

plist-body_start = 0.

plist-body_num = 0.

plist-doc_type = 'RAW'.

plist-obj_descr = 'Test ALV'.

APPEND plist.

plist-transf_bin = 'X'.

plist-head_start = 0.

plist-head_num = 0.

plist-body_start = 1.

DESCRIBE TABLE so_ali LINES plist-body_num.

plist-doc_type = real_type.

  • Get the size.

READ TABLE so_ali INDEX plist-body_num.

plist-doc_size = ( plist-body_num - 1 ) * line_size

+ STRLEN( so_ali ).

APPEND plist.

  • Move the receiver address.

MOVE: p_email TO rec_tab-receiver,

'U' TO rec_tab-rec_type.

APPEND rec_tab.

IF NOT sp_lang IS INITIAL.

document_data-obj_langu = sp_lang.

ELSE.

document_data-obj_langu = sy-langu.

ENDIF.

v_name = sy-uname.

  • Send the email.

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

document_data = document_data

sender_address = v_name

sender_address_type = 'B'

TABLES

packing_list = plist

contents_bin = so_ali

receivers = rec_tab

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 e208(00) WITH 'Error'.

ENDIF.

COMMIT WORK.

  • Send the email immediately.

SUBMIT rsconn01

WITH mode = 'INT'

AND RETURN.

Thanks,

Naren

Former Member
0 Kudos

Hi Narendran :

the first,

I try to convert as your code, then got correct result in Front-end Side(Client),

it's great!!

But I got another problem.

I set it in the background job,

when the program try to send mail with attachment file,

the mail moved to "Error" box by system (T-code SCOT,SAPConnect)

after checking the Log file, I found out the causing,

error is about transfer, the System Admin told me as below:

when program transferred RAW to PDF file, program got a error msg,

anybody know about that? how could I fix it?

trans the RAW format to ALI format? Can I?

Thanks A lot!