Skip to Content
Purpose:
The purpose of the document is to reduce the technical effort required in developing similar requirement.
Introduction:
This document is a reference work for the technical developers to add a standard attribute to the search criteria. I worked in a SAP CRM implementation project wherein we had similar requirement for activities.
Requirement:

Activity Search functionality provides the user with a tool to search for all Activities created in the system. Customer requires the ability to use Reason (Appointment Reason) field as a search criteria while searching for Activities in the system. The Reason search criteria would have a value field containing all FS related Appointment reasons. On using this search criterion, Users can select reasons in value field and search which provided in the results all Activities which contain that particular reason / reasons selected in search value. There are various search criteria provided by the SAP. Reason field is not provided by standard SAP and we will enhance functionality to provide the same.

Solution:

  • To achieve this functionality, go to transaction code se11 and open the data type CRMST_QUERY_ACT_BTIL and add a custom field ZCONC_KEY. Below screenshots gives the details

           Datatype.png

               Click on append structure

            ZCONC_KEY field.png
             ZCONC_KEY field2.png
             ZCONC_KEY field3.png

  • Launch transaction code sm34 and enter cluster view name as ‘CRMVC_DQ’ and click on ‘Maintain’.     
  • Select DQuery Object Name as ‘BTQAct’ and click on ‘exceptions per attribute’.
  • Click on ‘New entries’ and add the Attribute CONC_KEY.
  • Select the option ‘X Indicates Options that are available’.
  • Check the desired checkboxes for ‘EQ’, ‘BT’, ‘LT’ and ‘GT’.

          Below screenshots gives the details

            Cluster1.png

             Cluster2.png

             Cluster3.png

             Cluster4.png

  • Launch transaction BSP_WD_CMPWB and open the component BT126S_APPT.
  • Enhance the component and the view BT126S_APPT/ApptSQ.
  • Enhance the context node BTQACT and generate getter and setter method for z field STRUCT.ZCONC_KEY.

             Cluster5.png

                  

 

  • Implement GET_P and GET_V methods of the attribute to make the attribute as drop down and provide drop down values.

                    Method GET_P_ZCONC_KEY

                   

                    CASE IV_PROPERTY
                     WHEN IF_BSP_WD_MODEL_SETTER_GETTER=>FP_FIELDTYPE.
                     RV_VALUE = CL_BSP_DLC_VIEW_DESCRIPTOR=>FIELD_TYPE_PICKLIST.

                     ENDCASE

                     ENDMETHOD

                    METHOD GET_P_ZCONC_KEY

                    DATA: LT_DDLB TYPE BSP_WD_DROPDOWN_TABLE,
                    LS_DDLB LIKE LINE OF LT_DDLB.

                   IF NOT GR_DDLB IS BOUND.
                   CREATE OBJECT GR_DDLB
                     EXPORTING
                       IV_SOURCE_TYPE = ‘T’.
                   ENDIF

                  LS_DDLB-KEY   = ‘1’.
                  LS_DDLB-VALUE = VALUE1.
                  INSERT LS_DDLB INTO TABLE LT_DDLB.

                  LS_DDLB-KEY   = ‘2’.
                  LS_DDLB-VALUE = VALUE2.
                  INSERT LS_DDLB INTO TABLE LT_DDLB.

                 GR_DDLB->SET_SELECTION_TABLE (IT_SELECTION_TABLE = LT_DDLB).

                 RV_VALUEHELP_DESCRIPTOR = GR_DDLB.

                 ENDMETHOD

  • Launch transaction code se19 and create an implementation for the BADI CRM_BADI_RF_Q1O_SEARCH and write the following code.
  • Loop at the importing parameter IT_MULTIVALUES of the BADI and check whether a field named ZCONC_KEY is there or not. If so, pass the value of the attribute to a local variable LV_REASON.

               

                 LS_SELECTION_PARAMETERS-SIGN = ‘I’.
                 LS_SELECTION_PARAMETERS-OPTION =
‘EQ’.
                
