2

Email Notes are standard feature available in SAP ... - SAP Community

 1 month ago
source link: https://community.sap.com/t5/technology-blogs-by-members/email-notes-are-standard-feature-available-in-sap-xk01-xd01-but-are-not/ba-p/13319343
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Introduction:

Email Notes are standard functionality in ECC (Vendor/Customer). All the Notes/Remarks against email will get saved in the ADRT Table. However, this feature is not available in the MDG (till v9.0). As many of the current organization still uses the Notes/Remarks, so it kind of important to have this feature available in MDG UIs.
2017-09-27-10_52_15-.png

Requirement / Screen Overview:

Let's take an example of ERP Vendor Screen on MDG. Below Screen overview will give you comparison of MDG screen with Current & Expected Screen after the solution.

Current MDG Screen:-
2-29.png
Expected MDG Screen:-
3-37.png

Solution:

The below solution is done for Notes/Remarks field only for Email Segment. As we all know Telephone and Fax can also have their own Remarks field. The same solution can be extended to make it available for Telephone & Fax respectively.

Solution is divided into 6 steps. follow them carefully.

Step 1) Standard Structure which can carry the Notes Data & hold it during the CR preparation. This structure is used in the Handler Class to transfer the Data.

Good think about this development, that back-end structures already contains the REMARKS Table which can hold the Notes provided in the E-mail section. We are going to re-use those structures. Field representation is given in the below structures. Have a look at that.

In structure MDG_BS_BP_TT_ECC_EXTERN identify the relevant substructure.
4-31.png
Structure: BUS_EI_EXTERN
5-26.png
Structure: BUS_EI_CENTRAL_DATA
6-26.png
7-26.png
8-22.png
9-18.png
91.png
92.png
93.png
Actual Navigation Stack mentioned down below
94.png
Structure for Remark
95.png
96.png
We are going to use the highlighted field to store the Notes in the API.

Step 2) Active(Reuse) Area for Notes.

For this Development, we are going to use ADRT table as active area for Notes. Just have a look at the table/field which will be used.
97.png

Step 3) Extend the MDG-S/C data model with new attribute “Notes” under Email Entity.

While change requests are in process, the data is stored in the MDG staging area. Therefore, you must extend the BP data model accordingly. The necessary steps are outlined in this section.  As we are enhancing the standard entity, We just need to create one custom attribute and generate the structures.
98.png
Add Custom Attribute under AD_EMAIL entity. (The Structure BSS_ADIL_COMM_EMAIL_ATTR is enhanced in Step 4. Just Activate the data model with blank reference & later after Step 4, come back again & put the reference structure & activate it again).
99.png
Activate the Data Model, after activation, you should see the Staging Area for this entity like below:-

To Check the Staging Area: Use SE38.
11-18.png
12-14.png
13-13.png
Double Click on the Entity Type
14-11.png
After the above step, Generate the Data Model Structures

Select these 5 below and press Generate Button
15-10.png
After successful generation, you will have the custom field created in the standard structures created in the system
16-11.png
Last point in this step is to ADJUST THE STAGING AREA (optional), but it is important to perform this step if data model is changed

RUN the report USMD_ADJUST_STAGING

Step 4) Genil Model – As this is a Standard Entity/Object, we need to extend the attribute structure used by Genil Object for E-mail

GENIL ENHANCEMENT:

T-code: GENIL_MODEL_BROWSER or GENIL_MODEL_EDITOR

Open Enhancement: BUPA_CUSP
21-5.png
22-8.png
Double Click the Attribute Structure.

In the Standard structure, Use Append Structure technique to Append a new structure ZMDG_SMTP_NOTES_GENIL like Below
23-5.png
24-3.png
Activate the structure.

NOTE: If you remember this Genil Structure is used in the data model against that custom attribute ZZNOTE used for highlighting changes.

Step 5) Extending the MDG-S User Interface to incorporate this Field in the List UIBB for Workplace E-mails

1. Start transaction SE80.

2. Search for Web Dynpro Component FPM_LIST_UIBB

3. Locate and open the Component Configuration BS_BP_ADDRESS_EMAILS

4. Display the Configuration

25-3.png

5. Create new customizing: - New field is coming from the Genil structure. Use that to create a new column

26-3.png

6. Save your changes

Result

You have extended MDG-S to handle a new field ZZNOTE. Till this step, you can do all the functionality, add a new row, delete a row or change a row (with Notes) and save the CR. All the data is saved in the Staging Tables. You can open the CR and check the data again in the list. Everything is working fine. Except this solution is only half complete. When the CR is approved, the data would be removed from the Staging Area and because no SMT Mapping is available, so data will not move into active area (ADRT).

The Next Step (6) is the rest of the solution. It will move the staging data to the active area (ADRT), and bring the active area data to the UI.

Step 6) Custom Handler Class to do the mapping from Active Area(ADRT) to the UI and then During Approval, API to Active Area (ADRT)

  • Create Your Own Handler Class
Class: ZCL_MDG_BS_BP_HANDLER
31-4.png
  • Register the Handler Class to the BP Data Model

T:Code – SM30

