• Startseite

YCL_SO5_BCS (sourcecode)

  • Mittwoch, 15. Juni 2016 09:46
Artikel bewerten
(2 Stimmen)

YCL_SO5_BCS

 CLASS ycl_so5_bcs DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.

    CLASS-DATA my_control TYPE REF TO i_oi_container_control .
    CLASS-DATA my_doc_proxy TYPE REF TO i_oi_document_proxy .
    CLASS-DATA my_container TYPE REF TO cl_gui_custom_container .
    DATA my_send_request TYPE REF TO cl_bcs .
    DATA my_alt_message TYPE REF TO cl_bcs_message .
    DATA my_document TYPE REF TO cl_document_bcs .
    DATA my_sender_b TYPE REF TO cl_sapuser_bcs .
    DATA my_sender_u TYPE REF TO cl_cam_address_bcs .
    DATA my_recipient TYPE REF TO if_recipient_bcs .
    DATA my_bcs_exception TYPE REF TO cx_bcs .

*-- print a given document
    CLASS-METHODS print_document
      IMPORTING
        !iv_filepath    TYPE string
        !iv_printer     TYPE rspopname OPTIONAL
        !iv_popup_print TYPE abap_bool
      EXCEPTIONS
        error_print_document .
    CLASS-METHODS open_document
      IMPORTING
        !iv_filepath               TYPE string
        !iv_doc_title              TYPE char255
        !iv_startup_macro          TYPE c OPTIONAL
        !iv_close_macro            TYPE c OPTIONAL
      RETURNING
        VALUE(rv_filepath_new_doc) TYPE string
      EXCEPTIONS
        error_open_document .
*-- init the object
    METHODS constructor
      IMPORTING
        !iv_subject              TYPE so_obj_des
        !iv_convert_mail_as_html TYPE abap_bool DEFAULT abap_true
        !iv_is_mailtext_html     TYPE abap_bool
        !iv_mailtext_tab         TYPE bcsy_text
        !iv_create_sap_link      TYPE abap_bool DEFAULT abap_false
        !iv_footer               TYPE zme6_mail_footer OPTIONAL
        !iv_source_app           TYPE cdobjectcl OPTIONAL
        !iv_destination_app      TYPE cdobjectcl OPTIONAL
        !iv_programm             TYPE programm DEFAULT 'YCL_SO5_BCS'
        !iv_tcode                TYPE tcode DEFAULT sy-tcode
        !iv_werks                TYPE werks_d DEFAULT 'DE01'
        !iv_outlookkey           TYPE char120 OPTIONAL
        !iv_link_style           TYPE char1 OPTIONAL
        !iv_no_commit            TYPE abap_bool DEFAULT abap_false
      EXCEPTIONS
        error_create_document
        error_create_sap_link .
*-- set list of attachments
    METHODS set_attachments
      IMPORTING
        !iv_attachment_tab TYPE yso5_tt_a_attachment
        !iv_subject        TYPE so_obj_des OPTIONAL
      EXCEPTIONS
        attachment_type_not_supported .
    METHODS set_sender
      IMPORTING
        !iv_sender TYPE string
        !iv_type   TYPE char01 .
*-- send e-mail via Business Communication Services
    METHODS send_mail
      IMPORTING
        !iv_show_popup_before_send TYPE abap_bool OPTIONAL
        !iv_tab_reciever           TYPE yso5_tt_reciever
        !iv_country                TYPE land1 OPTIONAL
        !iv_only_outlook_mail      TYPE abap_bool DEFAULT abap_false
      EXCEPTIONS
        error_send_document
        error_create_document .
*-- send fax via Business Communication Services
    METHODS send_fax
      IMPORTING
        !iv_show_popup_before_send TYPE abap_bool OPTIONAL
        !iv_tab_reciever           TYPE yso5_tt_reciever
        !iv_country                TYPE land1
        !iv_only_outlook_mail      TYPE abap_bool DEFAULT abap_false
      EXCEPTIONS
        error_send_document
        error_create_document .
*-- create link between send request & application object
    METHODS create_link_2_appl_object
      IMPORTING
        !iv_application_objekt TYPE yso5_tt_swotobjid
        !iv_user_name          TYPE username OPTIONAL
        !iv_objpara            TYPE yso5_tt_selc OPTIONAL
        !iv_objparb            TYPE yso5_tt_soop1 OPTIONAL .
*-- get the default footer data
    METHODS get_my_default_footer
      IMPORTING
        !iv_footer           TYPE yso5_mail_footer
      RETURNING
        VALUE(rv_footer_tab) TYPE bcsy_text .
  PROTECTED SECTION.

    DATA pv_no_commit TYPE abap_bool .
  PRIVATE SECTION.

    DATA pt_mailtext TYPE bcsy_text .
    DATA pt_mailtext_header TYPE bcsy_text .
    DATA pt_mailtext_body TYPE bcsy_text .
    DATA pt_mailtext_footer TYPE bcsy_text .
    DATA pt_mailrec TYPE yso5_tt_reciever .
    DATA pv_subject TYPE so_obj_des .
    DATA pt_attachments TYPE yso5_tt_a_attachment .
    DATA pv_doc_type TYPE so_obj_tp .
    DATA pv_country4fax TYPE land1 .
    DATA pv_country TYPE werks_d .
    DATA pv_recipient_u TYPE adr6-smtp_addr .
    DATA pv_recipient_b TYPE sy-uname .
    DATA pv_recipient_f TYPE ad_fxnmbr .
    DATA pv_recipient_dl TYPE so_obj_nam .
    DATA pv_mail_copy TYPE abap_bool .
    DATA pv_mail_express TYPE abap_bool .
    DATA pv_mail_bc TYPE abap_bool .
    DATA pv_sent_to_all TYPE abap_bool .
    DATA pv_show_popup_before_send TYPE abap_bool .
    DATA pv_convert_mail_as_html TYPE abap_bool .
    DATA pv_is_mailtext_html TYPE abap_bool .
    DATA pv_sap_link TYPE string .
    DATA pt_shortcut_content TYPE soli_tab .
    DATA pv_source_app TYPE cdobjectcl .
    DATA pv_destination_app TYPE cdobjectcl .
    DATA pv_programm TYPE programm .
    DATA pv_tcode TYPE tcode .
    DATA pv_only_outlook_mail TYPE abap_bool .

*-- set the recipients
    METHODS set_recipients .
*-- create a SAP http url (link)
    METHODS create_sap_link
      IMPORTING
        !iv_werks      TYPE werks_d DEFAULT 'DE01'
        !iv_tcode      TYPE tcode
        !iv_outlookkey TYPE char120 OPTIONAL
        !iv_link_style TYPE char1
      EXCEPTIONS
        error_create_sap_link .
*-- set the body content
    METHODS set_my_doc_body
      IMPORTING
        !iv_body_tab TYPE bcsy_text .
*-- set the header content
    METHODS set_my_doc_header .
*-- set the footer content
    METHODS set_my_doc_footer
      IMPORTING
        !iv_footer TYPE yso5_mail_footer OPTIONAL .
*-- create a BCS document
    METHODS create_document
      EXCEPTIONS
        error_create_document .
*-- send the document
    METHODS send_document
      EXCEPTIONS
        error_send_document .
*-- get & set an email adress
    METHODS get_and_set_email_address
      IMPORTING
        !iv_recipient_dl TYPE so_obj_nam .
*-- convert the given raw text in html
    METHODS convert_raw2html
      IMPORTING
        !iv_mailtext_tab   TYPE bcsy_text
      RETURNING
        VALUE(rv_mailtext) TYPE bcsy_text .
*-- save data for info, that an email/fax was sent
    METHODS save_sap_mail
      IMPORTING
        !iv_source_app      TYPE cdobjectcl
        !iv_destination_app TYPE cdobjectcl
        !iv_programm        TYPE programm
        !iv_tcode           TYPE tcode .
ENDCLASS.



CLASS ycl_so5_bcs IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method YCL_SO5_BCS->CONSTRUCTOR
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_SUBJECT                     TYPE        SO_OBJ_DES
* | [--->] IV_CONVERT_MAIL_AS_HTML        TYPE        ABAP_BOOL (default =ABAP_TRUE)
* | [--->] IV_IS_MAILTEXT_HTML            TYPE        ABAP_BOOL
* | [--->] IV_MAILTEXT_TAB                TYPE        BCSY_TEXT
* | [--->] IV_CREATE_SAP_LINK             TYPE        ABAP_BOOL (default =ABAP_FALSE)
* | [--->] IV_FOOTER                      TYPE        ZME6_MAIL_FOOTER(optional)
* | [--->] IV_SOURCE_APP                  TYPE        CDOBJECTCL(optional)
* | [--->] IV_DESTINATION_APP             TYPE        CDOBJECTCL(optional)
* | [--->] IV_PROGRAMM                    TYPE        PROGRAMM (default ='YCL_SO5_BCS')
* | [--->] IV_TCODE                       TYPE        TCODE (default =SY-TCODE)
* | [--->] IV_WERKS                       TYPE        WERKS_D (default ='DE01')
* | [--->] IV_OUTLOOKKEY                  TYPE        CHAR120(optional)
* | [--->] IV_LINK_STYLE                  TYPE        CHAR1(optional)
* | [--->] IV_NO_COMMIT                   TYPE        ABAP_BOOL (default =ABAP_FALSE)
* | [EXC!] ERROR_CREATE_DOCUMENT
* | [EXC!] ERROR_CREATE_SAP_LINK
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD constructor.
*==> 1 | START
    TRY .
*== create persistent send request
        CASE iv_no_commit.
          WHEN abap_false.
            me->my_send_request = cl_bcs=>create_persistent( ).
          WHEN abap_true.
            CREATE OBJECT me->my_alt_message.
            me->my_alt_message->set_send_immediately( abap_false ).
        ENDCASE.

