Skip to Content
Author's profile photo Former Member

How to integrate attachments to Interaction Records

Table of Contents

  1. Pre-requisites
  2. Introduction
  3. Technical Implementation

  1. Pre-requisites

  This is a technical document aimed at developers having expertise in CRM ISU developments. The target audience for this document is expected to have good knowledge in SAP CRM Web UI programming.  

  1. Introduction

It is often a requirement for the clients to add the attachments to the Interaction Record in Web IC environment. As a standard solution form SAP for Utility clients, the business roles UTIL_IC/UTIL_SALES/UTIL_IC_REG/UTIL_IC_LEAN, does not provide this option. Here with this document we can learn how to integrate attachment section into Interaction Records with a very minimal development need.

  1. Technical Implementation:

SAP delivers a Generic UI component called “GS_CM” for handling the attachments in Web UI. We are going to leverage this component and integrate the same in Interaction Record. Refer to attachment GS_CM.JPG for the snapshot.

                          

     Following are the list of steps involved for integration:

  1. Create a new UI component ZICCMP_ATTACH.
  2. Add two component usages CUGSCM and CUGSCM_DET both referring to the component “GS_CM” and then add the interface view “Mainwindow”.
  3. Create an overview page ZICCMP_ATTACH/INRAttachOV and then assign View CUGSCM.MainWindow.
  4. Assign the above created overview page to the Mainwindow and then expose the same for use by other components.
  5. Add the following context nodes to the component controller of ZICCMP_ATTACH.
  Context Node

Base Entity

BTADMINH

BTAdminH

BTORDER

BTOrder

CMBO

CMBO

  1. For the context node CMBO we need to implement the ON_NEW_FOCUS method. Here we refresh the attachments whenever the Interaction Record is changed. Copy the following code.

method ON_NEW_FOCUS.
 
data:
    lr_qs                
type ref to cl_crm_bol_query_service,
    ls_cmbo_prop         
type crmt_cmic_rfolder_attr,
    lr_entity_col        
type ref to if_bol_entity_col,
    ls_admin_h           
type crmst_adminh_btil.

  check focus_bo is bound.

  lr_qs = cl_crm_bol_query_service=>get_instance( cl_crm_cm_genil_comp=>gc_query_bo_link ).

  focus_bo->get_properties( importing es_attributes = ls_admin_h ).
  ls_cmbo_prop-instid = ls_admin_h-guid.
  ls_cmbo_prop-typeid = ls_admin_h-object_type.
  ls_cmbo_prop-catid =
‘BO’.                                “#EC NOTEXT* fill and fire query
  lr_qs->set_properties( ls_cmbo_prop ).
  lr_entity_col = lr_qs->get_query_result( ).
* set context node
  collection_wrapper->clear_collection( ).
  collection_wrapper->set_collection( lr_entity_col ).
endmethod.

  1. Create value node ‘Attributes’ in the component controller with the following attribute structure.

             DISPLAY

TYPE BOOLE_D,
           NEXT_RUN_REREAD

TYPE BOOLE_D,
           SINGLE_DOC_MODE

TYPE BOOLE_D,
           DOC_TEMPLATE_PROFILE

TYPE CRMT_TEMPL_PROFILE,
           FOLDER_TEMPLATE_NAME

TYPE CRMT_TEMPLATE_NAME.

  

  1. Now we have to bind the context nodes with component usage CUGSCM and CUGSCM_DET. Redefine WD_USAGE_INITIALIZE method and copy the following code.

method WD_USAGE_INITIALIZE.

  DATA: lr_value_node TYPE REF TO cl_bsp_wd_value_node,
        ls_attr      
TYPE crmt_cm_comp_st,
        lr_attr      
TYPE REF TO crmt_cm_comp_st.

  CASE iv_usage->usage_name.
   
WHEN ‘CUGSCM’ or ‘CUGSCM_DET’.
     
CALL METHOD iv_usage->bind_context_node
       
EXPORTING
          iv_controller_type  = cl_bsp_wd_controller=>co_type_component
          iv_target_node_name =
