Application Development 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: 

Error when sending e-mails...

aris_hidalgo
Contributor
0 Kudos

Hello experts,

We are currently testing our report that lets users create new customers and then send e-mails

to specfified user's e-mail address located in a custom table. Now, we always get this error:

Database error for <ADDR_PERS_COMP_COMM_GET> <0>

We cannot pinpoint exactly whatcauses this error. Really need help on this guys and thank you very much.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

How you send the email? use the workplace in SAP or you wrote a customised program to do it?

If you write a customised program, please paste your coding here.

3 REPLIES 3

Former Member
0 Kudos

Hi,

How you send the email? use the workplace in SAP or you wrote a customised program to do it?

If you write a customised program, please paste your coding here.

0 Kudos

Hi Ong,

I am using FM SO_NEW_DOCUMENT_API1. Here is my code:

START-OF-SELECTION.

*----


SELECT * INTO CORRESPONDING FIELDS OF TABLE it_zts0001

FROM zts0001

WHERE kunnr = p_kunnr.

SELECT * FROM zshipto_email

INTO TABLE it_zshipto_email.

*if p_flag = 'A'.

IF p_flag = 'A'.

v_title = 'Add Information'.

SORT it_zts0001 BY cdseq DESCENDING.

READ TABLE it_zts0001 INDEX 1.

IF sy-subrc EQ 0.

v_seq = it_zts0001-cdseq + 1.

ELSE.

v_seq = 1.

ENDIF.

REFRESH it_zts0001.

CLEAR it_zts0001.

MOVE: p_kunnr TO it_zts0001-kunnr,

v_seq TO it_zts0001-cdseq,

p_addr TO it_zts0001-zaddress,

p_pers TO it_zts0001-zcperson,

p_numb TO it_zts0001-zcnumber,

sy-uname TO it_zts0001-zcreated_by,

sy-datum TO it_zts0001-zchanged_date.

MOVE-CORRESPONDING it_zts0001 TO it_zts_stpgeoloc.

APPEND: it_zts0001, it_zts_stpgeoloc.

CLEAR: it_zts0001, it_zts_stpgeoloc.

INSERT zts_stpgeoloc FROM TABLE it_zts_stpgeoloc.

INSERT zts0001 FROM TABLE it_zts0001.

IF sy-subrc EQ 0.

maildata-obj_name = 'New Ship-To parties for processing'.

maildata-obj_descr = 'New Ship-To parties for processing'.

maildata-obj_langu = sy-langu.

*code to send messages for e-mails found in table ZSHIPTO_EMAIL

*message body is dependent on field ZEVENT

LOOP AT it_zshipto_email.

  • for controllers

IF it_zshipto_email-zevent = 1.

mailtxt-line = 'You have new Ship-To parties for processing.'.

APPEND mailtxt.

CLEAR mailtxt.

CONCATENATE: 'Kindly activate the ship-to party in table'

'ZTS0001'

INTO v_contents

SEPARATED BY space.

mailtxt-line = v_contents.

APPEND mailtxt.

CLEAR: mailtxt, v_contents.

APPEND mailtxt.

  • dealer code and name

CONCATENATE: 'Dealer :' p_kunnr '-' p_name1

INTO v_contents

SEPARATED BY space.

mailtxt-line = v_contents.

APPEND mailtxt.

CLEAR: mailtxt, v_contents.

  • ship-to code

CONCATENATE: 'Ship-To:' v_seq

INTO v_contents

SEPARATED BY space.

mailtxt-line = v_contents.

APPEND mailtxt.

CLEAR: mailtxt, v_contents.

  • address

CONCATENATE: 'Address:' p_addr

INTO v_contents

SEPARATED BY space.

mailtxt-line = v_contents.

APPEND mailtxt.

CLEAR: mailtxt, v_contents.

  • contact person

CONCATENATE: 'Contact person:' p_pers

INTO v_contents

SEPARATED BY space.

mailtxt-line = v_contents.

APPEND mailtxt.

CLEAR: mailtxt, v_contents.

  • contact number

CONCATENATE: 'Contact number:' p_numb

INTO v_contents

SEPARATED BY space.

mailtxt-line = v_contents.

APPEND mailtxt.

CLEAR: mailtxt, v_contents.

APPEND mailtxt.

    • for handling cost admins

ELSE.

mailtxt-line = 'You have new Ship-To parties for processing.'.

APPEND mailtxt.

CONCATENATE: 'Kindly assign the geographical location'

'in table ZTS_STPGEOLOC'

INTO v_contents

SEPARATED BY space.

mailtxt-line = v_contents.

APPEND mailtxt.

CLEAR: mailtxt, v_contents.

APPEND mailtxt.

  • dealer code and name

CONCATENATE: 'Dealer :' p_kunnr '-' p_name1

INTO v_contents

SEPARATED BY space.

mailtxt-line = v_contents.

APPEND mailtxt.

CLEAR: mailtxt, v_contents.

  • ship-to code

CONCATENATE: 'Ship-To:' v_seq

INTO v_contents

SEPARATED BY space.

mailtxt-line = v_contents.

APPEND mailtxt.

CLEAR: mailtxt, v_contents.

  • address

CONCATENATE: 'Address:' p_addr

INTO v_contents

SEPARATED BY space.

mailtxt-line = v_contents.

APPEND mailtxt.

CLEAR: mailtxt, v_contents.

  • contact person

CONCATENATE: 'Contact person:' p_pers

INTO v_contents

SEPARATED BY space.

mailtxt-line = v_contents.

APPEND mailtxt.

CLEAR: mailtxt, v_contents.

  • contact number

CONCATENATE: 'Contact number:' p_numb

INTO v_contents

SEPARATED BY space.

mailtxt-line = v_contents.

APPEND mailtxt.

CLEAR: mailtxt, v_contents.

APPEND mailtxt.

ENDIF.

mailrec-receiver = it_zshipto_email-zemail.

TRANSLATE it_zshipto_email-zemail TO LOWER CASE.

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.

WRITE:/ 'Record Added' COLOR 1.

SKIP 1.

WRITE:/05 'Customer Number :', p_kunnr,

/05 'Code :', v_seq,

/05 'Address :', p_addr,

/05 'Contact Person :', p_pers,

/05 'Contact Number :', p_numb.

ENDIF.

0 Kudos

when you code as below:

mailrec-receiver = it_zshipto_email-zemail.

TRANSLATE it_zshipto_email-zemail TO LOWER CASE.

mailrec-rec_type = 'U'.

APPEND mailrec.

Are you expecting the every record you select in SELECT * FROM zshipto_email

INTO TABLE it_zshipto_email to be inside the mailrec-receiver?

I think you did the wrong thing, if you wish to append all the email inside it_zshipto_email, you need to loop your internal table as below.

LOOP at it_zshipto_email.

mailrec-receiver = it_zshipto_email-zemail.

TRANSLATE it_zshipto_email-zemail TO LOWER CASE.

mailrec-rec_type = 'U'.

APPEND mailrec.

ENDLOOP.

Hope it solve your problem.

Message was edited by: ong rukawaw

Message was edited by: ong rukawaw