*== assign object variables{
        me->pv_source_app = iv_source_app.
        me->pv_destination_app = iv_destination_app.
        me->pv_programm = iv_programm.
        me->pv_tcode = iv_tcode.
        me->pv_no_commit = iv_no_commit.
*-- set my_subject
        me->pv_subject = iv_subject.
*-- set my_doc_type
*   -->set mail(document) type as html or raw
        IF iv_convert_mail_as_html EQ abap_true.
          me->pv_doc_type = 'HTM'.
          me->pv_convert_mail_as_html = abap_true.
        ELSE.
          IF iv_is_mailtext_html EQ abap_true.
            me->pv_doc_type = 'HTM'.
            me->pv_is_mailtext_html = abap_true.
          ELSE.
            me->pv_doc_type = 'RAW'.
          ENDIF.
        ENDIF.
*== set my_mailtext
*-- set header
        me->set_my_doc_header( ).
*-- set body
        CASE iv_convert_mail_as_html.
          WHEN abap_true.   "mail as html
            me->set_my_doc_body( iv_mailtext_tab ).
          WHEN abap_false.  "mail as text | if is_mailtext_html eq true = keep the data as html
            me->pt_mailtext_body = iv_mailtext_tab.
        ENDCASE.
*-- set footer
        IF iv_footer IS NOT INITIAL.
          me->set_my_doc_footer( iv_footer ).
        ENDIF.
*==}
*-- create SAP Link
* if you use this function be aware that in this function we have a remote function call.
* if you use RFC we have a commit @ Database
        IF iv_create_sap_link EQ abap_true
          AND me->pv_no_commit EQ abap_false.
          me->create_sap_link(
            EXPORTING
              iv_werks              = iv_werks    " [str] plant
              iv_tcode              = iv_tcode    " [str] code of transaction
              iv_outlookkey         = iv_outlookkey    " [str] outlook key
              iv_link_style         = iv_link_style    " [char1] A = as attachment | U= as URL | X= Attachment+URL,
            EXCEPTIONS
              error_create_sap_link = 1
              OTHERS                = 2
          ).
          IF sy-subrc <> 0.
*   MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
        ENDIF.
*== create document
        me->create_document(
          EXCEPTIONS
            error_create_document = 1
            OTHERS                = 2
        ).
        IF sy-subrc <> 0.
          RAISE error_create_document.
        ENDIF.
**-- 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.
*        me->my_sender = cl_sapuser_bcs=>create( i_user = sy-uname ).
*        me->my_send_request->set_sender( i_sender = me->my_sender ).
      CATCH cx_send_req_bcs INTO my_bcs_exception.
      CATCH cx_address_bcs INTO my_bcs_exception.
    ENDTRY.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method YCL_SO5_BCS->CONVERT_RAW2HTML
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_MAILTEXT_TAB                TYPE        BCSY_TEXT
* | [<-()] RV_MAILTEXT                    TYPE        BCSY_TEXT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD convert_raw2html.
    CONSTANTS:
      c_div_start   TYPE soli VALUE '<div style="border-style:solid; border-width:5px; border-color:#95b2c3; font-family:Arial; font-size: 14px; text-align:left; padding:8px; margin:0px">',
      c_div_ende    TYPE soli VALUE '</div>',
      c_table_start TYPE soli VALUE '<table style="font-family:Arial; font-size: 12px;">',
      c_table_ende  TYPE soli VALUE '</table>',
      c_umbruch     TYPE soli VALUE '<br>'.
    DATA: ls_mailtext LIKE LINE OF iv_mailtext_tab.
*== init
    CLEAR ls_mailtext.
    APPEND c_div_start TO rv_mailtext.
    LOOP AT iv_mailtext_tab ASSIGNING FIELD-SYMBOL(<fs_mailtext>).
      <fs_mailtext>-line = <fs_mailtext>-line && c_umbruch-line.
      APPEND <fs_mailtext> TO rv_mailtext.
    ENDLOOP.
    APPEND c_div_ende TO rv_mailtext.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method YCL_SO5_BCS->CREATE_DOCUMENT
* +-------------------------------------------------------------------------------------------------+
* | [EXC!] ERROR_CREATE_DOCUMENT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD create_document.
    TRY .
*== create and set document
*-- set mailtext
        APPEND LINES OF me->pt_mailtext_header TO me->pt_mailtext.
*== ensure that the SAP Link is the last entry @ mailtext body
        IF me->pv_sap_link IS NOT INITIAL.
          DATA: ls_tmp_body LIKE LINE OF me->pt_mailtext.
          CLEAR ls_tmp_body.
          DESCRIBE TABLE me->pt_mailtext_body LINES DATA(lv_lines).
          ls_tmp_body-line = '<b>Absprung nach SAP:</b>'.
          INSERT ls_tmp_body INTO me->pt_mailtext_body INDEX lv_lines.
          CLEAR ls_tmp_body.
          ls_tmp_body-line = '<a href="' && me->pv_sap_link && '">' && me->pv_tcode && '</a>'.
          INSERT ls_tmp_body INTO me->pt_mailtext_body INDEX lv_lines + 1.
        ENDIF.
        APPEND LINES OF me->pt_mailtext_body TO me->pt_mailtext.
        APPEND LINES OF me->pt_mailtext_footer TO me->pt_mailtext.
*-- create document from internal table with text
        CASE me->pv_no_commit.
          WHEN abap_false.
            me->my_document = cl_document_bcs=>create_document(
                              i_type          = me->pv_doc_type
                              i_text          = me->pt_mailtext
                              i_subject       = me->pv_subject
                              ).
*-- add document to send request
            me->my_send_request->set_document( me->my_document ).
*-- create SAP Link as attachment
            IF me->pt_shortcut_content IS NOT INITIAL.
              DATA: lt_attachment TYPE yso5_tt_a_attachment,
                    wa_attachment LIKE LINE OF lt_attachment.
              wa_attachment-attachment_type = 'SAP'.
              wa_attachment-content_text = me->pt_shortcut_content.
              APPEND wa_attachment TO lt_attachment.
              me->set_attachments(
                EXPORTING
                  iv_attachment_tab             = lt_attachment    " tab| list of attachments
                  iv_subject = text-202
                EXCEPTIONS
                  attachment_type_not_supported = 1
                  OTHERS                        = 2
              ).
            ENDIF.
          WHEN abap_true.
*-- set subject
            me->my_alt_message->set_subject( CONV #( me->pv_subject ) ).
*-- set main doc
            DATA character_string TYPE string.
            CALL FUNCTION 'SWA_STRING_FROM_TABLE'
              EXPORTING
                character_table  = me->pt_mailtext
              IMPORTING
                character_string = character_string.
            me->my_alt_message->set_main_doc(
              EXPORTING
                iv_contents_txt = character_string    " Hauptdokument, 1. Bodypart
*                iv_contents_bin =     " Hauptdokument, 1. Bodypart (binär)
                iv_doctype      = me->pv_doc_type    " Dokumententyp
*                iv_codepage     =     " Zeichensatz eines Dokuments
            ).
        ENDCASE.
      CATCH cx_bcs INTO my_bcs_exception.
        CASE my_bcs_exception->error_type.
          WHEN 'INTERR_BCS'.
          WHEN 'OSERR_BCS'.
          WHEN 'XERR_BCS'.
          WHEN 'PARERR_BCS'.
          WHEN 'VERR_BCS'.
          WHEN 'CERR_BCS'.
          WHEN 'NA_BCS'.
          WHEN 'LOCKED_BCS'.
          WHEN 'CASTERR_BCS'.
          WHEN OTHERS.
        ENDCASE.
        RAISE error_create_document.
    ENDTRY.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method YCL_SO5_BCS->CREATE_LINK_2_APPL_OBJECT
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_APPLICATION_OBJEKT          TYPE        YSO5_TT_SWOTOBJID
* | [--->] IV_USER_NAME                   TYPE        USERNAME(optional)
* | [--->] IV_OBJPARA                     TYPE        YSO5_TT_SELC(optional)
* | [--->] IV_OBJPARB                     TYPE        YSO5_TT_SOOP1(optional)
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD create_link_2_appl_object.
*== BCS create_link{
    DATA: ls_appl_obj         TYPE borident,
          lv_all_binding_done TYPE sonv-flag.
*==}
*== save transfer{
*    DATA: ls_soud2     TYPE soud2,
*          ls_folder_id TYPE soodk,
*          ls_soodk     TYPE soodk,
*          lt_objhead   TYPE STANDARD TABLE OF soli,
*          lv_rcode     TYPE sysubrc.
*==}
*== currently valid application objects which can be connect with my send request (BCS){
*-- MARA connect
*      application_object-objtype      = 'BUS1001006'.
*      application_object-objkey  = lv_tmp_matnr.
*-- DRAW connect
*      application_object-objtype      = 'DRAW'.
*      application_object-objkey       = 'ZEF'."doctype.
*      application_object-objkey+3(25) = '0000000000000000010001509'."docnumber.
*      application_object-objkey+28(2) = '00'."docversion.
*      application_object-objkey+30(3) = '000'."docpart.
*-- IDOC connect
*      application_object-objtype      = 'IDOC'.
*      application_object-objkey  = '0000000000'."idocnumber
*-- Delivery connect
*      application_object-objtype      = 'LIKP'.
*      application_object-objkey  = '0000000000'."number of delivery
*==} currently valid application objects

    LOOP AT iv_application_objekt ASSIGNING FIELD-SYMBOL(<fs_appl_obj_row>).
      CLEAR ls_appl_obj.
      MOVE-CORRESPONDING <fs_appl_obj_row> TO ls_appl_obj.
*-- create link between send request & application object
      TRY .
          me->my_send_request->create_link( ls_appl_obj ).
        CATCH cx_send_req_bcs INTO me->my_bcs_exception.
      ENDTRY.
      lv_all_binding_done = abap_false.
    ENDLOOP.
*== save transfer
**-- read user profil
*    CALL FUNCTION 'SO_USER_READ'
*      EXPORTING
*        user_name             = iv_user_name
**       WITH_MAX_RECEIVER     = ' '
*      IMPORTING
*        user_display          = ls_soud2
*      EXCEPTIONS
*        communication_failure = 1
*        system_failure        = 2
*        user_not_exist        = 3
*        OTHERS                = 4.
*
*    ls_folder_id-objtp = 'FOL'.
*    ls_folder_id-objno = ls_soud2-inbno.
*    ls_folder_id-objyr = ls_soud2-inbyr.
*
*    TRY .
*        DATA(lv_docno) = me->my_document->get_docno( ).
*        DATA(lv_doctp) = me->my_document->get_doctp( ).
*        DATA(lv_docyr) = me->my_document->get_docyr( ).
*      CATCH cx_os_object_not_found.    "
*    ENDTRY.
*
*    ls_soodk-objtp = lv_doctp.
*    ls_soodk-objno = lv_docno.
*    ls_soodk-objyr = lv_docyr.
*
*    CALL FUNCTION 'SO_OBJECT_INSERT'
*      EXPORTING
*        folder_id                  = ls_folder_id
*        object_type                = 'RAW'
*        owner                      = iv_user_name
*      TABLES
*        objcont                    = me->pt_mailtext
*        objhead                    = lt_objhead
*        objpara                    = iv_objpara
*        objparb                    = iv_objparb
*      EXCEPTIONS
*        active_user_not_exist      = 1
*        communication_failure      = 2
*        component_not_available    = 3
*        dl_name_exist              = 4
*        folder_not_exist           = 5
*        folder_no_authorization    = 6
*        object_type_not_exist      = 7
*        operation_no_authorization = 8
*        owner_not_exist            = 9
*        parameter_error            = 10
*        substitute_not_active      = 11
*        substitute_not_defined     = 12
*        system_failure             = 13
*        x_error                    = 14
*        OTHERS                     = 15.

*    PERFORM socx_insert(sapfsso0) TABLES lt_objhead
*                                       me->pt_mailtext
*                                       iv_objpara
*                                       iv_objparb
*                                 USING ls_soodk
*                                       lv_rcode.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method YCL_SO5_BCS->CREATE_SAP_LINK
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_WERKS                       TYPE        WERKS_D (default ='DE01')
* | [--->] IV_TCODE                       TYPE        TCODE
* | [--->] IV_OUTLOOKKEY                  TYPE        CHAR120(optional)
* | [--->] IV_LINK_STYLE                  TYPE        CHAR1
* | [EXC!] ERROR_CREATE_SAP_LINK
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD create_sap_link.
    DATA: lv_rfcdest                  TYPE  rfcdest,
          lv_sysid                    TYPE sysysid,
          ls_vu_systeme               TYPE yso5_vu_systeme,
          lv_sysid_gui                TYPE sysysid,
          lv_parameter_for_url        TYPE char100,
          lv_parameter_for_attachment TYPE text255,
          lv_url                      TYPE string.
    DATA: lv_shortcut_string TYPE  string.
    DATA: wa_shortcut LIKE LINE OF me->pt_shortcut_content.
*== get the current valid rfc destination
    CALL FUNCTION 'Z_ME6_GET_RFCDEST'
      EXPORTING
        i_werks   = 'DE01'
      IMPORTING
        e_rfcdest = lv_rfcdest.
*== get current system id
    CALL FUNCTION 'Y_ME6_GET_SYSID'
      DESTINATION lv_rfcdest
      EXPORTING
        p_werks      = iv_werks
      IMPORTING
        p_sysid      = lv_sysid
      CHANGING
        p_vu_systeme = ls_vu_systeme
        p_sysid_gui  = lv_sysid_gui.
*== create parameter key for FuBa Y_ME6_CALL_TRANSACTION_VU | SWN_CREATE_SHORTCUT
*-- FuBa Y_ME6_CALL_TRANSACTION_VU
    CONCATENATE '*' iv_tcode '%20' iv_outlookkey INTO lv_parameter_for_url.
*-- SWN_CREATE_SHORTCUT
    lv_parameter_for_attachment = iv_outlookkey.
*== create a SAP URL Link | create SAP Link as shortcut
    CASE iv_link_style.
      WHEN 'A'.
*-- create SAP Link as shortcut
        CALL FUNCTION 'SWN_CREATE_SHORTCUT'
          EXPORTING
            i_transaction           = iv_tcode
            i_parameter             = lv_parameter_for_attachment
            i_sysid                 = sy-sysid
            i_client                = sy-mandt
            i_language              = sy-langu
            i_windowsize            = text-204 "Normal window
          IMPORTING
            shortcut_string         = lv_shortcut_string
          EXCEPTIONS
            inconsistent_parameters = 1
            OTHERS                  = 2. "#NO_TEXT
        IF sy-subrc <> 0.
* Implement suitable error handling here
        ELSE.
*-- populate attachment content
          REPLACE ALL OCCURRENCES OF sy-uname IN lv_shortcut_string WITH ''.
          CLEAR wa_shortcut.
          CONCATENATE lv_shortcut_string wa_shortcut-line INTO wa_shortcut-line.
          APPEND wa_shortcut TO me->pt_shortcut_content.
        ENDIF.
      WHEN 'U'.
*-- create a SAP URL Link
        CALL FUNCTION 'Y_ME6_CALL_TRANSACTION_VU'
          EXPORTING
            i_sysid         = lv_sysid
            i_parameter     = lv_parameter_for_url
            i_kz_exec       = ' '
            i_spras         = 'DE' "'@LANG@'
            i_vu_systeme    = ls_vu_systeme
          IMPORTING
            e_url           = me->pv_sap_link
          EXCEPTIONS
            sytem_unbekannt = 1
            fehler          = 2
            OTHERS          = 3.
        IF sy-subrc <> 0.
          RAISE error_create_sap_link.
        ENDIF.
      WHEN 'X'.
*-- create a SAP URL Link
        CALL FUNCTION 'Y_ME6_CALL_TRANSACTION_VU'
          EXPORTING
            i_sysid         = lv_sysid
            i_parameter     = lv_parameter_for_url
            i_kz_exec       = ' '
            i_spras         = '@LANG@'
            i_vu_systeme    = ls_vu_systeme
          IMPORTING
            e_url           = me->pv_sap_link
          EXCEPTIONS
            sytem_unbekannt = 1
            fehler          = 2
            OTHERS          = 3.
        IF sy-subrc <> 0.
          RAISE error_create_sap_link.
        ENDIF.
*-- create SAP Link as shortcut
        CALL FUNCTION 'SWN_CREATE_SHORTCUT'
          EXPORTING
            i_transaction           = iv_tcode
            i_parameter             = lv_parameter_for_attachment
            i_sysid                 = sy-sysid
            i_client                = sy-mandt
            i_language              = sy-langu
            i_windowsize            = text-204 "Normal window
          IMPORTING
            shortcut_string         = lv_shortcut_string
          EXCEPTIONS
            inconsistent_parameters = 1
            OTHERS                  = 2. "#NO_TEXT
        IF sy-subrc <> 0.
* Implement suitable error handling here
        ELSE.
*-- populate attachment content
          REPLACE ALL OCCURRENCES OF sy-uname IN lv_shortcut_string WITH ''.
          CLEAR wa_shortcut.
          CONCATENATE lv_shortcut_string wa_shortcut-line INTO wa_shortcut-line.
          APPEND wa_shortcut TO me->pt_shortcut_content.
        ENDIF.
    ENDCASE.
*== set the current user language @ SAP LINK / Shortcut
    CASE sy-uname(1).
      WHEN 'Q' OR 'U'.
        REPLACE ALL OCCURRENCES OF '@LANG@' IN me->pv_sap_link WITH 'EN'.
      WHEN 'B'.
        REPLACE ALL OCCURRENCES OF '@LANG@' IN me->pv_sap_link WITH 'PT'.
      WHEN OTHERS.
        REPLACE ALL OCCURRENCES OF '@LANG@' IN me->pv_sap_link WITH 'DE'.
    ENDCASE.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method YCL_SO5_BCS->GET_AND_SET_EMAIL_ADDRESS
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_RECIPIENT_DL                TYPE        SO_OBJ_NAM
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD get_and_set_email_address.
    DATA: lt_member  TYPE TABLE OF sodm1,
          lt_objpara TYPE TABLE OF selc,
          lt_objparb TYPE TABLE OF soop1.
    DATA: lt_return   TYPE TABLE OF bapiret2.
    DATA: ls_adress   TYPE bapiaddr3.
    DATA: ls_mail_rec TYPE somlrec90.
*== get all SAP USER from distribution list
    CALL FUNCTION 'SO_DLI_READ'
      EXPORTING
        distributionlist           = iv_recipient_dl
        system_dli                 = 'X'
      TABLES
        member                     = lt_member
        objpara                    = lt_objpara
        objparb                    = lt_objparb
      EXCEPTIONS
        active_user_not_exist      = 1
        communication_failure      = 2
        component_not_available    = 3
        dl_name_not_exist          = 4
        folder_not_exist           = 5
        folder_no_authorization    = 6
        forwarder_not_exist        = 7
        object_not_exist           = 8
        object_no_authorization    = 9
        operation_no_authorization = 10
        owner_not_exist            = 11
        parameter_error            = 12
        substitute_not_active      = 13
        substitute_not_defined     = 14
        system_failure             = 15
        user_not_exist             = 16
        x_error                    = 17
        OTHERS                     = 18.
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ELSE.
*== get the email address
      LOOP AT lt_member ASSIGNING FIELD-SYMBOL(<fs_member>).
        CALL FUNCTION 'BAPI_USER_GET_DETAIL'
          EXPORTING
            username = <fs_member>-memnam
          IMPORTING
            address  = ls_adress
          TABLES
            return   = lt_return.
*== set the email address and add this address to my_recipient
        IF lt_return IS INITIAL.
          CLEAR ls_mail_rec.
          TRANSLATE ls_adress-e_mail TO LOWER CASE.
          ls_mail_rec-receiver = ls_adress-e_mail.
          ls_mail_rec-rec_type = 'U'. "U = Internet Adresse
          APPEND ls_mail_rec TO me->pt_mailrec.
        ENDIF.
      ENDLOOP.
    ENDIF.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method YCL_SO5_BCS->GET_MY_DEFAULT_FOOTER
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_FOOTER                      TYPE        YSO5_MAIL_FOOTER
* | [<-()] RV_FOOTER_TAB                  TYPE        BCSY_TEXT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD get_my_default_footer.
    CONSTANTS:
      c_div_start1  TYPE soli VALUE '<div id="Footer" style="border-style:solid; border-width:2px; border-color:#5d5d5d; font-family:Arial; font-size: 14px; text-align:left; padding:0px; margin:0px">',
      c_div_start2  TYPE soli VALUE '<div id="Footer" style="border-style:solid; border-width:5px; border-color:#95b2c3; font-family:Arial; font-size: 14px; text-align:left; padding:8px; margin:0px">',
      c_div_ende    TYPE soli VALUE '</div>',
      c_table_start TYPE soli VALUE '<table style="font-family:Arial; font-size: 12px;">',
      c_table_ende  TYPE soli VALUE '</table>',
      c_umbruch     TYPE soli VALUE '<br>'.
    DATA: ls_footer_text LIKE LINE OF rv_footer_tab.
    CLEAR ls_footer_text.
*== prepare text lines as html tags
    APPEND c_div_start2 TO rv_footer_tab.
    APPEND c_umbruch TO rv_footer_tab.
    APPEND c_table_start TO rv_footer_tab.
    APPEND '<tr><td colspan=2><b>Systeminformationen:</b></td></tr>' TO rv_footer_tab.
    APPEND '<tr><td>Anwendung:</td><td>' TO rv_footer_tab.
    APPEND iv_footer-zzme6_anwendung TO rv_footer_tab.
    APPEND '</td></tr>' TO rv_footer_tab.
    APPEND '<tr><td>Rolle:</td><td>' TO rv_footer_tab.
    APPEND iv_footer-zzme6_rolle TO rv_footer_tab.
    APPEND '</td></tr>' TO rv_footer_tab.
    APPEND '<tr><td>Auslöseuser:</td><td>' TO rv_footer_tab.
    SELECT SINGLE * FROM zme6_skb INTO @DATA(zme6_skb)
      WHERE username = @sy-uname.
    CONCATENATE zme6_skb-username ',µ' zme6_skb-skb ',µ' zme6_skb-nachname ',µ' zme6_skb-vorname
      INTO ls_footer_text-line.
    TRANSLATE ls_footer_text-line USING 'µ '.
    APPEND ls_footer_text TO rv_footer_tab.
    APPEND '</td></tr>' TO rv_footer_tab.
    APPEND '<tr><td>Transaktion:</td><td>' TO rv_footer_tab.
    APPEND iv_footer-tcode TO rv_footer_tab.
    APPEND '</td></tr>' TO rv_footer_tab.
    APPEND '<tr><td>Programm:</td><td>' TO rv_footer_tab.
    CLEAR ls_footer_text.
    CONCATENATE me->pv_programm 'µ/µ' sy-sysid
          INTO ls_footer_text-line.
    TRANSLATE ls_footer_text-line USING 'µ '.
    APPEND ls_footer_text TO rv_footer_tab.
    APPEND '</td></tr>' TO rv_footer_tab.
    APPEND '<tr><td>Doku:</td><td>' TO rv_footer_tab.
    APPEND iv_footer-zzme6_doku TO rv_footer_tab.
    APPEND '</td></tr>' TO rv_footer_tab.
    APPEND '<tr><td>Zust. Org-Abt.:</td><td>' TO rv_footer_tab.
    APPEND iv_footer-zzme6_abteilung TO rv_footer_tab.
    APPEND '</td></tr>' TO rv_footer_tab.
    APPEND '<tr><td>Datum/Uhrzeit:</td><td>' TO rv_footer_tab.
    CLEAR ls_footer_text.
    WRITE sy-datum TO ls_footer_text-line.
    WRITE sy-uzeit TO ls_footer_text-line+12.
    APPEND ls_footer_text TO rv_footer_tab.
    APPEND '</td></tr>' TO rv_footer_tab.
    APPEND c_table_ende TO rv_footer_tab.
    APPEND c_div_ende TO rv_footer_tab.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method YCL_SO5_BCS=>OPEN_DOCUMENT
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_FILEPATH                    TYPE        STRING
* | [--->] IV_DOC_TITLE                   TYPE        CHAR255
* | [--->] IV_STARTUP_MACRO               TYPE        C(optional)
* | [--->] IV_CLOSE_MACRO                 TYPE        C(optional)
* | [<-()] RV_FILEPATH_NEW_DOC            TYPE        STRING
* | [EXC!] ERROR_OPEN_DOCUMENT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD open_document.
    DATA:
      lv_filepath      TYPE filep,
      lv_extension     TYPE filep,
      lv_key           TYPE string,
      lv_application   TYPE string,
      lv_program       TYPE string,
      lv_parameter     TYPE string,
      lv_document_type TYPE c LENGTH 255.
    DATA:
      lv_handle      TYPE cntl_handle.
    DATA: lv_sapworkdir TYPE string.
*== init
    BREAK-POINT ID zbreak_test.
    CLEAR lv_filepath.
    lv_filepath = iv_filepath.
*== Extension.
    CALL FUNCTION 'CV120_SPLIT_FILE'
      EXPORTING
        pf_file          = lv_filepath
      IMPORTING
        pfx_dotextension = lv_extension.
*== Application
    lv_key = lv_extension.
    cl_gui_frontend_services=>registry_get_value(
    EXPORTING
        root      = cl_gui_frontend_services=>hkey_classes_root
        key       = lv_key
    IMPORTING
      reg_value = lv_application
        ).
*== Executable
    CONCATENATE lv_application '\shell\open\command' INTO lv_key.
    cl_gui_frontend_services=>registry_get_value(
      EXPORTING
        root      = cl_gui_frontend_services=>hkey_classes_root
        key       = lv_key
      IMPORTING
        reg_value = lv_program
        ).
    REPLACE ALL OCCURRENCES OF '"%1"' IN lv_program WITH ''.
*== Print (/t for Acrobat Reader)
    CLEAR lv_document_type.
    CASE lv_extension.
      WHEN '.pdf'.
*== open the document with special params
        cl_gui_frontend_services=>execute(
        EXPORTING
          application = lv_program
*          parameter   = lv_parameter
        EXCEPTIONS
          cntl_error             = 1
          error_no_gui           = 2
          bad_parameter          = 3
          file_not_found         = 4
          path_not_found         = 5
          file_extension_unknown = 6
          error_execute_failed   = 7
          synchronous_failed     = 8
          not_supported_by_gui   = 9
          OTHERS                 = 10
        ).
        IF sy-subrc <> 0.
          RAISE error_open_document.
        ENDIF.
      WHEN '.doc' OR '.docx'.
        lv_document_type = 'Word.Document.12'.
        lv_filepath = 'file://' && lv_filepath.
      WHEN '.xls' OR '.xlsx'.
        lv_document_type = 'Excel.Sheet.12'.
        lv_filepath = 'file://' && lv_filepath.
      WHEN '.xlsm' OR '.xltm'.
        lv_document_type = 'Excel.SheetMacroEnabled.12'.
        lv_filepath = 'file://' && lv_filepath.
    ENDCASE.
*=={only for the document types: doc|docx|xls|xlsx }
    IF lv_document_type IS NOT INITIAL.
*== Create instance of OI
      c_oi_container_control_creator=>get_container_control(
        IMPORTING
          control = my_control    " Container-Control
      ).
*== create container
      CREATE OBJECT my_container
        EXPORTING
          container_name              = 'CONTAINER'   " Name of the dynpro CustCtrl name to link this container to
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5
          OTHERS                      = 6.
      IF sy-subrc <> 0.
        RAISE error_open_document.
      ENDIF.
*== init control
      my_control->init_control(
        EXPORTING
          r3_application_name       = sy-repid    " Anwendungsname
*            inplace_enabled           = 'X'
          no_flush                  = 'X'
          parent                    = my_container    " Parent-Container
          register_on_close_event   = 'X'
*            register_on_custom_event  = ''
        IMPORTING
          retcode = DATA(retcode)
        EXCEPTIONS
          javabeannotsupported     = 1
          OTHERS                   = 2
      )."#NO_TEXT
      IF retcode NE c_oi_errors=>ret_ok.
        RAISE error_open_document.
      ENDIF.
*== tmp function for getting a list of registered doc types
*   Diese Methode gibt eine Liste aller Dokumenttypen zurück, die für einen bestimmten Interface-
*   Typ lokal auf dem Präsentationsrechner registriert wurden.
      BREAK-POINT ID zbreak_test.
      my_control->get_registered_doc_types(
        IMPORTING
          descr_list     = DATA(descr_list)
      ).
*== get Documentproxy
      my_control->get_document_proxy(
        EXPORTING
          document_type      = lv_document_type"'Word.Document.12'
          no_flush           = 'X'
        IMPORTING
          document_proxy     = my_doc_proxy
          retcode            = retcode
      ).
      IF retcode NE c_oi_errors=>ret_ok.
        RAISE error_open_document.
      ENDIF.
*== register event handler --> is not working cause no dynpro --> we need a dynpro!?! :-)
*      SET HANDLER lcl_event_handler=>close_event FOR my_doc_proxy.
*      SET HANDLER lcl_event_handler=>custom_event FOR my_doc_proxy.
*== open the document
      my_doc_proxy->open_document(
        EXPORTING
          document_title   = iv_doc_title
          document_url     = lv_filepath
          no_flush         = 'X'
          startup_macro    = iv_startup_macro
        IMPORTING
          retcode          = retcode
      ).
      IF retcode NE c_oi_errors=>ret_ok.
        RAISE error_open_document.
      ENDIF.
*== get handle of document for work with OLE
      my_doc_proxy->get_document_handle(
        EXPORTING
          no_flush = 'X'
        IMPORTING
          handle   = lv_handle
          retcode  = retcode
      ).
      IF retcode NE c_oi_errors=>ret_ok.
        RAISE error_open_document.
      ENDIF.
*== get SAP Workdir
      cl_gui_frontend_services=>get_sapgui_workdir(
        CHANGING
          sapworkdir            = lv_sapworkdir
      ).
*== cleanup
*-- close document
      my_doc_proxy->save_document_to_url(
        EXPORTING
          url           = 'file://' && lv_sapworkdir && '\' && 'APQP_Auswertung_' && sy-datum && '.xlsm'
          no_flush = abap_true
        IMPORTING
          retcode       = retcode
      ).
      IF sy-subrc = 0.
        rv_filepath_new_doc = lv_sapworkdir && '\' && 'APQP_Auswertung_' && sy-datum && '.xlsm'.
      ENDIF.
      my_doc_proxy->execute_macro(
              EXPORTING
                macro_string = iv_close_macro
              IMPORTING
                retcode      = retcode
            ).
      my_doc_proxy->close_document( ).
*-- destroy control
      my_control->destroy_control( ).
*-- free objects
      IF NOT my_doc_proxy IS INITIAL.
        my_doc_proxy->release_document( ).
      ENDIF.
      FREE:   my_doc_proxy,
              my_control.
      CLEAR:  my_doc_proxy,
              my_control.
      CLEAR lv_document_type.
    ENDIF.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method YCL_SO5_BCS=>PRINT_DOCUMENT
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_FILEPATH                    TYPE        STRING
* | [--->] IV_PRINTER                     TYPE        RSPOPNAME(optional)
* | [--->] IV_POPUP_PRINT                 TYPE        ABAP_BOOL
* | [EXC!] ERROR_PRINT_DOCUMENT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD print_document.
    DATA:
      lv_filepath      TYPE filep,
      lv_extension     TYPE filep,
      lv_key           TYPE string,
      lv_application   TYPE string,
      lv_program       TYPE string,
      lv_parameter     TYPE string,
      lv_document_type TYPE c LENGTH 255.
    DATA:
      lv_handle      TYPE cntl_handle.
