`
JerryWang_SAP
  • 浏览: 1054949 次
  • 性别: Icon_minigender_1
  • 来自: 成都
文章分类
社区版块
存档分类
最新评论

使用扩展技术对SAP Fiori应用进行端到端的增强,一个实际案例介绍

阅读更多

第一章

These series of blogs give a step-by-step instructions about how to extend SAP standard CRM Fiori application in an End-to-End way. The CRM application “My Opportunity” is used as example. End-to-End means:

(1) Enhance the standard OData model to fulfill customer specific business requirement which could not be covered by standard. Technically, it means new extension fields are enhanced upon related standard DDIC structures. The Create, Read, Update and Delete operations are supported upon those extension fields. (2) Enhance the runtime OData service implementation to manipulate on the OData extensions done by step1.

(3) Consume the extension fields exposed enhanced OData service done by step1 & step2 in UI.

This article will cover step1 & step2. The involved scenario is:

(1) enhance a new field in OData model to store the user name who creates the current Opportunity currently being read. (2) enhance the OData service’s read operation, so that this extension field is filled with correct value in the backend.

Step1 Create extension project using transaction code SEGW

This extension project is used to store all kinds of extensions on standard gateway project CRM_OPPORTUNITY

 

 

choose Redefine->OData Service(SAP GW):

 

 

Select standard project: CRM_OPPORTUNITY

 

 

Just select all entities and click Finish button.

 

 

Generate all Runtime artifacts, ensure successful generation:

 

 

Use default proposed name or change according to your own naming convention. Write down your technical service Name, here is ZJERRY_DEMO_SRV:

 

 

Step2 Register your extension service in gateway ( frontend ) system

Till now we haven’t done any extension yet, which means all the CRUD operations on Opportunity should work. Log on to your gateway system, use transaction code /IWFND/MAINT_SERVICE, click Add Service button:

 

 

Search by the technical service name which you got in step 1:

 

 

Add the found technical service, then registration is done. Now you could test your service via gateway client.

 

 

Launch gateway client via this button:

 

 

Test whether metadata retrieve works.

 

 

Test whether read operation on given Opportunity instance specified by guid also works or not. Just replace the standard service name CRM_OPPORTUNITY with your own one: ZJERRY_DEMO_SRV:

 

 

Step3 Enhance OData model

Suppose we need to extend Opportunity header structure with new field which stores the information who has created the opportunity.

The first step is to figure out which DDIC structure you need to extend. In this example, since I need to extend Opportunity header, so I just look into data type TS_OPPORTUNITY defined in Opportunity MPC ( metadata provider class ),

 

 

types: TS_OPPORTUNITY type CRMT_ODATA_OPPT_HEADER.

If you need to do extension on any part of Opportunity, for example on product level, then use the structure defined in TS_OPPORTUNITYPRODUCT instead. Create a new extension field EXT_CREATED_BY via append structure.

 

 

go to tcode SEGW, extend the OData model as well. Double click on the folder icon “Properties” of Opportunity node, create a new field:

 

 

Specify the field name, field type and the most important is the ABAP field name EXT_CREATED_BY must be bound to this field in model.

 

 

Once done, regenerate the runtime artifacts by clicking the icon “Generate Runtime Objects” in toolbar.

Till now your model enhancement is done.

every time you have make modifications on your OData model in backend system, to make it take effect, you have to clear the cache in both gateway and backend system separately, or else when your model is accessed in the runtime, still the old structure stored in cache table is used. You could not see the new field you just created.

Tcode to clear cache in frontend system: /IWFND/CACHE_CLEANUP Tcode to clear cache in backend system: /IWBEP/CACHE_CLEANUP

Step4 finish data provider class enhancement

In this step, we must enhance the original OData service implementation: fetch the created by information of a given Opportunity being read and fill it to extension field EXT_CREATED_BY.

open your DPC_EXT class, and redefine method GET_ENTITY, as which will be called when an opportunity is read via its guid. Please always make changes on the DPC_EXT class. All your changes on DPC class will get lost every time you click “Generate Runtime Objects” button in tcode SEGW.

 

 

paste the source code below to method implementation:

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.
*  Customer extension could be put here
    CASE iv_entity_name.
      WHEN 'Opportunity'.
*         Extension logic on Opportunity header
        CALL METHOD fill_created_by
          EXPORTING
            it_key_tab = it_key_tab
          CHANGING
            cr_entity  = er_entity.
      WHEN OTHERS.
    ENDCASE.
  ENDMETHOD.

And source code for private method fill_created_by:

method FILL_CREATED_BY.

     FIELD-SYMBOLS: <s_guid> LIKE LINE OF it_key_tab,

                    <opp_header> TYPE cl_crm_opportunity_mpc=>ts_opportunity,

                    <created_by> TYPE sy-uname.

     DATA: lv_created_by TYPE crmd_orderadm_h-created_by.

     ASSIGN cr_entity->* TO <opp_header>.

     ASSIGN COMPONENT 'EXT_CREATED_BY' of STRUCTURE <opp_header> TO <created_by>.

     CHECK sy-subrc = 0.

     READ TABLE it_key_tab ASSIGNING <s_guid> WITH KEY name = 'Guid'.

     CHECK sy-subrc = 0.

     SELECT SINGLE created_by INTO lv_created_by FROM crmd_orderadm_h WHERE guid = <s_guid>-value.

     IF sy-subrc = 0.

        <created_by> = lv_created_by.

     ENDIF.

  endmethod.

The signature of method:

methods FILL_CREATED_BY
    importing
      !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR
    changing
      !CR_ENTITY type ref to DATA .

Then test in gateway client: the extension field is filled with correct data in the runtime.

 

 

第二章

In this part we will consume this extension field “extCreatedBy” in Fiori UI.

It is only possible for you to put your extension fields to UI area where an ExtensionPoint exists, which is delivered by SAP.

Since I need to put the new field under the last field “Log of Changes”, below screenshot is original UI before we extend:

 

 

The screenshot below is what we expect to achieve after this blog:? the enhanced UI with extension field:

 

 

Solution

Find out its ExtensionPoint in xml view:

 

 

The idea here is you need to create a new view fragment, and put your extension field into this fragment, which is embedded into the standard opportunity view via ExtensionPoint.

 

 

The complete source code of extCreatedBy.fragment.xml:

<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:ui="sap.ui.layout">
   <ui:form.SimpleForm id="opportunityExtension">
        <ui:content>
         <Label id="opportunityCreatedByLbael" text="Created By">
         </Label>
         <Text id="opportunityCreatedByValue" text="{json>/extCreatedBy}"></Text>
        </ui:content>
        </ui:form.SimpleForm>
</core:FragmentDefinition>

Finally, specify the OData service url to your own OData service implemented via the step mentioned in previous blog:

 

 

The complete source code of frontend part could be found in github:github.com/i042416/test commit id:

 

 

Last but not least, since now we have consumed the extension field in Fiori UI, not simply via gateway client in previous blog, so we need to ensure that the extension field could successfully be read out in all scenarios. It means the following two methods should be redefined now ( for the first method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITY, it is already redefined in previous blog ).

 

 

source code are listed below:

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.
*  Customer extension could be put here
    CASE iv_entity_name.
      WHEN 'Opportunity'.
*         Extension logic on Opportunity header
        CALL METHOD fill_created_by
          EXPORTING
            it_key_tab          = it_key_tab
            iv_called_by_expand = abap_false
          CHANGING
            cr_entity           = er_entity.
      WHEN OTHERS.
    ENDCASE.
  ENDMETHOD.
  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'.
*         Extension logic on Opportunity header
        CALL METHOD fill_created_by
          EXPORTING
            it_key_tab          = it_key_tab
            iv_called_by_expand = abap_true
          CHANGING
            cr_entity           = er_entity.
      WHEN OTHERS.
    ENDCASE.
  ENDMETHOD.
  method FILL_CREATED_BY.
     FIELD-SYMBOLS: <s_guid> LIKE LINE OF it_key_tab,
                    <opp_header> TYPE cl_crm_opportunity_mpc=>ts_opportunity,
                    <opp_expand> TYPE CRMT_ODATA_OPPT_HDR_EXPANDED,
                    <created_by> TYPE sy-uname.
     DATA: lv_created_by TYPE crmd_orderadm_h-created_by.
     IF iv_called_by_expand = abap_false.
       ASSIGN cr_entity->* TO <opp_header>.
       ASSIGN COMPONENT 'EXT_CREATED_BY' of STRUCTURE <opp_header> TO <created_by>.
     ELSE.
       ASSIGN cr_entity->* TO <opp_expand>.
       ASSIGN COMPONENT 'EXT_CREATED_BY' of STRUCTURE <opp_expand> TO <created_by>.
     ENDIF.
     READ TABLE it_key_tab ASSIGNING <s_guid> WITH KEY name = 'Guid'.
     CHECK sy-subrc = 0.
     SELECT SINGLE created_by INTO lv_created_by FROM crmd_orderadm_h WHERE guid = <s_guid>-value.
     IF sy-subrc = 0.
        <created_by> = lv_created_by.
     ENDIF.
  endmethod.
Signature of private method FILL_CREATED_BY:
methods FILL_CREATED_BY
    importing
      !IT_KEY_TAB type /IWBEP/T_MGW_NAME_VALUE_PAIR
      !IV_CALLED_BY_EXPAND type ABAP_BOOL
    changing
      !CR_ENTITY type ref to DATA .

In order to make FILL_CREATED_BY used by both read redefined method, I add a new importing parameter iv_called_by_expand to differentiate its used scenario, since for read and read_expand scenario, the exporting parameter’s structure are different. The fill_created_by should react accordingly.

第三章

In this blog we will go a step further: we will allow end user to manually type some value in this extension field and persist the value to the database table in CRM backend server, when save button is clicked. Requirement: The value must be saved into a new corresponding field in database table CRMD_OPPORT_H. Here below is the UI so far we get:

(1) There is an extension field done on Opportunity detail view. (2) When the detail is rendered, the value of the extension field is fetched from database table CRMD_ORDERADM_H, field CREATED_BY.

 

 

Step1 create new field in Opportunity edit view

We notice that once edit button in toolbar is clicked, we will reach opportunity edit view. Now the extension field is only available in detail view ( read only there ), so we need also to add the extension field into edit view. Use the similar approach in part2 blog to bring the extension field to edit view. Currently we didn’t do any binding to this field in edit value, just use a hard code value “Jerry”

<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:ui="sap.ui.layout">
   <ui:form.SimpleForm id="OpportunityEditExtension" minWidth="1024" maxContainerCols="2" editable="true" layout="ResponsiveGridLayout"
    labelSpanL="3" labelSpanM="3" emptySpanL="4" emptySpanM="4" columnsL="1" columnsM="1" class="editableForm" >
        <ui:content>
         <Label id="opportunityCreatedByLbael" text="Created By">
         </Label>
         <Input id="createdByInput" value="Jerry"></Input>
        </ui:content>
        </ui:form.SimpleForm>
</core:FragmentDefinition>

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

0
1
分享到:
评论

相关推荐

    SAP Fiori APP 应用快速实施解决办法

    本文档将详细介绍如何通过手动配置步骤或使用预定义任务列表来实现SAP Fiori应用程序的快速部署。此外,还将针对SAP Fiori的三种应用类型——交易应用程序、分析应用程序以及实况报告报表(Fact Sheets)——提供...

    SAP Fiori---快速指南 共82页 2018年编著 word文档

    ### SAP Fiori 快速指南知识点详述 #### 一、SAP Fiori 简介 SAP Fiori 是一款由 SAP 开发的新...随着 SAP HANA 的普及和技术的发展,SAP Fiori 的应用范围和功能也将不断扩展,成为企业信息化建设不可或缺的一部分。

    SAP Fiori 最新现金流案例

    【SAP Fiori 现金流案例详解】 SAP Fiori 是一款由SAP公司开发的现代化用户体验设计框架,它提供了丰富的用户界面,旨在优化业务流程并提升工作效率。在这个最新的现金流案例中,我们看到SAP Fiori如何帮助用户实时...

    sapFiori配置手册[整理].pdf

    SAP Fiori配置手册 本配置手册旨在指导用户完成SAP Fiori的设置和配置,从而实现SAP Fiori Launchpad的激活。下面是该手册中所涉及到的知识点: 1. 创建管理员账号和测试账号 在SAP Fiori的配置中,需要创建管理...

    SAP Fiori 2.0开发指南

    - SAP Fiori 2.0 引入了一个强大的工具,允许系统管理员轻松定制主题和样式。这有助于保持企业品牌的一致性,并提高用户体验。 #### 对开发者重要的变化 ##### 1. **SAP Fiori 2.0 标题栏** - **启用自动 SAP ...

    SAP官方Fiori使用说明文件

    SAP Fiori 2.0 对快速启动板进行扩展,通过视口为用户特定和系统驱动数据提供额外的空间。响应式视口以简单方式并行管理不同屏幕区域。 快速启动板的优点 快速启动板提供了简洁的用户界面、个性化的体验、强大的...

    SAP Fiori 学习概要

    SAP Fiori是一个为SAP软件用户界面提供全新设计框架的用户体验。它强调简洁直观的用户界面,并能够适应不同的设备,包括桌面电脑、平板和智能手机。SAP Fiori 2.0系列视频教程涵盖了从基础到高级的内容,帮助开发者...

    SAP Fiori用户界面与应用开发指南

    SAP Fiori提供了一个多设备兼容的应用环境,可以无缝切换不同的设备进行操作。文档还涉及了SAP Fiori架构、SAP NetWeaver Gateway、安装配置步骤、安全性和数据流等内容,帮助开发者更好地理解和实施SAP Fiori解决...

    SAP Fiori 2.0 产品介绍

    在**第一页**中,我们可以看到SAP对设计思维的理解和应用,即通过将人类价值(易用性、期望值)、商业价值(可行性)和技术可能性(可用性)三者结合来推动创新。 **设计思维**是一种以用户为中心的创新方法论,...

    SAP fiori 简易开发流程

    SAP fiori的简易开发过程指南,从开发者角度出发,分后面ODATA开发环境和前端SAP UI5环境搭建,以及发布进行了讲解

    SAP Fiori(SAPUI5)简介

    此外,SAP Fiori还支持SAP Web Dynpro,这是一个基于Web的应用开发技术平台,让上手SAP技术变得更加容易,而且Web Dynpro提供了一个丰富的数据交互能力。 总结来说,SAP Fiori结合SAPUI5框架为用户提供了全新的体验...

    SAP FIORI OVERVIEW

    SAP Fiori是一种创新的用户界面(UI)设计和交付...综上所述,SAP Fiori是企业IT领域的一个重要里程碑,它通过重新定义用户界面,使得企业应用程序变得更加用户友好,无论是在功能上还是在用户体验上都实现了质的飞跃。

    SAP Fiori配置全流程详解:从管理员账号创建到权限与服务激活

    使用场景及目标:主要用于新建立SAP Fiori应用程序环境时的基础设置,旨在让管理员掌握所有必要的配置技能来快速部署可用的企业应用门户解决方案。 阅读建议:在理解和实施本指南的过程中,应特别注意每个配置环节...

    Building SAP Fiori-like UIs with SAPUI5 in 10 Exercises

    SAPUI5适合用于开发SAP Fiori风格的用户界面,Fiori是SAP提出的一个用户体验设计准则,旨在为所有SAP软件产品提供统一、简洁且易于使用的界面。 本教程文档介绍了如何使用SAPUI5构建类似SAP Fiori的应用程序UI,并...

    SAP Fiori Elements Development UX 403

    同时,本课程还将为参与者提供一个宝贵的机会,了解 SAP Fiori 元素开发的最新趋势和发展方向。 SAP Fiori Elements Development UX 403 是一门非常实用的课程,旨在帮助开发人员快速掌握 SAP Fiori 元素开发的技能...

    SAP Fiori overview

    该文档提供了 SAP Fiori 用户体验在2015年3月时的一个概览,重点介绍了 SAP 如何通过设计简化世界,并将其消费者用户体验标准引入企业级应用中。 ### 关键知识点详解 #### 1. 消费者级别的用户体验成为新标准 ...

    SAP-Fiori-快速指南

    SAP Fiori 的诞生源于 SAP 对用户界面的深度研究,发现大多数用户使用 SAP GUI 访问应用程序,但界面复杂。因此,SAP 决定优化最常用的应用,创建了 SAP Fiori,以提供更简洁、更人性化的用户体验。 通过 SAP Fiori...

    SAPUI5(SAP Fiori)运行环境介绍

    SAP Fiori Launchpad是SAP Fiori用户界面的启动平台,它为最终用户提供一个个性化、角色基础的入口,可以访问各种SAPUI5应用。Fiori Launchpad可以基于SAP Netweaver、SCP等环境部署。 7. SAPUI5版本 SAPUI5的版本...

    提高开发SAPFiori应用程序的工作效率.zip

    8. **SAP HANA Cloud Platform (HCP)**:HCP提供了一个云环境,支持Fiori应用的快速部署和扩展。了解如何在HCP上设置和管理服务,可以加速应用的上线和更新。 9. **SAP Fiori 应用生命周期管理 (ALM)**:包括版本...

Global site tag (gtag.js) - Google Analytics