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

C program on Mainframe


IBM Mainframe Forums -> HomeWorks & Requests
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sabav42

New User


Joined: 09 Jun 2014
Posts: 5
Location: India

PostPosted: Mon Jun 09, 2014 1:30 pm
Reply with quote

Hi All,

I would like to know how to execute C program in Mainframe.
Please help me.

Advance Thanks for your sharing.
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 Jun 09, 2014 2:34 pm
Reply with quote

Code:
//stepname EXEC PGM=yourCprogram


If you need something else, first ask how it is done at your site. Is this part of a competition?
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 Jun 09, 2014 4:54 pm
Reply with quote

You did not tell us whether you really meant, "How do I compile and execute a C program on the mainframe?" or "How do I execute the binary program prepared by compiling a C program?"

Mr. Woodger answered the second question, at least in part. The answer for the first question is more complex. A forum such as this is not a good source for this type of query. It depends on the exact version of the C compiler used on the mainframe you are using and other conventions established for that mainframe. You should ask this question of the support organization for that mainframe.

Another question you did not ask is "How do I specify files for C functions like fopen?"

Going back to the second question in the first paragraph, you did not tell us the environment you expect to use when executing the prgram. There are four possible environments:
  • Batch from JCL
  • TSO command line
  • ISPF
  • The Unix like command environment within TSO
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Mon Jun 09, 2014 5:42 pm
Reply with quote

Man..that sounded like such a simple question when I read it, but these guys are correct. There is much more to it.

Let me tell you how I did it, years ago, under MVS.

You know how you have to compile a COBOL program to make it work? You have to do the same with a C program. In my shop, everyone pretty much uses batch jobs to compile COBOL programs. I poked around and found the libraries where the JCL was stored, then found the C versions of the compilers in that library.

I spent like a week getting the JCL fixed up to point to the needed libraries, have the correct compile options, and produce a usable load module.

Then, I created some execution JCL that needed to have the right system libraries in the STEPLIB.

This was a fun side project for me, and I got to learn about some of the lesser used parts of the shop's mainframe. If I had to do it for real, I would have started by asking my tech support folks where to get the approved compile JCL, or what on-line panel to use to create it.
Back to top
View user's profile Send private message
sabav42

New User


Joined: 09 Jun 2014
Posts: 5
Location: India

PostPosted: Tue Jun 10, 2014 9:17 am
Reply with quote

Yes.. I would like to excute the program in Batch from JCL environment.

As Ed Goodman said, i need to know the library details.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Tue Jun 10, 2014 11:31 am
Reply with quote

sabav42 wrote:
As Ed Goodman said, i need to know the library details.
If this is what you are looking forward to then you should be talking to someone at your shop ,no one here can really help you with names at your site.
Back to top
View user's profile Send private message
steve-myers

Active Member


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

PostPosted: Tue Jun 10, 2014 10:36 pm
Reply with quote

sabav42 wrote:
Yes.. I would like to excute the program in Batch from JCL environment. ...
OK. Batch JCL.

It's not widely appreciated, but

// EXEC PGM=xxx,PARM='a b c'

is roughly equivalent to using

xxx a b c

in a command line, and a C program can retrieve the text strings in the PARM text just like they would be retrieved from the command line in Windows or *NIX.

Just like any other batch program, you need a //STEPLIB DD statement or a //JOBLIB DD statement to specify the library where the compiled binary program is stored, and any other libraries needed to run your program.

The fopen function will use dynamic allocation if you specify fopen("data set name",...), or fopen will defer to a DD statement if it encounters fopen("dd:dd name",...). The I/O functions like gets and fgets map MVS data sets to Windows or *NIX "flat" files quite well. You can use MVS VSAM files, though I'm not familiar with the details.

This is about as much information as you can get in a public forum like this. For details in your mainframe environment you really need to consult with the support structure for your environment. Good luck.
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 -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
No new posts Error to invoke MPP program through B... IMS DB/DC 3
No new posts Email attachment from mainframe is empty PC Guides & IT News 9
No new posts Mainframe Dataset Binary or ASCII Mainframe Interview Questions 4
No new posts Need help In Mainframe Automation AF/... CLIST & REXX 14
No new posts SPOOL to Mainframe dataset in batch mode JCL & VSAM 7
Search our Forums:

Back to Top