‘BTORDER’                   “#EC NOTEXT
          iv_node_2_bind      =
‘PARENTNODE’.               “#EC NOTEXT

      CALL METHOD iv_usage->bind_context_node
       
EXPORTING
          iv_controller_type  = cl_bsp_wd_controller=>co_type_component
          iv_target_node_name =
‘CMBO’                “#EC NOTEXT
          iv_node_2_bind      =
‘CMBUSOBJ’.               “#EC NOTEXT

      ls_attr-next_run_reread = abap_true.
      GET REFERENCE OF ls_attr INTO lr_attr.
     
CREATE OBJECT lr_value_node
       
EXPORTING
          iv_data_ref = lr_attr.
      lr_value_node->if_bol_bo_property_access~set_properties( ls_attr ).
      me->typed_context->attributes->collection_wrapper->clear( ).
      me->typed_context->attributes->collection_wrapper->add( lr_value_node ).

      CALL METHOD iv_usage->bind_context_node
       
EXPORTING
          iv_controller_type  = cl_bsp_wd_controller=>co_type_component
          iv_target_node_name =
‘ATTRIBUTES’                “#EC NOTEXT
          iv_node_2_bind      =
‘ATTRIBUTES’.               “#EC NOTEXT

  endcase.endmethod.

  1. Add the Navigation link as shown in the attachment NavLink.JPG.   

Until the above step a re-usable component for attachment is created and now we need to integrate the same into Interaction record. The following steps will help us in doing the same.

  1. Enhance the standard component ICCMP_BT_INR with the enhancement set.
  1. Create component usage CUATTACH referring to component ZICCMP_ATTACH and then add the interface view ZICCMP_ATTACH/MainWindow.

 

  

  1. Now in the component controller we need to bind the context node. Redefine method WD_USAGE_INITIALIZE and copy paste the below code.

METHOD wd_usage_initialize.
 
CALL METHOD super->wd_usage_initialize
   
EXPORTING
      iv_usage = iv_usage.

  CASE iv_usage->usage_name.

    WHEN ‘CUATTACH’ .
     
CALL METHOD iv_usage->bind_context_node
       
EXPORTING
          iv_controller_type  = cl_bsp_wd_controller=>co_type_component
          iv_target_node_name =
‘BTORDER’                   “#EC NOTEXT
          iv_node_2_bind      =
‘BTORDER’.                  “#EC NOTEXT
 
ENDCASE.ENDMETHOD.

  1. Enhance ViewSet ICCMP_BT_INR/InrViewSet and add a new view area called Attachment

 

  

  1. Now assign view CUATTACH.ZICCMP_ATTACH/MainWindow to the above created view set.
  1. Save and activate the changes.

Now to test the output we need to login to CRM Web UI with any of the Utility web center role. After log in, confirm the business agreement and click on the Interaction Record work center. The output will be similar as shown in the attchement file InteractionRec.JPG.

The attachment block refreshes its content whenever a different interaction record is selected in the Last Interaction record table view