*== init
    BREAK-POINT ID zbreak_test.
    CLEAR lv_filepath.
    lv_filepath = iv_filepath.
*== Extension.
    CALL FUNCTION 'CV120_SPLIT_FILE'
      EXPORTING
        pf_file          = lv_filepath
      IMPORTING
        pfx_dotextension = lv_extension.
*== Application
    lv_key = lv_extension.
    cl_gui_frontend_services=>registry_get_value(
    EXPORTING
        root      = cl_gui_frontend_services=>hkey_classes_root
        key       = lv_key
    IMPORTING
      reg_value = lv_application
        ).
*== Executable
    CONCATENATE lv_application '\shell\open\command' INTO lv_key.
    cl_gui_frontend_services=>registry_get_value(
      EXPORTING
        root      = cl_gui_frontend_services=>hkey_classes_root
        key       = lv_key
      IMPORTING
        reg_value = lv_program
        ).
    REPLACE ALL OCCURRENCES OF '"%1"' IN lv_program WITH ''.
*== Print (/t for Acrobat Reader)
    CLEAR lv_document_type.
    CASE lv_extension.
      WHEN '.pdf'.
        DATA(lv_tmp_string) = '"\\http://printserverpool-de0\DE00' && iv_printer && '"'.
*=={ instant print? }
        IF iv_popup_print NE abap_true AND iv_printer IS NOT INITIAL.
          "print on the given printer
          CONCATENATE  '/t' lv_filepath lv_tmp_string INTO lv_parameter SEPARATED BY space.
        ELSEIF iv_popup_print NE abap_true AND iv_printer IS INITIAL.
          "print @ local default printer
          CONCATENATE  '/p /h' lv_filepath  INTO lv_parameter SEPARATED BY space.
        ELSE.
          "choose printer
          CONCATENATE  '/p' lv_filepath  INTO lv_parameter SEPARATED BY space.
        ENDIF.
*== open the document with special params
        cl_gui_frontend_services=>execute(
        EXPORTING
          application = lv_program
          parameter   = lv_parameter
        EXCEPTIONS
          cntl_error             = 1
          error_no_gui           = 2
          bad_parameter          = 3
          file_not_found         = 4
          path_not_found         = 5
          file_extension_unknown = 6
          error_execute_failed   = 7
          synchronous_failed     = 8
          not_supported_by_gui   = 9
          OTHERS                 = 10
        ).
        IF sy-subrc <> 0.
          RAISE error_print_document.
        ENDIF.
      WHEN '.doc' OR '.docx'.
        lv_document_type = 'Word.Document.12'.
        lv_filepath = 'file://' && lv_filepath.
      WHEN '.xls' OR '.xlsx'.
        lv_document_type = 'Excel.Sheet.12'.
        lv_filepath = 'file://' && lv_filepath.
    ENDCASE.
*=={only for the document types: doc|docx|xls|xlsx }
    IF lv_document_type IS NOT INITIAL.
*== Create instance of OI
      c_oi_container_control_creator=>get_container_control(
        IMPORTING
          control = my_control    " Container-Control
      ).
*== create container
      CREATE OBJECT my_container
        EXPORTING
          container_name              = 'CONTAINER'   " Name of the dynpro CustCtrl name to link this container to
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5
          OTHERS                      = 6.
      IF sy-subrc <> 0.
        RAISE error_print_document.
      ENDIF.
*== init control
      my_control->init_control(
        EXPORTING
          r3_application_name       = text-203    " Anwendungsname
*            inplace_enabled           = 'X'
          no_flush                  = 'X'
          parent                    = my_container    " Parent-Container
          register_on_close_event   = 'X'
*            register_on_custom_event  = ''
        IMPORTING
          retcode = DATA(retcode)
        EXCEPTIONS
          javabeannotsupported     = 1
          OTHERS                   = 2
      )."#NO_TEXT
      IF retcode NE c_oi_errors=>ret_ok.
        RAISE error_print_document.
      ENDIF.
*== tmp function for getting a list of registered doc types
*   Diese Methode gibt eine Liste aller Dokumenttypen zurück, die für einen bestimmten Interface-
*   Typ lokal auf dem Präsentationsrechner registriert wurden.
      BREAK-POINT ID zbreak_test.
      my_control->get_registered_doc_types(
        IMPORTING
          descr_list     = DATA(descr_list)
      ).
*== get Documentproxy
      my_control->get_document_proxy(
        EXPORTING
          document_type      = lv_document_type"'Word.Document.12'
          no_flush           = 'X'
        IMPORTING
          document_proxy     = my_doc_proxy
          retcode            = retcode
      ).
      IF retcode NE c_oi_errors=>ret_ok.
        RAISE error_print_document.
      ENDIF.
*== register event handler --> is not working cause no dynpro --> we need a dynpro!?! :-)
      SET HANDLER lcl_event_handler=>close_event FOR my_doc_proxy.
      SET HANDLER lcl_event_handler=>custom_event FOR my_doc_proxy.
*== load document from URL
      my_doc_proxy->open_document(
        EXPORTING
          document_url     = lv_filepath
          no_flush         = 'X'
        IMPORTING
          retcode          = retcode
      ).
      IF retcode NE c_oi_errors=>ret_ok.
        RAISE error_print_document.
      ENDIF.
*== get handle of document for work with OLE
      my_doc_proxy->get_document_handle(
        EXPORTING
          no_flush = 'X'
        IMPORTING
          handle   = lv_handle
          retcode  = retcode
      ).
      IF retcode NE c_oi_errors=>ret_ok.
        RAISE error_print_document.
      ENDIF.
*== print the document
      my_doc_proxy->print_document(
        EXPORTING
          prompt_user = iv_popup_print
        IMPORTING
          retcode     = retcode
      ).
      IF retcode EQ c_oi_errors=>ret_ok OR
         retcode EQ c_oi_errors=>ret_method_cancelled.
      ELSE.
        RAISE error_print_document.
      ENDIF.
*== cleanup
*-- close document
      my_doc_proxy->close_document( ).
*-- destroy control
      my_control->destroy_control( ).
*-- free objects
      IF NOT my_doc_proxy IS INITIAL.
        my_doc_proxy->release_document( ).
      ENDIF.
      FREE:   my_doc_proxy,
              my_control.
      CLEAR:  my_doc_proxy,
              my_control.
      CLEAR lv_document_type.
    ENDIF.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method YCL_SO5_BCS->SAVE_SAP_MAIL
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_SOURCE_APP                  TYPE        CDOBJECTCL
* | [--->] IV_DESTINATION_APP             TYPE        CDOBJECTCL
* | [--->] IV_PROGRAMM                    TYPE        PROGRAMM
* | [--->] IV_TCODE                       TYPE        TCODE
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD save_sap_mail.
    DATA ls_sap_mail TYPE zme6_sap_mail.
*== init
    BREAK-POINT ID zbreak_test.
    CLEAR ls_sap_mail.
    ls_sap_mail-zme6_quell_anw = iv_source_app.
    ls_sap_mail-zme6_ziel_objekt = iv_destination_app.
    ls_sap_mail-zme6_mailbetreff = me->pv_subject.
    ls_sap_mail-zme6_absender = sy-uname.
    ls_sap_mail-programm = iv_programm.
    ls_sap_mail-zme6_datum_orig = sy-datum.
    ls_sap_mail-zme6_zeit_orig = sy-uzeit.
*== Protokolleintrag erzeugen
*-- CALL FUNCTION 'Z_ME6_SAVE_MAIL'...
    LOOP AT me->pt_mailrec ASSIGNING FIELD-SYMBOL(<fs_mailrec>).
      IF <fs_mailrec> IS ASSIGNED.
        CASE <fs_mailrec>-rec_type.
          WHEN 'U' OR 'B'.
            ls_sap_mail-zme6_empfaenger = <fs_mailrec>-receiver.
          WHEN 'C'.
            ls_sap_mail-zme6_verteiler = <fs_mailrec>-receiver.
        ENDCASE.
*-- to save resources, ...
        DO.                                              "#EC CI_NESTED
          INSERT zme6_sap_mail FROM ls_sap_mail.    "#EC CI_IMUD_NESTED
          IF sy-subrc = 0.
            CLEAR ls_sap_mail-zme6_empfaenger.
            CLEAR ls_sap_mail-zme6_verteiler.
            EXIT.
          ELSE.
*-- we wait 1 second before next mail send
            WAIT UP TO 1 SECONDS.
            ls_sap_mail-zme6_datum_orig = sy-datum.
            ls_sap_mail-zme6_zeit_orig = sy-uzeit.
          ENDIF.
        ENDDO.
      ENDIF.
    ENDLOOP.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method YCL_SO5_BCS->SEND_DOCUMENT
* +-------------------------------------------------------------------------------------------------+
* | [EXC!] ERROR_SEND_DOCUMENT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD send_document.
*== send document
    TRY .
        CASE pv_show_popup_before_send.
          WHEN 'X'.
            CASE me->pv_no_commit.
              WHEN abap_false.
                me->my_send_request->edit(
                  EXPORTING
                    i_starting_at_x   =  12   " Aufruf als Popup: Start-X-Koordinate
                    i_starting_at_y   =  5   " Aufruf als Popup: Start-Y-Koordinate
                    i_ending_at_x     =  97   " Aufruf als Popup: End-X-Koordinate
                    i_ending_at_y     =  22   " Aufruf als Popup: End-Y-Koordinate
                    i_hide_note       =  'X'   " Notiz geschlossen auf Sendebildschirm
                    i_edit_subject    =  'X'   " Titel beim 1. Versenden änderbar auf Sendebildschirm
                ).
              WHEN abap_true.
                "! currently not implemented
            ENDCASE.
          WHEN OTHERS.
            CASE me->pv_no_commit.
              WHEN abap_false.
                me->pv_sent_to_all = my_send_request->send( i_with_error_screen = 'X' ).
                IF me->pv_sent_to_all = 'X'.
*          WRITE text-003. --> Document Sent Successfully
                ENDIF.
              WHEN abap_true.
                me->my_alt_message->send( ).
            ENDCASE.
        ENDCASE.
      CATCH cx_bcs_send INTO me->my_bcs_exception.
        MESSAGE me->my_bcs_exception->get_text( ) TYPE 'E'.
      CATCH cx_send_req_bcs INTO me->my_bcs_exception.    "
      CATCH cx_bcs INTO me->my_bcs_exception.    "
        CASE me->my_bcs_exception->error_type.
          WHEN 'INTERR_BCS'.
          WHEN 'OSERR_BCS'.
          WHEN 'XERR_BCS'.
          WHEN 'PARERR_BCS'.
          WHEN 'VERR_BCS'.
          WHEN 'CERR_BCS'.
          WHEN 'NA_BCS'.
          WHEN 'LOCKED_BCS'.
          WHEN 'CASTERR_BCS'.
          WHEN OTHERS.
        ENDCASE.
        RAISE error_send_document.
    ENDTRY.
*== confirming database updates
    IF me->pv_no_commit EQ abap_false
      AND sy-oncom NE 'V'.
      COMMIT WORK.
    ENDIF.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method YCL_SO5_BCS->SEND_FAX
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_SHOW_POPUP_BEFORE_SEND      TYPE        ABAP_BOOL(optional)
* | [--->] IV_TAB_RECIEVER                TYPE        YSO5_TT_RECIEVER
* | [--->] IV_COUNTRY                     TYPE        LAND1
* | [--->] IV_ONLY_OUTLOOK_MAIL           TYPE        ABAP_BOOL (default =ABAP_FALSE)
* | [EXC!] ERROR_SEND_DOCUMENT
* | [EXC!] ERROR_CREATE_DOCUMENT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD send_fax.
    BREAK-POINT ID zbreak_test.
*== assign values
    me->pv_show_popup_before_send = iv_show_popup_before_send.
    me->pv_source_app = 'FAX'.
    me->pv_destination_app = 'FAX'.
    me->pv_programm = 'YCL_SO5_BCS->SEND_FAX'.
    me->pv_only_outlook_mail = iv_only_outlook_mail.
*==> check & set country for fax
    IF iv_country IS NOT INITIAL.
      pv_country4fax = iv_country.
    ELSE.
      pv_country4fax = 'DE'.
    ENDIF.

*== add recipients
    IF me->pt_mailrec IS NOT INITIAL.
*      APPEND iv_tab_reciever TO me->pt_mailrec.
    ELSE.
      me->pt_mailrec = iv_tab_reciever.
    ENDIF.
    me->set_recipients( ).
*== send document
    me->send_document(
    EXCEPTIONS
        error_send_document = 1
        OTHERS              = 2
    ).
    IF sy-subrc <> 0.
*       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      RAISE error_send_document.
    ELSE.
*== save document @ SAP Table ZME6_SAP_MAIL
      me->save_sap_mail(
                EXPORTING
                  iv_source_app      = me->pv_source_app
                  iv_destination_app = me->pv_destination_app
                  iv_programm        = me->pv_programm
                  iv_tcode           = me->pv_tcode
              ).
    ENDIF.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method YCL_SO5_BCS->SEND_MAIL
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_SHOW_POPUP_BEFORE_SEND      TYPE        ABAP_BOOL(optional)
* | [--->] IV_TAB_RECIEVER                TYPE        YSO5_TT_RECIEVER
* | [--->] IV_COUNTRY                     TYPE        LAND1(optional)
* | [--->] IV_ONLY_OUTLOOK_MAIL           TYPE        ABAP_BOOL (default =ABAP_FALSE)
* | [EXC!] ERROR_SEND_DOCUMENT
* | [EXC!] ERROR_CREATE_DOCUMENT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD send_mail.
    BREAK-POINT ID zbreak_test.
*== assign values
    me->pv_show_popup_before_send = iv_show_popup_before_send.
    me->pv_source_app = 'MAIL'.
    me->pv_destination_app = 'MAIL'.
    me->pv_programm = 'YCL_SO5_BCS->SEND_MAIL'.
    me->pv_only_outlook_mail = iv_only_outlook_mail.
*== add recipients
    IF me->pt_mailrec IS NOT INITIAL.
*      APPEND iv_tab_reciever TO me->pt_mailrec.
    ELSE.
      me->pt_mailrec = iv_tab_reciever.
    ENDIF.
    me->set_recipients( ).
*== send document
    me->send_document(
    EXCEPTIONS
        error_send_document = 1
        OTHERS              = 2
    ).
    IF sy-subrc <> 0.
      RAISE error_send_document.
    ELSE.
*== save document @ SAP Table ZME6_SAP_MAIL
      me->save_sap_mail(
                EXPORTING
                  iv_source_app      = me->pv_source_app
                  iv_destination_app = me->pv_destination_app
                  iv_programm        = me->pv_programm
                  iv_tcode           = me->pv_tcode
              ).
    ENDIF.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method YCL_SO5_BCS->SET_ATTACHMENTS
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_ATTACHMENT_TAB              TYPE        YSO5_TT_A_ATTACHMENT
* | [--->] IV_SUBJECT                     TYPE        SO_OBJ_DES(optional)
* | [EXC!] ATTACHMENT_TYPE_NOT_SUPPORTED
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD set_attachments.
    DATA: lv_subject TYPE so_obj_des.
    IF iv_subject IS INITIAL.
      lv_subject = me->pv_subject.
    ELSE.
      lv_subject = iv_subject.
    ENDIF.
*==> ?* optional
*==> check attachment type: if RAW | PDF | DOC | XLS --> continue else error
    IF iv_attachment_tab IS NOT INITIAL.
      LOOP AT iv_attachment_tab ASSIGNING FIELD-SYMBOL(<fs_attachments>)
            WHERE attachment_type = 'RAW'
            OR attachment_type = 'TXT'
            OR attachment_type = 'PDF'
            OR attachment_type = 'DOC'
            OR attachment_type = 'XLS'
            OR attachment_type = 'SAP'.                  "#EC CI_STDSEQ
        IF sy-subrc <> 0.
          RAISE attachment_type_not_supported.
        ENDIF.
      ENDLOOP.
      me->pt_attachments = iv_attachment_tab.           "#EC CI_CONV_OK
    ENDIF.
