This document is about enhancing the search result structure with custom fields and updating those custom fields while search in BADI

Step1: First we need to enhance the search result structure with custom fields

find out structure name for the search Query result relation say for BTQRSrvReq attribute structure is CRMST_QUERY_R_SRV_REQ_BTIL

Search your Result structure in GENIL_MODEL_BROWSER

SR1.jpg

Go to the structure and click on append structure option and create new append structure with your custom fields and activate the structure

say ZZPERSON_RESP_ROLE is added in the append structure

SR2.jpg

Step2:We need to create new enhancement spot for ES_CRM_RF_Q1O_READ in Tcode SE18

SR3.jpg

Give the enhancement implementation name

SR4.jpg

Give BADI Implementation name and class name

SR7.jpg

After creating implementation we need to add filter data

click on filter and click on combination to create

SR8.jpg

After this double click on OBJ_IL and add the filetr values and activate the enhancement

SR9.jpg

After everything is done click on Implementation class

SR10.jpg

Step 3: We need to do code in READ method to fill the value in custom field

Click on the read method and call standard FM CRM_BSP_OIC_1O_READ_FROM_RF to get read standard field values in the structure

and then loop the table and populate your custom field value

  FIELD-SYMBOLS:<fwa_structure> TYPE crmt_bsp_scrstrucname,
                <ls_sc_structure>     TYPE any,
                <lt_screen_structure> TYPE table,
                <itf_ref_prod_gen>    TYPE any.

  CALL FUNCTION ‘CRM_BSP_OIC_1O_READ_FROM_RF’
    EXPORTING
      it_object_key            = it_object_key
      iv_screen_structure_name = iv_result_structure_name
      iv_refresh_headeredition = ”
      iv_call_authority_badi   = ‘X’
      iv_avoid_authorization   = ”
    IMPORTING
      et_screen_structure      = et_result_structure.

   LOOP AT et_result_structure ASSIGNING <ls_sc_structure>.
      CLEAR:,lv_role,lv_pers_resp.
      REFRESH:li_return,li_role,li_role_txt.

      CONCATENATE ‘<ls_sc_structure>’ ‘-GUID’ INTO lv_name.
      ASSIGN (lv_name) TO <itf_ref_prod_gen>.
      IF sy-subrc IS INITIAL.
        lv_guid = <itf_ref_prod_gen>.
        UNASSIGN <itf_ref_prod_gen>.
      ENDIF.

*person responsible role
      CONCATENATE ‘<ls_sc_structure>’ ‘-PERSON_RESP’ INTO lv_name.
      ASSIGN (lv_name) TO <itf_ref_prod_gen>.
      IF sy-subrc IS INITIAL.
        lv_pers_resp = <itf_ref_prod_gen>.
        UNASSIGN <itf_ref_prod_gen>.
      ENDIF.

      CALL FUNCTION ‘BUPA_ROLES_GET_2’
        EXPORTING
          iv_partner      = lv_pers_resp
        TABLES
          et_partnerroles = li_role
          et_return       = li_return.

      IF li_role IS NOT INITIAL.
        SELECT * FROM tb003t INTO TABLE li_role_txt FOR ALL ENTRIES IN li_role WHERE role = li_role-partnerrole AND spras = ‘E’.
      ENDIF.

      LOOP AT li_role_txt INTO lwa_role_txt.
        CONCATENATE lv_role lwa_role_txt-rltxt  INTO lv_role SEPARATED BY ‘,’.
      ENDLOOP.

      REPLACE FIRST OCCURRENCE OF ‘,’ IN lv_role WITH space.
      CONCATENATE ‘<ls_sc_structure>’ ‘-ZZPERSON_RESP_ROLE’ INTO lv_name.
      ASSIGN (lv_name) TO <itf_ref_prod_gen>.
      IF sy-subrc IS INITIAL.
        <itf_ref_prod_gen> = lv_role.
        UNASSIGN <itf_ref_prod_gen>.
      ENDIF.

ENDLOOP.

Step 4: Add your custom field in configuration of the required component in this case SRQM_INCIDENT_S

Step 5: Generate getter/setter methods for custom field in configuration of the required component in this case SRQM_INCIDENT_S

After this you can get the custom field value in the result where ever this query is executed

Regards,

Deepika.

To report this post you need to login first.

9 Comments

You must be Logged on to comment or reply to a post.

  1. kalpana l

    Hi deepika,

    I need one help..i have created AET field customer appointment date and customer appointment time field i have addded in Service order screen search and resutl list screen..i have added code in BTDATES component DATE_FROM field setter method and TIME_TO field set method ..

    But while creating service order  in GUI iam not getting values..if we create in web wui we will get the values..please help here.

    Thanks

    Kalpana

    (0) 
    1. om prakash

      Hi,

      I have one requirement ,where i have to find the Enhancement Spot/Badis for Search Enhancement with custom z fields.

      Thnaks,

      Om Prakash

      (0) 
      1. Sumeet Gehlot

        Hi Om,

        Which z fields u are referring to is it related to Accounts, One order transaction etc.

        This below is related to service request search result enhancement so here deepika has used ES_CRM_RF_Q1O_READ BADI..

        Open a seperate discussion to discuss more on this

        Regards,

        Sumeet

        (0) 
        1. om prakash

          Hi Sumeet,

          Great thanks for your prompt response,

          Actually ,I am looking for a Enhancement Spot/Badis for the following :

          For Result Relevant in Contact—-

          UI Component:  BP_CONT_SEARCH

          View: BP_CONT_SEARCH/SearchResult

          Context Node: RESULT

          Added  z field to — CRMST_CONTACT_PERSON_OBJ_BUIL .

          So, I can able to populate the  custom field .

          [New to CRM — learning]-please help me out..

          Help,suggestion,ideas will be greatly appreciated.

          thanks and regards,

          Om Prakash.

          (0) 
  2. Raimundo de Oro-Pulido Albo

    Thank you for sharing. Very useful.

    One comment: If you want to add an standard field included in the same table (CRMD_ORDERADM_H in this case), like ‘Changed at’, steps 2 & 3 are not necessary. Just append structure and add the field in BSP_WD_CMPWB.

    (0) 
  3. Mohamed Ansari

    Hi  Deepika,

    As per your screen shot,you have shown the Dquery object in the genil_model_editor. but you shown Append Stucture for Query Result object. ????

    You can enhance the dquery stucture always.

    Is it possibile to enhance query result stucture? becasue query result will be the root object .

    Please clarify.

    Regards,

    Mohamed

    (0) 
  4. Vivenchandar Raja

    Hi Deepika,

    Thank you very much for your blog, I used this and successfully created search result enhancement for bringing a custom partner function partner details.

    Regards,

    Vivenchandar Raja

    (0) 

Leave a Reply