天天看点

一步步创建ABAP CDS viewTest

  1. Add AG3 or ER9 in your local SAPGUI.
一步步创建ABAP CDS viewTest
  1. Open your ABAP Studio:
一步步创建ABAP CDS viewTest

Select the system where you will work:

一步步创建ABAP CDS viewTest

Click next:

一步步创建ABAP CDS viewTest

Once done, you can find your new project:

一步步创建ABAP CDS viewTest

Create your own package in SAPGUI:

一步步创建ABAP CDS viewTest

And add it to favourite:

一步步创建ABAP CDS viewTest
一步步创建ABAP CDS viewTest
一步步创建ABAP CDS viewTest

Paste the following source code:

@AbapCatalog.sqlViewName: 'zjerrySQLView'

@AbapCatalog.compiler.compareFilter: true

@AccessControl.authorizationCheck: #CHECK

@EndUserText.label: 'this is description'

define view Zjerrytest20160309(

   id,

   carrier,

   flight,

   departure,

   destination

 )

 as select from spfli

   join         scarr on scarr.carrid = spfli.carrid

{

 key spfli.carrid,

 key scarr.carrname,

 key spfli.connid,

     spfli.cityfrom,

     spfli.cityto

}

Activate your CDS view:

一步步创建ABAP CDS viewTest

Test

一步步创建ABAP CDS viewTest

or

一步步创建ABAP CDS viewTest

Difference between lt_wrong and lt_right is that the former also contains a column with client field, which is not needed in application handling. Always use the approach indicated by lt_right.

Guideline

In the above example, the CDS database view zjerrysqlview serves mainly the internal technical purpose to realize the view in the dictionary. You can, but you should not use it in ABAP programs. Instead, you work with the CDS entity, whose name is defined behind DEFINE VIEW. In the example it is zjerrytest20160309. Only the entity carries the full capabilities of the CDS view, like semantical information, client handling, connection to authority checks (planned), and so on. You can use the CDS entity behind TYPE for declaring work areas and in Open SQL in ABAP programs.