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

SO_DOCUMENT_SEND_API1 unknown file format

Former Member
0 Likes
1,025

Hi all,

Im using SO_DOCUMENT_SEND_API1 in my FM and it sends the email with xls attachment (filled from itab). However I can't open the .xls as it produces and Unknown File Format error.

For testing: I'm using the same SO_DOCUMENT_SEND_API1 code in a custom executable program and it works fine. Same email, same xls and no errors when opening the xls. (running in fore- and background)

Another test: Im calling this executable program from my FM and it works fine aswell (in background).

So it seems it only produces the Unknown File Format when coded into my FM...

Any help/input appreciated...

Here is the FM code:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++

----


  • Email Notification Logic

----


SELECT docnum pernr subty text longtext

UP TO 100 ROWS

FROM ythr_rem_service

INTO TABLE it_ythr_rem_serv WHERE docnum EQ idoc_contrl-docnum.

  • Build data table for .xls document - For Unicode check active

CLASS cl_abap_char_utilities DEFINITION LOAD.

CONSTANTS:

con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,

con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.

CONCATENATE 'DOCNUM' 'PERNR' 'SUBTY' 'TEXT' 'LONGTEXT'

INTO it_attach SEPARATED BY con_tab.

CONCATENATE con_cret it_attach INTO it_attach.

APPEND it_attach.

LOOP AT it_ythr_rem_serv INTO wa_charythr_rem_service.

CONCATENATE wa_charythr_rem_service-docnum

wa_charythr_rem_service-pernr

wa_charythr_rem_service-subty

wa_charythr_rem_service-text

wa_charythr_rem_service-longtext

INTO it_attach SEPARATED BY con_tab.

CONCATENATE con_cret it_attach INTO it_attach.

APPEND it_attach.

ENDLOOP.

  • Populate message body text

REFRESH it_message.

it_message = 'Please find attached the update overview.'.

APPEND it_message.

  • Send email

DATA: ld_error TYPE sy-subrc,

ld_reciever TYPE sy-subrc,

ld_mtitle LIKE sodocchgi1-obj_descr,

ld_email LIKE somlreci1-receiver,

ld_format TYPE so_obj_tp,

ld_attdescription TYPE so_obj_nam ,

ld_attfilename TYPE so_obj_des ,

ld_sender_address LIKE soextreci1-receiver,

ld_sender_address_type LIKE soextreci1-adr_typ,

ld_receiver LIKE sy-subrc.

ld_email = p_email.

ld_mtitle = p_title.

ld_format = p_format.

ld_attdescription = p_descr.

ld_attfilename = ' '.

ld_sender_address = ' '.

ld_sender_address_type = ' '.

  • Fill the document data.

w_doc_data-doc_size = 1.

  • Populate the subject/generic message attributes

w_doc_data-obj_langu = sy-langu.

w_doc_data-obj_name = 'SAPRPT'.

w_doc_data-obj_descr = ld_mtitle .

w_doc_data-sensitivty = 'F'.

  • Fill the document data and get size of attachment

CLEAR w_doc_data.

READ TABLE it_attach INDEX w_cnt.

w_doc_data-doc_size =

( w_cnt - 1 ) * 255 + STRLEN( it_attach ).

w_doc_data-obj_langu = sy-langu.

w_doc_data-obj_name = 'SAPRPT'.

w_doc_data-obj_descr = ld_mtitle.

w_doc_data-sensitivty = 'F'.

CLEAR t_attachment.

REFRESH t_attachment.

t_attachment[] = pit_attach[].

  • Describe the body of the message

CLEAR t_packing_list.

REFRESH t_packing_list.

t_packing_list-transf_bin = space.

t_packing_list-head_start = 1.

t_packing_list-head_num = 0.

t_packing_list-body_start = 1.

DESCRIBE TABLE it_message LINES t_packing_list-body_num.

t_packing_list-doc_type = 'RAW'.

APPEND t_packing_list.

  • Create attachment notification

t_packing_list-transf_bin = 'X'.

t_packing_list-head_start = 1.

t_packing_list-head_num = 1.

t_packing_list-body_start = 1.

DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.

t_packing_list-doc_type = p_format.

t_packing_list-obj_descr = ld_attdescription.

t_packing_list-obj_name = ld_attfilename.

t_packing_list-doc_size = t_packing_list-body_num * 255.

APPEND t_packing_list.

  • Add the recipients email address

CLEAR t_receivers.

REFRESH t_receivers.

t_receivers-receiver = ld_email.

t_receivers-rec_type = 'U'.

t_receivers-com_type = 'INT'.

