Creation of Custom GenIL Object Model

4192

A GenIL component consists of a GenIL (Generic Interaction Layer) data model and one or more GenIL implementation classes. SAP provides the genIL components for standard MDG data models. This component is responsible for all user interfaces related to the single object processing of the entity types from your custom data model.

In this blog I am going to show the steps to create a custom GenIL model.
First We need to create a database table using se11.

Creation of Custom GenIL Object Model

Our object model will be based on this database table. To create the Object model we need to perform the following steps:

Step 1: Go to transaction SM34 and maintain the view CRMVC_GIL_APPDEF

Creation of Custom GenIL Object Model

a) Double click on Component Definition and click on New Entries to define the custom component(say ZEMP). Maintain an implementation class, say ZCL_GENIL_EMPLOYEE

GenIL Object Model

b) Double click on Component Set Definition and click on New Entries to define the custom component set(say ZSET_EMP)

Object Model

c) Assign the component to the component set

GenIL Object Model 5

Step 2: Create the following database structures and table types

GenIL Object Model 6 GenIL Object Model 8 GenIL Object Model 7

Step 3: Go to transaction GENIL_MODEL_EDITOR to create the Object model. Give component name as ZEMP and click on Change

a) Right Click on the Root Object and select “Create Root Object”, give an object name and maintain the basic settings as shown below

GenIL Object Model 9

GenIL Object Model 10

b) Right click on Dynamic Query Objects and select “Create Dynamic Query Object”. Maintain the object name and the basic settings as shown below

GenIL Object Model 12

Step 4: Create a custom class (ZCL_EMP_MASTER_API) to hold the API methods to retrieve data from database. Create two public static methods SEARCH_EMPLOYEE and READ_EMPLOYEE with the following parameters

GenIL Object Model 13

SEARCH_EMP gets the employee keys from the database. IV_STRING contains the where conditions based on which the database query is executed.

GenIL Object Model 14

READ_EMP accepts the employee key as input and returns employee attributes for the corresponding employee.

GenIL Object Model 15

Add the following code:

METHOD search_emp.
REFRESH et_results.
IF iv_string IS NOT INITIAL.
SELECT id
FROM zemp_master_t
UP TO iv_max_hits ROWS
INTO CORRESPONDING FIELDS OF TABLE et_results
WHERE (iv_string).
ELSE.
SELECT id
FROM zemp_master_t
UP TO iv_max_hits ROWS
INTO CORRESPONDING FIELDS OF TABLE et_results.
ENDIF.
ENDMETHOD.
**************************************************************************************
METHOD read_emp.
SELECT SINGLE * FROM zemp_master_t INTO CORRESPONDING FIELDS OF es_emp_attr WHERE id EQ is_emp_key-id.
ENDMETHOD.

You can take any other approach to read the table data, like using FMs.

Step 5: Go to transaction SE24 and create the custom class ZCL_GENIL_EMPLOYEE which was mentioned during component definition

Maintain CL_WCF_GENIL_ABSTR_COMPONENT as the superclass

GenIL Object Model 16

Redefine the method IF_GENIL_APPL_INTLAY~GET_DYNAMIC_QUERY_RESULT. Add the following code

METHOD if_genil_appl_intlay~get_dynamic_query_result.

DATA: lr_msg_cont TYPE REF TO cl_crm_genil_global_mess_cont,
lv_num_hits TYPE i,
lt_results TYPE zbol_emp_master_key_tt,
lv_max_hits TYPE char5,
lv_max_hits_tmp TYPE int4,
lr_root_object TYPE REF TO if_genil_cont_root_object,
lt_request_obj TYPE crmt_request_obj_tab.
FIELD-SYMBOLS: <fs_results> TYPE zbol_emp_master_key.
lr_msg_cont = iv_root_list->get_global_message_container( ).
IF is_query_parameters-max_hits IS INITIAL.
lv_max_hits_tmp = 100.
ELSE.
lv_max_hits_tmp = is_query_parameters-max_hits.
ENDIF.
CASE iv_query_name.
WHEN ‘Search Employee’.

