CDS VIEW Table Function Using Sort
In CDS VIIEW , This is no possible way to do a sorting for table But , we achieve using OOPS
class object. Sorting helps us to make data align clean and clearly . So using of sorting is
good way in some place.
Example Code:
Part 1.
@[Link] : ’CDS View Sorting’
Define table function zji_tf_sorting
Returns
{
Mandt: mandt;
Ebeln:ebeln;
Ebelp:ebelp;
Matnr:matnr;
Maktx:maktx;
}
Implemented by method zcl_sort=>get_sorting;
Part 2:
Class zcl_sort definition public.
Public section.
Interfaces if_amdp_marker_hdb.
Class-methods get_sorting for table function zji_tf_sorting.
Endclass.
Class zcl_Sort implementation.
Method get_sorting for database function for hdb language sqlscript
Options read-only using ekpo makt.
Return select [Link] , ebeln , ebelp , [Link] , maktx from ekpo
Left outer join makt on [Link] = [Link] order by ebelp desc;
Endmethod.
Order by helps to make the sort option for CDS View
There is another way of making sort option without table Function, Examples on given
below.
Part 1:
@[Link]: ‘zjoins’
@[Link]: ‘TRUE’
@[Link]: #CHECK
@[Link] : ’CDS View Sorting’
Define view zsorting as select from ekpo
{
Key Ebeln,
Max(ebelp) as ebelp;
} group by ebeln
Part 2:
@[Link]: ‘zjoins’
@[Link]: ‘TRUE’
@[Link]: #CHECK
@[Link] : ’Source target’
Define view ztarget as select from zsorting left outer join ekpo on
[Link] = [Link] and [Link] = [Link]
{
Key [Link],
[Link],
Matnr,
maktx
}