Adding custom fields to advanced search screen of CRM objects
CRM objects can be searched conveniently using search criteria predefined in the corresponding search component view defined. However the predefined search criteria may not include all fields that the business wants to search the CRM objects with.
This Wiki article will illustrate how we can add custom fields to advanced search screen of CRM objects that are not available on the standard search component view.
To illustrate the above point, we will enable search of Marketing Initiatives based on Expense Type field. The Expense type field is not part of Initiative general data and thus not available on the advanced search screen. We will add Expense Type field to advance search screen of Marketing Initiatives.
To enable search of Marketing Initiatives based on Expense Type field. The Expense type field is not part of Initiative general data and thus not available on the advanced search screen.
To achieve this, we use the following technique
- Add the Expense type as a dummy field to Initiative header. This field is only used for search purposes.
- Enable the Expense type field on the Initiative search screen query and result views via UI config tool on the search component
- Implement BADI CRM_MKTPL_SEARCH, query criteria method, to remove the dummy Expense type field from the search criteria and save it in public attribute created for that purpose
- Implement BADI CRM_MKTPL_SEARCH, search result method. Query the Initiatives by the expense type and filter the results lists already queried by the system
- Expense type can also be enabled on the search results screen via personalization.
Adding Expense type as a dummy EEWB field to Initiative
Create a Project and assign package (or reuse existing), for adding Expense Type as a dummy EEWB field to Initiative. This field will only be used for search purposes and not to store data.
Assign customizing and workbench requests for the new project
Create extension for MARKETING_ELEMENT object with type BASIC_DATA
Click continue on the dialog
Title of extension
Select Initiative for object type
Since Expense Type is a standard SAP field with data element CRM_FM_EXPENSE_TYPE, define the new EEWB field with reference to this data element. Provide a name ZZEXPENSE_TYPE to the new field
Finish adding the EEWB field
Enabling the new EEWB field on Initiative advance search UI
Display component INIAS_ADVSEARCH using transaction BSP_WD_CMPWB
Navigate the Initiative search view ASInitiative and enable the newly added EEWB field for Expense type display in the search criteria
Navigate to the Inititive results view and enable the newly added field for Expense type in the result area
Implement BADI CRM_MKTPL_SEARCH
Method CHANGE_QUERY_CRITERIAS of BADI CRM_MKTPL_SEARCH can be implemented.
Here we can delete the query criteria based on the newly added EEWB field for Expense type and store it in an instance variable (LT_QUERY) in the BADI implementation Z class.
Method CHANGE_QUERY_RESULT of BADI CRM_MKTPL_SEARCH can be implemented
Here we can query the Initiative GUIDs based on the Expense Type values that the user selected. We can then use these GUIDs to filter the results table.