0% found this document useful (0 votes)
38 views

CDS Table Function Usage Scenario

table function

Uploaded by

smitha.ms
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

CDS Table Function Usage Scenario

table function

Uploaded by

smitha.ms
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Usage of ABAP CDS table function with Rank

-------------------------------------------------------
Requirement: We need to extract the latest Reference Code for each Customer
based on the latest Reference Date(NOTE: the reference codes are not following the
same order as the reference dates)
Table Structure: (MANDT,CUSTOMER,REFCODE,REFDATE)
When we try with GROUP BY and MAX() in ABAP CDS the output is not correct:
(define view ZCDS_GRP as select from <> { key customer, max(refcode),max(refdate)}
group by customer )

In this scenario we can use the Table Function and RANK()


define table function zcds_rank
returns{
client : abap.clnt;
customer : kunnr;
refcode : abap.char(10),
refdate : abap.dats;
} implemented by method zcl_cds_rank=>exec_method;

class zcl_cds_rank definition public final create public.


public section.
interfaces if_amdp_marker_hdb.
class-methods exec_method for table function zcds_rank.
endclass.

class zcl_cds_rank implementation.


method exec_method by database function for hdb language sqlscript options read-
only using <>.
rank_table = select mandt as client ,customer, refcode,refdate, rank() over
(partition by mandt,customer order by refdate desc) as rank from <>.

return select client,customer,refcode,refdate from :rank_table where rank = 1;


endmethod.
endclasss
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------

Open order requested not goods issued scenario e.g. open order = requested – goods
issued. All calculations are done in CDS view table function using SQL.
Let me walk you thought set base calculations inside the table function.

- Select order requested information on schedule line level


- Calculate order requested quantity totals and running totals for each order
item
- Calculate goods issued quantity on order item level
- Calculate open quantity e.g. open = requested – goods issued
- Calculate open order schedule line value and eliminate order schedule lines
that are not open

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------

Handling of SELECT-OPTIONS parameters within AMDP

The handling of SELECT-OPTIONS parameters in the context of AMDPs requires two


steps:
1) Conversion of the selection tables into an SQL WHERE clause using method
CL_SHDB_SELTAB=>COMBINE_SELTABS( )

Static method COMBINE_SELTABS( ) of the new class CL_SHDB_SELTAB shall be used for
the conversion of SELECT-OPTIONS parameters (selection tables or range tables) into
an SQL WHERE clause when running on HANA DB.
2) Handling of dynamic WHERE clauses within the AMDP method using the function
APPLY_FILTER
Use the SQLScript function APPLY_FILTER to apply the selection criteria to the
selected data in the AMDP

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------

Adding custom fields to SAP Fiori apps in 3 steps. OData fields extensibility.

Implementation steps are in 3 steps.


1. Extend the corresponding ABAP DDIC Structure by Append Structure

a) Goto SE80, open package GBAPP_APV_PO


b) open Structure: GBAPPS_PO_HEADER_DETAILS and GBAPPS_PO_WORKFLOW_TASK
c) using Append Structure add the field ZZEKGRP and activate both structure
2. Extend the OData Entity in the GW Model Provider by implementing BADI -> o
implement a BAdI method which adds “Purchasing Group” property in
the Model Provider class.
d) Goto SE18, Enhancement Spot : GBAPP_APV_PO
e) Create Badi implementaion. Open ~enhance_gw_service_entity_mdp method and
add the logic to fetch PO group from EKKO table
f) Repeat the above step for WorkflowTask as well
3. Fill data to the custom fields in the GW Data Provider by implementing BADI ->
going to implement a BAdI method which fills “Purchasing Group” value in the
Data Provider class.
g)Open SE18, Enhancement Spot: GBAPP_APV_PO
H) Implement the Badi class. Double click the method
CHANGE_HEADER_DETAILS_INFO_API.

You might also like