Skip to Content
0
Former Member
Mar 23, 2011 at 07:19 AM

send mail step using ooabap

39 Views

Hi guys,

Actually in send mail step i need to add more than 50 characters.I tried with FM and even in workflow.But its allowing only 50 characters.So iam trying using OOABAP.I have done the coding below but still iam unable to receive the mail in SOST.I dont need body(since its optional, i can add later).Please have a look into this code and let me know.

DATA :it_mail TYPE STANDARD TABLE OF zqm_email,

wa_mail TYPE zqm_email.

  • declaration for content

DATA: ig_content TYPE TABLE OF solisti1,

wa_content TYPE solisti1,

w_role(100) TYPE c.

DATA: lo_mailer TYPE REF TO cl_bcs,

lo_document TYPE REF TO cl_document_bcs,

lo_rec_mail TYPE REF TO cl_cam_address_bcs,

lo_error TYPE REF TO cx_bcs,

l_user TYPE uname,

l_string TYPE string,

lv_subject TYPE string,

lv_doc_title TYPE so_obj_des,

lt_table TYPE soli_tab.

LOOP AT it_mail INTO wa_mail.

wa_mail-smtp_addr = 'XXX''.

APPEND wa_mail TO it_mail.

ENDLOOP.

  • Mail Content creation

DATA: w_string1 TYPE string.

CONCATENATE 'Notification of Status Change for Supplier Corrective Action Request (SCAR) #'(007) w_string1 INTO

lv_subject SEPARATED BY space.

&----


  • MAIL GENERATION

----


REFRESH lt_table.

lt_table[] = ig_content[].

TRY.

lo_mailer = cl_bcs=>create_persistent( ).

lo_mailer->set_message_subject( lv_subject ). " Mail Subject

MOVE lv_subject TO lv_doc_title.

lo_document = cl_document_bcs=>create_document( i_type = 'HTM'

i_text = lt_table " Message body

i_subject = lv_doc_title ).

lo_mailer->set_document( lo_document ).

FREE lo_rec_mail.

lo_rec_mail = cl_cam_address_bcs=>create_internet_address( wa_mail-smtp_addr ).

lo_mailer->add_recipient( EXPORTING i_recipient = lo_rec_mail

i_express = abap_true ).

lo_mailer->set_status_attributes( 'N' ). " No read-recipt/delv-note

lo_mailer->send( ).

COMMIT WORK.

CATCH cx_bcs INTO lo_error. " Exception has occurred

ENDTRY.

CLEAR wa_mail.