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

Jobcount at runtime

weltspion
Participant
0 Likes
2,022

Hi everybody!

I'd like to determine the jobnumer (TBTCO-JOBCOUNT) of an actually running background job.

In other words: Does an ABAP report know its own jobnumber, when it is running as background job? I need it inside the running report.

Unfortunately the SY structure does not contain it.

Is there another way to get it (e.g. by kernel call)?

Best regards

Torsten

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,425

If the job is running in background you should have access to the JOBLOG.

Another way is to wrap an abap around the job you want to run which simply creates the batch job you want to run and pass the number as a parameter.

Cheers

jimbo

Hi everybody!

I'd like to determine the jobnumer (TBTCO-JOBCOUNT) of an actually running background job.

In other words: Does an ABAP report know its own jobnumber, when it is running as background job? I need it inside the running report.

Unfortunately the SY structure does not contain it.

Is there another way to get it (e.g. by kernel call)?

Best regards

Torsten

6 REPLIES 6
Read only

Former Member
0 Likes
1,425

hi

good

yes a ABAP program knows its own job number whenever you r creating a background job all the details related to that particular backgound job stores in the table TBTCS,only thing you need to access them in your program.So pls check that table you will get all your required fields.

thanks

mrutyun^

Read only

Former Member
0 Likes
1,426

If the job is running in background you should have access to the JOBLOG.

Another way is to wrap an abap around the job you want to run which simply creates the batch job you want to run and pass the number as a parameter.

Cheers

jimbo

Read only

0 Likes
1,425

Unfortunately I don't have the jobname, and the report might be executed differrent times in parallel. The job is repeated periodically, so I can't use the jobnumber from the jobplanning.

But I found a solution on my own: As the Workprocess-Numer is hold in Table TBTCO I just have to determine the WP number at runtime of the report (see below).

REPORT  zzschubert6001                          .
*
CONSTANTS  con_opcode_wp_get_id TYPE x VALUE 8.   "from Include TSKHINCL
DATA lv_wppid TYPE wppid.                         "like wpinfo-wp_pid
DATA lv_jbcnt TYPE btcjobcnt.                     "like tbtco-jobcount
*
IF sy-batch IS NOT INITIAL.
  CALL 'ThWpInfo' ID 'OPCODE' FIELD con_opcode_wp_get_id
                  ID 'PID'    FIELD lv_wppid.
  SELECT jobcount FROM tbtco INTO lv_jbcnt UP TO 1 ROWS WHERE wpprocid = lv_wppid. ENDSELECT.
  MESSAGE i398(00) WITH 'Batch-Jobnumber is' lv_jbcnt.
ENDIF.

Thank you anyway!

Torsten

PS: What a crappy editor...

Read only

0 Likes
1,425

Hi Torsten

UWE showed me a neat trick

Type "{"code"}"

Your ABAP code

more coding

"{"code"}"

leave off the inverted commas

you should see something like this


Abap coding
Abap coding
......

cheers

jimbo

Read only

0 Likes
1,425

Hallo Torsten

you can use the FM GET_JOB_RUNTIME_INFO

-


DATA: jobcount LIKE tbtcm-jobcount,

jobname LIKE tbtcm-jobname,

stepcount LIKE tbtcm-stepcount.

CALL FUNCTION 'GET_JOB_RUNTIME_INFO'

IMPORTING

jobcount = jobcount

jobname = jobname

stepcount = stepcount

EXCEPTIONS

no_runtime_info = 1

OTHERS = 2.

-


Kindly Regards,

Stefan

Read only

Former Member
0 Likes
1,425

Hi Schubert ,

you can retrieve it using join on TBTCP and TBTCO.

in where clause give sy-report as TBTCP-PROGNAME and check condition TBTCO-STATUS = 'R'.

Regards,

Mohaiyuddin