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: 

e-mailing: How to sent out an email to the Managers OUTLOOK express account

Former Member
0 Kudos

Hi Experts,

System is ECC6.0.

I hv requirement that, the sales orders comes from EDI into SAP. If there is a error in material (like,

non-sellable, not existing etc.), I need to trap this issue/error.....................fine, I did it and working fine.

But, in next step, I need to send out an email to the manager to his/her OUTLOOOK express(NOT work flow account) email account"s inbox, with a standard specified format!!!!

I do NOT think, work flow is necessorily involved here in this scenario!!!

So, let me know that,

1) Is WORK FLOW involvment i there?

2) How to get it done that, sending out email to OUTLOOK express account with a standard format

3) Any FMs, piece of code

replies appreciated.

Edited by: SAP ABAPer on Sep 6, 2008 3:34 PM

Edited by: SAP ABAPer on Sep 6, 2008 3:35 PM

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

Hello

I can offer two proposals:

1) Standard report RSEIDOCA is used to actively monitor IDoc processing.

This report can be scheduled in background and reports failed IDocs. Unfortunately SAP did not offer e-mail notification together with this report which is really a shortcoming. However, I have written a modified version of this report which allows to send e-mails (see below).

2) Another scenario we are using is to replace wrong partners/materials with dummy partners or materials ensuring that the IDoc will be processed under all circumstances. In this case we set the Purchase order number supplement (sales order -> header -> tabstrip Order Data: field VBAK-BSTZD) = 'ERR'.

Using a condition (transaction VOFM ) we trigger an ORDRSP IDoc if a new sales order has BSTZD = 'ERR'. This IDoc is forwared to SAP-XI and translated into an e-mail to the customer service.

The crucial parts of my report ZRSEIDOCA are shown below (adjust selection screen and notification routine):


...*    perform show_act_moni.
**    PERFORM send_notification.
    PERFORM _send_email_notification.
    MESSAGE s596.
  ELSE." keine Benachrichtigung
    MESSAGE s597.
  ENDIF.


*&---------------------------------------------------------------------*
*&      Form  _SEND_NOTIFICATION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM _send_email_notification.
* define local data
* All activities done via facade CL_BCS!

  DATA: lo_send_request       TYPE REF TO cl_bcs.
  DATA: lt_text               TYPE bcsy_text.
  DATA: lo_document           TYPE REF TO cl_document_bcs.
  DATA: lo_sender             TYPE REF TO cl_sapuser_bcs.
  DATA: lo_recipient          TYPE REF TO if_recipient_bcs.
  DATA: lo_bcs_exception      TYPE REF TO cx_bcs.
  DATA: lx_sent_to_all        TYPE os_boolean.

  DATA: ls_edidc              TYPE edidc,
        lo_idoc               TYPE REF TO zcl_idoc,
        lif_idoc              TYPE REF TO zif_idoc,
        ls_text               TYPE soli,
        ld_text(50)           TYPE c,
        ld_subject            TYPE so_obj_des,
        ld_date(10)           TYPE c,
        ld_time(8)            TYPE c.

  TYPES: BEGIN OF ty_s_idocdata.
  INCLUDE TYPE vbak AS vbak RENAMING WITH SUFFIX _vbak.
  INCLUDE TYPE kna1 AS kna1 RENAMING WITH SUFFIX _kna1.
  TYPES: END OF ty_s_idocdata.
  DATA: ls_idocdata   TYPE ty_s_idocdata.


  TRY.
*     -------- create persistent send request ------------------------
      lo_send_request = cl_bcs=>create_persistent( ).

