Hey guys,
I've managed to create custom fields where I wanted them to be. But there's another problem. I've created those fields in business hours relation. There are field to choose an employee and communication channel like e-mail, fax, etc.Anyway i still have a little problem.
When I click on a new button on business hours assignment block I see a view of new business hours element (as it should be). There are my two new fields. They're mandatory fields so I need to fill them. When I do this and fill all other fields (even those which aren't mandatory), I click the back button (the one which save the data). There is no error and I'm returning to the standard account view. Now, when I want to edit created object. I click the edit button. When the view changes to business hours view, my fields of employee and the channel are not filled out. But when I fill them now, on edit screen, they would be saved.
When I debug the redefinition of method MODIFY there is some problem with lwa_key. While creating the new business hours element the lwa_key equals 0, but when I edit the object it has some value. Here's the code of modify method (the assign part):
TRY. lv_obj ?= iv_ref. CATCH: cx_sy_assign_cast_error. EXIT. ENDTRY. lv_obj->get_key( IMPORTING es_key = lwa_key ). IF lwa_key IS INITIAL. lr_parent = lv_obj->get_parent( CALL METHOD lr_parent->get_key IMPORTING es_key = ls_parent_key. ENDIF. lv_delta = lv_obj->get_delta_flag( ). IF lv_delta EQ if_genil_cont_simple_object=>delta_created. lwa_key-parent_guid = ls_parent_key-partner_guid. CLEAR: lwa_global_bol_data, gt_global_bol_data. MOVE-CORRESPONDING lwa_key TO lwa_global_bol_data. TRY. CALL METHOD lv_obj->set_key EXPORTING is_object_key = lwa_key. CATCH cx_crm_genil_duplicate_key. ENDTRY. lv_obj->get_attributes( IMPORTING es_attributes = lwa_bol_data ). lv_obj->get_attributes( IMPORTING es_attributes = lwa_bol_data_chg ). lr_obj_prop = lv_obj->get_attr_props_obj( ). CALL METHOD lr_obj_prop->get_name_tab_4_property EXPORTING iv_property = if_genil_obj_attr_properties=>modified IMPORTING et_names = lt_changed_fields. LOOP AT lt_changed_fields INTO lwa_changed_fields. ASSIGN COMPONENT lwa_changed_fields OF STRUCTURE lwa_bol_data_chg TO<new_data>. ASSIGN COMPONENT lwa_changed_fields OF STRUCTURE lwa_global_bol_data TO <old_data>. <old_data> = <new_data>. ENDLOOP. APPEND lwa_global_bol_data TO gt_global_bol_data. ENDIF.