Advertisement
ignatov

Untitled

Jun 20th, 2020
2,047
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 3.11 KB | None | 0 0
  1.   METHOD if_swf_ifs_workitem_exit~event_raised.
  2.     DATA:
  3.       value_get    TYPE char10,
  4.       lv_user      TYPE sww_aagent,
  5.       lv_email     TYPE string,
  6.       lo_document  TYPE REF TO cl_document_bcs,
  7.       sender       TYPE REF TO cl_sapuser_bcs,
  8.       lv_body      TYPE string,
  9.       text         TYPE bcsy_text,
  10.       send_request TYPE REF TO cl_bcs,
  11.       recipient    TYPE REF TO if_recipient_bcs,
  12.       sent_to_all  TYPE os_boolean.
  13.  
  14.     DATA(lv_wi_id) = im_workitem_context->get_workitem_id(  ).
  15.     DATA(lv_heaad) = im_workitem_context->get_header(  ).
  16.  
  17.     IF im_event_name EQ swrco_event_after_creation.
  18.  
  19.       CLEAR value_get.
  20.       CALL METHOD get_elem(
  21.         EXPORTING
  22.           im_workitem_context = im_workitem_context
  23.           element_name        = 'prm1'
  24.         IMPORTING
  25.           element_value       = value_get
  26.                                 ).
  27.  
  28.       CLEAR value_get.
  29.       CALL METHOD get_elem(
  30.         EXPORTING
  31.           im_workitem_context = im_workitem_context
  32.           element_name        = 'prm2'
  33.         IMPORTING
  34.           element_value       = value_get
  35.                                 ).
  36.  
  37.       CLEAR value_get.
  38.       CALL METHOD get_elem(
  39.         EXPORTING
  40.           im_workitem_context = im_workitem_context
  41.           element_name        = 'user'
  42.         IMPORTING
  43.           element_value       = lv_user
  44.                                 ).
  45.       IF lv_user IS NOT INITIAL.
  46.  
  47.         CALL FUNCTION 'EFG_GEN_GET_USER_EMAIL'
  48.           EXPORTING
  49.             i_uname           = lv_user
  50.           IMPORTING
  51.             e_email_address   = lv_email
  52.           EXCEPTIONS
  53.             not_qualified     = 1
  54.             user_not_found    = 2
  55.             address_not_found = 3
  56.             OTHERS            = 4.
  57.         IF sy-subrc <> 0.
  58.           lv_email = 'admin@admin.fr'.
  59.         ENDIF.
  60.  
  61.         lv_body = 'mail from wi id #wi_id#'.
  62.         SHIFT lv_wi_id LEFT DELETING LEADING '0'.
  63.         REPLACE ALL OCCURRENCES OF '#wi_id#' IN lv_body WITH lv_wi_id.
  64.  
  65.         APPEND lv_body   TO text.
  66.  
  67.         send_request = cl_bcs=>create_persistent( ).
  68.  
  69.         lo_document = cl_document_bcs=>create_document(
  70.                         i_type    = 'HTM'
  71.                         i_text    = text
  72.                         i_subject = 'mail from program exit' ).
  73.  
  74.         CALL METHOD send_request->set_document( lo_document ).
  75.  
  76.         sender = cl_sapuser_bcs=>create( 'WF-BATCH' ).
  77.         CALL METHOD send_request->set_sender
  78.           EXPORTING
  79.             i_sender = sender.
  80.  
  81.         DATA lv_mail TYPE adr6-smtp_addr.
  82.         lv_mail = lv_email.
  83.         recipient = cl_cam_address_bcs=>create_internet_address(
  84.                                           lv_mail ).
  85.  
  86.  
  87.         CALL METHOD send_request->add_recipient
  88.           EXPORTING
  89.             i_recipient = recipient
  90.             i_express   = 'X'.
  91.  
  92.  
  93.         CALL METHOD send_request->send(
  94.           EXPORTING
  95.             i_with_error_screen = 'X'
  96.           RECEIVING
  97.             result              = sent_to_all ).
  98.         IF sent_to_all = 'X'.
  99.  
  100.         ENDIF.
  101.  
  102.       ENDIF.
  103.  
  104.     ENDIF.
  105.  
  106.   ENDMETHOD.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement