Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing arguments to mainframe COBOL 3

Status
Not open for further replies.

mattyp75

Programmer
Aug 28, 2002
16
GB
Does anyone know if it is possible to construct a COBOL program on a MVS mainframe and pass arguments to it in much the same way you would pass arguments into a VB program? If anyone has any advice please let me know,
thanks,
Matt
 
I think this is what you're looking for:
In the program on the mainframe after working-storage section, put:

Linkage Section.
01 linkfield1 pic x(20).
02 linkfield2 pic x(20).
...

procedure division using linkfield1 linkfield2.


In the calling program:

working-storage section.
01 myvar1 pic x(20).
02 myvar2 pic x(20).
...

procedure division.
...
call "mainframeprogram" using myvar1 myvar2. --------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
If I understand your question, the PARM= option of the // EXEC card can be used to pass in parameters to the program at run time much as the command line arguments can be passed in to VB programs.

See:
Glenn
Brainbench MVP for COBOL II
 
Hi Matt,

To avoid confusion, there are 2 ways to pass parm info to a cobol pgm: when the pgm is called as a subpgm or when it's executed directly from JCL.

When used as a subpgm, NVS's approach is used.
When executed from JCL, Glenn's is used.

One thing to note, when using the 2nd approach, the Linkage Section s/b coded as follows:
Code:
Linkage Section.
01 link-data.
   05 link-len  pic s9(004) comp.
   05 link-data pic  x(020).

link-len will contain the length of the PARM data provided in the // EXEC JCL stmt.

link-data will contain the data itself.

Note that the length field (link-len) is NOT required for the 1st approach.

BTW, in NVS's post, "02 linkfield2" should read
"01 linkfield2".

Regards, Jack.
 
Heh... oops :) --------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
Thanks a lot everyone for your help and support, I kinda worked out the first way (the subprogram route), but it is very useful to know the JCL parameter way.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top