FIELD-SYMBOLS: <LS_SEARCH_TAB> LIKE LINE OF IT_SEARCH_TAB.

                 DATA LS_RFW_MULTIVALUES TYPE CRMT_REPORT_SEARCH_MULTI_VAL.
                
LOOP AT IT_SEARCH_TAB ASSIGNING <LS_SEARCH_TAB>.
                 LS_SELECTION_PARAMETERS-ATTR_NAME = <LS_SEARCH_TAB>-NAME.
                 LS_SELECTION_PARAMETERS-LOW = <LS_SEARCH_TAB>-
VALUE.
                
INSERT LS_SELECTION_PARAMETERS INTO TABLE LT_SELECTION_PARAMETERS.
                
ENDLOOP.

                 FIELD-SYMBOLS: <LS_MULTIVALUES> LIKE LINE OF IT_MULTIVALUES.
                
LOOP AT IT_MULTIVALUES ASSIGNING <LS_MULTIVALUES>.
                 LS_SELECTION_PARAMETERS-ATTR_NAME = <LS_MULTIVALUES>-FIELDNAME.
                
IF    <LS_MULTIVALUES>-FIELDNAME EQ ‘ZCONC_KEY’.
                 LV_REASON =
‘X’.
                
ELSE.
                 LS_MULTIVALUES = <LS_MULTIVALUES>.
                
APPEND LS_MULTIVALUES TO LT_MULTIVALUES.
                
IF <LS_MULTIVALUES>-FIELDNAME EQ ‘OBJECT_ID’.
                  LV_OBJECT =
‘X’.
                
ENDIF.
                
CLEAR LV_AUTO
                
ENDIF.

                 FIELD-SYMBOLS: <LS_SEARCHVALUES> LIKE LINE OF <LS_MULTIVALUES>-SEARCHVALUES.
                
LOOP AT <LS_MULTIVALUES>-SEARCHVALUES ASSIGNING <LS_SEARCHVALUES>

                 IF LV_REASON = ‘X’.
                  LV_STATREASON = <LS_SEARCHVALUES>-LOW.
                 
CLEAR LV_REASON.
                
ENDIF.

                 MOVE-CORRESPONDING <LS_SEARCHVALUES> TO LS_SELECTION_PARAMETERS
                
INSERT LS_SELECTION_PARAMETERS INTO TABLE LT_SELECTION_PARAMETERS
                
ENDLOOP.
                
ENDLOOP.

  • Based on reason field availability in the search criteria filter the records as below

      

          **CHECK IF THE SELECTION CRITERIA HAS A VALUE IN REASON CODE
                
IF LV_REASON IS INITIAL.
                
CALL FUNCTION ‘CRM_BSP_OIC_1O_SEARCH_FROM_RF’
                    
EXPORTING
                            IT_SEARCH_TAB             = IT_SEARCH_TAB
                            IV_NUMBER                 = IV_NUMBER
                            IT_MULTIVALUES            = LT_MULTIVALUES
                            IV_EXTERN_CALL            =
‘X’
                            IV_SELECT_FOR_HEADERLEVEL =
‘X’
                            IV_CALL_AUTHORITY_BADI    =
‘X’
                   
IMPORTING
                           ET_GUIDLIST               = LT_GUIDLIST
                           ET_RETURN                 = ET_RETURN.
                   ET_GUIDLIST = LT_GUIDLIST.
                
ELSE
                  
DESCRIBE TABLE LT_MULTIVALUES LINESLV_COUNT.
                
IF LV_COUNT >= 1 OR LV_OBJID IS NOT INITIAL.
               
CALL FUNCTION ‘CRM_BSP_OIC_1O_SEARCH_FROM_RF’
                      
EXPORTING
                              IT_SEARCH_TAB             = IT_SEARCH_TAB
                              IT_MULTIVALUES            = LT_MULTIVALUES
                              IV_EXTERN_CALL            =
‘X’
                              IV_SELECT_FOR_HEADERLEVEL =
