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.

1

ABAP in Eclipse

Double-click the one you want, and—bi

changing things to your heart’s content.

ngo—it opens up, and you can start

1.2.3 Creating a Method from the Calling Code

ABAP Objects was introduced with release 4.6C of SAP, and ever since that point

SAP has been pushing developers to use it. Even now, there is a lot of resistance.

If SAP wants programmers to switch to object-oriented (OO) programming, then

OO programming has to be just as easy as or easier than the procedural programming

that programmers have been used to.

Sadly, even after all these years, in your SE80 environment there is one thing you

can do with procedural programming that you cannot do with OO programming

using local methods: FORM routines. For example, consider the sample procedural

code in Listing 1.2, which calls a FORM routine.

PERFORM create_monster USING ld_number_of_heads

CHANGING ld_monster_number.

Listing 1.2 FORM Routine

If there were no such FORM routine, then when you double-click CREATE_MONSTER

the system would ask you if you wanted to create that missing FORM routine.

Then, it would create it for you, along with the signature (though you would have

to manually code the TYPES of the signature parameters).

Now, consider the object-oriented code calling a method in Listing 1.3.

ld_monster_number = lo_laboratory->create_monster( ld_number_of_heads).

Listing 1.3 Method

You may expect that, if there were no such method, then the exact same thing

would happen, and a skeleton method im plementation and definition would be

created for you when you double-clicked the CREATE_MONSTER method. You

would, unfortunately, be wrong.

People have moaned and groaned about th at on the Internet for 14 years to no

avail. What happens when you try the same thing in ABAP in Eclipse? First of all,

write a small program (Listing 1.4).

CLASS lcl_laboratory DEFINITION.

PUBLIC SECTION.

50

www.allitebooks.com

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

Saved successfully!

Ooh no, something went wrong!