*     -------- create and set document -------------------------------
*     create document from internal table with text
**      APPEND 'Hello world!' TO lt_text.
**      lo_document = cl_document_bcs=>create_document(
**                      i_type    = 'RAW'
**                      i_text    = lt_text
**                      i_length  = '12'
**                      i_subject = 'test created by ZRSEIDOCA' ).

      ld_subject = 'IDoc Monitoring'.
      WRITE syst-datum TO ld_date DD/MM/YYYY.
      WRITE syst-uzeit TO ld_time.
      CONCATENATE ld_subject syst-slset
        INTO ld_subject SEPARATED BY space.
      CONCATENATE ld_subject ':' INTO ld_subject.
      CONCATENATE ld_subject ld_date 'at' ld_time
        INTO ld_subject SEPARATED BY space.

      LOOP AT i_edidc INTO ls_edidc.
        " Create IDoc instance
        CLEAR: lo_idoc,
               ls_idocdata.
        lo_idoc = zcl_idoc=>create_by_idoc_control( ls_edidc ).
        IF ( lo_idoc IS BOUND ).
          lif_idoc ?= lo_idoc.

          CALL METHOD lif_idoc->get_specific_data
            CHANGING
              c_data = ls_idocdata.
        ELSE.
        ENDIF.



        WRITE ls_edidc-docnum TO ls_text-line NO-ZERO.
        CONDENSE ls_text-line.

        IF ( ls_idocdata-vbak IS NOT INITIAL ).
          CONCATENATE 'POnumber' ls_idocdata-bstnk_vbak
            INTO ld_text SEPARATED BY '='.
          CONCATENATE ls_text-line ld_text
            INTO ls_text-line SEPARATED BY space.

          WRITE ls_idocdata-bstdk_vbak TO ld_text DD/MM/YYYY.
          CONCATENATE 'POdate' ld_text
            INTO ld_text SEPARATED BY '='.
          CONCATENATE ls_text-line ld_text
            INTO ls_text-line SEPARATED BY space.

          IF ( ls_idocdata-kunnr_vbak IS NOT INITIAL ).
            CONCATENATE 'Customer' ls_idocdata-kunnr_vbak
              INTO ld_text SEPARATED BY '='.
            CONCATENATE ls_text-line ld_text
              INTO ls_text-line SEPARATED BY space.
          ENDIF.

          IF ( ls_idocdata-name1_kna1 IS NOT INITIAL ).
            CONCATENATE '(' ls_idocdata-name1_kna1 ')'
              INTO ld_text.
            CONCATENATE ls_text-line ld_text
              INTO ls_text-line SEPARATED BY space.
          ENDIF.
        ENDIF.

        APPEND ls_text TO lt_text.
      ENDLOOP.
      lo_document = cl_document_bcs=>create_document(
                      i_type    = 'RAW'
                      i_text    = lt_text
**                      i_length  = '12'
                      i_subject = ld_subject ).




*     add document to send request
      CALL METHOD lo_send_request->set_document( lo_document ).

*     --------- set sender -------------------------------------------
*     note: this is necessary only if you want to set the sender
*           different from actual user (SY-UNAME). Otherwise sender is
*           set automatically with actual user.

      lo_sender = cl_sapuser_bcs=>create( sy-uname ).
      CALL METHOD lo_send_request->set_sender
        EXPORTING
          i_sender = lo_sender.

*     --------- add recipient (e-mail address) -----------------------
*     create recipients - please replace e-mail address !!!
      LOOP AT o_email.
        lo_recipient = cl_cam_address_bcs=>create_internet_address(
                                          o_email-low ).

*       add recipient with its respective attributes to send request
        CALL METHOD lo_send_request->add_recipient
          EXPORTING
            i_recipient = lo_recipient
            i_express   = 'X'.
      ENDLOOP.




*     ---------- send document ---------------------------------------
      TRY.
          CALL METHOD lo_send_request->set_status_attributes
            EXPORTING
              i_requested_status = 'N'  " suppress delivery confirmation
              i_status_mail      = 'E'.
        CATCH cx_send_req_bcs .
      ENDTRY.

      TRY.
          CALL METHOD lo_send_request->set_send_immediately
            EXPORTING
              i_send_immediately = 'X'.
        CATCH cx_send_req_bcs .
      ENDTRY.


      CALL METHOD lo_send_request->send(
        EXPORTING
          i_with_error_screen = 'X'
        RECEIVING
          result              = lx_sent_to_all ).
      IF lx_sent_to_all = 'X'.
        WRITE text-003.
      ENDIF.

      COMMIT WORK.

* -----------------------------------------------------------
* *                     exception handling
* -----------------------------------------------------------
* * replace this very rudimentary exception handling
* * with your own one !!!
* -----------------------------------------------------------
    CATCH cx_bcs INTO lo_bcs_exception.
      WRITE: text-001.
      WRITE: text-002, lo_bcs_exception->error_type.
      EXIT.

  ENDTRY.

ENDFORM.

Regards

Uwe

3 REPLIES 3

