使用CDS view获得CRM订单的状态值和描述信息

版权声明:本文为博主汪子熙原创文章,未经博主允许不得转载。 https://blog.csdn.net/i042416/article/details/89739526

The final achievement would look like below:
clipboard1
Here below are detail steps

(1) Copy a new CDS view by copying the following source code. This view will return all order’s guid together with their process type and status CODE.

@AbapCatalog.sqlViewName: 'zallstatus'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'all status'
define view Z_C_All_Status as select from crmd_orderadm_h
inner join crm_jest as _jest on crmd_orderadm_h.guid = _jest.objnr and _jest.inact = ''
{
key crmd_orderadm_h.guid,
key _jest.stat,
crmd_orderadm_h.process_type
}

(2) Get the description of system status CODE by creating this CDS view:

@AbapCatalog.sqlViewName: 'zsystatus'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'system status'
define view Zorder_Sys_Status as select from Z_C_All_Status
/_association [0..1] to tj02t as _tj02t on $projection.stat = _tj02t.istat
and tj02t.spras = 'E'/
inner join tj02t as _tj02t on Z_C_All_Status.stat = _tj02t.istat
and _tj02t.spras = 'E'
{
key Z_C_All_Status.guid,
key Z_C_All_Status.stat,
_tj02t.txt04,
_tj02t.txt30
}

(3) Get the description of user status CODE by creating this CDS view:

@AbapCatalog.sqlViewName: 'zusestatus'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'user status'
define view Zorder_use_Status as select from Z_C_All_Status
join crmc_proc_type as _proc_type on Z_C_All_Status.process_type = _proc_type.process_type
inner join tj30t as _tj30t on Z_C_All_Status.stat = _tj30t.estat
and _proc_type.user_stat_proc = _tj30t.stsma
and _tj30t.spras = 'E'
{
key Z_C_All_Status.guid,
key Z_C_All_Status.stat,
_tj30t.txt04,
_tj30t.txt30
}

(4) perform an UNION on view created by step 2 and 3, and that’s done.

@AbapCatalog.sqlViewName: 'zstatustxt'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'status with text'
define view Z_C_All_Status_Txt as select from Zorder_Sys_Status {
key Zorder_Sys_Status.guid,
key Zorder_Sys_Status.stat,
Zorder_Sys_Status.txt04,
Zorder_Sys_Status.txt30
} union select from Zorder_use_Status {
key Zorder_use_Status.guid,
key Zorder_use_Status.stat,
Zorder_use_Status.txt04,
Zorder_use_Status.txt30
}

猜你喜欢

转载自blog.csdn.net/i042416/article/details/89739526