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

Message body is incomplete (e-mail)

aris_hidalgo
Contributor
0 Likes
540

Hello experts,

I am currently analyzing my code wherein it sends an e-mail message to specified users.

Now, When I checked in tcode scot I noticed that the message body lacks some text or in other

words, incomplete(particularly when a user changes an address. Anyway, below is my code to give you

guys better understanding of my problem.

  • for records that were modified

IF NOT it_address_status[] IS INITIAL.

CLEAR maildata.

maildata-obj_name = 'Record Changed in table ZTS0001'.

maildata-obj_descr = 'Record Changed in table ZTS0001'.

maildata-obj_langu = sy-langu.

LOOP AT it_zshipto_email.

mailtxt-line = 'FYI: Record changed in table ZTS0001'.

APPEND mailtxt.

CLEAR it_address_status.

LOOP AT it_address_status.

IF NOT it_address_status-old_address IS INITIAL AND

NOT it_address_status-new_address IS INITIAL.

CONCATENATE: 'Address of dealer' it_address_status-kunnr

'code' it_address_status-cdseq 'was changed'

'from' it_address_status-old_address 'to'

INTO lv_contents

SEPARATED BY space.

mailtxt-line = lv_contents.

APPEND mailtxt.

CLEAR lv_contents.

CONCATENATE: it_address_status-new_address 'in table'

'ZTS0001 and ZTS_STPGEOLOC by user' sy-uname

INTO lv_contents

SEPARATED BY space.

mailtxt-line = lv_contents.

APPEND mailtxt.

CLEAR lv_contents.

ENDIF.

IF NOT it_address_status-old_person IS INITIAL AND

NOT it_address_status-new_person IS INITIAL.

CONCATENATE: 'Contact person of dealer' it_address_status-kunnr

'code' it_address_status-cdseq 'was changed'

'from' it_address_status-old_person 'to'

it_address_status-new_person 'in table'

'ZTS0001 and ZTS_STPGEOLOC by user' sy-uname

INTO lv_contents

SEPARATED BY space.

mailtxt-line = lv_contents.

APPEND mailtxt.

CLEAR lv_contents.

ENDIF.

IF NOT it_address_status-old_number IS INITIAL AND

NOT it_address_status-new_number IS INITIAL.

CONCATENATE: 'Contact number of dealer' it_address_status-kunnr

'code' it_address_status-cdseq 'was changed'

'from' it_address_status-old_number 'to'

it_address_status-new_number 'in table'

'ZTS0001 and ZTS_STPGEOLOC by user' sy-uname

INTO lv_contents

SEPARATED BY space.

mailtxt-line = lv_contents.

APPEND mailtxt.

CLEAR lv_contents.

ENDIF.

ENDLOOP.

mailtxt-line = 'NOTE: Do not reply to this message.'.

APPEND mailtxt.

mailrec-receiver = it_zshipto_email-zemail.

mailrec-rec_type = 'U'.

APPEND mailrec.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = maildata

document_type = 'RAW'

put_in_outbox = 'X'

commit_work = 'X'

TABLES

object_header = mailtxt

object_content = mailtxt

receivers = mailrec

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 sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CLEAR: mailtxt, mailrec.

REFRESH: mailtxt, mailrec.

ENDLOOP.

CLEAR it_address_status.

REFRESH it_address_status.

ENDIF.

ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
489

before the fubnction modulke check whether the contents are there in mailtxt ...also display the text in report and check.

Hello experts,

I am currently analyzing my code wherein it sends an e-mail message to specified users.

Now, When I checked in tcode scot I noticed that the message body lacks some text or in other

words, incomplete(particularly when a user changes an address. Anyway, below is my code to give you

guys better understanding of my problem.

  • for records that were modified

IF NOT it_address_status[] IS INITIAL.

CLEAR maildata.

maildata-obj_name = 'Record Changed in table ZTS0001'.

maildata-obj_descr = 'Record Changed in table ZTS0001'.

maildata-obj_langu = sy-langu.

LOOP AT it_zshipto_email.

mailtxt-line = 'FYI: Record changed in table ZTS0001'.

APPEND mailtxt.

CLEAR it_address_status.

LOOP AT it_address_status.

IF NOT it_address_status-old_address IS INITIAL AND

NOT it_address_status-new_address IS INITIAL.

CONCATENATE: 'Address of dealer' it_address_status-kunnr

'code' it_address_status-cdseq 'was changed'

'from' it_address_status-old_address 'to'

INTO lv_contents

SEPARATED BY space.

mailtxt-line = lv_contents.

APPEND mailtxt.

CLEAR lv_contents.

CONCATENATE: it_address_status-new_address 'in table'

'ZTS0001 and ZTS_STPGEOLOC by user' sy-uname

INTO lv_contents

SEPARATED BY space.

mailtxt-line = lv_contents.

APPEND mailtxt.

CLEAR lv_contents.

ENDIF.

IF NOT it_address_status-old_person IS INITIAL AND

NOT it_address_status-new_person IS INITIAL.

CONCATENATE: 'Contact person of dealer' it_address_status-kunnr

'code' it_address_status-cdseq 'was changed'

'from' it_address_status-old_person 'to'

it_address_status-new_person 'in table'

'ZTS0001 and ZTS_STPGEOLOC by user' sy-uname

INTO lv_contents

SEPARATED BY space.

mailtxt-line = lv_contents.

APPEND mailtxt.

CLEAR lv_contents.

ENDIF.

IF NOT it_address_status-old_number IS INITIAL AND

NOT it_address_status-new_number IS INITIAL.

CONCATENATE: 'Contact number of dealer' it_address_status-kunnr

'code' it_address_status-cdseq 'was changed'

'from' it_address_status-old_number 'to'

it_address_status-new_number 'in table'

'ZTS0001 and ZTS_STPGEOLOC by user' sy-uname

INTO lv_contents

SEPARATED BY space.

mailtxt-line = lv_contents.

APPEND mailtxt.

CLEAR lv_contents.

ENDIF.

ENDLOOP.

mailtxt-line = 'NOTE: Do not reply to this message.'.

APPEND mailtxt.

mailrec-receiver = it_zshipto_email-zemail.

mailrec-rec_type = 'U'.

APPEND mailrec.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = maildata

document_type = 'RAW'

put_in_outbox = 'X'

commit_work = 'X'

TABLES

object_header = mailtxt

object_content = mailtxt

receivers = mailrec

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 sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CLEAR: mailtxt, mailrec.

REFRESH: mailtxt, mailrec.

ENDLOOP.

CLEAR it_address_status.

REFRESH it_address_status.

ENDIF.

ENDIF.

2 REPLIES 2
Read only

Former Member
0 Likes
490

before the fubnction modulke check whether the contents are there in mailtxt ...also display the text in report and check.

Read only

Former Member
0 Likes
489

Hi Viray,

try to pass only object_content, don't pass object_header. since both are holding the same data, and use only one. and see....

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = maildata

document_type = 'RAW'

put_in_outbox = 'X'

commit_work = 'X'

TABLES

<b>object_header = mailtxt</b>

object_content = mailtxt

receivers = mailrec

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 sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Regards

vijay