Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Backgroud debugging?

Former Member
0 Likes
1,880

Hello Experts,

Can anybody tell me how to do the debugging in the backgroud job or the program is running in the back ground?

Thanks,

Amit

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,277

Hi,

Go to tcode sm50 and find your job and then follow the navigation : program/Session -> program -> debuging . Actually there are three poptions of doing that as per this SAP note : 573128

I am copying the same here :

<b>

Symptom

How can you debug a program that runs in the background?

Other terms

Background, job

Reason and Prerequisites

Information on troubleshooting

Solution

There are 3 options:

1. In SM37, select a job that has not yet been started (status 'planned' or 'released'). In addition, set a breakpoint at the point in the source code that you want to analyze when debugging. In SM37, enter JDBG in the OK code field, and select ENTER. The selected job is now started in debug mode, and the debugger initially stops in a system program. Select F8 to continue the job up to the next breakpoint.

Caution: After debugging, the job still appears in SM37 as 'planned' or 'released', but the entire job (or, more specifically, a copy of it) ran during debugging, and possible database changes are effective as a result of the job.

2. You can catch a current batch job by using SM37 (Catch active job) or SM50 (Debug program). To do this, you must be logged on to the instance on which the job is running. The job is then stopped, and you can keep it running in the debugger.

3. Use SM36 to create a job with two steps, step 1 with the BTCLOOP report and step 2 with the report to be debugged. Then release the job.

You can then debug the job in Transaction SM50. To do this, exit the endless loop in the BTCLOOP report by changing the variable i.

</b>

Thanks to all the members of SDN who helped me when I had the same problem .

Also Amit try to search in this forum before you post a new topic, because many quoestions were already addressed by many experts . Just a small suggestion .

Regards,

Varun .

Message was edited by: varun sonu

3 REPLIES 3
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,277

Yep, if you have control over this program, meaning that it is custom and you can modify it. You can put a endless loop in it before the code that you want to debug.

While sy-subrc = 0.
check sy-subrc = 0. 
endwhile.

then run your program in background. go to SM50, select the back ground process that you program is currently running in. From the menu, choose Program/Session, Program, Debugging. You will see that the debugger will fire and your program will be stuck in the endless loop. Just change the value of sy-subrc to 1 and step thru the code, it will come out of the loop and you can continue debugging.

Regards,

Rich Heilman

PS.

Put yourself on the SDN world map (http://sdn.idizaai.be/sdn_world/sdn_world.html) and earn 25 points.

Spread the wor(l)d!

Read only

Former Member
0 Likes
1,277

Hi Amit,

After running program in background, go to 'SM50' txn and select checkbox against your background job where Type will be 'BGD' and with your user id, go to Program/Mode -> Program -> debugging.

Cheers,

Vikram

Pls reward for helpful replies!!

Read only

Former Member
0 Likes
1,278

Hi,

Go to tcode sm50 and find your job and then follow the navigation : program/Session -> program -> debuging . Actually there are three poptions of doing that as per this SAP note : 573128

I am copying the same here :

<b>

Symptom

How can you debug a program that runs in the background?

Other terms

Background, job

Reason and Prerequisites

Information on troubleshooting

Solution

There are 3 options:

1. In SM37, select a job that has not yet been started (status 'planned' or 'released'). In addition, set a breakpoint at the point in the source code that you want to analyze when debugging. In SM37, enter JDBG in the OK code field, and select ENTER. The selected job is now started in debug mode, and the debugger initially stops in a system program. Select F8 to continue the job up to the next breakpoint.

Caution: After debugging, the job still appears in SM37 as 'planned' or 'released', but the entire job (or, more specifically, a copy of it) ran during debugging, and possible database changes are effective as a result of the job.

2. You can catch a current batch job by using SM37 (Catch active job) or SM50 (Debug program). To do this, you must be logged on to the instance on which the job is running. The job is then stopped, and you can keep it running in the debugger.

3. Use SM36 to create a job with two steps, step 1 with the BTCLOOP report and step 2 with the report to be debugged. Then release the job.

You can then debug the job in Transaction SM50. To do this, exit the endless loop in the BTCLOOP report by changing the variable i.

</b>

Thanks to all the members of SDN who helped me when I had the same problem .

Also Amit try to search in this forum before you post a new topic, because many quoestions were already addressed by many experts . Just a small suggestion .

Regards,

Varun .

Message was edited by: varun sonu