Hello All,
Good day.
Today we will discuss on how we can reuse attachment block (BSP Component View GS_CM/DocList) in Contract Account page in S4CRM Web UI. Before proceeding would like to throw some light on S4CRM which is different from CRM in some ways.
1)Custom extensions to standard objects which is now possible from Fiori Extensibility features replacing Application Enhancement Tool (AET).
2)One Order DB landscape has been flattened by knocking out CRMD_LINK table and having only header and item tables for different objects. For more details go through blogs by Jerry Wang. Found it very useful.
3)For certain industries, forms has replaced conventional BOL programming i.e., rather generating controller, context nodes its getters setters, navigation links, button, usages etc ‘forms’ can be used to configure views maintaining its action profiles and contexts with extensive options at field level, minimising developments at the BSP Component level. It has brought some convenience but requires research as did not found much documentation online. Respective article will highlight some of its features.
Now coming back to the article, Contract Account page for Utilities in Web UI can be introduced with Attachment block directly using below SPRO path.
SAP Customizing Implementation Guide->SAP Utilities->Customer Engagement->General Functions->Define Forms.
Firstly, create a form (ZCAP_ATTACHMENT) for attachments and maintain its window and parent context details to be exposed.
Secondly, maintain the attachment form under Contract Account Overview form (UCAP_OV) and set its positioning. We are positioning in 1st row 4th column.
Thirdly, we need to bind Attachments block contexts with Contract Account overview component which is IUICFMK. For that, new Custom Controller is created for required attachments context objects availability.
UTILSCONTRAACCTPARTNER is the Contract Account header object. It’s binded with respective component controller context ‘OBJECTS’ which will hold parent (contract account) instance for attachments (as ‘Transfer context to sub-form’ is configured for attachment form)
CMBO is the attachments access object which by standard supports contract account attachments under object type ‘BUS1006130’ and is fetched in its method ON_NEW_FOCUS.
METHOD on_new_focus.
* Declarations
DATA: lr_qs TYPE REF TO cl_crm_bol_query_service,
lr_data TYPE REF TO data,
ls_cmbo_prop TYPE crmt_cmic_rfolder_attr,
lr_entity_col TYPE REF TO if_bol_entity_col.
* Field Symbols
FIELD-SYMBOLS: <fs_guid> TYPE bu_partner_guid. "guid of your object
* get focus_bo
CHECK focus_bo IS BOUND.
TRY.
lr_qs = cl_crm_bol_query_service=>get_instance( 'CMBOLinkQuery' ).
CATCH cx_root. "#EC NO_HANDLER
* attachment model not yet loaded
ENDTRY.
CHECK lr_qs IS BOUND.
lr_data = focus_bo->get_property( 'GUID' ). "get guid according to the correct name
ASSIGN lr_data->* TO <fs_guid>.
ls_cmbo_prop-instid = <fs_guid>.
ls_cmbo_prop-typeid = 'BUS1006130'.
ls_cmbo_prop-catid = 'BO'.
* fill and fire query
lr_qs->set_properties( ls_cmbo_prop ).
lr_entity_col = lr_qs->get_query_result( ).
* set collection of context node CMBO, which is already bound
* to the model node CMBO of component controller
me->collection_wrapper->clear_collection( ).
me->collection_wrapper->set_collection( lr_entity_col ).
ENDMETHOD.
Fourthly, WD_USAGE_INITIALIZE binding at component controller level is done in filter based BADI CRM_IU_IL_S4OP_CMPCNTR where IUICFMK is added to filter and implementation made as custom one. Component usage name for attachments is dynamically generated, hence its binded using conditional string operation to identify it. Attachment functionality works now.
METHOD if_crm_iu_il_s4op_cmpcntr~wd_usage_initialize.
.
.
* Attachments Component Usage binding for Contract Account Component
IF ir_usage->usage_name CS |#GS_CM#SubFrm_00164|.
* Bind Attachments parent that will be Contract Account Object
CALL METHOD ir_usage->bind_context_node
EXPORTING
iv_controller_type = cl_bsp_wd_controller=>co_type_custom
iv_name = 'IUICFMK/Attachments' "#EC NOTEXT
iv_target_node_name = 'UTILSCONTRACCTPARTNER' "#EC NOTEXT
iv_node_2_bind = 'PARENTNODE'. "#EC NOTEXT
* Bind Attachments Business Object
CALL METHOD ir_usage->bind_context_node
EXPORTING
iv_controller_type = cl_bsp_wd_controller=>co_type_custom
iv_name = 'IUICFMK/Attachments' "#EC NOTEXT
iv_target_node_name = 'CMBO' "#EC NOTEXT
iv_node_2_bind = 'CMBUSOBJ'. "#EC NOTEXT
* Get binded CUCO instance
lr_cuco_attachement ?= ir_component_controler->get_custom_controller( 'IUICFMK/Attachments' ).
IF lr_cuco_attachement IS BOUND.
lr_cuco_attachement->typed_context->cmbo->on_new_focus( lr_cuco_attachement->typed_context->utilscontracctpartner->collection_wrapper->get_current( ) ).
ENDIF.
ENDIF.
ENDMETHOD.
Lastly, advanced button (in attachment block page) which navigate from DocList page to AdvancedOVP page dumps, as navigation links cannot be created in component IUICFMK as usage window is generated dynamically. Moreover GS_CM being a conventional component, does not support forms feature of action button generation. Hence dynamic navigation is used for same, binding context to component controller at landing inbound plug TO_ADVANCED. For required business role, generic outbound plug is defined for Target ID in View CRMV_UI_GEN_MAP.
Maintain inbound plug for the target ID which navigates to AdvancedOVP page in t-code crms_ui_tlink.
METHOD eh_on_advanced_btn.
* Declarations
DATA: lr_entity TYPE REF TO cl_crm_bol_entity,
lr_col TYPE REF TO cl_crm_bol_bo_col,
lr_nav_serv TYPE REF TO if_crm_ui_navigation_service,
lr_nav_descr TYPE REF TO if_bol_bo_property_access,
lr_coco TYPE REF TO cl_gs_cm_bspwdcomponent.
* Get parent entity
lr_coco ?= me->comp_controller.
lr_entity ?= lr_coco->typed_context->parentnode->collection_wrapper->get_current( ).
* When Contract Account is parent navigate using dynamic navigation
IF lr_entity IS BOUND AND lr_entity->get_name( ) = 'UtilsContrAcctPartner'.
CREATE OBJECT lr_col.
lr_col->if_bol_bo_col~add( lr_entity ).
cl_crm_ui_descriptor_obj_srv=>create_ui_object_based(
EXPORTING iv_component = 'GS_CM'
iv_ui_object_type = 'PARENTNODE'
iv_ui_object_action = 'B'
RECEIVING rr_result = lr_nav_descr ).
lr_nav_serv = cl_crm_ui_navigation_service=>get_instance( ).
* check if navigation is possible and start navigation
IF lr_nav_serv->is_dynamic_nav_supported( ir_descriptor_object = lr_nav_descr ) = abap_true.
lr_col->if_bol_bo_col~insert( iv_bo = lr_nav_descr iv_index = 1 ).
lr_nav_serv->navigate_dynamically( iv_data_collection = lr_col ).
ENDIF.
* Else, Call Super
ELSE.
CALL METHOD super->eh_on_advanced_btn
EXPORTING
htmlb_event = htmlb_event
htmlb_event_ex = htmlb_event_ex.
ENDIF.
ENDMETHOD.
METHOD ip_to_advanced.
* Declarations
DATA: lr_entity TYPE REF TO cl_crm_bol_entity,
lr_coco TYPE REF TO cl_gs_cm_bspwdcomponent.
IF iv_collection IS BOUND.
lr_entity ?= iv_collection->get_current( ).
ENDIF.
* For Contract Account navigation to Attachment advanced page, bind contract account and Attachments to component controller nodes
IF lr_entity IS BOUND AND lr_entity->get_name( ) = 'UtilsContrAcctPartner'.
lr_coco ?= me->comp_controller.
lr_coco->typed_context->seldoc->collection_wrapper->clear( ).
lr_coco->typed_context->parentnode->collection_wrapper->clear( ).
lr_coco->typed_context->cmbusobj->collection_wrapper->clear( ).
lr_coco->typed_context->parentnode->set_collection( iv_collection ).
* Method get_cmbusobj fetched details similar to ON_NEW_FOCUS.
lr_coco->typed_context->cmbusobj->set_collection( get_cmbusobj( EXPORTING im_focus_bo = lr_entity ) ).
* Else, Call Super
ELSE.
CALL METHOD super->ip_to_advanced
EXPORTING
iv_collection = iv_collection.
ENDIF.
ENDMETHOD.
Hope you liked the article. Please let me know if any comments/queries. Your feedback would really help.
Regards,
Ahmad Raza Karim