Former Member
0 Kudos

Hi,

Pls check out these links-

Regards

Lekha

uwe_schieferstein
Active Contributor
0 Kudos

Hello

I can offer two proposals:

1) Standard report RSEIDOCA is used to actively monitor IDoc processing.

This report can be scheduled in background and reports failed IDocs. Unfortunately SAP did not offer e-mail notification together with this report which is really a shortcoming. However, I have written a modified version of this report which allows to send e-mails (see below).

2) Another scenario we are using is to replace wrong partners/materials with dummy partners or materials ensuring that the IDoc will be processed under all circumstances. In this case we set the Purchase order number supplement (sales order -> header -> tabstrip Order Data: field VBAK-BSTZD) = 'ERR'.

Using a condition (transaction VOFM ) we trigger an ORDRSP IDoc if a new sales order has BSTZD = 'ERR'. This IDoc is forwared to SAP-XI and translated into an e-mail to the customer service.

The crucial parts of my report ZRSEIDOCA are shown below (adjust selection screen and notification routine):


...*    perform show_act_moni.
**    PERFORM send_notification.
    PERFORM _send_email_notification.
    MESSAGE s596.
  ELSE." keine Benachrichtigung
    MESSAGE s597.
  ENDIF.


*&---------------------------------------------------------------------*
*&      Form  _SEND_NOTIFICATION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM _send_email_notification.
* define local data
* All activities done via facade CL_BCS!

  DATA: lo_send_request       TYPE REF TO cl_bcs.
  DATA: lt_text               TYPE bcsy_text.
  DATA: lo_document           TYPE REF TO cl_document_bcs.
  DATA: lo_sender             TYPE REF TO cl_sapuser_bcs.
  DATA: lo_recipient          TYPE REF TO if_recipient_bcs.
  DATA: lo_bcs_exception      TYPE REF TO cx_bcs.
  DATA: lx_sent_to_all        TYPE os_boolean.

  DATA: ls_edidc              TYPE edidc,
        lo_idoc               TYPE REF TO zcl_idoc,
        lif_idoc              TYPE REF TO zif_idoc,
        ls_text               TYPE soli,
        ld_text(50)           TYPE c,
        ld_subject            TYPE so_obj_des,
        ld_date(10)           TYPE c,
        ld_time(8)            TYPE c.

  TYPES: BEGIN OF ty_s_idocdata.
  INCLUDE TYPE vbak AS vbak RENAMING WITH SUFFIX _vbak.
  INCLUDE TYPE kna1 AS kna1 RENAMING WITH SUFFIX _kna1.
  TYPES: END OF ty_s_idocdata.
  DATA: ls_idocdata   TYPE ty_s_idocdata.


  TRY.
*     -------- create persistent send request ------------------------
      lo_send_request = cl_bcs=>create_persistent( ).

*     -------- create and set document -------------------------------
*     create document from internal table with text
**      APPEND 'Hello world!' TO lt_text.
**      lo_document = cl_document_bcs=>create_document(
**                      i_type    = 'RAW'
**                      i_text    = lt_text
**                      i_length  = '12'
**                      i_subject = 'test created by ZRSEIDOCA' ).

      ld_subject = 'IDoc Monitoring'.
      WRITE syst-datum TO ld_date DD/MM/YYYY.
      WRITE syst-uzeit TO ld_time.
      CONCATENATE ld_subject syst-slset
        INTO ld_subject SEPARATED BY space.
      CONCATENATE ld_subject ':' INTO ld_subject.
      CONCATENATE ld_subject ld_date 'at' ld_time
        INTO ld_subject SEPARATED BY space.

      LOOP AT i_edidc INTO ls_edidc.
        " Create IDoc instance
        CLEAR: lo_idoc,
               ls_idocdata.
        lo_idoc = zcl_idoc=>create_by_idoc_control( ls_edidc ).
        IF ( lo_idoc IS BOUND ).
          lif_idoc ?= lo_idoc.

          CALL METHOD lif_idoc->get_specific_data
            CHANGING
              c_data = ls_idocdata.
        ELSE.
        ENDIF.



        WRITE ls_edidc-docnum TO ls_text-line NO-ZERO.
        CONDENSE ls_text-line.

        IF ( ls_idocdata-vbak IS NOT INITIAL ).
          CONCATENATE 'POnumber' ls_idocdata-bstnk_vbak
            INTO ld_text SEPARATED BY '='.
          CONCATENATE ls_text-line ld_text
            INTO ls_text-line SEPARATED BY space.

          WRITE ls_idocdata-bstdk_vbak TO ld_text DD/MM/YYYY.
          CONCATENATE 'POdate' ld_text
            INTO ld_text SEPARATED BY '='.
          CONCATENATE ls_text-line ld_text
            INTO ls_text-line SEPARATED BY space.

          IF ( ls_idocdata-kunnr_vbak IS NOT INITIAL ).
            CONCATENATE 'Customer' ls_idocdata-kunnr_vbak
              INTO ld_text SEPARATED BY '='.
            CONCATENATE ls_text-line ld_text
              INTO ls_text-line SEPARATED BY space.
          ENDIF.

          IF ( ls_idocdata-name1_kna1 IS NOT INITIAL ).
            CONCATENATE '(' ls_idocdata-name1_kna1 ')'
              INTO ld_text.
            CONCATENATE ls_text-line ld_text
              INTO ls_text-line SEPARATED BY space.
          ENDIF.
        ENDIF.

        APPEND ls_text TO lt_text.
      ENDLOOP.
      lo_document = cl_document_bcs=>create_document(
                      i_type    = 'RAW'
                      i_text    = lt_text
**                      i_length  = '12'
                      i_subject = ld_subject ).




*     add document to send request
      CALL METHOD lo_send_request->set_document( lo_document ).

*     --------- set sender -------------------------------------------
*     note: this is necessary only if you want to set the sender
*           different from actual user (SY-UNAME). Otherwise sender is
*           set automatically with actual user.

      lo_sender = cl_sapuser_bcs=>create( sy-uname ).
      CALL METHOD lo_send_request->set_sender
        EXPORTING
          i_sender = lo_sender.

*     --------- add recipient (e-mail address) -----------------------
*     create recipients - please replace e-mail address !!!
      LOOP AT o_email.
        lo_recipient = cl_cam_address_bcs=>create_internet_address(
                                          o_email-low ).

*       add recipient with its respective attributes to send request
        CALL METHOD lo_send_request->add_recipient
          EXPORTING
            i_recipient = lo_recipient
            i_express   = 'X'.
      ENDLOOP.




*     ---------- send document ---------------------------------------
      TRY.
          CALL METHOD lo_send_request->set_status_attributes
            EXPORTING
              i_requested_status = 'N'  " suppress delivery confirmation
              i_status_mail      = 'E'.
        CATCH cx_send_req_bcs .
      ENDTRY.

      TRY.
          CALL METHOD lo_send_request->set_send_immediately
            EXPORTING
              i_send_immediately = 'X'.
        CATCH cx_send_req_bcs .
      ENDTRY.


      CALL METHOD lo_send_request->send(
        EXPORTING
          i_with_error_screen = 'X'
        RECEIVING
          result              = lx_sent_to_all ).
      IF lx_sent_to_all = 'X'.
        WRITE text-003.
      ENDIF.

      COMMIT WORK.

* -----------------------------------------------------------
* *                     exception handling
* -----------------------------------------------------------
* * replace this very rudimentary exception handling
* * with your own one !!!
* -----------------------------------------------------------
    CATCH cx_bcs INTO lo_bcs_exception.
      WRITE: text-001.
      WRITE: text-002, lo_bcs_exception->error_type.
      EXIT.

  ENDTRY.

ENDFORM.

Regards

Uwe

0 Kudos

thanq

pls. let me know the 'Z' structures, zcl_idoc and zif_idoc...........How they looks like? I mean, How did u defined them? , so that, will copy them also.

and also, pls. let me know, Is there any ur custom pieces in ur code?

and there r 3 more FMs, Do u hv any idea aboout them, bcoz, i did not find any documentation for these FMs, these 3 r,

fm-SO_OBJECT_SEND---i guess, this is useful for me

fm - SO_NEW_DOCUMENT_ATT_SEND_API1--i guess, this is for attachment purpose

fm - SO_DOCUMENT_SEND_API1--i guess, this is for attachment purpose

thanq

Edited by: SAP ABAPer on Sep 7, 2008 2:32 AM

Edited by: SAP ABAPer on Sep 8, 2008 4:25 AM