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.

Database Access 2.1

Figure 2.1 Microsoft SQL Syntax

Because it provides more options, NativeSQL is more powerful. However, if your

organization ever decides to perform a database migration, then you are in trouble;

you will almost certainly have to rewrite any NativeSQL queries you have

coded. Even though database migrations are not a walk in the park, they do happen

every so often, and in order to avoid such potential extra work you will find

people like me: I have not written one NativeSQL query in the 17 years I have

been programming in ABAP.

The good news is that in release 7.4, SAP has expanded the range of options available

to use within ABAP programs whenyou are running an OpenSQL query. You

may not have STRAIGHT JOINS and SQL_BIG_RESULTS, as in the Microsoft SQL syntax

in Figure 2.1, but there are some new useful things, and the next sections will

take a look at the two most important: CASE statements embedded into SQL queries

and performing calculations inside SQL queries.

CASE Statements Inserted into SQL Queries

One of the new features of ABAP 7.4 is the ability to insert CASE statements into

SQL queries. Listing 2.2 shows an example of this. In this example there is a field

in an internal table called SCARINESS_STRING, and it should be filled with a string

describing how scary the monster is based on the values in the database columns

SANITY and STRENGTH.

83

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

Saved successfully!

Ooh no, something went wrong!