IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

getting JOBID in the JCL


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
antonrino.b

New User


Joined: 10 Jan 2006
Posts: 76
Location: Germany

PostPosted: Tue Aug 08, 2006 12:47 pm
Reply with quote

Hi,

I have a JCL to run a COBOL program which inserts a row into table tableA. While inserting, it populates the column Entry-id of the table with the JOBID.

After running the JCL, I have to submit the following query to check whether the row has been inserted.

Select * from tableA where Entry-id=<JOBID>.

I want to include this query submission in the JCL itself. For which I need the JOBID of the jcl being submitted. Is it possible to get that?

Thanks,
Antu
Back to top
View user's profile Send private message
narasimha_devi
Warnings : 1

New User


Joined: 10 Mar 2005
Posts: 26

PostPosted: Tue Aug 08, 2006 2:18 pm
Reply with quote

Hi,

OPTION 1:
You can pass Job-ID thru SYSIN.

//sysin dd *
job-id

This you can accept in your cobol program.

OPTION 2:
you can pass JOB-ID as data

//ddjobid dd *
job-id

In your cobol program allocate a file assigning to "ddjobid".
Read the file once to get the job-id.

Thanks
Devi
Back to top
View user's profile Send private message
antonrino.b

New User


Joined: 10 Jan 2006
Posts: 76
Location: Germany

PostPosted: Tue Aug 08, 2006 3:06 pm
Reply with quote

JOBID is assigned only at the time of JCL submission. My COBOL program already picks up the JOBID and uses it while inserting into table.

I need that for my inline SPUFI query, which I want to add next to my COBOL program run step.

Hope I am clear about my requirement.

Thanks,
Antu
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Tue Aug 08, 2006 6:09 pm
Reply with quote

Why doesn't your COBOL program get this information automatically?
Back to top
View user's profile Send private message
antonrino.b

New User


Joined: 10 Jan 2006
Posts: 76
Location: Germany

PostPosted: Tue Aug 08, 2006 6:19 pm
Reply with quote

No, My COBOL program automatically gets this information.

I need the jobid for executing the query as inline in JCL after the completion of cobol program.

Code:
//cobrun job-acc-info
****
//steplib dd dsn=my.pgm.lib
step1 exec pgm=pgmname
.
.
.

****
//step2 exec dsn=my.db.load
.
.
//systsin dd *
Select * from tableA where Entry-id=<JOBID> <--- here i need the jobid
Back to top
View user's profile Send private message
narasimha_devi
Warnings : 1

New User


Joined: 10 Mar 2005
Posts: 26

PostPosted: Wed Aug 09, 2006 11:21 am
Reply with quote

Hi,

If this table is inserted by only one JOB then we can get job-id using subquery.

//systsin dd *
Select * from tableA where Entry-id= (select JOBID from tableA fetch FIRST ROW ONLY)

If your table is inserted/updated with only one JOB then it picks the JOBID from first row and then assign the JOBID to Entry-Id in where clause.

Try this..
Back to top
View user's profile Send private message
antonrino.b

New User


Joined: 10 Jan 2006
Posts: 76
Location: Germany

PostPosted: Wed Aug 09, 2006 11:40 am
Reply with quote

No devi, it is updated by many programs simultaneously..
Back to top
View user's profile Send private message
narasimha_devi
Warnings : 1

New User


Joined: 10 Mar 2005
Posts: 26

PostPosted: Wed Aug 09, 2006 12:16 pm
Reply with quote

Hi,

If it is updated with multiple Jobs then what you want to check in your sql query?

if you want to check whether rows are inserted or not then why dont you add the sql query in the same Job where you are executing the cobol program to insert rows.
Back to top
View user's profile Send private message
antonrino.b

New User


Joined: 10 Jan 2006
Posts: 76
Location: Germany

PostPosted: Wed Aug 09, 2006 1:46 pm
Reply with quote

That is my requirement. I want to add the sql query in the same job.

I was trying to get the JOBID of the job being submitted, in the same job itself to execute the query.

Anyway, I will try running the query with "fetch first one row". But are you sure, that it will return the most recent row?
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Wed Aug 09, 2006 1:52 pm
Reply with quote

Here is my solution: Insert additional step between the COBOL and your SELECT.

In this step, put a REXX exec that gets the jobid and generate the SYSTSIN for the next step. You can use temporary file with DISP=(NEW,PASS) in the REXX setp, and DISP=(OLD,DELETE,DELETE) in the next step.

To get jobid from REXX, you may try the following code:
Code:
/* REXX */                                   
/* Get jobid: CURRENT_TCB->JSCB->SSIB */     
numeric digits 24 ; TRACE I                   
cvtptr=storage(10,4)   /*CVT*/               
psatcb=storage(d2x(c2d(cvtptr)),4)           
currtcb=storage(d2x(c2d(psatcb)),4)           
tcbjscb=storage(d2x(c2d(currtcb)+x2d(B4)),4) 
jscbssib=storage(d2x(c2d(tcbjscb)+x2d(13c)),4)
ssibjbid=storage(d2x(c2d(jscbssib)+x2d(c)),8)
say 'jobid='ssibjbid                         
return 0                                     


Enjoy.

O.
Back to top
View user's profile Send private message
narasimha_devi
Warnings : 1

New User


Joined: 10 Mar 2005
Posts: 26

PostPosted: Wed Aug 09, 2006 2:14 pm
Reply with quote

Hi,


If you are adding SQL query in the same job then you can use the job-id which is passed to cobol.
Otherwise job-id which is defined in jobcard.

Fetch first row only will retrieve the first row from the table not the latest one.

In ur table if you have current date or current time stamp then you can get latest row from the table using max(timstamp/date column) in subquery.

Thanks
Devi
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Regarding 'TSO OUTPUT jobname(jobid)' TSO/ISPF 17
No new posts Address TSO STATUS JOBNAME - Not gett... CLIST & REXX 4
No new posts How can I get jobid of a submitted jo... JCL & VSAM 24
No new posts Recovering compiler listing using jobid TSO/ISPF 1
No new posts Changing JOBID using REXX CLIST & REXX 3
Search our Forums:

Back to Top