zoukankan      html  css  js  c++  java
  • UI5-技术篇-Expand与Deep 服务测试

    1.SEGW创建服务

    2.创建Data Model

    2.1Entity Types

     ZRICO_USR 设置主键、排序字段、过滤字段

     ZRICO_USRITM设置主键 

    2.2Associations

     创建associations,设置主要实体 ZRICO_USR ,依赖实体ZRICO_USRITM,两者对应关系N:M

    0:0...1 记录可有可无,最多一条记录

    1:1必须存在一条记录

    M:0..n记录可有可无,可有n条记录

    N:1...n至少存在一条记录,可有n条记录

    主表与从表字段关联关系,如上图。

    2.3Navigation Properties

    3.Service Implementation

    4.Runtime Artifacts

    5.类方法重写

     /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY

     1   method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY.
     2 **try.
     3 *CALL METHOD SUPER->/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY
     4 *  EXPORTING
     5 **    iv_entity_name          =
     6 **    iv_entity_set_name      =
     7 **    iv_source_name          =
     8 *    IO_DATA_PROVIDER        =
     9 **    it_key_tab              =
    10 **    it_navigation_path      =
    11 *    IO_EXPAND               =
    12 **    io_tech_request_context =
    13 **  importing
    14 **    er_deep_entity          =
    15 *    .
    16 ** catch /iwbep/cx_mgw_busi_exception .
    17 ** catch /iwbep/cx_mgw_tech_exception .
    18 **endtry.
    19    data:
    20      begin of wa_deep_entity ,
    21      mandt   type zrico_usr-mandt,
    22      usrid   type zrico_usr-usrid,
    23      usrname type zrico_usr-usrname,
    24      usraddr type zrico_usr-usraddr,
    25      headertoitem type standard table of zrico_usritm with default key.
    26    data:end of wa_deep_entity .
    27 
    28    data:
    29      ls_deep_entity like wa_deep_entity,
    30      ls_header      type zrico_usr.
    31    data:
    32      lt_deep_entity like table of wa_deep_entity,
    33      lt_items       type table of zrico_usritm.
    34 
    35    field-symbols:
    36      <fs_item>      like line of lt_items.
    37 
    38    "Get data from front-end
    39    io_data_provider->read_entry_data(
    40       importing
    41          es_data = ls_deep_entity ).
    42 
    43     "Process data received
    44     "Data-action here****************
    45     loop at ls_deep_entity-headertoitem assigning <fs_item>.
    46       <fs_item>-usrte = '456'.
    47     endloop.
    48     "Data-action here****************
    49 
    50     "Returned processed data back to front-end
    51     copy_data_to_ref( exporting is_data = ls_deep_entity changing cr_data = er_deep_entity ).
    52 
    53     clear ls_deep_entity.
    54   endmethod.
    View Code

     /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITYSET

     1   method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITYSET.
     2 **try.
     3 *CALL METHOD SUPER->/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITYSET
     4 **  exporting
     5 **    iv_entity_name           =
     6 **    iv_entity_set_name       =
     7 **    iv_source_name           =
     8 **    it_filter_select_options =
     9 **    it_order                 =
    10 **    is_paging                =
    11 **    it_navigation_path       =
    12 **    it_key_tab               =
    13 **    iv_filter_string         =
    14 **    iv_search_string         =
    15 **    io_expand                =
    16 **    io_tech_request_context  =
    17 **  importing
    18 **    er_entityset             =
    19 **    et_expanded_clauses      =
    20 **    et_expanded_tech_clauses =
    21 **    es_response_context      =
    22 *    .
    23 ** catch /iwbep/cx_mgw_busi_exception .
    24 ** catch /iwbep/cx_mgw_tech_exception .
    25 **endtry.
    26     data:
    27       begin of wa_deep_entity ,
    28       mandt   type zrico_usr-mandt,
    29       usrid   type zrico_usr-usrid,
    30       usrname type zrico_usr-usrname,
    31       usraddr type zrico_usr-usraddr,
    32       headertoitem type standard table of zrico_usritm with default key.
    33     data:end of wa_deep_entity .
    34 
    35     data:
    36       rt_usrid     type range of zrico_usr-usrid.
    37     data:
    38       lt_deep_stru like table of wa_deep_entity.
    39     data:
    40       ls_usr       type zcl_zrico_deep_usr_mpc_ext=>ts_zrico_usr,
    41       ls_usritm    type zcl_zrico_deep_usr_mpc_ext=>ts_zrico_usritm,
    42       ls_filter    type /iwbep/s_mgw_select_option,
    43       ls_option    type /iwbep/s_cod_select_option,
    44       ls_deep_stru like wa_deep_entity,
    45       ls_expand    like line of et_expanded_tech_clauses,
    46       ls_range     like line of rt_usrid.
    47     data:
    48       lv_usrid     type zrico_usr-usrid.
    49 
    50     "过滤条件
    51     loop at it_filter_select_options into ls_filter.
    52       loop at ls_filter-select_options into ls_option.
    53         translate ls_filter-property to upper case.
    54         case ls_filter-property.
    55           when 'USRID'.
    56             lv_usrid = ls_option-low.
    57           when others.
    58         endcase.
    59       endloop.
    60     endloop.
    61 
    62     if lv_usrid is not initial.
    63       ls_range-sign   = 'I'.
    64       ls_range-option = 'EQ'.
    65       ls_range-low    = lv_usrid.
    66       append ls_range to rt_usrid.
    67     endif.
    68 
    69     select *
    70       into corresponding fields of ls_deep_stru
    71       from zrico_usr
    72      where usrid in rt_usrid.
    73       if sy-subrc = 0.
    74         select *
    75           into corresponding fields of table ls_deep_stru-headertoitem
    76           from zrico_usritm
    77          where usrid = ls_deep_stru-usrid.
    78 
    79         append ls_deep_stru to lt_deep_stru.
    80         clear:ls_deep_stru.
    81       endif.
    82     endselect.
    83 
    84     ls_expand = 'HEADERTOITEM'.
    85     append ls_expand to et_expanded_tech_clauses.
    86 
    87     if  iv_entity_set_name = 'ZRICO_USRSet'
    88     and io_expand->compare_to_tech_names( 'HEADERTOITEM') EQ io_expand->gcs_compare_result-match_equals .
    89 
    90       clear:er_entityset.
    91 
    92       copy_data_to_ref(
    93          exporting
    94            is_data = lt_deep_stru
    95          changing
    96            cr_data = er_entityset ).
    97 
    98    endif.
    99   endmethod.
    View Code

    6.服务注册

    7.Postman服务测试

     7.1GET_EXPANDED_ENTITYSET测试

      

     

     

     7.2CREATE_DEEP_ENTITY测试

     

     获取上一步GET到的TOKEN

     

     BODY赋值,如上图。

     

  • 相关阅读:
    SFDC_08(翻页功能)
    SFDC-07(图形)
    SFDC_06(Data Loader)
    SFDC_05(内部类)
    SFDC_03(覆盖率)
    vue项目搭建
    vue语法01
    IDEA 的逆向工程 mybatis generate tool 的使用
    Git: Git: There is no tracking information for the current branch.
    Tomcat 不一定 需要配置环境变量(startup.bat 闪退原因及解决办法)
  • 原文地址:https://www.cnblogs.com/ricoo/p/11271711.html
Copyright © 2011-2022 走看看