1、创建底表
2、创建接口视图
@AbapCatalog.sqlViewName: 'ZDPM_IMODULE'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'ZDPM_I_MODULE'
define view ZDPM_I_MODULE
as select from zdpm_module
{
key modul as Modul,
parent_modul as ParentModul,
dirsel as Dirsel
}
3、创建消费视图
@AbapCatalog.sqlViewName: 'ZDPM_CMODULE'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: '模块主数据消费视图'
@Search.searchable : true
@UI:
{
headerInfo:
{
typeName: 'Module',
typeNamePlural: 'Entry',
title: { type: #STANDARD, value: 'Module' }
}
}
//@OData.publish: true
define root view ZDPM_C_MODULE
as select from ZDPM_I_MODULE
{
@UI.facet: [
{
id: 'Module',
purpose: #STANDARD,
type: #IDENTIFICATION_REFERENCE,
label: 'Detail',
position: 10 } ]
@Search.defaultSearchElement: true
@UI: {
lineItem: [ { position: 10, importance: #HIGH } ],
identification:[ { position: 10 , label: 'Modul' } ] }
@Search.fuzzinessThreshold: 0.8
@UI.selectionField.position: 10
@Consumption.valueHelpDefinition:[{ entity:{ name: 'ZDPM_I_MODULE',element: 'Modul' } }]
key Modul,
@UI: {
lineItem: [ { position: 20, importance: #HIGH } ],
identification:[ { position: 20 , label: 'ParentModul' } ] }
ParentModul,
@UI: {
lineItem: [ { position: 30, importance: #HIGH , label: 'General marking' } ],
identification:[ { position: 30 , label: 'General marking'} ] }
Dirsel
}
4、创建behavior Definitions
unmanaged implementation in class zbp_dpm_c_module unique;
define behavior for ZDPM_C_MODULE alias module
//late numbering
//lock master
//authorization master
//etag
{
create;
update;
delete;
}
5、在ADT中创建和实现第4步中的zbp_dpm_c_module类
具体代码实现请写在Local Types中
class zbp_dpm_c_module definition
public abstract final for behavior of zdpm_c_module.
public section.
protected section.
private section.
endclass.
class zbp_dpm_c_module implementation.
endclass.
*"* use this source file for the definition and implementation of
*"* local helper classes, interface definitions and type
*"* declarations
*"* use this source file for the definition and implementation of
*"* local helper classes, interface definitions and type
*"* declarations
class lcl_buffer definition.
* 1) define the data buffer
public section.
types: begin of ty_buffer.
include type zdpm_module as data.
types: flag type c length 1,
end of ty_buffer.
types tt_module type sorted table of ty_buffer with unique key modul.
class-data mt_buffer type tt_module.
endclass.
class lcl_handler definition final inheriting from cl_abap_behavior_handler.
private section.
methods modify for behavior importing
roots_to_create for create module
roots_to_update for update module
roots_to_delete for delete module.
methods read for behavior
importing it_booking_key for read module result et_booking.
endclass.
class lcl_handler implementation.
method modify.
" %cid = control field
loop at roots_to_delete into data(ls_delete).
if ls_delete-modul is initial.
ls_delete-modul = mapped-module[ %cid = ls_delete-%cid_ref ]-modul.
endif.
read table lcl_buffer=>mt_buffer with key modul = ls_delete-modul assigning field-symbol().
if sy-subrc = 0.
if -flag = 'C'.
delete table lcl_buffer=>mt_buffer with table key modul = ls_delete-modul.
else.
-flag = 'D'.
endif.
else.
insert value #( flag = 'D' modul = ls_delete-modul ) into table lcl_buffer=>mt_buffer.
endif.
endloop.
loop at roots_to_create into data(ls_create).
ls_create-%data-modul = ls_create-Modul.
* data(item_msg) = new_message( id = '00' " id = Name Of message class
* number = '001' "number of message defined in the message class
* severity = cl_abap_behv=>ms-error "type of message
* v1 = ls_create-%data-booking "First Parameter
* v2 = '' "Second Parameter
* v3 = '' "Third Parameter
* v4 = '' "Fourth Parameter
* ).
* append value #( %cid = ls_create-%cid " %cid = "Content ID" in ABAP Behavior
* booking = ls_create-%data-Booking
* %msg = item_msg
* ) to reported-booking.
get time stamp field data(zv_tsl).
ls_create-%data-ParentModul = ls_create-ParentModul.
ls_create-%data-Dirsel = ls_create-Dirsel.
insert value #( flag = 'C'
data-modul = ls_create-%data-Modul
data-parent_modul = ls_create-%data-ParentModul
data-Dirsel = ls_create-%data-Dirsel
) into table lcl_buffer=>mt_buffer.
if ls_create-%cid is not initial.
insert value #( %cid = ls_create-%cid modul = ls_create-modul ) into table mapped-module.
endif.
endloop.
" handle update
* if roots_to_update is not initial.
* loop at roots_to_update into data(ls_update).
* if ls_update-booking is initial.
* ls_update-booking = mapped-booking[ %cid = ls_update-%cid_ref ]-booking.
* endif.
*
* read table lcl_buffer=>mt_buffer with key booking = ls_update-booking assigning .
* if sy-subrc <> 0.
*
* select single * from ztbooking_001 where booking = @ls_update-booking into @data(ls_db).
* insert value #( flag = 'U' data = ls_db ) into table lcl_buffer=>mt_buffer assigning .
* endif.
*
* if ls_update-%control-customername is not initial..
* -customername = ls_update-customername.
* endif.
* if ls_update-%control-cost is not initial..
* -cost = ls_update-cost.
* endif.
* if ls_update-%control-dateoftravel is not initial..
* -dateoftravel = ls_update-dateoftravel .
* endif.
* if ls_update-%control-currencycode is not initial..
* -currencycode = ls_update-currencycode.
* endif.
* get time stamp field data(zv_tsl2).
* -lastchangedat = zv_tsl2.
* endloop.
* endif.
endmethod.
method read.
* loop at it_booking_key into data(ls_booking_key).
* " check if it is in buffer (and not deleted).
* read table lcl_buffer=>mt_buffer with key booking = ls_booking_key-booking into data(ls_booking).
* if sy-subrc = 0 and ls_booking-flag <> 'U'.
* insert corresponding #( ls_booking-data ) into table et_booking.
* else.
* select single * from ztbooking_001 where booking = @ls_booking_key-booking into @data(ls_db).
* if sy-subrc = 0.
* insert corresponding #( ls_db ) into table et_booking.
* else.
* insert value #( booking = ls_booking_key-booking ) into table failed-booking.
* endif.
* endif.
* endloop.
endmethod.
* method lock.
* "provide the appropriate lock handling if required
* endmethod.
endclass.
class lcl_saver definition inheriting from cl_abap_behavior_saver.
protected section.
methods finalize redefinition.
methods check_before_save redefinition.
methods save redefinition.
endclass.
class lcl_saver implementation.
method save.
data lt_data type standard table of zdpm_module.
lt_data = value #( for row in lcl_buffer=>mt_buffer where ( flag = 'C' ) ( row-data ) ).
if lt_data is not initial.
insert zdpm_module from table @lt_data.
endif.
lt_data = value #( for row in lcl_buffer=>mt_buffer where ( flag = 'U' ) ( row-data ) ).
if lt_data is not initial.
update zdpm_module from table @lt_data.
endif.
lt_data = value #( for row in lcl_buffer=>mt_buffer where ( flag = 'D' ) ( row-data ) ).
if lt_data is not initial.
delete zdpm_module from table @lt_data.
endif.
endmethod.
method finalize.
endmethod.
method check_before_save.
endmethod.
endclass.
6、创建Service Definition
@EndUserText.label: 'Service Definition for Module'
define service ZDPM_S_MODULE {
expose ZDPM_C_MODULE as MODULE;
expose ZDPM_I_MODULE as value_help_module;
}
7、创建Service Binding
8、预览
9、使用webide消费第6步的Service Definition
关于webide与sap op的连接
webide的文件路径(我自己的):E:\eclipse\config_master\service.destinations\destinations\S4D
将以下代码添加txt修改保存为无后缀的文件。文件名称与Description请保持一致
#
Description=S4D
Type=HTTP
Authentication=BasicAuthentication
WebIDEUsage=odata_abap,dev_abap,ui5_execute_abap
Name=S4D
WebIDEEnabled=true
CloudConnectorLocationId=lieh
URL=http://XXXXXXXXXX:8000
ProxyType=Internet
sap-client=XXX
WebIDESystem=S4D
User=XXXX
Password=XXXX
10、登录webide
新建项目
11、发布
选择发布新的或者更新版本
选择开发包 等待发布即可
12、发布结果
13、制作role
将五个对象添加到从标准SAP_UI2_ADMIN_700复制出来的角色中
14、发布磁贴
创建语义对象 Tcode:/UI2/SEMOBJ
创建Catalogs Tcode:/UI2/FLPD_CUST
创建Target Mapping
图中红框ID去找BSP应用的id:moduletest
创建Tiles磁贴
15、创建自定义role并分配用户
16、/UI2/FLP
使用App Finder
以上