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.

Coding the SCRIPT Method 5.2

5.2 Coding the SCRIPT Method

An unknown person once said: “Don’t anthropomorphize computers; they hate

it.” Nonetheless, in this case you’ll need to think about how you can tell the computer

to behave as you would when debugging.

To start, think about how yo u yourself debug something. First, you keep going

through the program until you find something you are interested in. To do that,

you take a look at the screen. Your debugger script can’t do that, so it needs a way

to access the variables in the running program so that it can analyze their values.

Next, you may change a variable or va lue, step forward through the program

being debugged a line at a time looking for something else, or decide you’re in

the wrong place and press (F8) to move on to the next breakpoint or watchpoint.

Your debugger script needs a way to do al l of these things. To start, navigate to

the SCRIPT method implementation in your debugger script program. There is

already one line of code waiting for you (Listing 5.1).

*** insert your script code here

me->break( ).

Listing 5.1 Generic Command

That is just a generic command to stop the debugger. You’ll usually want to get rid

of that line and replace it with something more suited to the purpose at hand,

whatever it may be. (If you do want to stop the debugger after your script has

run—which you will find is not usually the case—then you can leave that line at

the end.)

At the top of the ABAP Editor section of the debugger Script tab, you’ll see four

buttons. Three of them just do what you would expect in an ABAP editor: a syntax

check, a “pretty print,” and a pattern insert. However, there’s an extra button

specific to debugger scripting: it’s called Script Wizard (though it has a multiple

personality disorder; when you hover your cursor over it, you see Script Services).

The important thing is that this button has a picture of a magic wand on it.

That has to be good.

The Script Wizard is a wonderful wizard , if ever a wizard there was, because,

because, because, because it serves as a bridge between the program being

debugged and the program that controls the debugger. Wh en you choose an

option from the Script Wizard, some code is inserted into your debugger script

209

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

Saved successfully!

Ooh no, something went wrong!