*-- add attachment to document
    IF me->pt_attachments IS NOT INITIAL.
      TRY .
          LOOP AT me->pt_attachments ASSIGNING <fs_attachments>.
            CASE me->pv_no_commit.
              WHEN abap_false.
                me->my_document->add_attachment(
                EXPORTING
                i_attachment_type     = <fs_attachments>-attachment_type  " Dokumenttyp der Anlage
                i_attachment_subject  = lv_subject                        " Titel der Anlage
                i_att_content_text    = <fs_attachments>-content_text     " Inhalt (textartig)
                i_att_content_hex     = <fs_attachments>-content_hex      " Inhalt (binär)
                i_attachment_size     = <fs_attachments>-content_size     " Größe des Dokumentinhalts
                ).
              WHEN abap_true.
                DATA character_string_text TYPE string.
                DATA character_string_hex TYPE string.
                CALL FUNCTION 'SWA_STRING_FROM_TABLE'
                  EXPORTING
                    character_table  = <fs_attachments>-content_text
                  IMPORTING
                    character_string = character_string_text.
                CALL FUNCTION 'SWA_STRING_FROM_TABLE'
                  EXPORTING
                    character_table  = <fs_attachments>-content_hex
                  IMPORTING
                    character_string = character_string_hex.
                me->my_alt_message->add_attachment(
                  EXPORTING
                    iv_doctype      = <fs_attachments>-attachment_type    " Dokumententyp
*                  iv_description  =     " Kurze Beschreibung des Inhaltes
*                  iv_filename     =     " Dateiname (mit Erweiterung)
*                  iv_codepage     =     " Zeichensatz eines Dokuments
                    iv_contents_txt = character_string_text   " Textueller Dokumenteninhalt
                    iv_contents_bin = CONV #( character_string_hex )   " Binärer Dokumenteninhalt
*                  iv_content_id   =     " Bodypart Content ID (für Related Bodyparts)
                ).
            ENDCASE.
          ENDLOOP.
        CATCH cx_document_bcs INTO me->my_bcs_exception.
      ENDTRY.
    ENDIF.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method YCL_SO5_BCS->SET_MY_DOC_BODY
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_BODY_TAB                    TYPE        BCSY_TEXT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD set_my_doc_body.
    CONSTANTS:
      c_div_start1  TYPE soli VALUE '<div id="Body" style="border-style:solid; border-width:2px; border-color:#5d5d5d; font-family:Arial; font-size: 14px; text-align:left; padding:0px; margin:0px">',
      c_div_start2  TYPE soli VALUE '<div id="Body" style="border-style:solid; border-width:5px; border-color:#95b2c3; font-family:Arial; font-size: 14px; text-align:left; padding:8px; margin:0px">',
      c_div_start3  TYPE soli VALUE '<div id="Body" style="font-family:Arial; font-size: 14px; text-align:left; padding:8px; margin:0px">',
      c_div_ende    TYPE soli VALUE '</div>',
      c_table_start TYPE soli VALUE '<table style="font-family:Arial; font-size: 12px;">',
      c_table_ende  TYPE soli VALUE '</table>',
      c_umbruch     TYPE soli VALUE '<br>',
      c_nobr(6)     TYPE c VALUE '<NOBR>'.
    DATA: ls_body     LIKE LINE OF iv_body_tab,
          lf_len_line TYPE i.
    CLEAR ls_body.
*== prepare text lines as html tags | keep it as raw (text)
    IF me->pv_convert_mail_as_html EQ abap_true.
      APPEND c_div_start3 TO me->pt_mailtext_body.
      LOOP AT iv_body_tab ASSIGNING FIELD-SYMBOL(<fs_body_row>).
        lf_len_line = strlen( <fs_body_row>-line ).
        IF lf_len_line GE 6.
          lf_len_line = lf_len_line - 6.
        ENDIF.
        IF <fs_body_row>-line+lf_len_line(6) = c_nobr.
          IF lf_len_line = 0.
            CLEAR: ls_body-line.
          ELSE.
            ls_body-line = <fs_body_row>-line(lf_len_line).
          ENDIF.
        ELSE.
          ls_body-line = <fs_body_row>-line && c_umbruch-line.
        ENDIF.
        APPEND ls_body TO me->pt_mailtext_body.
      ENDLOOP.
      APPEND c_div_ende TO me->pt_mailtext_body.
      APPEND c_umbruch TO me->pt_mailtext_body.
      APPEND c_umbruch TO me->pt_mailtext_body.
*-- placeholder für SAP LINK
      APPEND c_umbruch TO me->pt_mailtext_body.
    ELSE.
      me->pt_mailtext_body = iv_body_tab.
      APPEND INITIAL LINE TO me->pt_mailtext_body.
    ENDIF.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method YCL_SO5_BCS->SET_MY_DOC_FOOTER
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_FOOTER                      TYPE        YSO5_MAIL_FOOTER(optional)
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD set_my_doc_footer.
    CONSTANTS:
      c_div_start1  TYPE soli VALUE '<div id="Footer" style="border-style:solid; border-width:2px; border-color:#5d5d5d; font-family:Arial; font-size: 14px; text-align:left; padding:0px; margin:0px">',
      c_div_start2  TYPE soli VALUE '<div id="Footer" style="border-style:solid; border-width:5px; border-color:#95b2c3; font-family:Arial; font-size: 14px; text-align:left; padding:8px; margin:0px">',
      c_div_ende    TYPE soli VALUE '</div>',
      c_table_start TYPE soli VALUE '<table style="font-family:Arial; font-size: 12px;">',
      c_table_ende  TYPE soli VALUE '</table>',
      c_umbruch     TYPE soli VALUE '<br>'.
    DATA: ls_footer_text LIKE LINE OF me->pt_mailtext_footer.
    CLEAR ls_footer_text.
    IF me->pv_convert_mail_as_html EQ abap_true.
*== prepare text lines as html tags
      APPEND c_div_start2 TO me->pt_mailtext_footer.
      APPEND c_umbruch TO me->pt_mailtext_footer.
      APPEND c_table_start TO me->pt_mailtext_footer.
      APPEND '<tr><td colspan=2><b>Systeminformationen:</b></td></tr>' TO me->pt_mailtext_footer.
      APPEND '<tr><td>Anwendung:</td><td>' TO me->pt_mailtext_footer.
      APPEND iv_footer-zzme6_anwendung TO me->pt_mailtext_footer.
      APPEND '</td></tr>' TO me->pt_mailtext_footer.
      APPEND '<tr><td>Rolle:</td><td>' TO me->pt_mailtext_footer.
      APPEND iv_footer-zzme6_rolle TO me->pt_mailtext_footer.
      APPEND '</td></tr>' TO me->pt_mailtext_footer.
      APPEND '<tr><td>Auslöseuser:</td><td>' TO me->pt_mailtext_footer.
      SELECT SINGLE * FROM zme6_skb INTO @DATA(zme6_skb)
        WHERE username = @sy-uname.
      CONCATENATE zme6_skb-username ',µ' zme6_skb-skb ',µ' zme6_skb-nachname ',µ' zme6_skb-vorname
        INTO ls_footer_text-line.
      TRANSLATE ls_footer_text-line USING 'µ '.
      APPEND ls_footer_text TO me->pt_mailtext_footer.
      APPEND '</td></tr>' TO me->pt_mailtext_footer.
      APPEND '<tr><td>Transaktion:</td><td>' TO me->pt_mailtext_footer.
      APPEND iv_footer-tcode TO me->pt_mailtext_footer.
      APPEND '</td></tr>' TO me->pt_mailtext_footer.
      APPEND '<tr><td>Programm:</td><td>' TO me->pt_mailtext_footer.
      CLEAR ls_footer_text.
      CONCATENATE me->pv_programm 'µ/µ' sy-sysid
            INTO ls_footer_text-line.
      TRANSLATE ls_footer_text-line USING 'µ '.
      APPEND ls_footer_text TO me->pt_mailtext_footer.
      APPEND '</td></tr>' TO me->pt_mailtext_footer.
      APPEND '<tr><td>Doku:</td><td>' TO me->pt_mailtext_footer.
      APPEND iv_footer-zzme6_doku TO me->pt_mailtext_footer.
      APPEND '</td></tr>' TO me->pt_mailtext_footer.
      APPEND '<tr><td>Zust. Org-Abt.:</td><td>' TO me->pt_mailtext_footer.
      APPEND iv_footer-zzme6_abteilung TO me->pt_mailtext_footer.
      APPEND '</td></tr>' TO me->pt_mailtext_footer.
      APPEND '<tr><td>Datum/Uhrzeit:</td><td>' TO me->pt_mailtext_footer.
      CLEAR ls_footer_text.
      WRITE sy-datum TO ls_footer_text-line.
      WRITE sy-uzeit TO ls_footer_text-line+12.
      APPEND ls_footer_text TO me->pt_mailtext_footer.
      APPEND '</td></tr>' TO me->pt_mailtext_footer.
      APPEND c_table_ende TO me->pt_mailtext_footer.
      APPEND c_div_ende TO me->pt_mailtext_footer.
    ENDIF.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method YCL_SO5_BCS->SET_MY_DOC_HEADER
* +-------------------------------------------------------------------------------------------------+
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD set_my_doc_header.
    CONSTANTS:
      c_div_start1  TYPE soli VALUE '<div id="Header" style="border-style:solid; border-width:2px; border-color:#5d5d5d; font-family:Arial; font-size: 14px; text-align:left; padding:0px; margin:0px">',
      c_div_start2  TYPE soli VALUE '<div id="Header" style="border-style:solid; border-width:5px; border-color:#95b2c3; font-family:Arial; font-size: 14px; text-align:left; padding:8px; margin:0px">',
      c_div_ende    TYPE soli VALUE '</div>',
      c_table_start TYPE soli VALUE '<table style="font-family:Arial; font-size: 12px;">',
      c_table_ende  TYPE soli VALUE '</table>',
      c_umbruch     TYPE soli VALUE '<br>'.
    DATA: ls_header_text LIKE LINE OF me->pt_mailtext_footer.
**== init
    CLEAR ls_header_text.
*== prepare text lines as html tags | keep it as raw (text)
    IF me->pv_convert_mail_as_html EQ abap_true.
      APPEND c_div_start2 TO me->pt_mailtext_header.
