# batch mainframe job number available to natural program ?

**URL:** <https://techcommunity.softwareag.com/t/batch-mainframe-job-number-available-to-natural-program/90928>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-Code-Samples\
**Created:** [August 11, 2009, 6:58pm UTC](https://techcommunity.softwareag.com/t/batch-mainframe-job-number-available-to-natural-program/90928 "2009-08-11T18:58:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwilhelm](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@jwilhelm](https://techcommunity.softwareag.com/u/jwilhelm)\
**Post date:** [August 11, 2009, 6:58pm UTC](https://techcommunity.softwareag.com/t/batch-mainframe-job-number-available-to-natural-program/90928/1 "2009-08-11T18:58:15Z")

</div>

Is there a system variable holding the job number for jcl submitted to run natural program in batch on the mainframe?  
I use \*init-user for the job name, but how can I capture the job number?

thanks,

John

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [August 11, 2009, 7:48pm UTC](https://techcommunity.softwareag.com/t/batch-mainframe-job-number-available-to-natural-program/90928/2 "2009-08-11T19:48:59Z")

</div>

The job number is not available to Natural.

---

<div class="post-metadata">

**Author:** ![zarchasmpgmr](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/zarchasmpgmr/32/126_2.png) [@zarchasmpgmr](https://techcommunity.softwareag.com/u/zarchasmpgmr)\
**Post date:** [August 13, 2009, 4:06am UTC](https://techcommunity.softwareag.com/t/batch-mainframe-job-number-available-to-natural-program/90928/3 "2009-08-13T04:06:21Z")

</div>

Well, let’s just say it’s not available via Natural facilities.

However, it is easy to get it via an assembler program. You can find examples of the control block chain in several programs at the CBT Tape (think mainframe shareware) site - [http://www.cbttape.org](http://www.cbttape.org).

---

<div class="post-metadata">

**Author:** ![ToniCarl](https://avatars.discourse-cdn.com/v4/letter/t/ad7895/32.png) [@ToniCarl](https://techcommunity.softwareag.com/u/ToniCarl)\
**Post date:** [August 31, 2009, 6:46pm UTC](https://techcommunity.softwareag.com/t/batch-mainframe-job-number-available-to-natural-program/90928/4 "2009-08-31T18:46:21Z")

</div>

Do you have Entire System Server (NPR)? The job number can be obtained from it. JOB-NUMBER is found in the following NPR files:

ACTIVE-JOBS  
READ-SPOOL  
SPOOL-FILES  
SPOOL-QUEUE  
SPOOL-UPDATE  
SUBMIT  
TASK-INFO  
WRITE-SPOOL

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [September 1, 2009, 10:53am UTC](https://techcommunity.softwareag.com/t/batch-mainframe-job-number-available-to-natural-program/90928/5 "2009-09-01T10:53:39Z")

</div>

We “mine” the job number via:

… jcl  
//GETJOBNO EXEC PROC=GETJOBNO

which is SYS3.PROCLIB(GETJOBNO):

000001 //GETJOBNO PROC  
000002 //GETJOBNO EXEC PGM=IKJEFT1B,PARM=‘GETJOBNO’  
000003 //SYSTSPRT DD DSN=&&JOBNO,DISP=(NEW,PASS),SPACE=(TRK,1),UNIT=SYSDA  
000004 //SYSPROC DD DISP=SHR,DSN=SYS3.CTM.PROD.CNTL  
000005 //SYSTSIN DD DUMMY

Which runs rex script:

/\* REXX

This REX program will return the Job No of the currently executing  
job. It is used when you want to log job run infomation in file  
JOB-LOG. If you use “BATCHON JOB LOG” then you must put the  
following JCL step before Natural step:

```
 //JOBNO EXEC PROC=GETJOBNO

```

You then need to supply the following workfile into your Natural:

```
 //CMWKF32 DD DSN=&&JOBNO,DISP=SHR

```

and then PASREG JOB LOG will create a new record on JOB-LOG for  
your job name and job number, it will also set the AIV variable:

```
 +JOB-NUMBER (P5)

```

During the execution of your natural programs you can the callnat  
ZJOBLOG to record details about the program execution. At the end  
when BATCTOFF is executed it will create the final JOB LOG record  
You can inspect your jobs via ZJOBLOGP.

Written by Paul Macgowan for PSS 25/1/08  
\*/  
tcb = storage(21c,4)  
jscb = storage(d2x(c2d(tcb)+180),4)  
ssib = storage(d2x(c2d(jscb)+316),4)  
jobnum = storage(d2x(c2d(ssib)+12),8)  
say jobnum

Our Natural code then reads WF32 via a standard BATCHON program

//CMSYNIN DD \*  
LOGON   
BATCHON TEST X

BATCHON is:

DEFINE DATA INDEPENDENT  
1 +JOBLOG-JOB-NO (P5)

…

1 #JOBLINE (A20)  
1 REDEFINE #JOBLINE  
2 FILLER 1X  
2 #JOB-KEYWORD (A3)  
2 #JOB-NUMBER (N5)  
2 #JOB-SEP (A1)  
2 #JOB-RUN-NO (N6)

READ WORK 32 #JOBLINE  
IF #JOB-KEYWORD = ‘JOB’ THEN  
+JOBLOG-JOB-NO := #JOB-NUMBER  
ESCAPE BOTTOM  
END-IF  
END-WORK  
CLOSE WORK 32

So +JOBLOG-JOB-NO AIV will have the job No

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:57pm UTC](https://techcommunity.softwareag.com/t/batch-mainframe-job-number-available-to-natural-program/90928/6 "2021-04-02T14:57:22Z")

</div>


