14.01.2020 Views

ABAP_to_the_Future

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2

New Language Features in ABAP 7.4

INTO CORRESPONDING FIELDS OF ls_delivery_header

WHERE vbeln = ld_delivery_number.

Listing 2.20 Removing Leading Zeroes via a Formatting Option

When using the method shown in Listing 2.20, you no longer have to add the

leading zeroes back—as they were never actually removed from the delivery variable

in the first place.

2.4 Calling Functions

Often, you have to jump through hoops to play around with the variables in your

programs before you can call other meth ods or functions. Luckily for you, this

only gets easier over time. This section will discuss the new ABAP functionalities

that make calling functions much easier than it has been in the past.

2.4.1 Method Chaining

7.02 Feature

This feature came about with ABAP 7.02, but is discussed here because it’s little known.

All through this chapter, you have been reading about getting rid of data declarations.

Now, you’ll turn to the case in which you have dozens of helper variables,

all storing intermediate steps, and you stor e the result of one method call for a

short time solely for the purpose of passing that value into another method call.

In traditional programming terms, such variables are called “tramp data,” because

they are only there to pass on values from one place to another, as in the song

“that’s why the data is a tramp.”

With the advent of release 7.02, a new concept called method chaining was born,

whereby you can directly pass the result of one method into the input parameter

of another method without the need for a helper variable. Normally, you would

declare a helper variable, fill it with th e result of a method call, and pass that

helper variable into another method, as in Listing 2.21.

CATCH zcx_excel INTO lo_exception.

ld_helper = lo_exception->get_text( ).

zcl_bc_screen_message=>output( ld_helper ).

Listing 2.21 Helper Variable

98

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

Saved successfully!

Ooh no, something went wrong!