cancel
Showing results for 
Search instead for 
Did you mean: 

how to send the spool content as a body to email id

Former Member
0 Kudos
683

how to send the spool content as a body to email id

thanks

kumar

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member186741
Active Contributor
0 Kudos

it depends on exactly what your needs are but..

If you are trying to send a known spool number you can use:

fm CONVERT_ABAPSPOOLJOB_2_PDF and then use the techniques in abap BCS_EXAMPLE_5 TO EMAIL IT.

If you are running another abap you can:

1. SUBMIT abapname

EXPORTING LIST TO MEMORY

2. CALL FUNCTION 'LIST_FROM_MEMORY'

3. CALL FUNCTION 'LIST_FREE_MEMORY'

4. CALL FUNCTION 'TABLE_COMPRESS'

5. and then use the techniques in abap BCS_EXAMPLE_5 TO EMAIL IT.

Former Member
0 Kudos

i want to send around three pages of report output, same content to body of the mail from the spool no,when i submit in background.

Former Member
0 Kudos

basically i'm trying to send report output to external email id from sap(without converting ,same output as text)

former_member186741
Active Contributor
0 Kudos

I think you have to convert the spool:

check out fm CONVERT_ABAPSPOOLJOB_2_PDF and abap BCS_EXAMPLE_5.

Former Member
0 Kudos

Hi

I'm not usng SAP, so I don't remember how this fm works, but anyway have you tried to use fm RS_SEND_MAIL_FOR_SPOOLLIST

Max

Former Member
0 Kudos

as per my knowledge RS_SEND_MAIL_FOR_SPOOLLIST

fn module will only send to sab inbox(business workplace)

because it has parameter username or id.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Ok, how about coping the code out of that function module and modifing a bit to make it send to external email. I don't have a system in front of me to test, so I can only provide the idea. See if it works.

Maybe setting the email address to the RECEXTNAM field of the RECEIVERS table, or setting "U" as the RECTP.

Regards,

Rich Heilman

Former Member
0 Kudos

i done that..but still mail is going only to sap inbox not external mail id

suresh_datti
Active Contributor
0 Kudos

Hi Muthu,

Did you put a COMMIT WORK statementafter the function call? This is a reuirement for SO_OBJECT_SEND from 47 onward.

Regards,

Suresh Datti

Former Member
0 Kudos

it didn't work

Former Member
0 Kudos

Hi

Try to see the code RSPO_SPOOLJOB_TO_OFFICE. This fm send the spool to Office, but perhaps you can create an your own program by copyng it.

I tried this code and it worked fine:

tables tsp01.

parameters: rqident like tsp01-rqident.

data so_ali like soli occurs 100 with header line.

data: document_data like sodocchgi1.

data rec_tab like somlreci1 occurs 1 with header line.

data: real_type like soodk-objtp.

data: user_data like soudatai1.

data: startline type i, endline type i.

data: dinfo like sofolenti1.

data: plist like sopcklsti1 occurs 2 with header line.

data: sender_address like soextreci1-receiver,

sender_address_type like soextreci1-adr_typ value 'B'.

sender_address = sy-uname.

document_data-obj_langu = sy-langu.

document_data-obj_name = 'Liste'(sls).

document_data-obj_descr = sy-title.

document_data-sensitivty = 'O'.

move: <e-mail address> to rec_tab-receiver,

'U' to rec_tab-rec_type.

append rec_tab.

*startline = 1.

*

*endline = last_line.

refresh so_ali.

call function 'RSPO_RETURN_SPOOLJOB'

exporting

rqident = rqident

  • first_line = startline

  • last_line = endline

  • desired_type = desired_type

importing

real_type = real_type

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.

exit.

endif.

clear plist.

refresh plist.

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 = document_data-obj_descr.

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.

  • Insert note 690074 to calculate document size

read table so_ali index plist-body_num.

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

+ strlen( so_ali ).

append plist.

  • insertion note 591430

data: expdat like sy-datum.

move tsp01-rqdeltime(8) to expdat.

if expdat le sy-datum.

document_data-expiry_dat = sy-datum + 10.

document_data-obj_expdat = sy-datum + 10.

else.

document_data-expiry_dat = expdat.

document_data-obj_expdat = expdat.

endif.

  • end of insertion note 591430

call function 'SO_DOCUMENT_SEND_API1'

exporting

document_data = document_data

  • PUT_IN_OUTBOX = ' '

sender_address = sender_address

sender_address_type = sender_address_type

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

tables

packing_list = plist

  • OBJECT_HEADER =

contents_bin = so_ali

  • CONTENTS_TXT =

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

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 e780(po) with sy-subrc raising could_not_send.

endif.

commit work.

Max

Message was edited by: max bianchi

Former Member
0 Kudos

this is working fine.

but one thing is it is comming as html attachment in mail.

anyway i will debug this code and will try to get as body

(without attachment as it is)

thanks

Former Member
0 Kudos

<b>check out this to convert spool to html</b>

Former Member
0 Kudos

i don't want convert to html.

i have to send the report output to external id(not sap inbox)

Former Member
0 Kudos

<b>check out this to send mail to external mail id</b>

REPORT ZREPORT_TO_EMAIL NO STANDARD PAGE HEADING LINE-SIZE 200.

DATA : BEGIN OF ITAB OCCURS 0,

PERNR LIKE PA0001-PERNR,

ENAME LIKE PA0001-ENAME,

END OF ITAB.

DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE,

receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,

packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,

listobject LIKE abaplist OCCURS 10,

compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,

w_object_hd_change LIKE sood1,

compressed_size LIKE sy-index.

START-OF-SELECTION.

SELECT PERNR ENAME

INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM PA0001

WHERE PERNR < 50.

LOOP AT ITAB.

WRITE :/02 SY-VLINE , ITAB-PERNR, 15 SY-VLINE , ITAB-ENAME, 50

SY-VLINE.

ENDLOOP.

  • Receivers

receiver_list-recextnam = 'EXTERNAL-MAIL-ID@YAHOO.COM'. "-->

  • EMAIL ADDRESS

RECEIVER_list-RECESC = 'E'. "<-

RECEIVER_list-SNDART = 'INT'."<-

RECEIVER_list-SNDPRI = '1'."<-

APPEND receiver_list.

  • General data

w_object_hd_change-objla = sy-langu.

w_object_hd_change-objnam = 'Object name'.

w_object_hd_change-objsns = 'P'.

  • Mail subject

w_object_hd_change-objdes = 'Message subject'.

  • Mail body

APPEND 'Message content' TO message_content.

  • Attachment

CALL FUNCTION 'SAVE_LIST'

EXPORTING

list_index = '0'

TABLES

listobject = listobject.

CALL FUNCTION 'TABLE_COMPRESS'

IMPORTING

compressed_size = compressed_size

TABLES

in = listobject

out = compressed_attachment.

DESCRIBE TABLE compressed_attachment.

CLEAR packing_list.

packing_list-transf_bin = 'X'.

packing_list-head_start = 0.

packing_list-head_num = 0.

packing_list-body_start = 1.

packing_list-body_num = sy-tfill.

packing_list-objtp = 'ALI'.

packing_list-objnam = 'Object name'.

packing_list-objdes = 'Attachment description'.

packing_list-objlen = compressed_size.

APPEND packing_list.

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

object_hd_change = w_object_hd_change

object_type = 'RAW'

owner = sy-uname

TABLES

objcont = message_content

receivers = receiver_list

packing_list = packing_list

att_cont = compressed_attachment.

Former Member
0 Kudos

i need to send from spool no?.