32-4.png
33-5.png
  • Implement the Custom Handler to do the SMT Mapping.

Redefine all the below method of the class.

34-5.png
NOTE: We are not redefining the SAVE_ADDITIONAL_OBJECT_DATA! Remember we are using the standard structures in the Step 1. This is the reason of using Standard structures, if we populate these structures in this Class, Standard will take care of saving the data directly into ADRT table. As it’s a standard flow of data

Method Redefinition below:
  METHOD if_mdg_bs_bp_access_handler~read_object_data.
    DATA : lv_adrnr  TYPE ad_addrnum,
           lt_return TYPE TABLE OF bapiret2,
           lt_adrt   TYPE TABLE OF adrt.

    CALL METHOD super->if_mdg_bs_bp_access_handler~read_object_data
      EXPORTING
        it_idlist   = it_idlist
        iv_read_all = iv_read_all.

* Read the Vendor Number
    READ TABLE it_idlist ASSIGNING FIELD-SYMBOL(<ls_idlist>) INDEX 1.
    CHECK sy-subrc EQ 0.

    DATA(lv_bp) = <ls_idlist>-bpartner.

* Get the ADRT Data into the internal structures
    READ TABLE gt_bp_data_db ASSIGNING FIELD-SYMBOL(<ls_data>)
          WITH KEY partner-header-object_instance-bpartner = lv_bp
          BINARY SEARCH.
    IF <ls_data> IS ASSIGNED.
      "Read the Address of the Business Partner
      READ TABLE <ls_data>-partner-central_data-address-addresses ASSIGNING FIELD-SYMBOL(<fs_address>) INDEX 1.
      CHECK sy-subrc = 0.

      IF <fs_address>-data-communication-smtp-smtp IS NOT INITIAL.   "Fetch the ADRT data only for the 1st Time.
* Read the ADRNR from the BP number
        "ADRT Data should be fetched based on the ADRNR & CONSNO.
        <fs_address>-data-zzsmtp_notes-CURRENT_STATE = abap_true.
        DATA(lv_error)  = abap_false.
        CALL FUNCTION 'BAPI_BUPA_ADDRESSES_GET'
          EXPORTING
            businesspartner       = lv_bp
          IMPORTING
            standardaddressnumber = lv_adrnr
          TABLES
            return                = lt_return.

        LOOP AT lt_return INTO DATA(ls_reutrn) WHERE type EQ 'E'.
          lv_error  = abap_true.
          EXIT.
        ENDLOOP.

        CHECK lv_error EQ abap_false.

* Read the ADRT Data for this Address Number
        SELECT * FROM adrt INTO TABLE lt_adrt WHERE addrnumber = lv_adrnr
                                              AND persnumber EQ space.
        IF sy-subrc EQ 0 AND lt_adrt IS NOT INITIAL.

          " Fill the REMARKS structure of the SMTP Componenet of the Internal Strucutre
          LOOP AT <fs_address>-data-communication-smtp-smtp ASSIGNING FIELD-SYMBOL(<fs_smtp>).
            READ TABLE lt_adrt INTO DATA(ls_adrt) WITH KEY consnumber = <fs_smtp>-contact-data-consnumber.
            IF sy-subrc = 0.
              READ TABLE <fs_smtp>-REMARK-remarks ASSIGNING FIELD-SYMBOL(<fs_remark>) INDEX 1.
              IF sy-subrc = 0.
                <fs_remark>-data-langu      = sy-langu.
                <fs_remark>-data-langu_iso  = 'EN'.
                <fs_remark>-data-comm_notes = ls_adrt-remark.
              ENDIF.
            ENDIF.
          ENDLOOP.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDMETHOD.
  METHOD if_mdg_bs_bp_access_handler~get_object_data_by_entity.
    CALL METHOD super->if_mdg_bs_bp_access_handler~get_object_data_by_entity
      EXPORTING
        iv_entity    = iv_entity
        iv_partner   = iv_partner
      IMPORTING
        er_data      = er_data
        ef_not_found = ef_not_found.

    CASE iv_entity.
      WHEN if_mdg_bp_constants=>gc_bp_model_entity-address_email.       "AD_EMAIL entity
        "search the requested business partner in the buffer
        READ TABLE gt_bp_data_db ASSIGNING FIELD-SYMBOL(<ls_data>)
          WITH KEY partner-header-object_instance-bpartner = iv_partner
          BINARY SEARCH.
        IF <ls_data> IS ASSIGNED.
          GET REFERENCE OF <ls_data> INTO er_data.
          ef_not_found = abap_false.
        ELSE.
          CLEAR er_data.
          ef_not_found = abap_true.
        ENDIF.
      WHEN OTHERS.
        RETURN.
    ENDCASE.
  ENDMETHOD.
