SAP CRM Fiori應用如何啟用Sales Office和Sales Group兩個欄位
User story
In CRM WebUI, the sales area of a given opportunity consists of the following fields in assignment block “Organizational Data”. Note the “Sales Office” and “Sales Group” marked with red:
However in Fiori these two fields are not available.
The series of this blog will introduce how to bring these two standard fields into Fiori and provide CRUD operations on them.
As the first step, we need to expose the read operation of these two fields via odata service, which means when we test the odata service read operation, we expect to see both in response stream. Below is the screenshot of response before extension – both fields are missing there.
(1) When the data for Sales area tab in Fiori is read from backend, we make investigation and find out the data for both fields are already returned by one order API and available in the context of standard odata service implementation.
Since there is a MOVE-CORRESPONDING fields to move the opportunity data from one order API result to result structure of odata service, for the read operation, we just need to create two new fields in the structure of ls_entityset with exactly the same name, SALES_OFFICE and SALES_GROUP, then the MOVE-CORRESPONDING will take effect.
(2) The DDIC structure of Opportunity header is enhanced as below:
Add these two fields in service builder as well, re-generate runtime objects and clear model cache in both gateway and backend system to ensure the new fields could be visible in the runtime.
(3) retest the odata service read operation, the sales office and sales group are now available in the read response.
第二部分
In previous blog, the two fields Sales Office and Sales Group have already been exposed via OData service read operation. In this part I will make the two fields visible in Fiori UI. The final UI would look like below:
Step1: find the available extension point in UI to hold the two fields
There is existing extension point in opportunity detail view:
As the first step, our aim is just to display the two fields in Fiori UI without considering format requirement. So we just directly bind the two fields to SalesOfficeCode and SalesGroupCode exposed by blog part1.
This step is quite easy to do. The UI after this step looks like below. We can notice that for the other three standard fields, always the format + ( +
+ ) is displayed in UI.
The format is defined in xml view as below:
<Text id="salesorganization_Text"
text="{parts: [{path :'json>/SalesOrganizationDescription'},{path : 'json>/SalesOrganization'}], formatter : 'cus.crm.opportunity.util.Formatter.formatSalesOrganization'}"></Text>
and the simple format function:
formatSalesOrganization : function(SalesOrganizationDescription, SalesOrganizationId){
var SalesOrganization = "";
if(SalesOrganizationId != undefined && SalesOrganizationId != "")
{
SalesOrganization = SalesOrganizationDescription + " (" + SalesOrganizationId + ")";
}
return SalesOrganization;
},
In next step, we will enable the same format function for the two new fields.
Step2: create another two new fields SalesGroupText and SalesOfficeText to hold the description
The steps are also exactly the same as how we create the two fields SalesGroupCode and SalesOfficeCode in blog1: add the fields in DDIC structure and related Odata Model node:
After we have these two fields to store description, we can write the logic to get description by code. All READ-related methods need to be enhanced with this logic. a. redefine method OPPORTUNITIES_GET_ENTITYSET and paste the following source code:
METHOD opportunities_get_entityset.
DATA: lv_otype TYPE otype.
FIELD-SYMBOLS: <opportunity> LIKE LINE OF et_entityset.
CALL METHOD super->opportunities_get_entityset
EXPORTING
iv_entity_name = iv_entity_name
iv_entity_set_name = iv_entity_set_name
iv_source_name = iv_source_name
it_filter_select_options = it_filter_select_options
is_paging = is_paging
it_key_tab = it_key_tab
it_navigation_path = it_navigation_path
it_order = it_order
iv_filter_string = iv_filter_string
iv_search_string = iv_search_string
IMPORTING
et_entityset = et_entityset.* Note: the single read below is not efficient from performance point of view.* In production code you can use cl_crm_orgman_interface=>READ_TEXT_MULTI to improve performance
LOOP AT et_entityset ASSIGNING <opportunity>.
IF <opportunity>-sales_group IS NOT INITIAL.
lv_otype = <opportunity>-sales_group+0(1).
CALL METHOD cl_crm_orgman_interface=>read_text_single
EXPORTING
otype = lv_otype
objid = <opportunity>-sales_group+2(8)
IMPORTING
display_text = <opportunity>-sales_group_txt.
ENDIF.
IF <opportunity>-sales_office IS NOT INITIAL.
lv_otype = <opportunity>-sales_office+0(1).
CALL METHOD cl_crm_orgman_interface=>read_text_single
EXPORTING
otype = lv_otype
objid = <opportunity>-sales_office+2(8)
IMPORTING
display_text = <opportunity>-sales_office_txt.
ENDIF.
ENDLOOP.
ENDMETHOD.
b. create a new private method FILL_SALES_TEXT with the following signature:
source code:
METHOD fill_sales_text.
FIELD-SYMBOLS: <opp_header> TYPE cl_crm_opportunity_mpc=>ts_opportunity,
<opp_expand> TYPE crmt_odata_oppt_hdr_expanded,
<opp> TYPE any,
<salegroup_text> TYPE crmt_odata_oppt_header-sales_group_txt,
<saleoffice_text> TYPE crmt_odata_oppt_header-sales_office_txt,
<salegroup_code> TYPE crmt_odata_oppt_header-sales_group,
<saleoffice_code> TYPE crmt_odata_oppt_header-sales_office.
DATA: lv_otype TYPE otype.
IF iv_called_by_expand = abap_false.
ASSIGN cr_entity->* TO <opp_header>.
ASSIGN <opp_header> TO <opp>.
ELSE.
ASSIGN cr_entity->* TO <opp_expand>.
ASSIGN <opp_expand> TO <opp>.
ENDIF.
ASSIGN COMPONENT 'SALES_GROUP' OF STRUCTURE <opp> TO <salegroup_code>.
ASSIGN COMPONENT 'SALES_GROUP_TXT' OF STRUCTURE <opp> TO <salegroup_text>.
ASSIGN COMPONENT 'SALES_OFFICE' OF STRUCTURE <opp> TO <saleoffice_code>.
ASSIGN COMPONENT 'SALES_OFFICE_TXT' OF STRUCTURE <opp> TO <saleoffice_text>.
IF <salegroup_code> IS NOT INITIAL.
lv_otype = <salegroup_code>+0(1).
CALL METHOD cl_crm_orgman_interface=>read_text_single
EXPORTING
otype = lv_otype
objid = <salegroup_code>+2(8)
IMPORTING
display_text = <salegroup_text>.
ENDIF.
IF <saleoffice_code> IS NOT INITIAL.
lv_otype = <saleoffice_code>+0(1).
CALL METHOD cl_crm_orgman_interface=>read_text_single
EXPORTING
otype = lv_otype
objid = <saleoffice_code>+2(8)
IMPORTING
display_text = <saleoffice_text>.
ENDIF.
ENDMETHOD.
c. in DPC_EXT’s method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITY, call the FILL_SALES_TEXT:
METHOD /iwbep/if_mgw_appl_srv_runtime~get_entity.
CALL METHOD super->/iwbep/if_mgw_appl_srv_runtime~get_entity
EXPORTING
iv_entity_name = iv_entity_name
iv_entity_set_name = iv_entity_set_name
iv_source_name = iv_source_name
it_key_tab = it_key_tab
it_navigation_path = it_navigation_path
io_tech_request_context = io_tech_request_context
IMPORTING
er_entity = er_entity
es_response_context = es_response_context.
CASE iv_entity_name.
WHEN 'Opportunity'.
CALL METHOD fill_sales_text
EXPORTING
iv_called_by_expand = abap_false
CHANGING
cr_entity = er_entity.
WHEN OTHERS.
ENDCASE.
ENDMETHOD.
in DPC_EXT’s method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITY, call the method as well:
METHOD /iwbep/if_mgw_appl_srv_runtime~get_expanded_entity.
CALL METHOD super->/iwbep/if_mgw_appl_srv_runtime~get_expanded_entity
EXPORTING
iv_entity_name = iv_entity_name
iv_entity_set_name = iv_entity_set_name
iv_source_name = iv_source_name
it_key_tab = it_key_tab
it_navigation_path = it_navigation_path
io_expand = io_expand
io_tech_request_context = io_tech_request_context
IMPORTING
er_entity = er_entity
es_response_context = es_response_context
et_expanded_clauses = et_expanded_clauses
et_expanded_tech_clauses = et_expanded_tech_clauses.
CASE iv_entity_name.
WHEN 'Opportunity'.
CALL METHOD fill_sales_text
EXPORTING
iv_called_by_expand = abap_true
CHANGING
cr_entity = er_entity.
ENDCASE.
ENDMETHOD.
Once this step is done, you could test your enhanced Odata service read operation and ensure you could see both code and description of SalesGroup and SalesOffice in response.
Step3: change the binding of extension fields
Just change the binding path from code to the converted value formatted by the formatter.
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:ui="sap.ui.layout">
<ui:form.SimpleForm id="salesAreaInfoTabContentBottomExtension">
<ui:content>
<Label id="SalesOfficeLabel" text="Sales Office">
</Label>
<Text id="SalesOffice" text="{parts: [{path :'json>/SalesOfficeText'},{path : 'json>/SalesOfficeCode'}], formatter : 'cus.crm.opportunity.CRM_OPPRTNTYExtension.UtilExtension.Util.formatSalesOffice'}"></Text>
<Label id="SalesGroupLabel" text="Sales Group">
</Label>
<Text id="SalesGroup" text="{parts: [{path :'json>/SalesGroupText'},{path : 'json>/SalesGroupCode'}], formatter : 'cus.crm.opportunity.CRM_OPPRTNTYExtension.UtilExtension.Util.formatSalesOffice'}"></Text>
</ui:content>
</ui:form.SimpleForm></core:FragmentDefinition>
The complete UI code could be found in github: with commit id: 7489bd487cc40fff1a9dd3b9d3683036961a1061 The complete backend source code could be found from attachment.
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2718381/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 如何給 SAP Fiori Elements 應用的欄位新增 value help
- SAP CRM Fiori應用和SAP JAM的整合配置
- 兩種使用程式碼獲得SAP CRM product sales status的辦法
- SAP Cloud for Customer裡Sales Order和Sales Quote的建模方式Cloud
- SAP Fiori Launchpad 應用的兩個實用技巧分享
- 如何利用BAPI SD_SALESDOCUMENT_CHANGE修改Sales Order的欄位API
- SAP CRM Fiori 應用的 Deep Create 行為和實現分析
- 如何用WebIDE開啟並執行CRM Fiori應用WebIDE
- 如何免費試用SAP的Fiori應用
- SAP CRM Fiori應用冗餘round trip的原因分析
- 如何分辨 SAP Fiori Launchpad 裡的真假 Fiori 應用
- SAP CRM中介軟體Material Sales Organization和distribution channel的對映邏輯
- SAP Fiori應用索引大全索引
- SAP CRM,Cloud for Customer和Fiori應用的direct navigation比較CloudNavigation
- SAP Fiori應用索引大全工具和 SAP Fiori Tools 的使用介紹索引
- CRM和ERP的Sales Organization的對映關係
- SAP CRM Product Sales status在中介軟體中的處理邏輯
- 淺談SAP Cloud for Sales 自動化Cloud
- 如何定製化Fiori標準應用裡UI欄位的標籤UI
- 如何根據角色批量啟用SAP Fiori服務
- SAP CRM Fiori 應用和 SAP 電商雲 UI 如何通過調整CSS來改變UI顯示風格UICSS
- SAP SD (Sales & Distribution) Training TutorialAI
- 如何在SAP Fiori應用裡使用React componentReact
- SAP C4C Opportunity和SAP ERP Sales流程的整合Unity
- 使用擴充套件技術將SAP Fiori應用隱藏動態建立的UI欄位套件UI
- 如何查詢SAP Fiori UI上某個欄位對應的底層資料庫表UI資料庫
- SAP Fiori 應用 Manage Workflows for Purchase RequisitionsUI
- SAP Fiori應用沒能從Fiori Launchpad啟動的一個可能原因及分析過程
- 如何給 SAP Fiori Elements 應用新增自定義按鈕
- SIS(Sales Information System)步驟1-維護自定義欄位目錄ORM
- SAP一句話入門:Sales and Distribution
- SAP Fiori Elements 應用裡和 Fiori 3 相關的外觀設定
- marketing和sales的區別
- 如何把SAP CRM WebClient UI上某個欄位高亮加粗顯示WebclientUI
- SAP Fiori應用的搜尋問題
- SAP Fiori應用的三種部署方式
- SAP S/4HANA Material Fiori應用根據擴充套件欄位搜尋的實現原理套件
- 如何將自定義XML檢視注入SAP Fiori Elements應用XML