Submit JCL from C



Help for C/C++ for MVS, OS/390 C/C++, z/OS C/C++ and C/C++ Productivity Tools for OS/390

Submit JCL from C

Postby mendijur » Sun May 12, 2013 11:42 pm

Hello,

I wonder how I can submit a job in C. The JCL to be submitted is in a file/dataset.

Is it possible to allocate -with dynalloc()- and open -with fopen()- a file called "DD:INTRDR" to be able to write to JES Internal Reader?

Any hint or suggestion would be highly appreciated.
Thanks.
mendijur
 
Posts: 14
Joined: Tue Feb 14, 2012 3:14 am
Has thanked: 2 times
Been thanked: 0 time

Re: Submit JCL from C

Postby enrico-sorichetti » Mon May 13, 2013 12:22 am

Device independence is one of the paradigms of zOS
from the very first incarnations... OS/360,MFT,MVT,... , ..., ...

any DD referring to a dataset with DCB=(RECFM=FB,LRECL=80,BLKSIZE=80)
can be changed to a DD referring to SYSOUT=(<somesysoutclass>,INTRDR)
with the same DCB attributes

see the forum for examples

the programming language used is irrelevant, as long as it can write a dataset in the requested format.


but if the JCL in the dataset is ready to be submitted, no need to write a program,
the invocation of a simple utility like IEBGENER can do it.
or from TSO use the SUBMIT command
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort

These users thanked the author enrico-sorichetti for the post:
mendijur (Tue May 14, 2013 6:32 pm)
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Submit JCL from C

Postby steve-myers » Mon May 13, 2013 1:05 am

Performing fopen("DD:INTRDR", ...) does not necessarily require the use of dynamic allocation; a "file name" DD:dd name directs fopen to use an existing DD statement with the specified DD name; the JCL used to run the program might specify

//INTRDR DD SYSOUT=A,DCB=(RECFM=F,LRECL=80,BLKSIZE=80)

Of course, your program could use MVS dynamic allocation to allocate the internal reader and then use fopen to open the data set that was just allocated.

As Mr. Sorichetti says, writing -
  FILE *infile, *intrdr;
  char record[ 81 ];

  if ( ( infile = fopen( "input", "r" ) ) == NULL )
   printf( "Unable to open input\n" );
  else
   {
    if ( ( intrdr = fopen( "DD:INTRDR", "w" ) ) == NULL )
     printf( "Unable to open INTRDR\n" );
    else
     {
      while( fgets( record, sizeof( record ), intrdr ) != NULL )
       fputs( record, intrdr );
      fclose( intrdr );
     }
    fclose( infile );
   }
when you can use a simple utility such as IEBGENER seems like overkill, but ...

These users thanked the author steve-myers for the post:
mendijur (Tue May 14, 2013 6:32 pm)
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Submit JCL from C

Postby mendijur » Tue May 14, 2013 6:45 pm

Thanks for your quick responses.

I agree that it may be overkill to try to submit a JCL from C when one can use other, immediate and more flexible ways. However, I think I wasn't explicit enough. The idea of using C to submit a JCL is that the (sub)routine in C will be called by the FTP server, that is, it's an FTP exit, and the objective is to submit a JCL after an FTP transfer has completed. This is why I was interested in submitting a JCL from C. That exit will read a file where the JCL to be submitted is stored.

From your responses, I guess that it won't be necessary to dynamically allocate a dataset if in the FTP procedure (run as a started task) there's a DDNAME pointing to that file, so it would be accessible to the exit, and the exit would only need to fopen()-ing it.

So if the Internal Reader and the file with JCL source code are specified as DDNAMEs in the FTP start procedure, then no need to dynamically allocate them. Am I correct?

Thanks.
mendijur
 
Posts: 14
Joined: Tue Feb 14, 2012 3:14 am
Has thanked: 2 times
Been thanked: 0 time

Re: Submit JCL from C

Postby Robert Sample » Tue May 14, 2013 7:01 pm

FTP can submit jobs directly to JES, so why not have your sequence of FTP commands transfer the data, then submit the job directly? That way you don't need any exit, nor a C program.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Submit JCL from C

Postby enrico-sorichetti » Tue May 14, 2013 7:30 pm

and the objective is to submit a JCL after an FTP transfer has completed.


then use Your scheduler facilities
when a dataset is created the scheduler has the capability to schedule for execution the jcl associated to the dataset creation

speak to Your operations support.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Submit JCL from C

Postby mendijur » Tue May 14, 2013 9:11 pm

Yes, I'm aware that FTP can submit jobs, but for security reasons, that feature is disabled on purpose.
mendijur
 
Posts: 14
Joined: Tue Feb 14, 2012 3:14 am
Has thanked: 2 times
Been thanked: 0 time

Re: Submit JCL from C

Postby mendijur » Tue May 14, 2013 9:13 pm

enrico-sorichetti wrote:then use Your scheduler facilities
when a dataset is created the scheduler has the capability to schedule for execution the jcl associated to the dataset creation
speak to Your operations support.

We don't have, for the time being, any scheduling facility/tool. The FTP user exit is the only short-term solution.
mendijur
 
Posts: 14
Joined: Tue Feb 14, 2012 3:14 am
Has thanked: 2 times
Been thanked: 0 time

Re: Submit JCL from C

Postby steve-myers » Wed May 15, 2013 8:23 am

mendijur wrote:Yes, I'm aware that FTP can submit jobs, but for security reasons, that feature is disabled on purpose.
Then why are you attempting to "beat" it? Or do you dislike your job that much!
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Submit JCL from C

Postby mendijur » Thu May 16, 2013 3:46 pm

steve-myers wrote:Then why are you attempting to "beat" it? Or do you dislike your job that much!

I'm not trying to beat anything nor going against the current. The feature of submitting jobs through the FTP server is disabled. This shop doesn't want any client to submit "foreign" JCL code. Clients are only allowed to send files. Files that they want to process once they've arrived. However, as I said in previous posts, there is no scheduling facility for the time being, so to process received files, I was just exploring the possibility of implementing the FTP post-processing user exit.
Of course I like my job. Another different thing is the limited tools that this shop has.
Kind regards.
mendijur
 
Posts: 14
Joined: Tue Feb 14, 2012 3:14 am
Has thanked: 2 times
Been thanked: 0 time


Return to C, C++