t_receivers-notif_del = 'X'.

t_receivers-notif_ndel = 'X'.

APPEND t_receivers.

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

document_data = w_doc_data

put_in_outbox = 'X'

sender_address = ld_sender_address

sender_address_type = ld_sender_address_type

commit_work = 'X'

IMPORTING

sent_to_all = w_sent_all

TABLES

packing_list = t_packing_list

contents_bin = t_attachment

contents_txt = it_message

receivers = t_receivers

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.

  • Populate zerror return code

ld_error = sy-subrc.

  • Populate zreceiver return code

LOOP AT t_receivers.

ld_receiver = t_receivers-retrn_code.

ENDLOOP.

  • Instructs mail send program for SAPCONNECT to send email.

WAIT UP TO 2 SECONDS.

SUBMIT rsconn01 WITH mode = 'INT'

WITH output = 'X'

AND RETURN.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++

And here's the Program version:

REPORT z_test.

TABLES: ythr_rem_service.

PARAMETERS: p_email TYPE somlreci1-receiver

DEFAULT 'joe@blog.com'.

PARAMETERS: p_docnum TYPE edidc-docnum.

TYPES: BEGIN OF t_ythr_rem_service,

docnum TYPE ythr_rem_service-docnum,

pernr TYPE ythr_rem_service-pernr,

subty TYPE ythr_rem_service-subty,

text TYPE ythr_rem_service-text,

longtext TYPE ythr_rem_service-longtext,

END OF t_ythr_rem_service.

DATA: it_ythr_rem_serv TYPE STANDARD TABLE OF t_ythr_rem_service INITIAL SIZE 0,

wa_ythr_rem_serv TYPE t_ythr_rem_service.

TYPES: BEGIN OF t_charythr_rem_service,

docnum(16) TYPE c,

pernr(8) TYPE c,

subty(4) TYPE c,

text(29) TYPE c,

longtext(50) TYPE c,

END OF t_charythr_rem_service.

DATA: wa_charythr_rem_service TYPE t_charythr_rem_service.

DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0

WITH HEADER LINE.

DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0

WITH HEADER LINE.

DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,

t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,

t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,

t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,

t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,

w_cnt TYPE i,

w_sent_all(1) TYPE c,

w_doc_data LIKE sodocchgi1,

gd_error TYPE sy-subrc,

gd_reciever TYPE sy-subrc.

************************************************************************

*START_OF_SELECTION

START-OF-SELECTION.

  • Retrieve data from table ythr_rem_service

PERFORM data_retrieval.

  • Populate table with detaisl to be entered into .xls file

PERFORM build_xls_data_table.

************************************************************************

*END-OF-SELECTION

END-OF-SELECTION.

  • Populate message body text

perform populate_email_message_body.

  • Send file by email as .xls speadsheet

PERFORM send_file_as_email_attachment tables it_message

it_attach

using p_email

'Rem Service Test - see xls attachment'

'XLS'

'filename'

' '

' '

' '

changing gd_error

gd_reciever.

  • Instructs mail send program for SAPCONNECT to send email(rsconn01)

PERFORM initiate_mail_execute_program.

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form ythr_rem_service table and

  • populate itab it_ythr_rem_serv

----


FORM data_retrieval.

SELECT docnum pernr subty text longtext

UP TO 100 ROWS

FROM ythr_rem_service

INTO TABLE it_ythr_rem_serv WHERE docnum EQ p_docnum.

ENDFORM. " DATA_RETRIEVAL

&----


*& Form BUILD_XLS_DATA_TABLE

&----


  • Build data table for .xls document

----


FORM build_xls_data_table.

*For Unicode check active in program attributes then we will

*need to declare constants as follows

class cl_abap_char_utilities definition load.

constants:

con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,

con_cret type c value cl_abap_char_utilities=>CR_LF.

CONCATENATE 'DOCNUM' 'PERNR' 'SUBTY' 'TEXT' 'LONGTEXT'

INTO it_attach SEPARATED BY con_tab.

CONCATENATE con_cret it_attach INTO it_attach.

APPEND it_attach.

LOOP AT it_ythr_rem_serv INTO wa_charythr_rem_service.

CONCATENATE wa_charythr_rem_service-docnum

wa_charythr_rem_service-pernr

wa_charythr_rem_service-subty

wa_charythr_rem_service-text

wa_charythr_rem_service-longtext

INTO it_attach SEPARATED BY con_tab.

CONCATENATE con_cret it_attach INTO it_attach.

APPEND it_attach.

ENDLOOP.

ENDFORM. " BUILD_XLS_DATA_TABLE

&----


