Q
Problem solve Get help with specific problems with your technologies, process and projects.

Going from CL's QTEMP to batch QTEMP

Going from CL's QTEMP to batch QTEMP

I have a CL program that calls an RPG program to accept a bunch of parameters (via a subfile). These get saved in a QTEMP file. The CL program would then SUBMIT a second RPG program to run in batch to generate a report based on the parameters captured. How do I send the stuff from the calling CL's QTEMP to the batch QTEMP? The OS/400 SBMJOB command does have a 'Copy environment variables Y/N ?' option, would that do the trick?
The 'Copy environment variables' parameter on the SBMJOB command does not copy a QTEMP library. It just copies the labels and values of the Qshell environment variables that you may have in your job. Use GO CMDENVVAR to see environment variable commands, if you are interested - but they won't help you here.

What you need to do is to make the file in QTEMP available to your submitted job by putting it into a proper library. When you create the file, name it using the job number of the creating (interactive, in you case) job - like this:

 
: 
Dcl  &JobNum  *Char   Len(6) 
Dcl  &File    *Char   Len(10) 
: 
: 
RtvJobA  Nbr(&JobNum) 
: 
: 
ChgVar   &File  ('X' *CAT &JobNum) 
CrtDupObj  BaseFile  BaseLib  *File  WorkLib  &File Data(*No) 
MonMsg  CPF0000 
: 
: 
SbmJob   BatchJob Cmd(Call MyPgm Parm(∥m1 ∥m2 &File)) .... 
: 

We pass the name of the file to the submitted job, which does its override and reads the file. Once it has finished processing, it will delete the file.

This technique is fine as long as the user does not run the program more than once between the interactive side creating the file and the batch side deleting it -- if that is likely to happen, you will have to devise a more unique naming method. Try involving a sequential number, and incrementing it if your interactive CL finds that a file with that name (X + Job number + Sequence) already exists:

 

: 
Dcl  &JobNum  *Char   Len(6) 
Dcl  &SeqNum  *Dec    Len(3 0) Value(0) 
Dcl  &SeqChr  *Char   Len(3) 

Dcl  &File    *Char   Len(10) 
: 
: 
RtvJobA  Nbr(&JobNum) 
: 
: 
Loop: 
ChgVar   &SeqNum (&SeqNum + 1) 
ChgVar   &SeqChr (&SeqNum) 
ChgVar   &File   ('X' *CAT &JobNum *CAT &SeqChr) 

CrtDupObj  BaseFile  BaseLib  *File  WorkLib  &File Data(*No) 
MonMsg  CPF0000 Exec(GoTo Loop) 
: 
: 
SbmJob   BatchJob Cmd(Call MyPgm Parm(∥m1 ∥m2 &File)) .... 
: 

Another way to pass a list of data is in a User Space. This is a much more involved process, and requires the use of a number of IBM APIs. You still have to uniquely name the object and pass the name to the batch job. Lastly, you could pass data using a 'pipe'. This is another API-based solution, and uses programs and techniques associated with Qshell. Best to stick with the file option, I think!

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Visit the ITKnowledge Exchange and get answers to your developing questions fast.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

This was last published in December 2004

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Join the conversation

2 comments

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

I have a SFTP CL using qsh command. Command is SFTP -b /tmp/SFTPScript Server@ServerName.com and I have 6 polling jobs sending to the Remove Server. I would love to use qtemp for SFTPScript like FTP uses OVRDBF(Input) but QSH is not friendly with Qtemp. How can I get SFTPScript instantiated to each of the 6 polling jobs?  STDIN? Create Members?
Cancel
Hi apalmer1968, I would recommend asking your question on our ITKE forum. Our experts can certainly help you out.
Cancel

-ADS BY GOOGLE

SearchDataCenter

Close