back ground job abap

38
scheduling background jobs By Rahul Tyagi Objective: Scheduling a background job in SAP R/3. These document intents to provide steps which can be done even by an end user to prepare a Job. Main Steps: 1. Change screen layout of stock report as per the requirement. 2. Create variant to run the stock report (MB52) via Job. 3. Access transaction code SM36 to create the Job. 4. Monitor the Job and check the spool 5. Access SAP Business Work place to check the Spool. Step1: Create Screen layout

Upload: suryaredi123

Post on 06-Dec-2015

21 views

Category:

Documents


3 download

DESCRIPTION

sap back ground jobs

TRANSCRIPT

Page 1: Back Ground Job abap

scheduling background jobs

By Rahul Tyagi

Objective: Scheduling a background job in SAP R/3. These document intents to provide steps which can be done even by an end user to prepare a Job.  

Main Steps:  

1.     Change screen layout of stock report as per the requirement.

2.     Create variant to run the stock report (MB52) via Job.

3.     Access transaction code SM36 to create the Job.

4.     Monitor the Job and check the spool

5.     Access SAP Business Work place to check the Spool.  

Step1: Create Screen layout

Assumption: Go to transaction MB52 and enter the value of the Plant (let’s say 1000).   

Page 2: Back Ground Job abap
Page 3: Back Ground Job abap

 

Step : Create Variant along with the layout which we have created in previous step.

Press F4 on the layout field in initial screen and then press save.  

Page 4: Back Ground Job abap

After selecting the layout here please click on save.  

Step: Please mention the variant name as per your choice and also mention the description.

You may also mark the check box protect variant for the field plant and layout though its not mandatory.

To continue...click here

Scheduling background jobs

...Previous

Page 5: Back Ground Job abap

 Save  

Step: Finding the program name for transaction code MB52  

Page 6: Back Ground Job abap

 

Now please notice the Program name RM07MLBS.  

Page 7: Back Ground Job abap

Step: Log in transaction code SM36.

Mention the Job name as ZDaliystk_MB52_1000.  

Page 8: Back Ground Job abap

Press enter to get the below screen  

Page 9: Back Ground Job abap

cheduling background jobs

...Previous    

Click on the ABAP program and mention the program and also select the variant name which was created in initial steps.  

Page 10: Back Ground Job abap

 

Page 11: Back Ground Job abap

  

Click on check and save  

Step : Now click on the start condition button.

In this step we are giving the frequency of running the job. As already mentioned the Job needs to run daily basis.  

Page 12: Back Ground Job abap

click on the period values button  and also mark the period check box as the job has to run every day.  

Page 13: Back Ground Job abap

Click on the spool recipient button  

Page 14: Back Ground Job abap

Just press enter and save to get the message that job is in release status  

Monitor and check the output of job. Access transaction code SM37.

Page 15: Back Ground Job abap

Also mention the Job name  

  

execute and check the spool.  

click on the type  

Page 16: Back Ground Job abap

Step: Here we are with the results which is list of stock in our case

By Joyjit Ghosh, IBM India

Go to the transaction SM37 and select the background job (with job status ‘Active’) that you want to debug. 

Page 17: Back Ground Job abap

 

 

Now select ‘Capture: active job’ from menu ‘Job’, 

 

This will open the selected active job (program) in the debugger.

Page 18: Back Ground Job abap

 

Also you can do the same from transaction SM50.

 

Select the work process where this job is running and then choose the menu path Program/ModeProgramDebugging.

 

It will display a pop up window for confirmation, click on the ‘Yes’ button.

Page 19: Back Ground Job abap

 

Then you can see the job (program) in the debugger.

Debugging Background Scheduled Jobs

ABAPers some times find themselves struggling to get the background scheduled jobs in debugging mode

specially in the case where the jobs have different Job Status.

Page 20: Back Ground Job abap

Following steps helps you for Debugging Background Scheduled Jobs with different statuses:

1. Background jobs with Scheduled or Released Status:

After scheduling the program to run in background, select the job in SM37 and type jdbg in the command

area. It will take you to debugging mode for the corresponding job.

2. Background jobs with Active Status:

Goto SM50 to get the list of processes. Identify the process related to the program. Goto menu

optionProgram/Mode->Program->Debugging.

During the integrated tests, sometimes we need to debug a RFC that has been called from ASP.NET, just

because the bug we are facing does not happens at SE37.

So, everytime we needed to debug the RFC, we have to insert code something like following:

IF <<CONDITION>>. WHILE 1 EQ 1. BREAK-POINT. ENDWHILE. ENDIF.

By doing so, the program may get stuck. Then we have to go to SM50 and debug it.

Following are the easy alternate steps for RFC debugging:

Get the username that makes the RFC call into SAP in ASP

Fire up SE37, go to the code section of your RFC

Look at the menu on top, click on ‘Utilities’

Page 21: Back Ground Job abap

Click on Settings

Go for the Debugging tab

Fill in the username that will make the call from ASP

Click IP Matching ( otherwise a debug session appears for every time any user makes the call )

Session breakpoint active immediately is nice to click as well

Put your external breakpoint where you need it ( click the icon with the stop sign and the little man )

Test your ASP connector

The breakpoint should come into effect , a debug window will pop up

You might not have the authorization to do this, if it doesnt work, use SU53 to find out what you’re

missing.

This should work.

You might also be interested in these posts:

******************************************************************************

*******How to Kill an ABAP Developer???

Simple Go and Remove F6, F7 keys from his/her keyboard and He will suffer the most painful death.

(**we used to crack this joke in our ABAP Training)

Page 22: Back Ground Job abap

After my 3 weeks of ABAP training it was my first day in office .My so called Guruji came to my desk and

gave me a standard function module and told me that this function module is called from the APO system

you need to debug it.

I did not even know how to debug a normal function module and this guy wants me to debug the RFC

enabled function module!!!!!

So This Article is dedicated to All my friends who is facing the issue with typical Debugging J.This article

covers RFC, portal, update task and background job debugging.

Debugging a Remote enabled Function module application.

Suppose you want to debug a function module which is there in APO system from the R/3.

(FYI: As you all know this RFC Destination is maintained via transaction code SM59 )

So here you can see the R/3 Program which is calling the APO Function module Z_TEST_CONNECTION_R3.

As you can see in the below image, keep the external break-point in your program before it calls the RFC

enabled Function module.

Now login into the APO system where you’re remote enabled function module exist and put an external

break-point.

Page 23: Back Ground Job abap

Now go to Transaction code: SRDEBUG and click on the Activate Debugging Button:

It will give you a pop up which confirm your id, application server etc…. click enter which will give you

another popup as shown in the below image. Keep it as it is.

Now go to your Report program in R/3 system and Execute it , it will open debugger , when you press F5 key

to go inside the RFC Function module it  will start debugging in APO system.

How to debug a portal application

Assume that there is a Java based application which is using HTML/JSP as its user interface and intern it uses

the Java code to call the ABAP RFC enabled function module. So when user click on the submit or search

option it fetches or update the data inside the ABAP system.

Page 24: Back Ground Job abap

As compare to RFC Debugging from R/3 to APO here it’s somewhat tricky as here the user is not same, As

Portal application and ABAP will not see the same user id.(***It depends but mostly it will not be same)

You need to consult with portal designer and needs to set your user id as the default user when you submit

the FORM in portal. Once both the JAVA and ABAP system uses the same user id you just needs to put the

external break point in your ABAP System it will stops when this RFC is called.

How to debug the background job

There are two ways to debug the background job

Option: 1. Open the running job in SM37 and select it . Enter “JDBG” in the command line and click enter. It

will start the abap debugger.

Option: 2. Go to Transaction code SM50. Select your job which you want to debug as shown in the below

image.

Page 25: Back Ground Job abap

It will give you a popup for asking whether you want to debug the program or not and in few seconds it will

open the debugger screen .

How to Debug an Update Function Module:

As you know update function module is called when a commit work is happend.To Debug an update function

put a break-point just above the update function module and executes the program. Go to the property of

the debugger (Setting-> Display/change debugger setting) and select the flag “Update Debugging”.

When program encounter a Commit work statement it will start the debugger in new window for the update

function module.

Page 26: Back Ground Job abap

Tips and Tricks related to Debugger.

If you want to jump to a specific line of code just put your cursor on the desired line and click on the

Shift+F12 .It will start the execution of the program/code from that line (Not if you are skipping the

lines ,those peace of code is not executed so that code is as equal as empty lines)

Debug Finished Job.Go to SM37, pointing at the job you want to debug and type JDBG at the command box (where you typed in the Tcode).

Debug Running Job.This is a little bit tricky, it the job finished too fast you wouldn't be able to debug properly. One workaround is to add "WAIT UP TO 30 SECONDS" in your ABAP code at the point where you want to debug. This can buy you some time to do the following:Go to SM66, point at the job you want to debug, press the Debugging button or right click -> debugging.

If in normal debugging it won't stop at the break point even you tick the System Debugging & Update Debugging in Settings -> Change Debugger Profiles/ Settings,You can try the above.

Page 27: Back Ground Job abap

Working with Screen Variants

By Rajeshwar Rao Gadiraju, Yash Technologies

Screen Variants

Screen variants allow you to simplify screen editing by:

Providing default values on the screen fields Hiding and changing the ready for input status of fields

Hiding and changing the attributes of table control columns

A screen variant contains field values and attribute for exactly one screen. A screen variant may be assigned to multiple transaction variants. Screen variants are always cross-client; they may, however, be assigned to a client-specific transaction. They can also be called at runtime by a program. The different possibilities for calling screen variants guarantee great flexibility of use.

Normally when we create sales order, we can change the “ship to party” which comes based on sold to party, now for the demo purpose, we would disable “ship to party” so that the end-user cant make changes to it.

Transaction code: SHD0.  

Enter the transaction code, for which you want the field to be disabled, give a transaction variant name, this transaction variant will be assigned to order type later.

Page 28: Back Ground Job abap

Here in this case transaction code is ‘VA01’.

Click on Create button

Page 29: Back Ground Job abap

Enter the order type and press enter.

Page 30: Back Ground Job abap

If you want to hide a field in sales order, then in this screen you can make necessary changes, according to our scenario we are just going to make changes only to ship to party so do not make any changes in the screen, Click on enter

Click on enter

Page 31: Back Ground Job abap

Click on enter until you get the below screen where you are going to make modifications to ship to party field

Check the ship to party checkbox in output only (means display purpose) as shown below.  

Page 32: Back Ground Job abap

Working with Screen Variants

...Previous

After checking the checkbox, just click on EXIT and SAVE button shown in the below screen shot.

Enter the short description

Click on save

Page 33: Back Ground Job abap

Assign it to a package.

Assign it to a transport request, and click on enter, you may get the same package and transport request, just click on save and go on until you encounter with the last screen.

Page 34: Back Ground Job abap

Now this is the final screen.

Now go to transaction VOV8.

Page 35: Back Ground Job abap

After selecting the order type, either double click or click on details button, it will take you to the next screen where you have to maintain the variant name.

Page 36: Back Ground Job abap

Now when you try to create a sales order using the same document type then you can see that the ship to party field is in display mode.