CALL METHOD search_employee
EXPORTING
it_serach_criteria = it_selection_parameters
iv_max_hits = lv_max_hits_tmp
IMPORTING
et_results = lt_results.
IF lt_results IS NOT INITIAL.
DESCRIBE TABLE lt_results LINES lv_num_hits.
IF lv_num_hits > lv_max_hits_tmp.
lv_max_hits = lv_max_hits_tmp.
lr_msg_cont->add_message( iv_msg_type = ‘I’
iv_msg_id = ‘ZBOL_MSG’
iv_msg_number = ‘000’
iv_msg_v1 = lv_max_hits
iv_show_only_once = abap_true ).
ENDIF.
LOOP AT lt_results ASSIGNING <fs_results>.
TRY.
lr_root_object = iv_root_list->add_object(
iv_object_name = ‘zemp’
is_object_key = <fs_results> ).
lr_root_object->set_query_root( abap_true ).
CATCH cx_crm_genil_duplicate_rel cx_crm_genil_model_error.
ENDTRY.
ENDLOOP.
me->if_genil_appl_intlay~get_objects( it_request_objects = lt_request_obj
iv_root_list = iv_root_list ).
ELSE.
lr_msg_cont->add_message( iv_msg_type = ‘W’
iv_msg_id = ‘ZBOL_MSG’
iv_msg_number = ‘001’
iv_show_only_once = abap_true ).
ENDIF.
WHEN OTHERS.
RETURN.
ENDCASE.
ENDMETHOD.
****************************************************************
Redefine the method IF_GENIL_APPL_INTLAY~GET_OBJECTS
****************************************************************
METHOD if_genil_appl_intlay~get_objects.
DATA lv_root TYPE REF TO if_genil_cont_root_object.
DATA lv_empl_key TYPE zbol_emp_master_key.
DATA lv_empl_att TYPE zbol_emp_master_attr.
DATA lv_temp_att TYPE zbol_emp_master_attr.
lv_root = iv_root_list->get_first( ).
WHILE lv_root IS BOUND.
lv_root->get_key( IMPORTING es_key = lv_empl_key ).
IF lv_root->check_attr_requested( ) = abap_true.
zcl_emp_master_api=>read_emp(
EXPORTING is_emp_key = lv_empl_key
IMPORTING es_emp_attr = lv_empl_att ).
IF lv_empl_att IS NOT INITIAL.
lv_root->set_attributes( lv_empl_att ).
ENDIF.
ENDIF.
lv_root = iv_root_list->get_next( ).
ENDWHILE.
ENDMETHOD.

Create a Public Instance method SEARCH_EMPLOYEE with the following parameters

GenIL Object Model 17

