fhg
Volume 6, Number 16 -- April 19, 2006

CL's Null Value

Published: April 19, 2006

Hey, Ted:

I am writing a CL program in which I pass variables to the Change User Profile (CHGUSRPRF) command. The command fails when I try to use a qualified name containing a single value like *SAME or *NONE. If I use one variable for the qualified parameter, *SAME and *NONE work, but the compiler won't allow me to put both library name and program name into one variable. How can I pass qualified names that allow single values as variables to commands?

--Brian


Use two variables for the qualified name in your CHGUSRPRF command. When you need to use a single value, put CL's null value, *N, in the part of the qualified name that doesn't need a value.

Here's an example. Suppose you want to run the Display Job (DSPJOB) command in a CL program. There are two ways to tell which job you want to display: You can qualify the job by entering the job name, user, and job number, or you can use the single value * to indicate the current job.

The following program accepts three parameters that indicate which job is to be displayed. If the first parameter, the job name, has the single value *, then the other two parts of the job identifier, name and number, do not need a value. For that reason, I place *N into the &USER and &JOBNBR variables. The same DSPJOB command works for both the single value and a qualified value.

pgm parm(&inJob &inUser &inJobNbr)   
                                     
dcl &inJob     *char  10             
dcl &inUser    *char  10             
dcl &inJobNbr  *char   6             
                                     
dcl &Job       *char  10             
dcl &User      *char  10             
dcl &JobNbr    *char   6             
                                     
chgvar &Job &inJob                   
if (&inJob *eq '*') do              
   chgvar &User   '*N'              
   chgvar &JobNbr '*N'             
enddo                              
else do                            
   chgvar &User   &inUser          
   chgvar &JobNbr &inJobNbr        
enddo                              
                              
dspjob job(&JobNbr/&User/&Job)

Let's complicate the example slightly by adding another qualified parameter-sort sequence. The Sort Sequence (SRTSEQ) parameter of the Change Job (CHGJOB) command can accept six single values or a qualified sort sequence table name. The following program changes the sort sequence for a job.

pgm parm(&inJob &inUser &inJobNbr + 
         &inSortSeq &inSortLib)     
                                    
dcl &inJob     *char  10            
dcl &inUser    *char  10            
dcl &inJobNbr  *char   6            
dcl &inSortSeq *char  10            
dcl &inSortLib *char  10            
                                    
dcl &Job       *char  10            
dcl &User      *char  10            
dcl &JobNbr    *char   6            
dcl &SortSeq   *char  10            
dcl &SortLib   *char  10            
                                    
chgvar &Job &inJob                  
if (&inJob *eq '*') do              
   chgvar &User   '*N'              
   chgvar &JobNbr '*N'             
enddo                              
else do                            
   chgvar &User   &inUser          
   chgvar &JobNbr &inJobNbr        
enddo                              
                                   
chgvar &SortSeq &inSortSeq         
if (&inSortSeq *eq '*SAME' +       
*or &inSortSeq *eq '*USRPRF' +     
*or &inSortSeq *eq '*SYSVAL' +     
*or &inSortSeq *eq '*HEX' +        
*or &inSortSeq *eq '*LANGIDUNQ' +  
*or &inSortSeq *eq '*LANGIDSHR') do
   chgvar &SortLib '*N'            
enddo                              
else do                            
   chgvar &SortLib &inSortLib      
enddo                                                   
                                                        
chgjob job(&JobNbr/&User/&Job) srtseq(&SortLib/&SortSeq)

If the first parameter is a single asterisk, the user and job number portions of the job parameter are loaded with *N. If the sort sequence, in the fifth parameter, is any of the single values, the sort table library name is given the value *N. The following text, cut from the job log, shows how the system interprets the CHGJOB command when single values are used.

CHGJOB JOB(*) SRTSEQ(*LANGIDSHR)

--Ted



Sponsored By
ADVANCED SYSTEMS CONCEPTS

SEQUEL can be used for virtually ALL data access functions on the iSeries.

A Windows-based user interface makes it easy to design queries and reports.

SEQUEL offers executive dashboards, drill-down data analysis and run-time prompts to deliver important iSeries data to managers and other non-technical users.

E-mail and FTP delivery let you deliver information to remote users and servers.

www.asc-iseries.com



Senior Technical Editor: Ted Holt
Technical Editors: Howard Arner, Joe Hertvik, Shannon O'Donnell, Kevin Vandever
Contributing Technical Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Brian Kelly, Marc Logemann, David Morris
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.

Sponsored Links

Maximum Availability:  Secure, cost-effective, real-time iSeries replication software solutions
COMMON:  Join us at the Fall 2006 conference, September 17-21, in Miami Beach, Florida
nuBridges:  Leading provider of secure FTP on the iSeries

 


 
Subscription Information:
You can unsubscribe, change your email address, or sign up for any of IT Jungle's free e-newsletters through our Web site at http://www.itjungle.com/sub/subscribe.html.

Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement