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

How to run a job from COBOL


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
krishna_Murty
Warnings : 2

New User


Joined: 17 Sep 2006
Posts: 24

PostPosted: Mon Sep 25, 2006 9:25 am
Reply with quote

Can some one give a sample and simple code to run a job from a Cobol Program.

Actually if we write a output file and write the output lines which makes
up a JCL, once the output lines are completed are there any instructions given like submit from cobol itself to run this output file.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Mon Sep 25, 2006 10:54 am
Reply with quote

Since SUBMIT is also a TSO command, you can issue it from within COBOL, just like any other TSO command. See example here.

Another option is to direct your output lines to INTRDR.

O.
Back to top
View user's profile Send private message
krishna_Murty
Warnings : 2

New User


Joined: 17 Sep 2006
Posts: 24

PostPosted: Mon Sep 25, 2006 12:14 pm
Reply with quote

Thanks but the example site here is not active. Is there any alternative. viz give other links or copy and paste the code here.
Back to top
View user's profile Send private message
murali922

New User


Joined: 25 Jul 2005
Posts: 92
Location: India

PostPosted: Tue Sep 26, 2006 3:34 pm
Reply with quote

Your question : How do I submit a JOB from my COBOL program ?

If I have understood your question I have a suggestion.

1. Do all processing you want to in your COBOL program.
2. Define the JOB card, EXEC, DD statements as working storage varialbles, like the below one :-

Code:
01  BATCH-JCL-AREA.                                             
...CARD 1                                                       
    05 JOB-CARD.                                                 
      10 FILLER           PIC X(04) VALUE "//DL".               
      10 WS-XXX                PIC X(02).                             
      10 WS-JOB-NAME-2    PIC X(05) VALUE "EXAMP".               
      10 FILLER           PIC X(10) VALUE "JOB CLASS=".         
      10 WS-XXX              PIC X(01).                             
      10 FILLER           PIC X(10) VALUE ",MSGCLASS=".         
      10 WS-MSGCLASS-1    PIC X(01).                             
      10 FILLER           PIC X(47) VALUE SPACES.               
...CARD 2                                                       
    05 JCLLIB-CARD.                                             
      10 FILLER           PIC X(20) VALUE "// JCLLIB ORDER=(ZX.".
      10 WS-ENV-1         PIC X(07) VALUE "PROD.DL".             
      10 WS-DEPOT-2       PIC X(02).                             
      10 FILLER           PIC X(12) VALUE ".PROCLIB,ZX.".       
      10 WS-ENV-2         PIC X(04) VALUE "PROD".   


define the job cards just like the above. You coding this depends on what your JCL should have.

Code:
EXEC CICS WRITEQ TD       
          QUEUE("DSUB")   
          FROM(JCL-CARD)
END-EXEC                 


DSUB is my INTRDR. You might need to ask your system administrator about yours.

Write all the contents into the INTRDR (Internal reader).
You would require a TDQ to which you write your job statements and the TDQ name is the name of your INTRDR.

Once you start writing it into the INTRDR, the job would get submitted.

Hope this info helps...
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Tue Sep 26, 2006 4:19 pm
Reply with quote

I think he was asking about COBOL under TSO, not CICS...

O.
Back to top
View user's profile Send private message
Kevin

Active User


Joined: 25 Aug 2005
Posts: 234

PostPosted: Tue Sep 26, 2006 5:50 pm
Reply with quote

Quote:

How to run a JCL from COBOL


You run a JOB. Jobs are written in JCL. This is like saying you want to "execute a COBOL". Doesn't really make sense, does it?
Back to top
View user's profile Send private message
krishna_Murty
Warnings : 2

New User


Joined: 17 Sep 2006
Posts: 24

PostPosted: Wed Sep 27, 2006 9:35 am
Reply with quote

Thank you so much, after posting the question i became little busy and could not see the forum again. i will review the code and get back.

Once again thanks for taking so much importance for my query and replying to it.
Back to top
View user's profile Send private message
krishna_Murty
Warnings : 2

New User


Joined: 17 Sep 2006
Posts: 24

PostPosted: Sat Sep 30, 2006 12:23 pm
Reply with quote

ofer71

I wrote a COBOL program, Just for ur understanding the main statements in COBL PRG ARE

FILE-CONTROL
SELECT JCL-OUT ASSIGN TO UT-S-JCLDD.

DATA DIVISION.
FD JCL-OUT
RECORD CONTAINS 80 CHARACTERS
RECORDING MODE IS F
DATA RECORD IS JCL-RECOUT.

01 JCL-RECOUT PIC X(80).

00000-MAINLINE.
OPEN INPUT JCL-IN
OPEN OUTPUT JCL-OUT
PERFORM 1000-READ-MOVE UNTIL EOF
CLOSE JCL-IN
CLOSE JCL-OUT
GOBACK.

1000-READ-MOVE.
IF NOT EOF
READ JCL-IN INTO WS-RECORD
AT END MOVE 'Y' TO WS-EOF
END-READ
MOVE WS-RECORD TO JCL-RECOUT
END-IF

This above cobol program reads JCL input file and move the records to output file, (Note I did not write the records to output only moved)

Now from the JCL point of view to run the above cobol , i wrote

//JCLDD DD SYSOUT=(*,INTRDR)

The job thus the Program is running fine but not executing the JCLDD file, ie. the output JCL file is not firing.

