@AbapCatalog.sqlViewName: 'zcdjptca'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'cds annot test'
@OData.publish: true
define view zjptca
as select from aufk
{
key mandt,
key aufnr,
autyp,
auart,
werks,
objnr,
@ObjectModel.readOnly: true
@ObjectModel.virtualElement
@ObjectModel.virtualElementCalculatedBy: 'ABAP:ZCLJPTTF'
cast('' as co_sttxt) as istatus,
@ObjectModel.readOnly: true
@ObjectModel.virtualElement
@ObjectModel.virtualElementCalculatedBy: 'ABAP:ZCLJPTTF'
cast('' as co_asttx) as estatus
};
class zcljpttf definition
public
final
create public .
public section.
interfaces if_amdp_marker_hdb.
interfaces if_sadl_exit .
interfaces if_sadl_exit_calc_element_read .
protected section.
private section.
types: begin of ty_objnr,
objnr type j_objnr,
end of ty_objnr,
tyt_objnr type standard table of ty_objnr,
begin of ty_status,
objnr type j_objnr,
istatus type char255,
estatus type char255,
end of ty_status,
tyt_status type standard table of ty_status.
class-methods get_statuses
importing value(it_objnr) type tyt_objnr
value(iv_mandt) type sy-mandt
value(iv_langu) type sy-langu
exporting value(et_status) type tyt_status.
endclass.
class zcljpttf implementation.
method get_statuses by database procedure for hdb language sqlscript options read-only using jest jsto tj02t tj02 tj02t tj30 tj30t.
lt_ijest = select jest.objnr, replace(cast(string_agg(txt04, ', ' order by jest.stat desc) as nvarchar(255)),',','') as istatus
from jest
join tj02
on jest.stat = tj02.istat
and substr(jest.stat,1,1) = 'I'
join tj02t
on tj02.istat = tj02t.istat
and tj02t.spras = :iv_langu
where jest.objnr in ( select objnr from :it_objnr )
and inact = ''
and tj02.nodis = ''
group by jest.objnr;
lt_ejest = select jest.objnr, replace(cast(string_agg(txt04, ', ' order by tj30.stonr desc) as nvarchar(255)),',','') as estatus
from jest
join jsto
on jest.mandt = jsto.mandt
and jest.objnr = jsto.objnr
join tj30
on jest.mandt = tj30.mandt
and tj30.stsma = jsto.stsma
and tj30.estat = jest.stat
join tj30t
on jest.mandt = tj30t.mandt
and tj30t.stsma = jsto.stsma
and tj30t.estat = jest.stat
and tj30t.spras = :iv_langu
where jest.objnr in ( select objnr from :it_objnr )
and inact = ''
group by jest.objnr;
et_status = select distinct inp.objnr, istatus, estatus
from :it_objnr inp
left outer join :lt_ijest int
on inp.objnr = int.objnr
left outer join :lt_ejest ext
on inp.objnr = ext.objnr;
endmethod.
method if_sadl_exit_calc_element_read~calculate.
*Called after selection from CDS view is completed and is only called if fields are requested by the frontend
*Call calculation method, this can be a HANA procedure too
me->get_statuses( exporting iv_mandt = sy-mandt iv_langu = sy-langu it_objnr = corresponding #( it_original_data )
importing et_status = data(lt_status) ).
*Pass data back
loop at it_original_data assigning field-symbol(<lfs_row>).
assign ct_calculated_data[ sy-tabix ] to field-symbol(<lfs_nrow>).
assign component 'OBJNR' of structure <lfs_row> to field-symbol(<lfs_objnr>).
if sy-subrc eq 0.
read table lt_status into data(lwa_status) with key objnr = <lfs_objnr>.
if sy-subrc eq 0.
<lfs_nrow> = corresponding #( lwa_status ).
endif.
endif.
endloop.
endmethod.
method if_sadl_exit_calc_element_read~get_calculation_info.
*Which fields are required for the calculation.
append 'OBJNR' to et_requested_orig_elements.
endmethod.
endclass.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
5 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
2 |