Home > Ask the AS/400 Experts > iSeries Application Development Questions & Answers > Going from CL's QTEMP to batch QTEMP
Ask The iSeries 400 Expert: Questions & Answers
EMAIL THIS

Going from CL's QTEMP to batch QTEMP

John Blenkinsop EXPERT RESPONSE FROM: John Blenkinsop

Pose a Question
Other iSeries 400 Categories
Meet all iSeries 400 Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 16 December 2004
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(&parm1 &parm2 &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(&parm1 &parm2 &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.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
iSeries COBOL programming
Implementing a browser interface in COBOL: Displaying database fields
Implementing a browser interface in COBOL: Creating your graphic Web page
Implementing a browser interface in COBOL: Getting started
Allow access to data from a stored procedure result set using COBOL or RPG
Eight steps for creating program documentation using AS/400 utilities
Coloring source lines with COBOL and using a shortcut from within PDM
Top 10 programmer tips YTD
Slow system performance
Changing the font size
New option within the WRKSYSACT command
iSeries COBOL programming Research

iSeries Application Development
Monitoring escape messages and using RCVMSG for diagnostic messages
Listing contents of multiple FTP directories on AS/400
Chain operation error after converting RPG3 to ILE RPG (RPGIV)
Space offset X'0015FF00' or X'0000000000000000' is outside current limit for object QIGC2424C
Searching fields for values
iSeries application display subfiles with other program windows
Searching part of a name or address in AS/400
Passing parameters in an ILE RPG module
What's happening to my subfile?
What happening to my subfile?

RPG iSeries programming
Enhancing RPG with external SQL stored procedures
Introduction to SQLRPGLE on IBM i: Making a report
Making the most of RPG data handling on IBM i
IBM i shop boosts online sales with RPG-based Web platform
Migrating from RPG to EGL on IBM i
Allow access to data from a stored procedure result set using COBOL or RPG
EGL Rich UI on IBM i: Do you Dojo?
Programming for the Web on the IBM i, what is possible
A taste of COMMON: ILE, IBM releases, Web applications and new products
Documenting nested program structures on the AS/400

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Report Program Generator  (Search400.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



iSeries Networking - Printing, Remote Access, TCP/IP
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts