Monday, April 19, 2010

Debugging ATP with print statements

I sure did my share of debugging using print statements (in basic, pascal, fortran, C, python, etc). But actually with ABAP that was not a common pattern, mainly because the debugger is so convenient and also because it is not so easy to print. But today I found myself debugging with print statement in global ATP programs and it turns out it can be simple using the ATP log. A short recipe bellow.

1) Activate the ATP log



2) Report to write to the bound ATP log object a generic message


report ylog.

form print using m2 m3 m4.
data: l_msgv2 type symsgv,
l_msgv3 type symsgv,
l_msgv4 type symsgv.
l_msgv2 = m2.
l_msgv3 = m3.
l_msgv4 = m4.
if /sapapo/cl_log_atp=>the_log is bound.
call method /sapapo/cl_log_atp=>the_log->add_msg
exporting
im_msgty = 'E'
im_msgid = '/SAPAPO/AMON'
im_msgno = '000'
im_msgv1 = 'DEBUG>>>'
im_msgv2 = l_msgv2
im_msgv3 = l_msgv3
im_msgv4 = l_msgv4
im_probclass = 'X'
im_applclass = 'X'
im_repid = sy-repid.
endif.
endform.


3) This report allows the writing of print-like statements in the code


perform print(ylog) using 'some text' some_variable other_variable.


4) It will show in the ATP log screen that opens in the end of the ATP process



It was a quite effective tool for the job. I think I will use this again.

Labels: ,

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home