*& Form SEND_FILE_AS_EMAIL_ATTACHMENT

&----


  • Send email

----


FORM send_file_as_email_attachment tables pit_message

pit_attach

using p_email

p_mtitle

p_format

p_filename

p_attdescription

p_sender_address

p_sender_addres_type

changing p_error

p_reciever.

DATA: ld_error TYPE sy-subrc,

ld_reciever TYPE sy-subrc,

ld_mtitle LIKE sodocchgi1-obj_descr,

ld_email LIKE somlreci1-receiver,

ld_format TYPE so_obj_tp ,

ld_attdescription TYPE so_obj_nam ,

ld_attfilename TYPE so_obj_des ,

ld_sender_address LIKE soextreci1-receiver,

ld_sender_address_type LIKE soextreci1-adr_typ,

ld_receiver LIKE sy-subrc.

ld_email = p_email.

ld_mtitle = p_mtitle.

ld_format = p_format.

ld_attdescription = p_attdescription.

ld_attfilename = p_filename.

ld_sender_address = p_sender_address.

ld_sender_address_type = p_sender_addres_type.

  • Fill the document data.

w_doc_data-doc_size = 1.

  • Populate the subject/generic message attributes

w_doc_data-obj_langu = sy-langu.

w_doc_data-obj_name = 'SAPRPT'.

w_doc_data-obj_descr = ld_mtitle .

w_doc_data-sensitivty = 'F'.

  • Fill the document data and get size of attachment

CLEAR w_doc_data.

READ TABLE it_attach INDEX w_cnt.

w_doc_data-doc_size =

( w_cnt - 1 ) * 255 + STRLEN( it_attach ).

w_doc_data-obj_langu = sy-langu.

w_doc_data-obj_name = 'SAPRPT'.

w_doc_data-obj_descr = ld_mtitle.

w_doc_data-sensitivty = 'F'.

CLEAR t_attachment.

REFRESH t_attachment.

t_attachment[] = pit_attach[].

  • Describe the body of the message

CLEAR t_packing_list.

REFRESH t_packing_list.

t_packing_list-transf_bin = space.

t_packing_list-head_start = 1.

t_packing_list-head_num = 0.

t_packing_list-body_start = 1.

DESCRIBE TABLE it_message LINES t_packing_list-body_num.

t_packing_list-doc_type = 'RAW'.

APPEND t_packing_list.

  • Create attachment notification

t_packing_list-transf_bin = 'X'.

t_packing_list-head_start = 1.

t_packing_list-head_num = 1.

t_packing_list-body_start = 1.

DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.

t_packing_list-doc_type = ld_format.

t_packing_list-obj_descr = ld_attdescription.

t_packing_list-obj_name = ld_attfilename.

t_packing_list-doc_size = t_packing_list-body_num * 255.

APPEND t_packing_list.

  • Add the recipients email address

CLEAR t_receivers.

REFRESH t_receivers.

t_receivers-receiver = ld_email.

t_receivers-rec_type = 'U'.

t_receivers-com_type = 'INT'.

t_receivers-notif_del = 'X'.

t_receivers-notif_ndel = 'X'.

APPEND t_receivers.

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

document_data = w_doc_data

put_in_outbox = 'X'

sender_address = ld_sender_address

sender_address_type = ld_sender_address_type

commit_work = 'X'

IMPORTING

sent_to_all = w_sent_all

TABLES

packing_list = t_packing_list

contents_bin = t_attachment

contents_txt = it_message

receivers = t_receivers

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.

  • Populate zerror return code

ld_error = sy-subrc.

  • Populate zreceiver return code

LOOP AT t_receivers.

ld_receiver = t_receivers-retrn_code.

ENDLOOP.

ENDFORM.

&----


*& Form INITIATE_MAIL_EXECUTE_PROGRAM

&----


  • Instructs mail send program for SAPCONNECT to send email.

----


FORM initiate_mail_execute_program.

WAIT UP TO 2 SECONDS.

SUBMIT rsconn01 WITH mode = 'INT'

WITH output = 'X'

AND RETURN.

ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM

&----


*& Form POPULATE_EMAIL_MESSAGE_BODY

&----


  • Populate message body text

----


form populate_email_message_body.

REFRESH it_message.

it_message = 'Please find attached the update overview.'.

APPEND it_message.

endform. " POPULATE_EMAIL_MESSAGE_BODY

1 ACCEPTED SOLUTION
Read only

p291102
Active Contributor
0 Likes
833

Hi,

I am sending model report for that. Kindly go through that.

&----


*& Report YMS_EXTERNALMAIL *

*& *

&----


*& *

*& *

