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

For example, some options give the script program the values of various variables

in the program being debugged ( Variable Information), system stack information

(ABAP and Screen Stack), or PID values ( Special Information)—basically

anything you could normally see by po king about manually in the debugger

screen. There are also a few options to control stepping through the debugger to

simulate pressing, for example, (F5) or (F8) (Debugger Control). Some options

let you change the values of a variable in the program being debugged ( Change

Variable Value), and let me tell you, it’s a lot easier to append an internal table

row via a program than to fill in all the cells by hand. Finally, some options are

the equivalent of writing down some in formation on a piece of paper on your

desk—for example, ALV output, messages , or writing to the application log

(Script Output [ALV] and Messages). This removes the risk of the useful information

you have written on your piece of paper getting lost when the fixed asset

accountant comes around to complain about your data conversion program not

working and then trips up and spills her drink all over your desk.

Frankly, the options on this screen should make you want to jump up and down

and start screaming at the top of your voi ce, “Look at this; look how good it is!”

But a more reasonable observation would bethat a lot of thought has clearly gone

into this, and it seems like most if not all of the manual steps during debugging

can be replicated in a debugger script program.

Examine this a little closer to see whether it’s true. The manual steps a programmer

takes while debugging can be broken into four stages: look, move, act, and

log.

The purpose of the look stage is to find out the value of one of the variables in the

program being debugged. To accomplish this in the Script Wizard, open it and

navigate to Variable Information 폷 Variable Value. A blank template is

inserted into the debugger script code, as shown in Listing 5.2.

*TRY.

CALL METHOD CL_TPDA_SCRIPT_DATA_DESCR=>GET_SIMPLE_VALUE

EXPORTING

P_VAR_NAME =

RECEIVING

P_VAR_VALUE =

.

* CATCH cx_tpda_varname .

* CATCH cx_tpda_script_no_simple_type .

*ENDTRY.

Listing 5.2 Variable Value

211

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

Saved successfully!

Ooh no, something went wrong!