Can u please guide me, where i went wrong.

Also this is not from CICS point of view, this is batch programing i am looking for.

Thanks
Back to top
View user's profile Send private message
kamran

New User


Joined: 01 May 2005
Posts: 55

PostPosted: Sat Sep 30, 2006 6:54 pm
Reply with quote

Hi,
You coded completly right except you must write the record instead of just "MOVE WS-RECORD TO JCL-RECOUT"
so change the code to:
"write JCL-RECOUT from WS-RECORD."


krishna_Murty wrote:
ofer71

I wrote a COBOL program, Just for ur understanding the main statements in COBL PRG ARE

FILE-CONTROL
SELECT JCL-OUT ASSIGN TO UT-S-JCLDD.

DATA DIVISION.
FD JCL-OUT
RECORD CONTAINS 80 CHARACTERS
RECORDING MODE IS F
DATA RECORD IS JCL-RECOUT.

01 JCL-RECOUT PIC X(80).

00000-MAINLINE.
OPEN INPUT JCL-IN
OPEN OUTPUT JCL-OUT
PERFORM 1000-READ-MOVE UNTIL EOF
CLOSE JCL-IN
CLOSE JCL-OUT
GOBACK.

1000-READ-MOVE.
IF NOT EOF
READ JCL-IN INTO WS-RECORD
AT END MOVE 'Y' TO WS-EOF
END-READ
MOVE WS-RECORD TO JCL-RECOUT
END-IF

This above cobol program reads JCL input file and move the records to output file, (Note I did not write the records to output only moved)

Now from the JCL point of view to run the above cobol , i wrote

//JCLDD DD SYSOUT=(*,INTRDR)

The job thus the Program is running fine but not executing the JCLDD file, ie. the output JCL file is not firing.

Can u please guide me, where i went wrong.

Also this is not from CICS point of view, this is batch programing i am looking for.

Thanks
Back to top
View user's profile Send private message
kris.2020

New User


Joined: 09 May 2006
Posts: 2

PostPosted: Tue Oct 03, 2006 1:15 pm
Reply with quote

Thanks for info
icon_biggrin.gif
Back to top
View user's profile Send private message
krishna_Murty
Warnings : 2

New User


Joined: 17 Sep 2006
Posts: 24

PostPosted: Tue Oct 03, 2006 5:04 pm
Reply with quote

Thanks to all
I got the job running fine

Regards
Krishna
Back to top
View user's profile Send private message
jijesh

New User


Joined: 09 May 2006
Posts: 4

PostPosted: Mon Nov 13, 2006 3:44 pm
Reply with quote

Hi all

I am very news to Mainframes.

i was just not able to figure out the advantage of submitting a JCl through a cobol??????

if we need to run multiple programs, we can use a Proc. why then do we need one program like this?????

also can we submit the job for the same program???? or is it that this program will be run normally and all the others jobs will be triggered subsequently by this program.

please help me in having a better clarity about the entire concept.

thanks
Back to top
View user's profile Send private message
supreethi.srid

New User


Joined: 15 Oct 2009
Posts: 5

PostPosted: Mon Feb 20, 2017 5:46 pm
Reply with quote

I am trying to execute a TSO command from IMS online by invoking transaction from the terminal. Getting RC of 16 while executing IKJTSOEV. Ignoring that assuming that the environment is already set, I continue to execute IKJEFTSR, I am getting the following :
RETURN CODE - 000000012
REASON CODE - 00000000J
ABEND CODE - 00000000J
For the above, I am trying to execute a sample TSO command to allocate a new dataset. Passed this flag combination - X'00010001'. (My original intent is to execute a set of ACF sub-commands, say, to reset expired password by resetting invalid pw count).

Please provide help on setting up appropriate flags for a sample allocate function. Does the command work at all for executing the TSO ACF sub-commands? - a question on feasibility now. If, so what flags for this one?
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Mon Feb 20, 2017 6:10 pm
Reply with quote

Running the TSO SUBMIT command from a Cobol program is more complex than it has to be.

In z/OS, the system provides a capability called an "internal reader." An internal reader is a pseudo data set specified in JCL as

//ddname DD SYSOUT=(x,INTRDR)

The x in SYSOUT=(x,INTRDR) becomes the output message class for the submitted job unless the job's // JOB statement specifies MSGCLASS=y.

With the internal reader specified in the JCL used to run a Cobol program, all the Cobol program has to do is open the data set assigned to DD name ddname for output and write the JCL for the job the Cobol program wants to run to the data set.

This capability has been in the system since the first release of MVS. Use it!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Mon Feb 20, 2017 6:28 pm
Reply with quote

supreethi.srid, you replied to a topic TEN AND A HALF YEARS OLD! And your question really has nothing to do with the original topic. You need to find and read the forum rules before you post anything else.
Quote:
Ignoring that assuming that the environment is already set, I continue to execute IKJEFTSR
This is stupid. You ignore return codes ONLY if you don't expect anything else you're doing to work. You should figure out what the return code means, and why you got it, and how to fix it BEFORE attempting to do anything else.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Feb 20, 2017 10:36 pm
Reply with quote

Please start a completely new question, and be exactly clear about what you are trying to achieve, rather than how you are trying to achieve it.

"I want to be able to reset an 'ACF-password' from an IMS transaction". Is that it?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top