Assigned Tags

      13 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi,

      Thanks for this document. I found it very helpfull, and it met exactly my needs. I have a problem, though, and maybe you could kindly help me. I now see the attachment block in the interaction record, but the fields are not editable. Do you have an idea where I went wrong?

      Thank you very much.

      Michele

      Author's profile photo Former Member
      Former Member

      Hi,

      This document is the exact scenario we want to implement.  However I'm having a problem adding the context nodes as listed in step 5.  I also don't completely understand what is meant in step 4 by " then expose the same for use by other components."

      When I tried to perform step 5 it errors stating "BOL entity CMBO does not exist." I received this same error on the first 2 and resolved it by adding Models -> Model BT in the Runtime Repository Editor but the system doesn't allow for 2 models in this section. 

      Is there another Model which contains all 3 of these context nodes or have I misunderstood something in a previous step?

      Thanks for your help,

      Duane Chapman

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hello,

      Perhaps my response is late. Hopefully the below response helps if you have not figured out the solution yet.

      1) step -4, you can expose the window in the runtime repository. Edit runtime repository->right click on the Component interface ->Add mainwindow-> save changes.

      2) Step-5 ) In the runtime repository add model ONEORDER. This should resolve your context node issue.

      Thanks,

      Gopal

      Author's profile photo Former Member
      Former Member

      Hello Gopal,

      The ONEORDER model step is the one I was missing, thank you.  Also, once working on step 6 there was an issue with FOCUS_BO not existing.  I used another wiki, http://wiki.sdn.sap.com/wiki/display/CRM/CRM+Web+UI+Technical+-+Creating+Table+View+In+Web+UI, to determine how this parameter should be configured. 

      I have completed all the steps but the system dumps due to "incorrect implementation" of component controller.  I have retraced my steps and can't seem to find the cause. In step 12 the case returns an exception. I added extra lines to catch this exception but attachments view does not appear. In method iv_usage->bind_context_node there is a line which does not return an entity: LV_NODE_2_BIND = ME->IF_BSP_WD_COMPONENT_USAGE~GET_CONTEXT_NODE( IV_NODE_2_BIND ). Upon debugging further, the method IF_BSP_WD_COMPONENT_USAGE~GET_CONTEXT_NODE has lines:

      LV_REPOSITORY = ME->COMPONENT_FACTORY->GET_COMPONENT_REPOSITORY( COMPONENT_TYPE ).

          LT_ALLOWED_NODES = LV_REPOSITORY->GET_INTF_CONTROLLER_CNODES( ).

      These lines do not return any controllers for when passed BTORDER as shown in your step 12 above.  Any ideas on what I'm missing?

      Thanks for your help,

      Duane Chapman

      Author's profile photo Former Member
      Former Member

      Hi ,

      Did you got Solution, I am getting same error.

      Could you give steps how you have corrected.

      Author's profile photo Former Member
      Former Member

      Hi, I have the same error:

      ERROR: The view of custom controller '' iis implemented incorrectly.

      Anyone who can help me/us?

      Thanks,

      Robbe Wuyts

      Author's profile photo Sandesh K
      Sandesh K

      Hi Gopal,

      I have a requirement to make this Attachment assignment block as Tablink beside the "Notes" Tab link in the "Interaction Record". I have tried to implement it as per your document but I am unable to see the GS_CM buttons like "Add URL" ,"Advanced" etc

      Can you please let me know how to do this

      Thanks,

      San

      Author's profile photo Parveen Kumar
      Parveen Kumar

      Very useful and detailed.

      Author's profile photo Former Member
      Former Member

      Brilliant. The document was very helpful

      Author's profile photo Former Member
      Former Member

      Hi Guys

      after the above steps I can see the new view but the message inside is 'No result found'. Any advise?

      Regards

      MG

      Author's profile photo Former Member
      Former Member

      The attachments are missing is there any way to post them again?Thanks.

      Author's profile photo Rohit Mansukh Gugale
      Rohit Mansukh Gugale

      The attachments are missing is there any way to post them again?

      Please help

      Author's profile photo Uday Gubbala
      Uday Gubbala

      Thanks for the wonderful blog was able to use it in my development. For the people who are still following this article. I had followed the instructions in the blog & similarly got stuck at the point where the below code snippet fails to return the context node reference:

      LV_NODE_2_BIND = ME->IF_BSP_WD_COMPONENT_USAGE~GET_CONTEXT_NODE( IV_NODE_2_BIND ). 

      To overcome the issue you would need to go to the interface controller of your Z-Component and add the context nodes onto it.

       

      Once you add them to the interface controller it would result in LT_ALLOWED_NODES being filled with the 4 context node names

      LT_ALLOWED_NODES LV_REPOSITORY->GET_INTF_CONTROLLER_CNODES).

      The entries in LT_ALLOWED_NODES are the one's which LV_NODE_2_BIND = ME->IF_BSP_WD_COMPONENT_USAGE~GET_CONTEXT_NODE( IV_NODE_2_BIND ) would eventually refer to while trying to get the context node reference.