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: 

Sender in the mail

Former Member
0 Kudos
694

Hi !

I have an requiremnet to add the sender of the mailer which is most likly hard core i. abc@*******in the Call Function

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

Please guide .

Regards

Sheetal

1 ACCEPTED SOLUTION

former_member183804
Active Contributor
0 Kudos
427

Hello Sheetal,

in case the classes Cl_Bcs, cl_Document_Bcs, cl_Cam_Address_Bcs are available in your system/ release then try these. Cl_Bcs has a Set_Sender() method which may be a solution to your requirement.

Hope this helps

Klaus

13 REPLIES 13

manthanraja
Active Participant
0 Kudos
427

hi sheetal

use this code


REPORT ZSEND .

TABLES: KNA1.

* data for send function 
DATA DOC_DATA  LIKE SODOCCHGI1. 
DATA OBJECT_ID LIKE SOODK. 
DATA OBJCONT   LIKE SOLI OCCURS 10 WITH HEADER LINE. 
DATA RECEIVER  LIKE SOMLRECI1 OCCURS 1 WITH HEADER LINE.

SELECT * FROM KNA1 WHERE ANRED LIKE 'C%'. 
  WRITE:/ KNA1-KUNNR, KNA1-ANRED.

* send data internal table 
  CONCATENATE KNA1-KUNNR KNA1-ANRED 
                         INTO OBJCONT-LINE SEPARATED BY SPACE.

  APPEND OBJCONT. 
ENDSELECT.

* insert receiver (sap name) 
  REFRESH RECEIVER. 
  CLEAR RECEIVER. 
  MOVE: SY-UNAME TO RECEIVER-RECEIVER, 
        'X'      TO RECEIVER-EXPRESS, 
        'B'      TO RECEIVER-REC_TYPE. 
  APPEND RECEIVER.

* insert mail description 
  WRITE 'Sending a mail through abap' 
                 TO DOC_DATA-OBJ_DESCR.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1' 
     EXPORTING 
          DOCUMENT_DATA              = DOC_DATA 
     IMPORTING 
          NEW_OBJECT_ID              = OBJECT_ID 
     TABLES 
          OBJECT_CONTENT             = OBJCONT 
          RECEIVERS                  = RECEIVER 
     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.

BR

Manthan.

0 Kudos
427

Hi !

In the given solution where we are mentioning sender mail as default it is picking my one only .....

Please guide

Regards

Sheetal

former_member183804
Active Contributor
0 Kudos
428

Hello Sheetal,

in case the classes Cl_Bcs, cl_Document_Bcs, cl_Cam_Address_Bcs are available in your system/ release then try these. Cl_Bcs has a Set_Sender() method which may be a solution to your requirement.

Hope this helps

Klaus

0 Kudos
427

Hi !

Not able to understand the given solution ..m required to add sender in the mail from abap and currently using the Call Function :SO_NEW_DOCUMENT_SEND_API1

FORM MAIL USING ERRORCODE TYPE I.

  • Recipients

SELECT SINGLE PARAMVALUE

FROM ZIBHR_PARAMS

INTO LV_MAIL1

WHERE PARAMCODE EQ 'MAIL_ID_EXCP_1'.

SELECT SINGLE PARAMVALUE

FROM ZIBHR_PARAMS

INTO LV_MAIL2

WHERE PARAMCODE EQ 'MAIL_ID_EXCP_2'.

IF LV_MAIL1 NE ''.

lt_mailrecipients-rec_type = 'U'.

lt_mailrecipients-receiver = LV_MAIL1.

APPEND lt_mailrecipients .

CLEAR lt_mailrecipients .

ENDIF.

IF LV_MAIL2 NE ''.

lt_mailrecipients-rec_type = 'U'.

lt_mailrecipients-receiver = LV_MAIL2.

APPEND lt_mailrecipients .

CLEAR lt_mailrecipients .

ENDIF.

IF LV_MAIL1 NE '' AND LV_MAIL2 NE ''.

lt_mailrecipients-rec_type = 'U'.

lt_mailrecipients-receiver = at .....com.

APPEND lt_mailrecipients .

CLEAR lt_mailrecipients .

ENDIF.

IF ERRORCODE = '1'.

  • Subject.

lt_mailsubject-obj_name = 'TEST'.

lt_mailsubject-obj_langu = sy-langu.

lt_mailsubject-obj_descr = 'Biometric INET Time Correction Upload Program Exception <001>'.

lt_mailtxt = 'Biometric INET Time Correction Upload Program. Missing parameters in ZIBHR_PARAMS table Please contact SAP IT HR Team for further action'.

APPEND lt_mailtxt.

