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: 

Reg FM SO_NEW_DOCUMENT_ATT_SEND_API1

Former Member
0 Kudos

Hi Folks,

   I am using the FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send the excel attachement to the shared distribution list.

if iam using the distribution list i am getting mail in SBWP inbox, but I am not able to see the same in my mail box(outlook).

Do i get the same in my mail box(outlook) or not.

Please suggest me i want the same mail in my mail box .

under it_adr6 i have all the mailids of distribution list.

LOOP AT it_adr6 INTO wa_adr6.
     reclist-receiver = wa_adr6-smtp_addr.
     reclist-rec_type = 'C'.
*  reclist-express = 'X'.
*  reclist-COM_TYPE = 'INT'.
*  reclist-NOTIF_DEL = 'X'.
*  reclist-NOTIF_NDEL = 'X'.
     APPEND reclist.
   CLEAR wa_adr6.
  ENDLOOP.


Please advice me asap.


Thanks,

Smriti

1 ACCEPTED SOLUTION

former_member196651
Contributor
0 Kudos

One more thing. Test this FM directly from SE37 using rec_type as 'U'.

Regards,

Abijith

18 REPLIES 18

former_member196651
Contributor
0 Kudos

Hai Smriti,

Use rec_type as 'U' for sending mail to external mail IDs. I had cut & pasted the code

given above and changed the rec_type.

LOOP AT it_adr6 INTO wa_adr6.

     reclist-receiver = wa_adr6-smtp_addr.

     reclist-rec_type = 'U'.

*  reclist-express = 'X'.

*  reclist-COM_TYPE = 'INT'.

*  reclist-NOTIF_DEL = 'X'.

*  reclist-NOTIF_NDEL = 'X'.

     APPEND reclist.

   CLEAR wa_adr6.

  ENDLOOP.


Please check & confirm if this works.


Regards,

Abijith

0 Kudos

Hi ,

I already tried it is not working..

Please suggest.

Thanks..

Former Member
0 Kudos

and I am getting sy-subrc = 6. in my FM but when i am checking my SWBP transaction Inbox iam getting mail with attachment.

x_error   = 6.

Please advice help.

Thanks,

smriti

0 Kudos

Hi Smriti,

Please put the break point on FM  SO_DOC_INSERT_WITH_ORIG_API1 and check below routine!

perform sopr_select(sapfsso0) using profile
                                       rcode.
   if rcode ne ok.
     raise x_error.
   endif.

former_member196651
Contributor
0 Kudos

Hi Smriti,

This worked for me. This send mail to my official id in Lotus notes.

Regards,

Abijith

former_member196651
Contributor
0 Kudos

One more thing. Test this FM directly from SE37 using rec_type as 'U'.

Regards,

Abijith

0 Kudos

Hi Abijith,

  Could you please share your sample code so that will check where i doing wrong..

and please find my code below and suggest if iam doing any wrong.

wa_log-zrecord = 'yyyy;xyz12;0020;0010;'.
   wa_log-zsf = 'SUCCESS'.
   wa_log-zmsg = ''.
   APPEND wa_log TO it_log.
   CLEAR wa_log.

   wa_log-zrecord = 'xxxx;abcdef;0010;0010;'.
   wa_log-zsf = 'fAILED'.
   wa_log-zmsg = 'ENTERED DATA DOES NOT EXISTS'.
   APPEND wa_log TO it_log.
   CLEAR wa_log.



*&---------------------------------------------------------------------*
*&      Form  SEND_MAIL
*&---------------------------------------------------------------------*
*       Send Email
*----------------------------------------------------------------------*

FORM send_mail.

   DATA: objpack   LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
   DATA: objhead   LIKE solisti1 OCCURS 1 WITH HEADER LINE.
   DATA: objbin    LIKE  solisti1 OCCURS 10 WITH HEADER LINE.                             "solix OCCURS 10 WITH HEADER LINE.
   DATA: objtxt    LIKE solisti1 OCCURS 10 WITH HEADER LINE.
   DATA: reclist   LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
   DATA: doc_chng  LIKE sodocchgi1.
   DATA: tab_lines LIKE sy-tabix.
   DATA: l_num(3).
   DATA: subj_date(10) TYPE c.

* Mail Subject
*  CONCATENATE lv_date+6(2) '-' lv_date+4(2) '-' lv_date+0(4) INTO subj_date.
   CONCATENATE 'SAP APO ZRAMPPIPO Report ' lv_date INTO doc_chng-obj_descr SEPARATED BY space.

* Mail Contents
   objtxt = 'Dear User,'.
   APPEND objtxt.

   CLEAR objtxt.
   APPEND objtxt.

   CONCATENATE 'Please find the attached ZRAMPIPO Report for ' lv_date INTO objtxt SEPARATED BY space.              " Mail Contents
   APPEND objtxt.

   CLEAR objtxt.
   APPEND objtxt.

   objtxt = 'Thanks & Regards,'.
   APPEND objtxt.

   objtxt = 'Neelima'.
   APPEND objtxt.

   DESCRIBE TABLE objtxt LINES tab_lines.
   READ TABLE objtxt INDEX tab_lines.
   doc_chng-doc_size = ( tab_lines - 1 ) * 255 + strlen( objtxt ).
   doc_chng-obj_langu  = sy-langu.
   doc_chng-obj_name   = 'OFFER'.
*      doc_chng-obj_descr  = ld_mtitle.
*      gs_doc_chng-sensitivty = 'f'.

* Packing List For the E-mail Body
   objpack-transf_bin   = space.
   objpack-head_start = 1.
   objpack-head_num   = 0.
   objpack-body_start = 1.
   objpack-body_num   = tab_lines.
   objpack-doc_type   = 'RAW'.
   APPEND objpack.

* Creation of the Document Attachment
   CONCATENATE 'Record' 'Success/Fail' 'Message'

       INTO objbin-line SEPARATED BY cl_abap_char_utilities=>horizontal_tab.

   APPEND objbin.

   CLEAR objbin.

   CONCATENATE objbin cl_abap_char_utilities=>newline INTO objbin.

   APPEND objbin.

   CLEAR objbin.



   LOOP AT it_log INTO wa_log.

     CONCATENATE wa_log-zrecord wa_log-zsf wa_log-zmsg

     INTO objbin-line SEPARATED BY cl_abap_char_utilities=>horizontal_tab.

     APPEND objbin.

     CLEAR objbin.

     CONCATENATE objbin cl_abap_char_utilities=>newline INTO objbin.

     APPEND objbin.

     CLEAR objbin.

     CLEAR wa_log.

   ENDLOOP.


   DESCRIBE TABLE objbin LINES tab_lines.
   objhead = 'Excel_Details'.
   APPEND objhead.

* Packing List For the E-mail Attachment
   objpack-transf_bin = 'X'.
   objpack-head_start = 1.
   objpack-head_num   = 0.
   objpack-body_start = 1.
   objpack-body_num = tab_lines.
   CONCATENATE 'Excel_Details' lv_date INTO objpack-obj_descr SEPARATED BY space.
   objpack-doc_type = 'XLS'.
    OBJPACK-OBJ_NAME   = 'XLS'.
   objpack-doc_size = tab_lines * 255.
   APPEND objpack.
***** Distribution list*****

   TYPES: BEGIN OF ty_usr21,
          bname TYPE xubname,
          persnumber TYPE ad_persnum,
          addrnumber TYPE ad_addrnum,
          END OF ty_usr21.

   TYPES : BEGIN OF ty_adr6,
           addrnumber TYPE ad_addrnum,
           persnumber TYPE ad_persnum,
           date_from TYPE ad_date_fr,
           consnumber TYPE ad_consnum,
           smtp_addr TYPE ad_smtpadr,
          END OF ty_adr6.

   DATA: wa_usr21 TYPE ty_usr21,
         it_usr21 TYPE STANDARD TABLE OF ty_usr21,
         wa_adr6 TYPE ty_adr6,
         it_adr6 TYPE STANDARD TABLE OF ty_adr6.

   DATA: it_distlist TYPE STANDARD TABLE OF sodlienti1,
         wa_distlist TYPE sodlienti1 .


   CALL FUNCTION 'SO_DLI_READ_API1'
     EXPORTING
       dli_name                   = ''DEFG'
       shared_dli                 = 'X'
     TABLES
       dli_entries                = it_distlist
     EXCEPTIONS
       dli_not_exist              = 1
       operation_no_authorization = 2
       parameter_error            = 3
       x_error                    = 4
       OTHERS                     = 5.

   IF it_distlist[] IS NOT INITIAL.
     SELECT bname persnumber addrnumber FROM usr21 INTO TABLE it_usr21
       FOR ALL ENTRIES IN it_distlist
       WHERE bname = it_distlist-member_nam.
   ENDIF.
   IF it_usr21[] IS NOT INITIAL.
     SELECT persnumber addrnumber date_from consnumber smtp_addr FROM adr6
            INTO TABLE it_adr6
            FOR ALL ENTRIES IN it_usr21
            WHERE persnumber = it_usr21-persnumber AND
                  addrnumber = it_usr21-addrnumber.
   ENDIF.

**********





* Target Recipent
*  CLEAR reclist.
   LOOP AT it_adr6 INTO wa_adr6.
     reclist-receiver = wa_adr6-smtp_addr.
     reclist-rec_type = 'U'.
*  reclist-express = 'X'.
*    T_RECEIVERS-REC_TYPE = 'U'.
*  reclist-COM_TYPE = 'INT'.
*  reclist-NOTIF_DEL = 'X'.
*  reclist-NOTIF_NDEL = 'X'.
     APPEND reclist.
     CLEAR wa_distlist.
   ENDLOOP.

* Sending the document
   CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
     EXPORTING
       document_data              = doc_chng
       put_in_outbox              = 'X'
       commit_work                = 'X'
*   IMPORTING
*     SENT_TO_ALL                      = 'X'
*     NEW_OBJECT_ID                    =
     TABLES
       packing_list               = objpack
       object_header              = objhead
       contents_bin               = objbin
       contents_txt               = objtxt
*     contents_hex               = objbin
       receivers                  = reclist
     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.
     WRITE:/ 'mail sent'.
   ENDIF.



Thanks,

Smriti

0 Kudos

Hi Folks,

PLease suggest me where iam going wrong by the above code.

My program is executed successfully and sy-subrc = 0. but mail is not going to the respective mail id.

if the same i am checking from t-code SOST  it is showing error as

Cannot process message; no node determined for xxxx@yyyy.com"

please advice me , appreciate your help ..

Thanks,

smriti

0 Kudos

Hi Smirti

If you are able to see SOST code the email with error. Then its configuration in SCOT which is the issue.

Please ask your basis team to properly maintain SCOT settings else you can read sap note 129950

for the same and maintain it yourself

Nabheet

0 Kudos

Hi Smriti,

I have used services of class CL_BCS to successfully send emails internally with attachments. If you need it, please reply.

BR.

0 Kudos

Hi,

Use CL_BCS class, try to execute the program BCS_EXAMPLE_5 and see whether any mail is shown in SOST transaction. The program uses CL_BCS class with MS Word attachment.

Thanks & Regards

Bala Krishna

0 Kudos

Hi Everybody,

Thanks for your instant reply,. After settings in SCOT iam able to send and recieve mails to external id..

1.    but it is taking quite long time , even after i added the following code after sy-subrc of the FM.

if ys-subrc = 0.


     submit rsconn01 with mode = 'INT' and return.

endif.


2. and one more issue is in my excel file. for the first column value long empty space is coming before the value should be like( Fe01;sunset;0020;0090)

but appearing as

                                                                     Fe01;sunset;0020;0090;


please advice how can avoid the empty space before the value for all the records of first column.

appreciate your help..


Thanks,

Smriti

Former Member
0 Kudos

Hi,

This is a basis issue. Check the transaction SCOT and see the SMTP node configurations. Ask your basis guy to set it up.

In Transaction scot, goto SMTP node maintainance, and check 'Node in use' check box and enter '*' in the address area. Save the settings, then log off and login. It should work fine.

Hope this is helpful.

Regards,

Thiru.

0 Kudos

Hi All,

   yes that was basis issue, after the SCOT configuration it has been resolved.

one more issue is in my excel file. for the first column value long empty space is coming before the value should be like( Fe01;sunset;0020;0090)

but appearing as

                                                                     Fe01;sunset;0020;0090;(blank space before )


please advice how can avoid the empty space before the value for all the records of first column.

appreciate your help..


Thanks,

Smriti

0 Kudos

Hi Smriti,

Since the issue seems very specific, please debug and see how the values are getting populated in the internal table which you are passing for the email.

BR.

0 Kudos

Hi Ankit,

   In debugging mode if iam checking the internla table which we are passing to the FM the data is coming and appears to be correct(no blank space is coming) but when we check the mail attachment the blank space is coming before the first value of all the records.

Please advice me

Thanks,

Smriti

0 Kudos

Hi Smriti,

Please search on the lines of File format and play around with it to see if your issue is resolved.

As mentioned by me, i have used CL_BCS services and used attachment of type 'RAW' file format. It worked well for me.

BR.

0 Kudos

Hi All,

Thanks for your help,.

solved ..