14.01.2020 Views

ABAP_to_the_Future

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

15

ABAP Programming for SAP HANA

HANA, like CDS views. You can create a CDS view in SAP HANA alone, but in this

example you’re going to create one from the ABAP environment.

Say that you want to create a view in SE11 to get all the details of monsters who

own certain pets. The first thing you woul d do is to create a database view in

SE11 and then choose what tables to join—for example, connect the monster

items to the main monster table (which the system achieves by comparing foreign

key relationships and thus doing a join on MONSTER_NUMBER) and then make a big

list of fields from one or more of the linked database tables. Next, you might add

some hard-coded selection criteria (e.g., you’re only interested in green monsters

or monsters with sanity less than 10%).

However, if you wanted to do an outer join between the monster table and the

monster pets table and also on MONSTER_NUMBER to get the details of what pets, if

any, the monster owns , then you’d be out of luck. You can’t do outer joins in an

SE11 database view. You have to create th e view linking the fi rst two tables, and

then do the outer join in your program via a SELECT statement between the newly

created view and the monster per table. View creation in SE11 works well, but like

all form-based development in ABAP, it’s somewhat clunky and involves clicking a

lot of buttons, choosing options on pop-up screens, and moving from tab to tab.

Luckily, thanks to SAP HANA, there is now a new ABAP repository object that

you can create that not only is less clun ky but also gives you more options. The

name of the ABAP repository object is DDL (Data Definition Language), and it

looks like a tiny program consisting of one complicated SELECT statement. When

the DDL object is generated in the ABAP system, an equivalent view is generated

within SAP HANA, called a CDS view. (The cut-down version of a CDS view can

be seen in SE11 but not changed.) What’s even better is that this technique works

with any database, not just SAP HANA.

To recap, instead of the form-based approach of view creation using SE11, you’re

specifying everything using code.

The steps in building and calling a CDS view can be broken down as follows:

1. Creating a DDL in Eclipse.

2. Coding the DDL.

3. Generating the CDS view in the database from the DDL.

Each step is discussed in more detail next.

660

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!