ELSEIF ERRORCODE = '2'.

lt_mailsubject-obj_name = 'TEST'.

lt_mailsubject-obj_langu = sy-langu.

lt_mailsubject-obj_descr = 'Biometric INET Time Correction Program Exception <002>'.

lt_mailtxt = 'Biometric INET Time Correction Upload Program. Program did not find any file to upload in the directory.'.

APPEND lt_mailtxt.

ENDIF.

  • Mail Contents

IF t_error_ind EQ 'Y'.

lt_mailtxt = 'Please note that some errors have been encountered while loading the records. Please check error log for further details'.

APPEND lt_mailtxt.

ENDIF.

  • Send Mail

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = lt_mailsubject

TABLES

object_content = lt_mailtxt

receivers = lt_mailrecipients

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

COMMIT WORK.

  • Push mail out from SAP outbox

SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.

ENDIF.

refresh lt_mailtxt.

ENDFORM. "MAIL

Edited by: sheetal Gulati on Mar 8, 2010 5:22 AM

Former Member
0 Kudos
427

Hello,

Try using the FM 'SO_DOCUMENT_SEND_API1'. You will have to pass all the same parameters as you are passing in the current function module. In this function module in the importing parameters there is sender_address , in this just send the email address of the sender and in the parameter sender_address_type pass 'SMTP'. This will solve your issue.

Regards,

Sachin

0 Kudos
427

Thanks Sachin,

Thanks for the solution .....but i dont know why m not able to use this , every time it is giving some errors .

Regards

Sheetal

0 Kudos
427

Hello,

Could let us know the error that you are receiving. Is it at the time of execution or is it some syntax error that you are receiving?

Regards,

Sachin

0 Kudos
427

Hi !

It was syntax error ..can u tell me what is PACKING_LIST

Regards

Sheetal

0 Kudos
427

Hi check this link

">

Regards,

Aby

0 Kudos
427

Hi,

If you check the FM documentation it will explain each of the parameter being used it this function module.

Say you need to send a document as an attachment, you will define its attributes in this table parameter.

Check the following as given in the documentation

PACKING_LIST This table requires information about how the data in the tables OBJECT_HEADER, CONTENTS_BIN and CONTENTS_TXT are to be distributed to the documents and its attachments. The first row is for the document, the following rows are each for one attachment TRANSF_BIN If this flag is activated ('X'), the table entry describes an object stored in binary format. The content of the object is in the table CONTENTS_BIN. If the flag is not activated, the object content is in the table CONTENTS_TXT in ASCII format. HEAD_START Requires the start row of the table OBJECT_HEADER, as of which the specific header data of the object is stored. HEAD_NUM Requires the number of rows in the table OBJECT_HEADER that contain specific header data for the object. The relevant rows are arranged in a block and defined uniquely together with the entry in HEAD_START. BODY_START Requires the start row of the table dependent on the TRANSF_BIN flag as of which the object content is stored. BODY_NUM Requires the number of rows of the table dependent on the flag TRANSFER_BIN, which contain the object content. The relevant rows are arranged in a block and defined uniquely together with the entry in HEAD_START. DOC_TYPE Attachment type. In the first row of the table, this field is not used. OBJ_NAME Attachment name. In the first row of the table, this field is not used. OBJ_DESCR Attachment title (short description). In the first row of the table, this field is not used. OBJ_LANGU Attachment language. In the first row of the table, this fiels is not used. DOC_SIZE Attachment size in bytes. For PC objects, the size of the relevant file should be entered here. For RAW and SCR objects, the size is the "length of the last page" + "number of other rows multiplied by 255". In the first row of the table, this field is not used.

Regards

Sachin

0 Kudos
427

Hi !

I have no issue in reciver mail id but having the problem to hardcore sender mail id .

Sheetal

0 Kudos
427

hi sheetal , I would advise you to use CL_BCS .. along with my above answer ..

Also you could refer the following fora for further ideas on the same ..

The first link will surely solve your issue !!

[Highly recommended|;

and [LINK|;

best regards

Manthan.

Former Member
0 Kudos
427

Hi,

To Change the Sender Email ID,

Try to Use the object oriented technique where you can give the Hardcoded Value for the Sender Mail ID,

** Sender addess*

l_sender = cl_sapuser_bcs=>create( sy-uname ).

call method l_send_request->set_sender

exporting

i_sender = l_sender.

For the Entire Coode you can refer the blow link which will be helpful,

[http://wiki.sdn.sap.com/wiki/display/Snippets/SendMailhavingMultipleFilesasAttachmentusingobjectorientedtechnique]

Regards,

Sathish