&----


REPORT YMS_EXTERNALMAIL .

*REPORT zsendemail .

PARAMETERS: PSUBJECT(40) TYPE C DEFAULT 'Hello',

P_EMAIL(40) TYPE C DEFAULT 'test@sapdev.co.uk' .

DATA: IT_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,

IT_CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

IT_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,

IT_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

GD_CNT TYPE I,

GD_SENT_ALL(1) TYPE C,

GD_DOC_DATA LIKE SODOCCHGI1,

GD_ERROR TYPE SY-SUBRC.

DATA: IT_MESSAGE TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0

WITH HEADER LINE.

***********************************************************************

*START-OF-SELECTION.

START-OF-SELECTION.

PERFORM POPULATE_MESSAGE_TABLE.

*Send email message, although is not sent from SAP until mail send

*program has been executed(rsconn01)

PERFORM SEND_EMAIL_MESSAGE.

*Instructs mail send program for SAPCONNECT to send email(rsconn01)

PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.

&----


*& Form POPULATE_MESSAGE_TABLE

&----


  • Adds text to email text table

----


FORM POPULATE_MESSAGE_TABLE.

APPEND 'Email line 1' TO IT_MESSAGE.

APPEND 'Email line 2' TO IT_MESSAGE.

APPEND 'Email line 3' TO IT_MESSAGE.

APPEND 'Email line 4' TO IT_MESSAGE.

ENDFORM. " POPULATE_MESSAGE_TABLE

&----


*& Form SEND_EMAIL_MESSAGE

&----


  • Send email message

----


FORM SEND_EMAIL_MESSAGE.

  • Fill the document data.

GD_DOC_DATA-DOC_SIZE = 1.

  • Populate the subject/generic message attributes

GD_DOC_DATA-OBJ_LANGU = SY-LANGU.

GD_DOC_DATA-OBJ_NAME = 'SAPRPT'.

GD_DOC_DATA-OBJ_DESCR = PSUBJECT.

GD_DOC_DATA-SENSITIVTY = 'F'.

  • Describe the body of the message

CLEAR IT_PACKING_LIST.

REFRESH IT_PACKING_LIST.

IT_PACKING_LIST-TRANSF_BIN = SPACE.

IT_PACKING_LIST-HEAD_START = 1.

IT_PACKING_LIST-HEAD_NUM = 0.

IT_PACKING_LIST-BODY_START = 1.

DESCRIBE TABLE IT_MESSAGE LINES IT_PACKING_LIST-BODY_NUM.

IT_PACKING_LIST-DOC_TYPE = 'RAW'.

APPEND IT_PACKING_LIST.

  • Add the recipients email address

CLEAR IT_RECEIVERS.

REFRESH IT_RECEIVERS.

IT_RECEIVERS-RECEIVER = P_EMAIL.

IT_RECEIVERS-REC_TYPE = 'U'.

IT_RECEIVERS-COM_TYPE = 'INT'.

IT_RECEIVERS-NOTIF_DEL = 'X'.

IT_RECEIVERS-NOTIF_NDEL = 'X'.

APPEND IT_RECEIVERS.

  • Call the FM to post the message to SAPMAIL

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = GD_DOC_DATA

PUT_IN_OUTBOX = 'X'

IMPORTING

SENT_TO_ALL = GD_SENT_ALL

TABLES

PACKING_LIST = IT_PACKING_LIST

CONTENTS_TXT = IT_MESSAGE

RECEIVERS = IT_RECEIVERS

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.

  • Store function module return code

GD_ERROR = SY-SUBRC.

  • Get it_receivers return code

LOOP AT IT_RECEIVERS.

ENDLOOP.

ENDFORM. " SEND_EMAIL_MESSAGE

&----


*& Form INITIATE_MAIL_EXECUTE_PROGRAM

&----


  • Instructs mail send program for SAPCONNECT to send email.

----


FORM INITIATE_MAIL_EXECUTE_PROGRAM.

WAIT UP TO 2 SECONDS.

IF GD_ERROR EQ 0.

SUBMIT RSCONN01 WITH MODE = 'INT'

WITH OUTPUT = 'X'

AND RETURN.

ENDIF.

ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM

Thanks,

Shankar

3 REPLIES 3
Read only

Former Member
0 Likes
833

**fill data for the so_document_send_apl1 structure

    • the key thing here is &SO_FORMAT

    • we have this problem after support pack..try it...it works for me

att_type = 'XLS'.

constants: wc_so_format(11) value '&SO_FORMAT='.

concatenate wc_so_format att_type line.

append ls_objhead to lt_objhead.

