0% found this document useful (0 votes)
72 views42 pages

Ds

CDS view can be buffered only if it does not contain views as data sources. The select distinct statement removes duplicate rows from the result set. Table functions can be used to overcome data type mismatches when joining tables, such as joining a RAW column to a character column, by executing the table function instead of the join. This avoids errors due to the data type incompatibility.

Uploaded by

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

Ds

CDS view can be buffered only if it does not contain views as data sources. The select distinct statement removes duplicate rows from the result set. Table functions can be used to overcome data type mismatches when joining tables, such as joining a RAW column to a character column, by executing the table function instead of the join. This avoids errors due to the data type incompatibility.

Uploaded by

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

CDS view can be buffered only if it does not contain any views (database views or CDS

views) as data sources. select distinct { } removes duplicates in result set

... ..... ....


(itab)

............................................ (wa)

............................... (tt structure)

(tt structure)
................................................
Consuming view with Parameters into another View with Parameters

old view is aliased & joined --

Basic View
..........
.........

*
Composite View

....... .....
Instr( ) ==> returns the position of a substring in a string
@AbapCatalog.sqlViewName: 'ZXXXXXX'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Test CDS for substring'
define view ZXXXXXX as select from bkpf as posted{
posted.mandt,
posted.bukrs,
posted.belnr,
posted.gjahr,
xblnr,
substring( xblnr , 1 , instr( posted.xblnr , ' ' ) ) as test -- you can replace it with a input parameter
}
@AbapCatalog.sqlViewName: 'ZXXXXX'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Test CDS viewn'
define view ZXXX_XX_XX with parameters p_test : abap.numc(2) as select from bkpf as posted{
posted.mandt,
posted.bukrs,
posted.belnr,
posted.gjahr,
xblnr,
substring(xblnr , 1, :p_test) as test
}
@EndUserText--> heading label quickInfo
View on View

Association is always left outer join, you can force it to inner join in the following way [inner] always follows dot .
Table Function:

CL_DEMO_AMDP_FUNCTIONS

ENDCLASS.
1

Host and Other Expressions:


A new foundation for Open SQL was laid by introducing a new SQL parser into the ABAP runtime environment

display_data( name = 'xyz '


value = result )

loop at result into data(wa) .


write: / wa-carrid, wa-connid,wa-fldate.
Endloop.

......................

TYPE REF can be avoided by Using keyword DATA


play with join conditions according to requirement

primary key = non pk

in 3 table join, repeating table join column should be different


Next Class

No associations are found as we didn’t expose them

Changing syntax to expose associations


Finally, exposing associations

Adding annotations to above view

If you on NW 7.4 then T-code SEGW


DDIC Structure copy the DDIC view name from CDS

Shitty in NW 7.4, use @odata.publish: true -- but you an expose only 1 service per CDS view
3

Structure & Table Type

Simple AMDP:
4

AMDP II
5
6

ABAP Report
7
8

OLD ABAP

NEW ABAP:
With New SQL ony a line code will replace all the above code
9

To check if the record exists or not

cl_demo_output=>display_data( name = 'show me'


value = lt_result ).
10
11

ABAP coding to refer a table you use~ instead of dot .


We can do concatenation, arithmatic expressions inside the select statement
12

Default Value in ABAP


value '0.9' Parameters name type char(10) VALUE
'Sai'.

-----…………………………
13
14
15

……..
16

String Functions:

Numeric Functions:
17

Current Date in CDS Views:

Casting Parameter to fix her error


18
19
,
,
. Types: tt_po_data type std. table of ity_po_data
, with empty key.
class-

tt_po_data.

dot

..........

ABAP Report.

zcl_sapyard_po_amdp=>get_o_data (
ex .
ip_lifnr = p_matnr
im. ).
ex_po_data = DATA(result)
Types:
20
Begion OF ty_name,
End OF ty_name.

Types:
tt_name TYPE standard table of
ty_name with empty key.

CLASS-METHODS is used to define a static method:

last line has end with a period .

......................

........................
.....

....
21
AMDP - CHEATED
22

You build the Table Type structure after


you define the exporting Value in AMDP

When you getting value from

Outside, you precede with a colon :

You can use the table type structure


here, but for training sake
23

Consuming AMDP in ABAP Program/Report: I will call my AMDP class from the ABAP Program

…..
Showing an inner join for practice in method implementation
24

We need to include above internal table itab_vbap in the structure definition of Class

AMDP’s

-- assigning literal value where vbak.vbeln = '00002455'

................
25

APPLY_FILTER

ENDCLASS
ABAP ReportAMDP Source
Sample AMDP:

- Call AMDP inside AMDP Method : Call “CLASS=>METHOD”

Continued Below:_
-
;

..................

................ ...............
for table funtion

..........

Return ........
......

;
Why you use Table Functions?

- Partner_GUID in CRMD_PARTNER table is RAW 16 data type


- Partner in BUT000 table is char 10 data type
- Joining on these 2 tables in CDS views, would give error
- You cannot do CAST on RAW 16

- This view will fail as data type mismatch on the join columns
- To overcome this issue, we’ll use Table Function

View won’t fail, as the join won’t happen, ‘cuz, we are not exposing the association above:, after adding it below, it throws error
Final view: TABLE FUNCTION TO FIX DATA TYPE MISMATCH:- RAW vs Char10

Activate & Creating class and implementing its method


……………….. :execute the Table Function after defining class and
it's method implementation

The earlier issue with join sc.partner_no = sp.partner_guid works fine and is gone Finally F8 on Table Function to see
the output

You might also like