SAP CRM Interaction center Identification search screen validation
I am writing this to help my CRM technical friends to avoid hardcoding while trying to validate a search screen for informing business user to enter search criteria before clicking on search/pressing enter. Normally most of us due to time crunch embraces the path of validating each and every field by putting “IS INITIAL”. This is fine in case of simple query search but its very hectic and ugly when you are dealing with search application like SAP CRM ISU identification screen. As there multiple search applications/logic embedded in one for instance Business partner search, Business agreement search, Premise search, installation device and so on.
I encountered this recently wherein we had the requirement from business team to put in the check as their customer care executives while talking to business partners most of times just click on search or press enter without entering any selection criteria. This resulted in massive system performance issue and lots of processing time, causing inconvenience to business users.
this is how the typical search screen appears:-
Most of us will commit the same mistake on the basis of search for parameter check for each field in the screen and put in the key word “IS INITIAL”. As there are lots of permutations and combinations so your IF ELSE/CASE statement will be long and very ugly as this is nothing but hard coding.
Now we have a solution for this. We’ll be using the SAP concept of RTTS(Run time type services concept. You can refer to my blog https://blogs.sap.com/2019/09/16/use-of-rtts-to-solve-generate_subpool_dir_full-exception-for-dynamic-table-generation/ for more details ).
Firstly we need a place to write this code at one place wherein it could be reused in all the views/screens of BSP component for Identification, thus ensuring code reusability. Best place here is component controller class as here it will have all the context nodes binded to the search screen.
After that starting the code fetch the search context node as well other context node which is the variant one which decides which type of search application it is.
Then the magic begins with SAP utility class CL_CRM_GENIL_MODEL_SERVICE method Get_runtime_model. This is the major class which will at the runtime will help you provide the search query application
DATA(lrobject_model) = CL_CRM_GENIL_MODEL_SERVICE=>get_runtime_model().
now check which is the search query application as per below code
DATA(lv_queryname) = lr_entity->get_name(). “le entity should be instantiated with the context node meant for search in component controller
after that we will try to dynamically get the structure of search query containing all the search parameters on the basis of model. code snippet is given below
DATA(lr_object_model) = cl_crm_genil_model_service=>get_runtime_model( ).
IF lr_entity IS BOUND.
DATA(lv_queryname_bp) = lr_entity->get_name( ).
IF lr_object_model IS BOUND.
* Determine Attribute Structure Of Query
CALL METHOD lr_object_model->get_attr_struct_name
iv_object_name = lv_queryname_bp
rv_attr_struct = DATA(lv_attribute_structure).
IF NOT lv_attribute_structure IS INITIAL.
CREATE DATA lr_search TYPE (lv_attribute_structure).” now here we need form the data in the form search parameters/fields which will be ofcourse blank so that the same could be assigned to field symbol
IF lr_search IS BOUND.
* Get Search Criteria
ASSIGN lr_search->* TO <ls_qs>.
Now you have the dynamic search parameter on the basis of search is available in the field symbol.
now simply call the method to fetch the actual value of list of search parameters from the screen
es_attributes = <ls_qs>.
simply call the “IS INITIAL” check whether <ls_qs> is INIITAL and then give the message to user informing them to enter search criteria.
Nice one Rajwin