call function 'SO_DOCUMENT_SEND_API1'

Read only

0 Likes
833

**also search variable SO_FORMAt in the program. You can try to use '&SO_FORMAT=ASC'. if your excel open with repair message.

Read only

p291102
Active Contributor
0 Likes
834

Hi,

I am sending model report for that. Kindly go through that.

&----


*& Report YMS_EXTERNALMAIL *

*& *

&----


*& *

*& *

&----


REPORT YMS_EXTERNALMAIL .

*REPORT zsendemail .

PARAMETERS: PSUBJECT(40) TYPE C DEFAULT 'Hello',

P_EMAIL(40) TYPE C DEFAULT 'test@sapdev.co.uk' .

DATA: IT_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,

IT_CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

IT_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,

IT_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

GD_CNT TYPE I,

GD_SENT_ALL(1) TYPE C,

GD_DOC_DATA LIKE SODOCCHGI1,

GD_ERROR TYPE SY-SUBRC.

DATA: IT_MESSAGE TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0

WITH HEADER LINE.

***********************************************************************

*START-OF-SELECTION.

START-OF-SELECTION.

PERFORM POPULATE_MESSAGE_TABLE.

*Send email message, although is not sent from SAP until mail send

*program has been executed(rsconn01)

PERFORM SEND_EMAIL_MESSAGE.

*Instructs mail send program for SAPCONNECT to send email(rsconn01)

PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.

&----


*& Form POPULATE_MESSAGE_TABLE

&----


  • Adds text to email text table

----


FORM POPULATE_MESSAGE_TABLE.

APPEND 'Email line 1' TO IT_MESSAGE.

APPEND 'Email line 2' TO IT_MESSAGE.

APPEND 'Email line 3' TO IT_MESSAGE.

APPEND 'Email line 4' TO IT_MESSAGE.

ENDFORM. " POPULATE_MESSAGE_TABLE

&----


*& Form SEND_EMAIL_MESSAGE

&----


  • Send email message

----


FORM SEND_EMAIL_MESSAGE.

  • Fill the document data.

GD_DOC_DATA-DOC_SIZE = 1.

  • Populate the subject/generic message attributes

GD_DOC_DATA-OBJ_LANGU = SY-LANGU.

GD_DOC_DATA-OBJ_NAME = 'SAPRPT'.

GD_DOC_DATA-OBJ_DESCR = PSUBJECT.

GD_DOC_DATA-SENSITIVTY = 'F'.

  • Describe the body of the message

CLEAR IT_PACKING_LIST.

REFRESH IT_PACKING_LIST.

IT_PACKING_LIST-TRANSF_BIN = SPACE.

IT_PACKING_LIST-HEAD_START = 1.

IT_PACKING_LIST-HEAD_NUM = 0.

IT_PACKING_LIST-BODY_START = 1.

DESCRIBE TABLE IT_MESSAGE LINES IT_PACKING_LIST-BODY_NUM.

IT_PACKING_LIST-DOC_TYPE = 'RAW'.

APPEND IT_PACKING_LIST.

  • Add the recipients email address

CLEAR IT_RECEIVERS.

REFRESH IT_RECEIVERS.

IT_RECEIVERS-RECEIVER = P_EMAIL.

IT_RECEIVERS-REC_TYPE = 'U'.

IT_RECEIVERS-COM_TYPE = 'INT'.

IT_RECEIVERS-NOTIF_DEL = 'X'.

IT_RECEIVERS-NOTIF_NDEL = 'X'.

APPEND IT_RECEIVERS.

  • Call the FM to post the message to SAPMAIL

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = GD_DOC_DATA

PUT_IN_OUTBOX = 'X'

IMPORTING

SENT_TO_ALL = GD_SENT_ALL

TABLES

PACKING_LIST = IT_PACKING_LIST

CONTENTS_TXT = IT_MESSAGE

RECEIVERS = IT_RECEIVERS

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.

  • Store function module return code

GD_ERROR = SY-SUBRC.

  • Get it_receivers return code

LOOP AT IT_RECEIVERS.

ENDLOOP.

ENDFORM. " SEND_EMAIL_MESSAGE

&----


*& Form INITIATE_MAIL_EXECUTE_PROGRAM

&----


  • Instructs mail send program for SAPCONNECT to send email.

----


FORM INITIATE_MAIL_EXECUTE_PROGRAM.

WAIT UP TO 2 SECONDS.

IF GD_ERROR EQ 0.

SUBMIT RSCONN01 WITH MODE = 'INT'

WITH OUTPUT = 'X'

AND RETURN.

ENDIF.

ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM

Thanks,

Shankar