METHOD search_employee.
DATA: lv_max_hits TYPE i,
lv_string TYPE string,
lt_search_criteria TYPE genilt_selection_parameter_tab,
lv_last_attr_name TYPE name_komp.
FIELD-SYMBOLS: <search_criteria> TYPE genilt_selection_parameter.
lv_max_hits = iv_max_hits.
IF lv_max_hits EQ 0.
lv_max_hits = 100.
ENDIF.
lt_search_criteria = it_serach_criteria.
SORT lt_search_criteria BY attr_name.
LOOP AT lt_search_criteria ASSIGNING <search_criteria>.
IF ( <search_criteria>-option EQ ‘CP’ OR <search_criteria>-option EQ ‘EQ’ ).
IF lv_string IS NOT INITIAL.
IF <search_criteria>-attr_name NE lv_last_attr_name.
CONCATENATE lv_string ‘) AND (‘ INTO lv_string SEPARATED BY space.
ELSE.
CONCATENATE lv_string ‘OR’ INTO lv_string SEPARATED BY space.
ENDIF.
ELSE.
lv_string = ‘(‘.
ENDIF.
CONCATENATE lv_string <search_criteria>-attr_name <search_criteria>-option ” INTO lv_string SEPARATED BY space.
CONCATENATE lv_string <search_criteria>-low INTO lv_string.
CONCATENATE lv_string ” INTO lv_string.
ENDIF.
lv_last_attr_name = <search_criteria>-attr_name.
ENDLOOP.
REFRESH et_results.
IF lv_string IS NOT INITIAL.
CONCATENATE lv_string ‘)’ INTO lv_string SEPARATED BY space.
ENDIF.
CALL METHOD zcl_emp_master_api=>search_emp(
EXPORTING
iv_string = lv_string
iv_max_hits = lv_max_hits
IMPORTING
et_results = et_results ).
ENDMETHOD.

Our GenIL component is ready for test.

To test whether the Genil Object is working properly or not go to transaction GENIL_BOL_BROWSER, give component name ZEMP and execute. The dynamic query object ‘Search Employee’ will be present in Model Browser Search Objects window. Double click on it to get the search window, where you can enter search parameters and click on the FIND.

GenIL Object Model 18

Database entries are shown in the List Browser window based on the query parameters. Double click on the individual object to see the details.

Database entries are shown in the List Browser window based on the query parameters. Double click on the individual object to see the details.

GenIL Object Model 19

Hope this blog is helpful to you..

4,192 Comments

  1. I am only writing to make you understand what a superb experience our princess undergone viewing yuor web blog. She picked up such a lot of things, with the inclusion of what it is like to possess an ideal teaching style to make the mediocre ones without hassle master specified tricky topics. You undoubtedly surpassed visitors’ expected results. Thanks for showing those valuable, trustworthy, revealing not to mention unique tips on your topic to Sandra. https://zujepopoem.online/

  2. I am just writing to make you understand what a outstanding experience my wife’s girl obtained using your webblog. She noticed so many pieces, which included what it is like to possess an excellent helping spirit to let other people with no trouble learn specific specialized things. You truly surpassed readers’ expected results. Thank you for providing these priceless, trusted, informative as well as fun tips about this topic to Lizeth. https://zujepopoem.online/

  3. purchase vardenafil on

    A lot of thanks for all your valuable efforts on this site. Kate loves getting into investigation and it’s really easy to understand why. I know all concerning the dynamic medium you give informative solutions on this web blog and as well as foster participation from others on that content plus our daughter is always discovering a lot. Have fun with the remaining portion of the new year. You are conducting a great job. https://joneslawncarela.com/

  4. I intended to compose you a bit of note in order to give many thanks again for your personal marvelous principles you’ve featured in this article. It is quite seriously generous of people like you to give openly just what many individuals might have marketed as an e book to generate some dough for themselves, most notably given that you could possibly have done it if you ever decided. These points as well served to be a fantastic way to fully grasp other people have similar fervor much like my own to know the truth many more pertaining to this issue. I am certain there are millions of more fun opportunities in the future for individuals who looked at your blog post. https://gemerekliler.com/

  5. tadalafil pills on

    I am also commenting to let you know of the great encounter my friend’s daughter found reading through your web page. She figured out numerous issues, not to mention what it’s like to have an amazing giving mood to have men and women really easily have an understanding of selected hard to do subject areas. You really exceeded our own expectations. Many thanks for imparting the interesting, safe, explanatory and even easy thoughts on the topic to Janet. https://hillsdaledowcenter.com/

  6. tadalafil online on

    I am commenting to let you know of the fabulous encounter my cousin’s daughter experienced reading your site. She even learned many issues, not to mention what it’s like to have a wonderful giving mindset to have many people just grasp chosen grueling subject areas. You really exceeded our expectations. Many thanks for distributing the informative, healthy, educational and as well as easy thoughts on the topic to Jane. https://hillsdaledowcenter.com/

  7. Thanks for your entire labor on this web site. My mother take interest in participating in research and it is simple to grasp why. My spouse and i notice all regarding the powerful tactic you produce useful thoughts via your website and in addition recommend response from the others on this subject then our own princess is truly studying a whole lot. Take pleasure in the rest of the year. You have been performing a terrific job. https://habebihookahbar.com/

  8. purchase viagra on

    I enjoy you because of all your efforts on this site. Ellie enjoys doing internet research and it’s easy to see why. All of us hear all concerning the compelling means you deliver good information by means of the blog and as well cause contribution from other people about this concept plus my daughter is actually being taught a lot. Enjoy the remaining portion of the new year. You’re the one carrying out a first class job. https://habebihookahbar.com/

  9. levitra online on

    I needed to draft you one little observation so as to say thank you as before for those great knowledge you’ve documented here. It has been certainly pretty generous of people like you to convey freely exactly what a number of people could possibly have made available as an e book to earn some cash for their own end, even more so considering the fact that you could possibly have done it if you ever decided. The ideas also acted like a fantastic way to comprehend other individuals have similar dreams like my own to grasp good deal more on the subject of this issue. I’m sure there are many more fun occasions ahead for individuals that go through your blog post. https://eskaliths.com/

  10. Thanks for your own labor on this web site. My mother take interest in participating in research and it is simple to grasp why. My spouse and i notice all regarding the powerful way you produce valuable thoughts via your website and in addition recommend response from the others on this subject then our own princess is undoubtedly studying a whole lot. Take pleasure in the rest of the year. You have been performing a terrific job. https://bupronbupropion.com/

  11. venlafaxine pills on

    My wife and i were very thankful when Raymond managed to round up his web research with the precious recommendations he was given while using the weblog. It is now and again perplexing to simply possibly be releasing tips and tricks which usually the rest might have been trying to sell. We really take into account we now have you to thank for this. Those illustrations you made, the straightforward website navigation, the relationships your site make it possible to promote – it is mostly unbelievable, and it is making our son in addition to us understand this topic is thrilling, which is certainly very vital. Thanks for the whole thing! https://effexorvenlafaxines.com/

  12. fluvoxamine buy on

    I am just writing to make you understand what a outstanding experience my wife’s girl obtained using your webblog. She noticed so many pieces, which included what it is like to possess an excellent helping spirit to let other people with no trouble learn specific specialized things. You truly surpassed readers’ expected results. Thank you for providing these priceless, trusted, informative as well as fun tips about this topic to Lizeth. https://luvoxfluvoxamine.com/

  13. pamelor prices on

    I precisely needed to appreciate you once again. I am not sure the things that I might have handled in the absence of the entire pointers provided by you on such a problem. It has been a very frightening difficulty in my circumstances, however , looking at the skilled manner you processed that made me to jump over fulfillment. I am happier for this help and in addition have high hopes you comprehend what a powerful job you’re carrying out instructing most people through your blog. I am sure you’ve never encountered all of us. https://pamelornortriptyline.com/

  14. generic ziprasidone on

    My spouse and i got really joyous that Jordan managed to do his reports through your precious recommendations he had through the web pages. It is now and again perplexing to just find yourself handing out secrets and techniques which people may have been selling. So we keep in mind we have got the writer to give thanks to for that. The most important illustrations you have made, the simple web site navigation, the relationships you will help to foster – it’s got many overwhelming, and it’s really leading our son in addition to the family know that the situation is exciting, which is rather mandatory. Thank you for everything! https://geodonziprasidone.com/

  15. My wife and i have been so peaceful when Michael managed to finish up his researching via the precious recommendations he obtained using your web site. It is now and again perplexing to simply happen to be making a gift of techniques which often some others might have been trying to sell. We recognize we need you to thank for this. The type of illustrations you made, the straightforward website navigation, the relationships your site make it easier to instill – it is most spectacular, and it is letting our son in addition to us reckon that this subject matter is interesting, which is certainly tremendously serious. Thanks for the whole lot! https://geodonziprasidone.com/

  16. cheap nortriptyline on

    I simply wanted to thank you so much once more. I am not sure the things that I would’ve sorted out without the type of solutions revealed by you over that situation. It truly was an absolute hard matter in my opinion, however , seeing the very specialised style you resolved that made me to leap over gladness. I will be happy for this service and then pray you realize what a great job you happen to be providing teaching people today using your web site. Most likely you have never got to know any of us. https://pamelornortriptyline.com/

  17. paxil without a prescription on

    I’m commenting to let you be aware of of the amazing discovery my child developed browsing the blog. She came to find a good number of details, including how it is like to have a great coaching character to get a number of people clearly completely grasp a number of advanced issues. You actually did more than her desires. I appreciate you for churning out such beneficial, dependable, edifying and cool guidance on that topic to Emily. https://paxilparoxetines.com/

  18. paroxetine no rx on

    I’m commenting to let you be aware of of the beneficial discovery my child developed browsing the blog. She came to find a lot of details, including how it is like to have a great coaching character to get certain people completely comprehend a number of complex issues. You actually did more than her desires. I appreciate you for coming up with such effective, dependable, edifying and cool guidance on that topic to Ethel. https://paxilparoxetines.com/

  19. My husband and i felt absolutely ecstatic Edward could complete his homework from the ideas he discovered from your very own site. It’s not at all simplistic just to be giving for free helpful tips that men and women could have been making money from. And we do know we have the blog owner to appreciate because of that. Most of the explanations you’ve made, the easy blog menu, the friendships you assist to engender – it’s everything excellent, and it’s assisting our son and our family do think that content is brilliant, and that’s extremely fundamental. Many thanks for all the pieces! https://tofranilimipramine.com/#

  20. Thanks for the suggestions about credit repair on this particular web-site. The things i would offer as advice to people is usually to give up this mentality that they buy at this point and fork out later. Being a society most of us tend to make this happen for many factors. This includes trips, furniture, in addition to items we’d like. However, it is advisable to separate one’s wants from the needs. As long as you’re working to raise your credit ranking score actually you need some trade-offs. For example you may shop online to economize or you can check out second hand outlets instead of high priced department stores intended for clothing. https://zyprexaolanzapine.com/#

  21. order bupropion on

    I am only writing to make you understand what a remarkable experience our princess undergone viewing your webblog. She picked up some things, which included what it is like to possess an ideal teaching spirit to make the mediocre ones without difficulty master specified tortuous things. You undoubtedly surpassed readers’ expected results. Thanks for rendering those productive, trustworthy, revealing as well as unique tips on your topic to Mary. https://wellbutrinbupropions.com/#

  22. generic seroquel on

    I’m also commenting to let you be aware of of the brilliant discovery my child encountered checking the blog. She came to understand a lot of details, including how it is like to have a marvelous coaching character to get folks completely fully grasp a variety of complex issues. You actually did more than her desires. I appreciate you for coming up with such essential, dependable, edifying and cool guidance on that topic to Ethel. https://seroquelquetiapine.com/#

  23. I am just writing to make you understand what a perfect experience my wife’s princess obtained using your webblog. She noticed some things, which included what it is like to possess an excellent teaching spirit to make others with no trouble learn about specific specialized things. You undoubtedly surpassed readers’ expected results. Thanks for providing those productive, trusted, informative as well as unique tips on your topic to Mary. https://wellbutrinbupropions.com/#

  24. purchase olanzapine on

    Thanks for the useful information on credit repair on your web-site. The thing I would offer as advice to people will be to give up a mentality they will buy at this moment and pay back later. As being a society most people tend to repeat this for many factors. This includes family vacations, furniture, plus items we really want to have. However, you must separate a person’s wants from the needs. When you’re working to fix your credit score you really have to make some trade-offs. For example you possibly can shop online to economize or you can click on second hand suppliers instead of highly-priced department stores to get clothing. https://zyprexaolanzapine.com/#

  25. Winston Soderling on

    What are the most effective WordPress plugins to attract the most relevant traffic, the most relevant traffic and maximize website sales?. . I am thinking maybe:. 1. RSS feed plugins, . 2. Cost Per Action (CPA) plugins or code snippets, . 3. Affiliate plugins and/or links. . Can you provide links to the tools that you think are the best, and let me know why you think they are the best?.

  26. Ꮤonderfuul beat ! I would like to apprentice while you amenjd
    your web site, һow could i subscribe for a weblog web site?
    The account helped me a acceptablе deaⅼ. I had bеen a little bit famijliar
    of this your broadcast offered brilliant transparent cⲟncept

    Also visit myy web-site single chatting free

  27. Does yoսr site have a contact paցе? I’m having
    a tough time locating it but, I’d like tto send you an e-mail.
    I’ᴠe got some sugɡestions for yoir blog үou might
    be interested in hearіng. Either way, great site and I look foorward to seeng it
    grow over time.

    Also visit mу wensite :: advance america payday loans