*== set information for recipients
      IF sy-sysid(1) = 'D' OR sy-sysid(1) = 'Q'.
        CONCATENATE '<b>' text-201 sy-sysid '</b>' c_umbruch c_umbruch
          INTO ls_header_text-line SEPARATED BY space.
        APPEND ls_header_text TO me->pt_mailtext_header.
      ENDIF.
      APPEND c_div_ende TO me->pt_mailtext_header.
      APPEND c_umbruch TO me->pt_mailtext_header.
    ELSE.
      IF sy-sysid(1) = 'D' OR sy-sysid(1) = 'Q'.
        CONCATENATE text-201 sy-sysid
          INTO ls_header_text-line SEPARATED BY space.
        APPEND ls_header_text TO me->pt_mailtext_header.
        APPEND INITIAL LINE TO me->pt_mailtext_header.
      ENDIF.
    ENDIF.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method YCL_SO5_BCS->SET_RECIPIENTS
* +-------------------------------------------------------------------------------------------------+
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD set_recipients.
*== declaratio for FuBa: BAPI_USER_GET_DETAIL{
    DATA: ls_adress TYPE bapiaddr3.
    DATA: lt_return TYPE STANDARD TABLE OF bapiret2.
*== declaratio for FuBa: BAPI_USER_GET_DETAIL}
*==> 3
*== add recipients
*-- check type of recipient
*-- check distribution list is inside: if yes get the email address and add it to my_mailrec
    READ TABLE me->pt_mailrec ASSIGNING FIELD-SYMBOL(<fs_mailrec>) "BINARY SEARCH
    WITH KEY rec_type = 'C'.
    IF sy-subrc = 0 AND <fs_mailrec> IS ASSIGNED.
      me->pv_recipient_dl = <fs_mailrec>-receiver.
      me->get_and_set_email_address( me->pv_recipient_dl ).
      CLEAR me->pv_recipient_dl.
    ENDIF.
*-- delete duplicated entries
    LOOP AT me->pt_mailrec ASSIGNING FIELD-SYMBOL(<fs_tmp_mailrec>).
      TRANSLATE <fs_tmp_mailrec>-receiver TO UPPER CASE.
    ENDLOOP.
    SORT me->pt_mailrec BY receiver rec_type.
    DELETE ADJACENT DUPLICATES FROM me->pt_mailrec COMPARING receiver copy.
    TRY .
        LOOP AT me->pt_mailrec ASSIGNING <fs_mailrec>.
          CLEAR: me->pv_recipient_u, me->pv_recipient_b, me->pv_recipient_f, me->pv_mail_copy.
          CASE <fs_mailrec>-rec_type.
*-- add recipient (e-mail address)
            WHEN 'U'. "Internet Adresse --> send Outlook mail
              CASE me->pv_no_commit.
                WHEN abap_false.
                  me->pv_recipient_u = <fs_mailrec>-receiver.
                  me->my_recipient = cl_cam_address_bcs=>create_internet_address( me->pv_recipient_u ).
              ENDCASE.
*-- add recipient (SAP Benutzer)
            WHEN 'B'. "SAP Benutzer --> send SAP mail
              IF me->pv_only_outlook_mail <> abap_true.
                CASE me->pv_no_commit.
                  WHEN abap_false.
                    me->pv_recipient_b = <fs_mailrec>-receiver.
                    me->my_recipient = cl_sapuser_bcs=>create( me->pv_recipient_b ).
                ENDCASE.
              ELSE.
                CALL FUNCTION 'BAPI_USER_GET_DETAIL'
                  EXPORTING
                    username = CONV sy-uname( <fs_mailrec>-receiver )
                  IMPORTING
                    address  = ls_adress
                  TABLES
                    return   = lt_return.
                IF lt_return IS INITIAL.
*-- check if the e-mail adress is already set as recipient
                  TRANSLATE ls_adress-e_mail TO UPPER CASE.
                  READ TABLE me->pt_mailrec TRANSPORTING NO FIELDS
                  WITH KEY receiver = ls_adress-e_mail rec_type = 'U'. "#EC CI_STDSEQ
                  IF sy-subrc <> 0.
                    CASE me->pv_no_commit.
                      WHEN abap_false.
                        me->pv_recipient_u = ls_adress-e_mail.
                        me->my_recipient = cl_cam_address_bcs=>create_internet_address( me->pv_recipient_u ).
                    ENDCASE.
                  ENDIF.
                ENDIF.
              ENDIF.
            WHEN 'F'. "Faxnummer --> send FAX
*-- add recipient (fax)
              CASE me->pv_no_commit.
                WHEN abap_false.
                  me->pv_recipient_f = <fs_mailrec>-receiver.
                  me->my_recipient = cl_cam_address_bcs=>create_fax_address(
                                  i_country = me->pv_country4fax
                                  i_number  = me->pv_recipient_f ).
              ENDCASE.
            WHEN 'C'.
              CASE me->pv_no_commit.
                WHEN abap_false.
                  IF me->pv_only_outlook_mail <> abap_true.
                    me->pv_recipient_dl = <fs_mailrec>-receiver.
                    me->my_recipient = cl_distributionlist_bcs=>getu_persistent(
                      EXPORTING
                        i_dliname      = me->pv_recipient_dl    " Name der Verteilerliste
                        i_private      = ' '    " Flag für öffentliche/private VL
                    ).
                  ENDIF.
                WHEN abap_true.
                  "! not supported in CL_BCS_MESSAGE
              ENDCASE.
          ENDCASE.
*-- email cc?
          IF <fs_mailrec>-copy IS NOT INITIAL.
            me->pv_mail_copy = 'X'.
          ENDIF.
*-- express?
          IF <fs_mailrec>-express IS NOT INITIAL.
            me->pv_mail_express = 'X'.
          ENDIF.
*-- blind copy?
          IF <fs_mailrec>-blind_copy IS NOT INITIAL.
            me->pv_mail_bc = 'X'.
          ENDIF.
*-- add recipient with its respective attributes to send request
          CASE me->pv_no_commit.
            WHEN abap_false.
              me->my_send_request->add_recipient(
                EXPORTING
                  i_recipient     =  me->my_recipient   " Empfänger einer Nachricht
                  i_express       =  me->pv_mail_express   " Senden als Expressnachricht
                  i_copy          =  me->pv_mail_copy   " Senden in Kopie
                  i_blind_copy    =  me->pv_mail_bc   " Senden als geheime Kopie
              ).
            WHEN abap_true.
              IF <fs_mailrec>-rec_type NE 'C'.
                me->my_alt_message->add_recipient(
                  EXPORTING
                    iv_address      = CONV #( <fs_mailrec>-receiver )   " Kommunikationsadresse (für INT, FAX, SMS...)
                    iv_commtype     = SWITCH #( <fs_mailrec>-rec_type "! 'INT'    " Kommunikationsart
                                                WHEN 'U' THEN 'INT'
                                                WHEN 'B' THEN 'USR'
                                                WHEN 'F' THEN 'FAX'
                                                )
*                  iv_visible_name =     " Anzeigename einer Adresse
                    iv_copy         = SWITCH #( <fs_mailrec>-copy    "! Kopieempfänger (kein, CC, BCC)
                                        WHEN abap_true THEN 'CC'
                                        ELSE SWITCH #( <fs_mailrec>-blind_copy
                                              WHEN abap_true THEN 'BCC'
                                              )
                                        )
*                  iv_fax_country  =     " Land für Telefon-/Faxnummer
                ).
              ENDIF.
          ENDCASE.
        ENDLOOP.
      CATCH cx_address_bcs INTO me->my_bcs_exception.
      CATCH cx_send_req_bcs INTO me->my_bcs_exception.
    ENDTRY.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method YCL_SO5_BCS->SET_SENDER
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_SENDER                      TYPE        STRING
* | [--->] IV_TYPE                        TYPE        CHAR01
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD set_sender.
    DATA: lv_str_address TYPE adr6-smtp_addr.
*== 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.
    TRY .
        CASE iv_type.
          WHEN 'B'.
            CASE me->pv_no_commit.
              WHEN abap_false.
                me->my_sender_b = cl_sapuser_bcs=>create( i_user = sy-uname ).
                me->my_send_request->set_sender( i_sender = me->my_sender_b ).
              WHEN abap_true.
                me->my_alt_message->set_sender(
                  EXPORTING
                    iv_address      = CONV #( sy-uname  )   " Kommunikationsadresse (für INT, FAX, SMS...)
                    iv_commtype     = 'USR'    " Kommunikationsart
                ).
            ENDCASE.
          WHEN 'U'.
            CASE me->pv_no_commit.
              WHEN abap_false.
                lv_str_address = iv_sender.
                me->my_sender_u = cl_cam_address_bcs=>create_internet_address( lv_str_address ).
                me->my_send_request->set_sender( i_sender = me->my_sender_u ).
              WHEN abap_true.
                me->my_alt_message->set_sender(
                  EXPORTING
                    iv_address      = CONV #( lv_str_address )   " Kommunikationsadresse (für INT, FAX, SMS...)
                    iv_commtype     = 'INT'    " Kommunikationsart
                ).
            ENDCASE.
        ENDCASE.
      CATCH cx_address_bcs INTO me->my_bcs_exception.
      CATCH cx_send_req_bcs INTO me->my_bcs_exception.
    ENDTRY.
  ENDMETHOD.
ENDCLASS.

Lokale Definition/Implementierungen

 *"* use this source file for the definition and implementation of
*"* local helper classes, interface definitions and type
*"* declarations
CLASS lcl_event_handler DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
*== print document{
      close_event FOR EVENT on_close_document OF i_oi_document_proxy
        IMPORTING document_proxy,
      custom_event FOR EVENT on_custom_event OF i_oi_document_proxy
        IMPORTING document_proxy.
*==} print document
ENDCLASS.
CLASS lcl_event_handler IMPLEMENTATION.
  METHOD close_event.
  ENDMETHOD.
  METHOD custom_event.
  ENDMETHOD.
ENDCLASS.
Letzte Änderung am %AM, %15. %517 %2016 %11:%Jun
Kommentare einblenden

Copyright © 2017 ABAP-Workbench.de