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

background

Former Member
0 Likes
1,096

Hi Guys,

i want to create a program wants to run in background ie batch job/ program that is scheduled periodically ? can u give some ideas on it ?

points for sure for good answers

regards

Srini

7 REPLIES 7
Read only

vinod_gunaware2
Active Contributor
0 Likes
1,025

Execute transaction <b>SM36</b>

Click Steps

Click ABAP/4 and type in the program name

Click Save

Finally fill in the Start date

In 4.6x, SAP provide a friendly GUI transaction code <b>SM36WIZ</b> for users to submit jobs in the background.

<b>Schedule Manager</b>

Automate your routinue task with Schedule Manager. It facilitate the definition, scheduling, execution, and review of tasks that are executed on a regular basis, such as period-end closing.

<b>SCMA</b> - Schedule Manager

<b>Checking your program Background Job Status</b>

Checking your job status with <b>SM50</b> (processor type BTC) is more accurate then <b>SM37</b>. SAP updates the tables TBTCO wheneveryour background jobs status change. If SAP is shutdown, the currentjobs might not be update ontime to the table. ( e.g. a background job wasshown as Active (SM37), in fact it real status should be Cancelled.

The type of work process:

DIA - work process for executing dialog steps in user transactions

UPD - update process for executing U1 (time-critical) database changes

UP2 - update process for executing U2 (non-critical) database changes

ENQ - for setting and releasing locks on SAP lock objects

BTC - for executing background jobs

SPO - for spool formatting processes

PID: Process ID of the work process.

<b>Change the variants or SAP Printers of scheduled background jobs</b>

SM37 - At the Job Overview screen, position your cursor at the scheduled jobs you want to changed (the jobs status must still be Released)

Click Job -> Change

Click the Steps button -> here you can move, add or delete addition programs steps to be run

Double click the program name you want to change

Click the Print specifications button if you want to change the SAP printers

regards

vinod

Read only

Former Member
0 Likes
1,025

Hi srini,

1. Any program (se38) program,

having a saved variant,

can be run in background.

2. Its only matter of scheduling this

program to run in background,

using SM36.

regards,

amit m.

Read only

0 Likes
1,025

i dont want using tcode SM36 but i want to write a program using job_open ? can u help me in this regard ?

Read only

0 Likes
1,025

Hi again,

1. sample code.

2. Note (we can either use SUBMIT statement,

or JOB_SUBMIT to submit our program in background.

3.

report abc.

DATA : JN(32) TYPE C.

JN = 'JOB001'.

BREAK-POINT.

DATA : J(8) TYPE C.

*----


CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = JN

  • JOBCLASS =

IMPORTING

JOBCOUNT = J

EXCEPTIONS

CANT_CREATE_JOB = 1

INVALID_JOB_DATA = 2

JOBNAME_MISSING = 3

OTHERS = 4

.

*----


DATA : P TYPE PRI_PARAMS.

P-PDEST = 'PRINTER'.

P-PDEST = 'LOCL'.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING NO_DIALOG = 'X'

MODE = 'CURRENT'

  • NEW_LIST_ID = $PRNEW

IMPORTING OUT_PARAMETERS = P.

*----


submit HINCF160 using selection-set '2102'

VIA JOB JN NUMBER J

AND RETURN

.

*----


CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = J

jobname = JN

STRTIMMED = 'X'

EXCEPTIONS

CANT_START_IMMEDIATE = 1

INVALID_STARTDATE = 2

JOBNAME_MISSING = 3

JOB_CLOSE_FAILED = 4

JOB_NOSTEPS = 5

JOB_NOTEX = 6

LOCK_FAILED = 7

INVALID_TARGET = 8

OTHERS = 9.

*----


BREAK-POINT.

regards,

amit m.

Read only

0 Likes
1,025

hi ,

or use fm K_BATCH_REQUEST

Andreas

Read only

Former Member
0 Likes
1,025

1. Create ZPROGRAM

2. SM36 -> start condition -> Date/Time -> Save

3. Step -> Specify zprogram and variant

4. Save

Read only

Former Member
0 Likes
1,025

Hi,

You need to create two programs say Zreport1 and zreport2. From zreport1, you are passing selection parameters to zreport2.

In ZREPORT1.

Export it_tab

to database db(idx) index indx.

Use FM : JOB_OPEN

Pass Job name & import Jobcount. Jobcount is unique id.

If you want to set print parameters then use FM 'GET_PRINT_PARAMETERS'. If spool size is not important then this FM is not required.

Use FM : JOB_SUBMIT. pass report name as 'ZREPORT2'. This is the program which you want to call in background.

Instead of JOB_SUBMIT, you can also use SUBMIT <report>.

Use FM : JOB_CLOSE.

In ZREPORT2.

Import it_tab

from database db(idx) index indx.

loop at it_tab into wa_tab.

write 😕 wa_tab-matnr.

endloop.

Best regards,

Prashant