METHOD if_mdg_bs_bp_access_handler~map_data_2sta.

    DATA: lo_data TYPE REF TO   data,
          ls_smtp TYPE bus_ei_bupa_smtp.

    FIELD-SYMBOLS: <fs_gt_bp_data> TYPE mdg_bs_bp_t_fnd_extern,
                   <fs_partner>    TYPE bus_ei_extern,
                   <fs_remark>     TYPE bus_ei_bupa_comrem,
                   <fs_address>    TYPE bus_ei_bupa_address.

    ASSIGN COMPONENT 'PARTNER' OF STRUCTURE is_data TO <fs_partner>.
    CHECK <fs_partner> IS ASSIGNED.
    READ TABLE <fs_partner>-central_data-address-addresses ASSIGNING <fs_address> INDEX 1.
    IF sy-subrc = 0.

    ENDIF.

    CREATE DATA lo_data LIKE LINE OF ct_data.
    ASSIGN lo_data->* TO FIELD-SYMBOL(<ft_data>).
    CHECK <ft_data> IS ASSIGNED.


    CASE iv_entity.
      WHEN if_mdg_bp_constants=>gc_bp_model_entity-address_email.       "AD_EMAIL entity
        "search the requested business partner in the buffer
        " Read the Data from IS_DATA and push them in CT_DATA.
        LOOP AT ct_data ASSIGNING FIELD-SYMBOL(<fs_data>).
          ASSIGN COMPONENT 'BP_HEADER' OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<fs_bp>).
          CHECK <fs_bp> IS ASSIGNED.
          IF <fs_bp> IS NOT INITIAL.
            ASSIGN COMPONENT 'AD_CONSNO' OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<fs_consno>).
            CHECK <fs_consno> IS ASSIGNED AND <fs_consno> IS NOT INITIAL.
            READ TABLE <fs_address>-data-communication-smtp-smtp INTO ls_smtp WITH KEY contact-data-consnumber = <fs_consno>.
            IF sy-subrc = 0.
              ASSIGN COMPONENT 'ZZNOTE' OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<fs_zznote>).
              IF <fs_zznote> IS ASSIGNED.
                READ TABLE ls_smtp-remark-remarks ASSIGNING <fs_remark> WITH KEY data-langu = sy-langu.
                IF sy-subrc = 0 AND <fs_remark> IS ASSIGNED.
                  <fs_zznote> = <fs_remark>-data-comm_notes.
                ENDIF.

              ENDIF.
            ENDIF.
          ENDIF.
        ENDLOOP.
      WHEN OTHERS.
        RETURN.
    ENDCASE.
  ENDMETHOD. 
METHOD if_mdg_bs_bp_access_handler~prepare_ei_header_map_2api.
    CALL METHOD super->if_mdg_bs_bp_access_handler~prepare_ei_header_map_2api
      EXPORTING
        iv_entity   = iv_entity
        iv_task     = iv_task
        is_data     = is_data
      IMPORTING
        er_data_ext = er_data_ext
      CHANGING
        ct_data_ext = ct_data_ext.
  ENDMETHOD. 
METHOD if_mdg_bs_bp_access_handler~map_data_2api.

    DATA : ls_notes_data        TYPE bus_ei_bupa_comrem.            " We are using Existing REMARKS structure which are already in API to store the chanegd data

    FIELD-SYMBOLS: <fs_partner> TYPE bus_ei_extern,
                   <fv_consno>  TYPE ad_consnum.

    CASE iv_entity.
      WHEN if_mdg_bp_constants=>gc_bp_model_entity-address_email.       "AD_EMAIL entity
        ASSIGN COMPONENT 'PARTNER' OF STRUCTURE cs_data_ext TO <fs_partner> .
        CHECK <fs_partner> IS ASSIGNED.

        READ TABLE <fs_partner>-central_data-address-addresses ASSIGNING FIELD-SYMBOL(<fs_address>) INDEX 1.
        CHECK sy-subrc = 0.

        " Get the CONS NO from the IS_DATA
        ASSIGN COMPONENT 'AD_CONSNO' OF STRUCTURE is_data TO <fv_consno>.
        CHECK <fv_consno> IS ASSIGNED AND <fv_consno> IS NOT INITIAL.

        " Get the ZZNOTES from the IS_DATA
        ASSIGN COMPONENT 'ZZNOTE' OF STRUCTURE is_data TO FIELD-SYMBOL(<fv_note>).
        CHECK <fv_note> IS ASSIGNED AND <fv_note> IS NOT INITIAL.

        " Read the SMTP line based on the CONSNO.
        READ TABLE <fs_address>-data-communication-smtp-smtp ASSIGNING FIELD-SYMBOL(<fs_smtp>)
                                                             WITH KEY contact-data-consnumber = <fv_consno>.
        IF sy-subrc = 0.
* Task
          ls_notes_data-task = iv_task.
* Data
          ls_notes_data-data-langu       =  sy-langu.
          ls_notes_data-data-langu_iso   =  'EN'.
          ls_notes_data-data-comm_notes  =  <fv_note>.

* Append the Data
          APPEND ls_notes_data TO <fs_smtp>-remark-remarks.
        ENDIF.

        cv_xchange = abap_true.
      WHEN OTHERS.

    ENDCASE.
  ENDMETHOD.
35-5.png
36-4.png

Result

This above solution is working for Email remarks, similarly telephone/fax entity can be enhanced with another custom field and using SMT mapping in custom handler, remarks can be populated against each field.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK