Tips and Tricks in ABAP
for functional
consultants
ABAP for functional Consultants
By Abhishek Ghosh
© 2010 Wipro Ltd - Confidential
Agenda
1 Introduction
2 Advanced ABAP debugging Techniques
3 Changing DB record in debug mode
4 Message debugging / Calling function
5 Case Studies
6 New debugger useful tools
2 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Advanced ABAP Debugging
Techniques
• Debugging a Background Job
• Debugging a Background Task
• Debugging an Update Task
• SAPScript debugging
3 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Advanced ABAP Debugging Techniques
Debugging a Background Job:
Background jobs (processes) can be
debugged using Transactions SM37 and
SM51.
In SM37, the job needs to be selected and
type jdbg to start job debugging.
The job should be in any status
other than ‘Ready’ or ‘Active’.
(For e.g. ‘Scheduled’,
‘Released’, ‘Completed’,
‘Canceled’.
This methodology is adopted
when the transaction can be
executed only in background .
4 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Advanced ABAP Debugging Techniques
– Jobs which are in status ‘Active’ or ‘Ready’ can be debugged by
debugging its corresponding Background process.
Goto SM51 to get the background process
and Click on Program/Mode ->Program-
>Debugging.
5 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Advanced ABAP Debugging Techniques
But special administration authorization is required for debugging an active job.
6 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Advanced ABAP Debugging Techniques
Debugging a background task
– A separate background task is spawned by the ABAP statement
• CALL FUNCTION …. IN BACKGROUND TASK ….
– These Function calls aren’t processed immediately, but in the next
COMMIT WORK statement. Each process has an attached debugger,
which can be utilized to debug the above Function calls.
– To enable background task debugging, we need to enable the option
‘In Background Task: Do not process’ checkbox in the debugger screen.
7 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Advanced ABAP Debugging Techniques
Now the tRFC call can be seen in transaction SM58, with
status
‘Transaction Recorded’.
You can debug this LUW by selecting the option
‘Edit -> Debug LUW’.
This will help us debug a background task.
8 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Advanced ABAP Debugging Techniques
Debugging an update task
– A separate update task is spawned by the ABAP statement
• CALL FUNCTION …. IN UPDATE TASK…
It can be enabled by
selecting the option of
“Update Debugging” in
Debugger screen, else
processing continues in
the update task
separately.
9 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Advanced ABAP Debugging Techniques
This locks the document for updation (as can be seen in
SM12 & SM13) and can’t be canceled.
If document is locked due to system shutdown, it can be
unlocked by deleting the lock entries via SM12 or Selecting
“Repeat Output” via SM13.
SM12 Option doesn’t retrigger the entire steps, while SM13 option does.
10 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Changing DB record in debug mode
There are 4 OK codes based on which
table data can be seen,modified,inserted
and deleted.They are SHOW,EDIT,INSR
and DELE respectively
11 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Changing DB record in debug mode
So if the code is changed from SHOW to DELE. This record can be deleted. But
these operations are possible when the user has got debug rights and change
authorization.
12 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Message debugging / calling function
Now for this transaction if we want to know where the message is coming
from then the following process will have to be followed.
First use the command ‘/h’ in the text bar and press enter. The control will go
to a debug screen where ABAP command has to be provided in the
breakpoint area.
13 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Message debugging / calling function
To get to know where the
message is coming from type in
the statement ‘message’ as
shown in the adjacent figure.
14 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Message debugging / calling function
Breakpoints get set for all the message statements and the control will point to the
place where the message is coming from. Similarly what all function module gets
called within a process can be found out by putting a statement ‘CALL FUNCTION’
But if we know which function module to go to then the statement breakpoint at
function module can be used as shown in the next slide.
15 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Message debugging / calling function
Similarly breakpoint at subroutines, methods (OOABAP), exceptions and source
code can be used along with statements and function modules. To skip authorization
for a statement/FM breakpoints can be set a statement ‘CHECK-AUTHORITY’ and
then change the sy-subrc value from non zero to zero to skip the authorization.
16 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
SAPScript debugging
SAPScript debugging can be done by enabling debugger in SE71 transaction.
Now if you try to do Print/Print Preview, Script Form
Debugger will be activated and we can do script
debugging.
17 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Case studies
Scenario:
While generating the Printout of an invoice, the output type RD00 is failing .
To find out the root cause of the issue, we have enabled the
breakpoint in the processing program . We repeated the output and
saved the Invoice again. But the processing is not stopping at the
breakpoint.
18 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Case studies
Explanation:
Reason is that processing of the output type in this case is done in a
separate update task. So to reach the break-point, we need to enable
update debugging.
Step1: Enable debugging though /h.
Step 2: Save the document and enable update debugging in the
debugger and saving it.
19 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Case studies
Now if you execute by pressing F8, it will come to the
breakpoint , after getting selected by the update task.
20 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Case studies
Scenario2
When cheque printout is generated, it doesn’t print the
amount in figures.
Solution:
Enable debugger in the corresponding
SAPScript and Print program. Upon
reprinting the cheque, SAPScipt debugger
is enabled.
21 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Case studies
After writing the Cheque amount in figures, it was found that the
program was encountering error routine BLOCK_END and triggering
the End-of-window processing.
This was because the window height was maintained as 23 Lines and whenever the cheque amount (in words) is
more than 1 line long, the total no: of lines is exceeded , triggering the End-of-window processing, while trying to print
check amt. in figures.
22 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
New debugger useful tools
Embedded document will provide the details regarding the usable
Tools of new ABAP debugger
Debug
Question and Answer Session
23 ©
© 2010
2009 Wipro
Wipro Ltd
Ltd -- Confidential
Confidential
Thank You
Abhishek Ghosh
SAP ABAP Consultant
[email protected]
m
© 2010 Wipro Ltd - Confidential