Application Development and Automation 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: 
Read only

Urgent...

Former Member
0 Likes
559

how to send output of program via email?

how to send output of program via email?

3 REPLIES 3
Read only

Former Member
0 Likes
533
Read only

Former Member
0 Likes
533

Hi,

Just copy this code in Your program and execute,U will understand easily.

DATA:i_pack LIKE soxpl OCCURS 0 WITH HEADER LINE,

i_lines TYPE i.

DESCRIBE TABLE i_marc LINES i_lines.

*The required information to send an attachment

  • i_pack-transf_bin = 'X'.

  • i_pack-head_start = 0.

  • i_pack-head_num = 0.

  • i_pack-body_start = 1.

  • i_pack-body_num = i_lines.

  • i_pack-objtp = 'PDF'.

  • i_pack-objnam = 'CHAN'.

  • APPEND i_pack.

*populate the receivers list

DATA:i_receiver LIKE soos1 OCCURS 0 WITH HEADER LINE.

i_receiver-recesc = 'U'.

i_receiver-recextnam = '[email protected]'.

APPEND i_receiver.

*sending the output in the mail body

DATA:i_list LIKE abaplist OCCURS 0 WITH HEADER LINE,

i_compress LIKE soli OCCURS 100 WITH HEADER LINE.

***this function module gives the output of the report into an internal table

CALL FUNCTION 'SAVE_LIST'

EXPORTING

list_index = 0

TABLES

listobject = i_list

EXCEPTIONS

list_index_invalid = 1

OTHERS = 2.

*this will compress the above internal table

    • LOOP AT i_list.

    • MOVE i_list-rfcrecord TO i_compress-line.

    • APPEND i_compress.

    • ENDLOOP.

CALL FUNCTION 'TABLE_COMPRESS'

TABLES

in = i_list

out = i_compress

EXCEPTIONS

compress_error = 1

OTHERS = 2.

DATA: wa_sood1 TYPE sood1,

w_l TYPE i,

l_length TYPE i.

DESCRIBE FIELD i_compress LENGTH l_length IN BYTE MODE.

DESCRIBE TABLE i_compress LINES w_l.

wa_sood1-objlen = l_length * w_l.

wa_sood1-objla = sy-langu.

wa_sood1-objnam = 'List'.

wa_sood1-objpri = '1'.

wa_sood1-objsns = '0'.

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

  • FOLDER_ID = ' '

  • FORWARDER = ''

  • OBJECT_FL_CHANGE = ' '

object_hd_change = wa_sood1

  • OBJECT_ID = ' '

object_type = 'ALI'

  • outbox_flag = 'X'

  • OWNER = ' '

  • STORE_FLAG = ' '

  • DELETE_FLAG = ' '

  • SENDER = ' '

  • CHECK_SEND_AUTHORITY = ' '

  • CHECK_ALREADY_SENT = ' '

  • GIVE_OBJECT_BACK =

  • ORIGINATOR = ' '

  • ORIGINATOR_TYPE = 'J'

  • LINK_FOLDER_ID = ' '

  • SEND_REQUEST_OID = ' '

  • IP_ENCRYPT = 'U'

  • IP_SIGN = 'U'

  • IP_REC_COUNT_ADD =

  • IMPORTING

  • OBJECT_ID_NEW =

  • SENT_TO_ALL =

  • ALL_BINDING_DONE =

  • OFFICE_OBJECT_KEY =

  • ORIGINATOR_ID =

  • E_SEND_REQUEST_OID =

TABLES

objcont = i_compress

  • OBJHEAD =

  • OBJPARA =

  • OBJPARB =

receivers = i_receiver

  • packing_list = i_pack

  • ATT_CONT =

  • ATT_HEAD =

  • NOTE_TEXT =

  • LINK_LIST =

  • APPLICATION_OBJECT =

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 <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

COMMIT WORK.

Message was edited by:

CSR