‘X’
                              IV_CALL_AUTHORITY_BADI    =
‘X’
                      
IMPORTING
                              ET_GUIDLIST               = LT_GUIDLIST
                              ET_RETURN                 = ET_RETURN.

                     LT_GUID = LT_GUIDLIST.
                     IF LV_STATREASON IS NOT INITIAL AND LT_GUID IS NOT INITIAL.**********
                       STR1 =
‘A1’.
                       STR2 =
‘Z0000003’.
                      
CASE LV_STATREASON
                       
WHEN ‘DROPDOWNVALUE1’.
                         STR3 =
‘Z001’.
                      
WHEN ‘ DROPDOWNVALUE2’.
                         STR3 =
‘Z002’.
                     
WHEN ‘ DROPDOWNVALUE3’.
                         STR3 =
‘Z003’.
                     
WHEN ‘ DROPDOWNVALUE4.
                          STR3 =
‘Z004’.
                   
ENDCASE.*
                   
SELECT CRMD_ORDERADM_H~GUID FROMCRMD_ORDERADM_H INNER JOIN CRMD_LINK AS LINKON LINK~GUID_HI = CRMD_ORDERADM_H~GUID
                    INNER
JOIN  CRMD_SRV_OSSET AS SET
                         
ON SET~GUID_SET = LINK~GUID_SET
                    INNER
JOIN CRMD_SRV_SUBJECT AS SUBJECT
                         
ON SUBJECT~GUID_REF = SET~GUID
                    
INTO TABLE LT_GUIDS FOR ALL ENTRIES IN LT_GUID
                  
WHERE
                    CRMD_ORDERADM_H~GUID = LT_GUID-TABLE_LINE
                    
AND LINK~OBJTYPE_SET = ’29’
                   
AND SUBJECT~KATALOGART = STR1 AND SUBJECT~CODEGRUPPE = STR2
                  
AND SUBJECT~CODE =  STR3.

                  LT_GUID = LT_GUIDS.
                  IF IV_NUMBER IS NOT INITIAL
                  LV_NUM = IV_NUMBER.
                 
APPEND LINES OF LT_GUID FROM 1 TO IV_NUMBER TO ET_GUIDLIST.
                 
ELSE
                   LV_NUM =
100.
                 
APPEND LINES OF LT_GUID FROM 1 TO LV_NUM TO ET_GUIDLIST.
                 
ENDIF
                 
ELSE
                  LT_GUID = LT_GUIDLIST.

                  IF IV_NUMBER IS NOT INITIAL
                  LV_NUM = IV_NUMBER.
                 
APPEND LINES OF LT_GUID FROM 1 TO IV_NUMBER TO ET_GUIDLIST.
                
ELSE
                 LV_NUM =
100.
                
APPEND LINES OF LT_GUID FROM 1 TO LV_NUM TO ET_GUIDLIST.
               
ENDIF
              
ENDIF.

              

             ENDMETHOD.

DESCRIBE TABLE LT_GUID LINES LV_LINES.
              
IF LV_LINES > LV_NUM.
              
MOVE LV_NUM TO LV_HELP_PAR1.
             
MOVE LV_HELP_PAR1 TO LV_PAR1.
             
CALL FUNCTION ‘BALW_BAPIRETURN_GET2’
                   
EXPORTING
                           
TYPE   = ‘S’
                               CL     =
‘CRM_BSP_FRAME’
                        
NUMBER = ‘017’
                              PAR1   = LV_PAR1
                    
IMPORTING
                            
RETURN = LS_RETURN.
             
APPEND LS_RETURN TO ET_RETURN.

              ENDIF.
            
ENDIF.
            
ENDIF.

Result:

              

                    Result1.png

                    Result2.png

Note: The above process can be followed with any standard attribute to make it as search field. What all needed is just adding the custom attribute to the standard search structure and the corresponding cluster followed by BADI implementation relevant to the object.

    

                                                                                                                                   

To report this post you need to login first.

1 Comment

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

Leave a Reply