Sie sind auf Seite 1von 5

Customer Relationship Management (SAP CRM): ste...

| SCN

Page 1 of 5

Getting Started Newsletters Store

Welcome, Guest

Login

Register

Search the Community

Products Industries Lines of Business

Services & Support Training & Education University Alliances

About SCN Partnership Events & Webinars

Downloads Developer Center Innovation


Activity Browse Communications Actions

Customer Relationship Management (SAP CRM)

step by step to enable your Genil component with AET - Part Two
Posted by Jerry Wang in Customer Relationship Management (SAP CRM) on Oct 25, 2013 12:18:15 PM
Share 1 0 Tweet 2 Like 0

in part1 we discuss about: 1. How to enhance your genil component ( create a new Dependent object and corresponding DDIC structure ) to support AET 2. how to create a new UI object type 3. Create necessary EEW include structure and respective DB table to store FE transaction data. In this part2 I will show you how to enhance the Genil component implementation class. step1: support read access. If there is transaction data stored in DB table ZCRM_SOC_FE, it must be fetched and displayed in UI accordingly. The read access is done in genil implementation class method IF_GENIL_APPL_INTLAY~GET_OBJECTS. The original code before enhancement is using handler style. Every node has its corresponding handler class to do the job. The handler class for SocialPost is ZCL_CRM_SOC_POST, which means in order to support read access of extension fields, we need to enhance ZCL_CRM_SOC_POST->READ_OBJECT. 01. lr_object = go_handler_factory->get_handler( iv_object_name = lv_name ). 02. 03. TRY. 04. lr_post ?= lr_object. 05. CATCH:cx_sy_move_cast_error. 06. EXIT. 07. ENDTRY. 08. 09. CHECK lr_post IS NOT INITIAL. 10. CALL METHOD lr_post->read_object 11. EXPORTING 12. it_request_objects = it_request_objects 13. iv_ref = iv_root_list 14. CHANGING 15. ct_bapireturn = lt_bapireturn. This blog will not go deep into the Genil component implementation itself, but just focus what needs to be enhanced in Genil component implementation. as you see, I just add the code surrounded with red to read the extension field data. I pass the reference of container object into method get_fe_data. After that method is executed, the extension field data will be fetched and filled into the container object lo_post.

01. 02. 03. 04. 05. 06. 07. 08. 09. 10. 11. 12. 13.

method GET_FE_DATA. data: lv_guid TYPE crmt_genil_object_guid, lv_attr TYPE ZCRM_EXT_SMC_DYNP_SV, lv_convert_guid TYPE socialdata-socialdatauuid, ls_data TYPE ZCRM_SOC_FE. data(lv_children) = iv_container->GET_CHILDREN( IV_AS_COPY = ABAP_TRUE ). data(lv_child) = lv_children->GET_FIRST( ). ASSERT lv_child IS BOUND. iv_container->get_key( IMPORTING es_key = lv_guid ). lv_convert_guid = lv_guid. lv_attr = zcl_crm_soc_fe_buffer_access=>get( lv_convert_guid ). lv_child->set_attributes( lv_attr ). DATA(lv_attr_props) = lv_child->get_attr_props_obj( ).

http://scn.sap.com/community/crm/blog/2013/10/25/step-by-step-to-enable-your-genil-co... 10/26/2013

Customer Relationship Management (SAP CRM): ste... | SCN

Page 2 of 5

14. lv_attr_props->set_all_properties( if_genil_obj_attr_properties=>changeable ). 15. data(ls_key) = VALUE ZCRM_EXT_SMC_KEY( client = sy-mandt post_id = ls_data-post_id ). 16. lv_child->set_key( ls_key ). 17. endmethod. in get_fe_data, there is nothing special logic inside. The real data is returned via zcl_crm_soc_fe_buffer_access, which encapsulate the buffer handling of extension field data in current session. so let's have a look at the buffer class zcl_crm_soc_fe_buffer_access's get method: 01. method GET. 02. DATA: ls_data TYPE ZCRM_SOC_FE, 03. ls_attr TYPE ZCRM_EXT_SMC_DYNP_SV. 04. READ TABLE st_buffer ASSIGNING FIELD-SYMBOL(<buffer>) WITH KEY uuid = iv_guid. 05. IF sy-subrc = 0. 06. rs_data = <buffer>-data. 07. RETURN. 08. ENDIF. 09. SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_data FROM ( ZCRM_SOC_FE AS A INNER JOIN socialdata AS B 10. ON B~internal_id = A~post_id ) WHERE B~SOCIALDATAUUID = iv_guid. 11. CHECK ls_data IS NOT INITIAL. 12. MOVE-CORRESPONDING ls_data TO ls_attr. 13. DATA(ls_entry) = VALUE ty_buffer( uuid = iv_guid data = ls_attr ). 14. APPEND ls_entry TO st_buffer. 15. rs_data = ls_attr. 16. endmethod. first check in the buffer table whether there is already an entry there for the current social post. If buffer hits, the bufferred data is directly returned. If not, just load it from DB table. Why I use inner join is the type of buffer table has uuid as key, not internal id. And the uuid is the key field of hosting table of Social post, that is SOCIALDATA. After the data is loaded from DB, never forget to insert it into buffer table. 01. types: 02. BEGIN OF ty_buffer, 03. uuid TYPE socialdata-socialdatauuid, 04. data TYPE ZCRM_EXT_SMC_DYNP_SV, 05. END OF ty_buffer . 06. types: 07. tt_buffer TYPE STANDARD TABLE OF ty_buffer WITH KEY uuid . now the read access of extension fields are done. step2: write access. After we type some value in UI fields and click enter key, IF_GENIL_APPL_INTLAY~MODIFY_OBJECTS will be called. Just the same logic as step1, the call will be delegated to handler class ZCL_CRM_SOC_POST. In method MODIFY_OBJECT, I only add one more line to handle with extension fields by creating a new method process_children.

for simplicity reasons I only react on the change mode. Again I pass the call to zcl_crm_soc_fe_api.

in set_fe_data I just put the list of changed attribute ( lt_changed_attr ) and the latest data typed by user ( ls_attributes ) to buffer class.

http://scn.sap.com/community/crm/blog/2013/10/25/step-by-step-to-enable-your-genil-co... 10/26/2013

Customer Relationship Management (SAP CRM): ste... | SCN

Page 3 of 5

in set method of buffer class, again the similiar logic as done in read case. First check in the buffer table whether there exists an entry for current social post. If buffer hits, I just to update the buffer with latest extension fields data. I loop the internal table it_changed_attr to make sure all changed attributes are handled.

if there is no entry in the buffer, the situation should be that such post has not any extension fields stored in DB table at the begining of this transaction. The iv_new_data would come from the manual input typed by user in UI. In this case all I need is just to append the latest extension field data into the buffer table. step3: save case. No doubt the method SAVE_OBJECT of ZCL_CRM_SOC_POST must now take care the saving of both SocialPost itself and extension fields data as well. I just add two more lines to original code. I first save the extension field( done by zcl_crm_soc_fe_api=>save_fe_data), then the SocialPost itself ( via function module SOC_POST_SAVE ). The condition "no value changed" is enhanced that only the situation neither Socialpost nor its extension fields are changed could be regarded as no value changed. If the line 18 is missing, you will receive message in UI "No value changed", even you have already modified some extension field but not touch standard field in social post itself.

The method save_fe_data is also very simple: just fetch the extension field buffer from buffer table and then modify database table. method SAVE_FE_DATA. DATA: ls_change TYPE ZCRM_SOC_FE. DATA(ls_buffer) = zcl_crm_soc_fe_buffer_access=>get( iv_guid ). CHECK ls_buffer IS NOT INITIAL. MOVE-CORRESPONDING ls_buffer TO ls_change.

http://scn.sap.com/community/crm/blog/2013/10/25/step-by-step-to-enable-your-genil-co... 10/26/2013

Customer Relationship Management (SAP CRM): ste... | SCN

Page 4 of 5

rv_fe_changed = abap_true. endmethod. Summary: The genil component implementation is enhanced regarding following three parts: 1. enhance IF_GENIL_APPL_ALTERNATIVE_DSIL~SAVE_OBJECTS to support extension field save. 2. enhance IF_GENIL_APPL_ALTERNATIVE_DSIL~MODIFY_OBJECTS to support extension field change. 3. enhance IF_GENIL_APPL_ALTERNATIVE_DSIL~GET_OBJECTS to support extension field change. Now it's time to enjoy our labour! Just create three extension fields to test. The three extension fields has type Quantity and sub type PRESS ( built-in type provided by SAP), so AET framework automatically creates two seperate fields for you, one for quantity value and the other for unit.

Those features like F4 help and validation logic for respective data type are automaitcally handled by AET framework. You do not need to code by yourself Now have a look at the EEW structure created in part4. All extension fields are attached here.

And extension fields data are stored in DB.

http://scn.sap.com/community/crm/blog/2013/10/25/step-by-step-to-enable-your-genil-co... 10/26/2013

Customer Relationship Management (SAP CRM): ste... | SCN

Page 5 of 5

162 Views Tags: crm, webclientui, genil, enhancement, aet

Average User Rating (1 rating)

Share Share

Tweet

Like

2 Comments
Arjun Pawar Oct 25, 2013 2:01 PM

Hi

Jerry Wang,

Thanks for a lot for sharing knowledge. Very good article and amazing...Keep rocking..
Like (0)

Jerry Wang Oct 25, 2013 2:02 PM (in response to Arjun Pawar)

Hi Arjun, I am glad you like it Best regards, Jerry


Like (1)

Site Index Privacy

Contact Us Terms of Use

SAP Help Portal Legal Disclosure

Copyright

Follow SCN

http://scn.sap.com/community/crm/blog/2013/10/25/step-by-step-to-enable-your-genil-co... 10/26/2013

Das könnte Ihnen auch gefallen