CONVERT STRING TO NUMBER USING C FUNCTIONS
In the July 5 Club Tech Programming Tips newsletter, I described how to convert a string to a number using IBM-supplied RPG code. Mike Kienenberger wrote me about another method: calling functions in the C runtime library from RPG IV.
The code below shows how to use C functions atoi (ASCII to Integer) and atof (ASCII to Floating point) to convert an alphameric string to a number. Note that atoi expects only digits (no decimals, signs, or commas), while atof can convert numbers containing a decimal, +/- sign, and commas.
h bnddir('QC2LE')
D atoi pr 10i 0 extproc('atoi')
D num * options(*string) value
D atof pr 8f extproc('atof')
D num * options(*string) value
D i s 10i 0
D p s 13p 7
C movel '-100 ' num 6
C eval i = atoi(%trim(num))
* > EVAL i
* I = -100
C eval(h) p = atof(%trim(num))
* > EVAL i
* P = -000100.0000000
C movel '-5.67 ' num 6
C eval(h) p = atof(%trim(num))
* > EVAL p
* P = -000005.6700000
C return
Code provided by IBM's Barbara Morris
2.ALLOCATE OBJECT
http://www.as400network.com/nwn/story.cfm?ID=7826
Q. We wrote and use our own change management system. The problem is that when we move the changed objects to the production system, we can't use the ALCOBJ command to lock a display file, temporarily preventing its use. Is there a way to lock a display file in a CL program so we can compile the display file?
A. The ALCOBJ command doesn't work with device files. However, you can mimic an exclusive object lock in a number of ways. One way is to use the MOVOBJ command to move the display file to a temporary library. You then compile the new version of the display file and delete the original file from the temporary library. The advantage of this approach is that you can restore the original display file if an exception occurs.
Julian Monypenny, NEWS/400 Tech Editor
3.BINDING PROBLEM
http://www.as400network.com/nwn/story.cfm?ID=7861
Q. I have a module (let's call it X) that I bind by copy into several different programs. If I ever have to change module X, I must rebind all programs in which it occurs. How can I keep track of which programs use a particular module?
A. Most third-party change management systems have this capability. If you want to do this yourself, you can use the DSPOBJD command specifying you want the output to go to an *OUTFILE to produce a list of all program objects in a database file. You can then read each record in this database file and use the QBNLPGMI (List ILE Program Information) API to determine what modules are contained in each program.
Actually, all of this pretty much misses the point. If you have a module, which is potentially usable in more than one program, you should place that module into a service program. ILE programs can access procedures in a service program without binding them by copy into the program object. If you change a module in a service program without changing the exports (i.e., procedures and data that are available outside the service program), you don't have to rebind all the programs that use the service program. Modules bound to ILE programs are bound by copy because a copy of the module is placed into the program object itself. Modules contained in a service program are bound by reference because the program object, which uses them, contains only a reference to the service program and not a copy of any of its modules.
Mike Cravitz, NEWS/400 Tech Editor
4.RPG, CL, AND Java
http://www.as400network.com/nwn/story.cfm?ID=7814
Q. I want to learn more about RPG and CL programs calling Java programs. I've read about this and am aware of commands such as RUNJVA and also that RPG can use the QCMDEXC API. However, in my reading I didn't see much information about passing parameters. Can you explain more about this?
A. You can pass parameters to a Java class by using the RUNJVA command in a CL program. These parameters end up as the array of string arguments to a Java class's main method. Note, however, that these parameters are input only; a Java class can't return values to a CL program. To execute a Java class with a CL program and pass parameters in both directions, look to IBM's AS/400 Toolbox for Java. Using the Toolbox, you can use AS/400 data area or data queue objects as a means to accommodate a bidirectional data exchange.
You might be interested to know that a Java class can directly call an RPG or a CL program and exchange data with the program by using the AS/400 Toolbox for Java's program call facility. A Java class using the Toolbox can call an RPG or a CL program and pass data as input, output, and input/output parameters.
Dan Darnell, NEWS/400 Tech Editor
5.TRACKING FILE USAGE
http://www.as400network.com/nwn/story.cfm?ID=7775
Q. Is there an AS/400 file that stores the activity or characteristics of all AS/400 objects? I want to run a query on this file to determine an object's size and last-used date.
A. There's no AS/400 file that holds this information, but you can create one using the DSPOBJD command. Issue the following command:
DSPOBJD
OBJ(*ALL/*ALL) +
OBJTYPE(*ALL) +
OUTPUT(*OUTFILE) +
OUTFILE(YourLib/YourFile)
For performance reasons, be sure to run this command in batch. Once the command has finished executing, you can query file YourLib/YourFile for the information you want.
Gary Guthrie, NEWS/400 Tech Editor
6.BATCH FILE TRANSFER VIA FTP
http://www.as400network.com/nwn/story.cfm?ID=7719
Q. I'm trying to automate the transfer of a PC .txt file to our AS/400 and then automatically trigger a conversion program to integrate the data into our data files. I wrote a .bat file that uses Rumba AS/400 file transfer to upload the file to the AS/400. I now must call a CL program from within the .bat file. Can I do this and, if so, how?
A. Although you can't do this with Rumba's file transfer, you can easily do it with FTP. Although FTP's primary function is to perform file transfers, you can use its RCMD subcommand to execute commands and programs on the AS/400. RCMD is handy for launching AS/400 jobs that process the transferred files. The following sample FTP command line shows how you can execute under Windows NT a batch FTP job that performs a file transfer and calls an AS/400 program.
ftp -n -i -s:ftp400cmd.txt S101AA0A
The ftp command starts the Windows FTP application, and the -n and -i switches indicate that the program will run in batch mode and won't perform any interactive prompting. At the end of the line, S101AA0A specifies the name of the AS/400 host system. The -s: switch specifies a file that contains the FTP subcommands to be executed.
The contents of the ftp400cmd.txt file are as follows:
USER myID
myPWD
cd QGPL
put myfile.txt
quote rcmd call pgm(mylib/mypgm)
quit
The first line supplies the user ID used to connect to the AS/400, and the second line supplies the password. Note that by default these values are sent across the network in clear text. Although this is probably fine for most internal networks, you shouldn't do this for public Internet access. The cd subcommand changes the AS/400's current library to QGPL. The put subcommand sends the file myfile.txt from the Windows NT system to the AS/400's QGPL library. Next, the quote rcmd subcommands execute AS/400 program mypgm in mylib. Finally, the quit subcommand terminates the FTP session.
Michael Otey, NEWS/400 Senior Technical Editor
7.OBTAINING AS/400 COMMAND INFORMATION
http://www.as400network.com/nwn/story.cfm?ID=7644
Q. I'm working on a project to supply a graphical front end to our AS/400 software product. Our system uses the QCMDCHK command to prompt for command details. I need to provide the information QCMDCHK uses to let my GUI client rather than the AS/400 prompt for the file information. Specifically, I must obtain the information as specified by the command PARM in the command source file (e.g., KWD, TYPE, LEN, PROMPT). Unfortunately, the DSPCMD command doesn't provide this information. My server programs are written in ILE RPG and the graphical client with Java.Given that the source files aren't shipped with our product, how can I retrieve this information from "compiled commands?"
A. You might find Dave McKenzie's RTVCMDSRC freeware utility helpful.This handy utility retrieves from the command object source that reflects the command's structure. Remember, IBM could at some point change the command object's structure, thereby causing the utility to fail or produce unpredictable results. On the bright side, this utility has been stable for some time, and it's quite possible that IBM won't introduce problematic changes. You can download RTVCMDSRC from http://www.as400network.com/sharewarefiles/rtvcmd.zip
Gary Guthrie, NEWS/400 Tech Editor
8.GETTING TO THE ROOT OF 63A0
http://www.as400network.com/nwn/story.cfm?ID=7638
Q. When I perform a WRKCFGSTS (Work with Configuration Status) command, my tape device appears as a 63A0 tape device. I know this is a generic tape device name; how can I learn the actual model of my tape device?
A. To find out whether your 63A0 is a model 6380, 6381, 6382, 6385, 6386, or other tape device that appears as a 63A0, perform the following steps:
1. Type the command STRSST (Start System Service Tools) and press Enter.
2. Type 1 to Start a service tool and press Enter.
3. Type 7 to select Hardware service manager and press Enter.
4. Type 2 to select Logical hardware resources and press Enter.
5. Type 1 to select System bus resources and press Enter.
6. Find the resource name where the tape device is located (usually CMB01 for 63A0), type 9 to select Resources associated with IOP, and press Enter.
7. Find the description of the tape device with type 63A0, type 8 to select Associated packaging resources, and press Enter.
8. Type 5 to Display detail and press Enter. The actual model type of the tape device is listed on the Type-Model line.
Debbie Saugen, IBM Senior Backup and Recovery Specialist
9.ASSIGNING 5250 WORKSTATION DEVICE ID
http://www.as400network.com/nwn/story.cfm?ID=7605
Q. Does PC5250 display emulation let me assign a unique workstation device ID, or does TN5250 assign it randomly when I connect to an AS/400?
A. You can select your workstation device ID when using either Client Access for Windows 95/NT or Client Access Express PC5250 emulation. However, many additional PC5250 capabilities have been available for Client Access Express since January 2000 via Service Pack SF60698 or later.
Many emulation programs don't handle 5250 workstation IDs over TCP/IP very well, and users and administrators want more control over how workstation IDs are assigned and maintained. The Express client has improved this area so that you can select your workstation ID, have multiple 5250 sessions, and maintain everything in one workstation (.WS) profile. A .WS profile is where information about a 5250 session is stored. AS/400 administrators can choose to maintain only one .WS profile on an AS/400 and have it shared by all PC5250 sessions, thus enabling standardization of settings. Alternatively, users can save their .WS profiles on their PCs and change them to suit their preferences.
IBM has added a new parameter for setting up the workstation ID name.
The format of this parameter is
Workstation ID=[+][%](Workstation + _Name/&COMPN/&USERN)[*][=]
* + indicates to truncate the workstation ID from the end if it's longer than 10 characters
* % adds P (Printer) or S (diSplay) to the front of the workstation's name
* Workstation_Name is the "hard-code device name" (e.g., "WS1")
* &COMPN is the Computer name (this is the name identified in the Windows Network Identification area)
* &USERN is the Windows User name
* * means add a suffix (e.g., A, B, C) to the workstation ID
* = means auto-increment the workstation ID if additional sessions are started (increments go from 1 to 9, then A-Z)
By establishing guidelines for naming the workstation ID for display and printer sessions, AS/400 operators and administrators can more easily determine what's attached to their AS/400 at any time.
Carole Miner, IBM Senior Software Engineer
10. MESSAGE CPI1466
http://www.as400network.com/nwn/story.cfm?ID=7600
Q. Why do I sometimes see message CPI1466 -- "Job holds large number of locks" -- in my job log during save operations?
A. Message CPI1466, which sometimes appears in the job log during save operations, is sent to message queue QSYSOPR and to the history log (QHST) when a specific job obtains a suspiciously large number of locks. This message is meant to draw your attention to any application that holds a large number of locks so you don't overlook any of them. A typical save operation obtains and releases many locks as it processes objects, so it's not unusual to see message CPI1466 at this time. During save operations, you don't need to take any action when you see message CPI1466.
The number of locks required to trigger message CPI1466 is release-dependent, so you may see it at one release but no longer see it after you upgrade. Sometimes message CPI1466 will appear every time a save is run except the first time after an IPL. This is because after an IPL, objects have been paged out to disk, which slows the preprocessing on the next save because the objects must be brought back into memory. Therefore, the system won't hold as many locks.
Debbie Saugen IBM Senior Business Recovery Specialist
11. DISPLAY FILE ERROR MESSAGE
http://www.as400network.com/nwn/story.cfm?ID=7563
Q. I want to know why I've been getting this error message: "SDA3659: Extract description is not allowed for file QDPTDSP in QSYS." I get the error when I try to use the STRSDA command's option 3 on file QDPTDSP for testing the record formats and selecting a record for testing.
A. Display file QDPTDSP in library QSYS is an IBM-supplied system file. Sometimes, IBM-supplied objects aren't quite "what they seem." Although QDPTDSP is a display file, it differs from the display files you create. It doesn't contain everything that user-created display files contain. This is true of most IBM-supplied display files. For instance, when you use the DSPFFD command on file QDPTDSP, you don't see a record format list displayed, unlike when you invoke DSPFFD on a user-created display file.
Although IBM states the missing information has been removed to save space, I suspect other motives. IBM often likes to "hide" a few things from customers. The bottom line is that this behavior isn't unique to file QDPTDSP. Because IBM-supplied display files don't contain the information SDA requires, you can't use them in an SDA session.
Gary Guthrie, NEWS/400 Tech Editor
12. MANAGING DISK USE
To help you manage disk use on your AS/400, OS/400 includes the RTVDSKINF (Retrieve Disk Information) and PRTDSKINF (Print Disk Information) commands. You can use these two commands to monitor the utilization of your disks, or you can write your own queries over the data captured by RTVDSKINF to analyze changes in disk use.
You use command RTVDSKINF to gather information about all the objects on your system. The command outputs the information to member QCURRENT in file QAEZDISK in library QUSRSYS. For a large system with many thousands of objects, running RTVDSKINF can take many hours, so IBM requires you to run the command in batch. The easiest way to do this is to use the SBMJOB (Submit Job) command:
SBMJOB CMD(RTVDSKINF)
You use command PRTDSKINF to print the information that command RTVDSKINF generates in file QAEZDISK. PRTDSKINF lets you print a summary of your system information or print details of disk use by library, folder, owner, or object. For example, to print a list of libraries that are more than 1,000 K in size in descending order by size, you run the command
PRTDSKINF RPTTYPE(*LIB) +
OBJ(*NONE) +
MINSIZE(1000) +
SORT(*SIZE)
The online help for PRTDSKINF explains all the available options.
If the standard PRTDSKINF report options don't meet your needs, you can write your own queries over file QAEZDISK. In addition, you can save the data in member QCURRENT in QAEZDISK to a file and write queries to compare the output from different runs of RTVDSKINF.
From a NEWS/400 Tech Corner item by Julian Monypenny
13. Short Takes:
1. STORAGE USED BY ALL USER PROFILES
To get a list of all user profiles and the amount of storage they use, you first use the DSPUSRPRF command to create an outfile, then create a query over that outfile. IBM has provided simple instructions on this process at http://as400service.ibm.com/8625680A007CA5C6/0/9E2935A65DC72239862565C2007D2F24?Open&Highlight=2,4664258
2. FINDING DEFAULT IBM PASSWORDS
Q. What command or utility checks for IBM-supplied user IDs that haven't had their passwords changed from their default values?
A. The command is ANZDFTPWD. You can either enter the command or enter GO SECTOOLS and select menu option 1. When run, ANZDFTPWD prints a report named QPSECPWD that shows all the user profiles on the system with default passwords. ANZDFTPWD optionally lets you disable or expire the password for user profiles with default passwords.
3. READABLE FONT FOR 132-COLUMN 5250 DISPLAYS
If you're not happy with the font used in your Rumba or other 5250 emulation software, Microsoft offers a free font that you might try. The font, Andale Mono, can be downloaded from http://www.microsoft.com/OpenType/fontpack/default.htm. I've tried it in MochaSoft's TN5250 product in both 80-column and 132-column modes, and it is very readable.
14. ALLOW DESIGNATED PERSONNEL TO CHANGE PASSWORDS WITHOUT QSECOFR
How many times in a month does a user who has forgotten his or her password interrupt your security officer? Although resetting a user's password is not a complicated task, the command it requires, CHGUSRPRF (Change User Profile), calls for QSECOFR authority. It would be nice to be able to shift the responsibility for resetting user passwords to others -- such as help desk personnel -- without compromising the system's security. Command SETPWD does just that: It lets an authorized operator quickly, easily, and securely reset a user's password.
SETPWD prompts for a single parameter: the user profile whose password needs to be reset. You can download the SETPWRD program from http://www.as400network.com/noderesources/code/clubtechcode/setpwd.cmd .
CL program SC002CL is the command processing program (CPP) for SETPWD and can be downloaded from http://www.as400network.com/noderesources/code/clubtechcode/sc002cl.clp . The program begins by retrieving the identifier attributes of the authorized operator's current job and profile information about the user whose password is to be changed. The program checks the profile information, and if it determines that the profile belongs to the security officer or to a user whose group profile is QSECOFR (hence, changing the password could breach your system's security), it sends control to label SECERROR. Otherwise, the program continues by issuing a DSPUSRPRF (Display User Profile) command for the profile. The program then stores the command's output in a new record added to SC002AF, a file in a member that has the same name as the user profile. File SC002AF serves as a log of password changes.
Next, the program sets up a loop to retrieve the most recent record added to the appropriate member of SC002AF. As another security check, at label PROCESS, the CPP uses QCLSCAN to make sure the profile does not have special authority *ALLOBJ or *SECADM. If it has either, control drops to label SECERROR.
When the program finds no potential security breach, it resets the user profile's password to the user profile name, sets password expiration to *YES (so the user will have to change the password immediately after signing on), and enables the profile. The program also sends a message to the system operator, to the person who issued the SETPWD command, and to the user whose password has been changed, informing them that the password has been reset. The message includes the date of the last successful sign-on and the number of invalid sign-on attempts since then. Control then drops to label EXIT, and the CPP ends.
If either security check fails, the code at label SECERROR sends a message to QSYSOPR, to the user who issued the command, and to the user whose password the program tried to reset. The message details who was trying to reset whose password and confirms that the password was not reset. Control then drops to EXIT, and the program ends without changing the password.
Installation instructions for the SETPWD utility can be found at http://www.as400network.com/noderesources/code/clubtechcode/setpwd.txt
Adapted from an October 1993 NEWS/400 article by Judy Yaeger and John Earl
15. Short Takes:
1. RETRIEVING THE PERCENTAGE OF SYSTEM ASP USED
When you want to automatically monitor for available disk space or transfer very large files on your system (e.g., copy a library or duplicate large objects), you can run a CL program to check whether your AS/400 has enough available storage space before you start the job. The simple CL program, below, retrieves the percentage of disk space used in the system auxiliary storage pool (ASP), the total storage capacity of the system ASP in megabytes, and the total auxiliary storage capacity on the system in megabytes.
DCL &APIASP TYPE(*DEC) LEN(7 0)
DCL &SYSASPPERC TYPE(*DEC) LEN(4 1)
DCL &SYSASPTOT TYPE(*DEC) LEN(7 0)
DCL &TOTAUX TYPE(*DEC) LEN(7 0)
DCL &RCV TYPE(*CHAR) LEN(100)
DCL &RCV_LEN TYPE(*CHAR) LEN(4)
CHGVAR VAR(%BIN(&RCV_LEN)) VALUE(100)
CALL PGM(QWCRSSTS) PARM(&RCV &RCV_LEN +
'SSTS0200' '*NO' X'00000000')
CHGVAR &APIASP VALUE(%BIN(&RCV 53 4))
/* retrieve the % system ASP used */
CHGVAR &SYSASPPERC VALUE(&APIASP / 10000)
/* retrieve the total system ASP in MB */
CHGVAR &SYSASPTOT VALUE(%BIN(&RCV 49 4))
/* retrieve the total auxiliary storage +
capacity in MB */
CHGVAR &TOTAUX VALUE(%BIN(&RCV 57 4))
Adapted from a NEWS/400 Tech Corner item by Herman Van der Staey
2. MONITORING PERCENTAGE OF SYSTEM ASP USED
The following CL program programmatically monitors ASP and sends a message to QSYSOPR message queue when the ASP percentage exceeds 90%.
PGM
DCL VAR(&FORMAT) TYPE(*CHAR) LEN(8) VALUE('SSTS0200')
DCL VAR(&LENFLD) TYPE(*DEC) LEN(4) VALUE(68)
DCL VAR(&SYSUSEC) TYPE(*CHAR) LEN(4)
DCL VAR(&SYSUSE) TYPE(*DEC) LEN(9 2)
DCL VAR(&SYSINFO) TYPE(*CHAR) LEN(68)
DCL VAR(&ERRCODE) TYPE(*CHAR) LEN(8) +
VALUE(X'0000000000000000')
DCL VAR(&RESETSY) TYPE(*CHAR) LEN(10) VALUE(*YES)
DCL &Q90PER TYPE(*DEC) LEN(9 2) VALUE(900000)
PROCED1: CALL PGM(QWCRSSTS) PARM( &SYSINFO &LENFLD &FORMAT &RESETSY +
&ERRCODE )
MONMSG MSGID(CPF0000) +
EXEC(GOTO PROCED2)
CHGVAR &SYSUSEC VALUE(%SST(&SYSINFO 53 4))
CHGVAR &SYSUSE %BINARY(&SYSUSEC)
IF (&SYSUSE > &Q90PER) (DO)
SNDPGMMSG MSG('**SYSTEM OVER 90% ASP**') +
TOMSGQ(QSYSOPR) MSGTYPE(*INFO)
RETURN
ENDDO
SNDPGMMSG MSG('**SYSTEM UNDER 90% ASP**') +
TOMSGQ(QSYSOPR) MSGTYPE(*INFO)
RETURN
PROCED2: SNDPGMMSG MSG('GETTING ERROR ON SYS CALL') TOMSGQ(QSYSOPR) +
MSGTYPE(*INFO)
ENDPGM
Adapted from an IBM Knowledgebase document
3. PRINTING A LIST OF ALL INSTALLED IBM SOFTWARE
You probably already know that if you enter GO LICPGM and select option 10, you can display a list of IBM software packages installed on your system. Unfortunately, this method might not display all IBM software packages installed, and it also doesn't let you print this list. You could, of course, simply use the Print Screen key, but you might have to print 15 different screens with messy formats, and you could inadvertently truncate data or forget to print a screen. There's a better solution. The following DSPSFWRSC (Display Software Resources) command
DSPSFWRSC OUTPUT(*PRINT)
not only prints out all your software package names, but it also prints the library name in which each package is located.
From a NEWS/400 Tech Corner item by Jean-Jacques Risch
16. EXISTENCE OF AN IFS FILE
Q. For objects in the QSYS.LIB system, I can use CHKOBJ to determine command existence. What is the equivalent for items in the IFS?
A. Here are two solutions, one in RPG IV and one in CL.
(a) RPG IV program FileExists:
* NOTE: Compile with DFTACTGRP(*NO)
*
* IFS API prototypes
*
* Access
*
Daccess PR 10I 0 extproc('access')
Dpathptr1 * value
Dmode1 10I 0 value
*
* IFS API Constants
*
DF_OK S 10I 0 inz(0)
*
* Some working environment for us
*
DFile_exists S 10I 0
Dpathptr S *
Dpathname S 21
DExists C 'File Exists'
DNotExists C 'File does not exist'
*
* Main{}
*
C *entry plist
C parm filename 20
* Set a character pointer to the file name string
C eval pathname = %trim(filename)+x'00'
C eval pathptr = %addr(pathname)
* Call the IFS API
C eval File_Exists = access(pathptr:F_OK)
* Did we find it?
C File_exists ifeq 0
C Exists dsply
C else
C NotExists dsply
C endif
* That's all, folks
C move *on *inlr
The filename should be supplied as //dir/dir/file, so a valid call would be:
CALL FILEEXISTS ('//etc/pmap')
(b) The ChkIfsObj command is
CMD PROMPT('Validate an IFS Object')
PARM KWD(OBJECT) TYPE(*PNAME) LEN(256) MIN(1) +
EXPR(*YES) PROMPT('IFS object')
The ChkIfsObj command uses CL program ChkIfsObjC, shown below:
PGM PARM(&PARM)
DCL VAR(&PARM) TYPE(*CHAR) LEN(256)
DCL VAR(&RTNVALINT) TYPE(*CHAR) LEN(4)
DCL VAR(&RTNVAL) TYPE(*CHAR) LEN(2)
DCL VAR(&PATH) TYPE(*CHAR) LEN(100)
DCL VAR(&NULL) TYPE(*CHAR) LEN(1) VALUE(X'00')
DCL VAR(&BUF) TYPE(*CHAR) LEN(4096)
CHGVAR VAR(&PATH) VALUE(&PARM *TCAT &NULL)
CALLPRC PRC('stat') PARM(&PATH &BUF) +
RTNVAL(%BIN(&RTNVALINT 1 4))
CHGVAR VAR(&RTNVAL) VALUE(%BIN(&RTNVALINT))
IF COND(&RTNVAL *NE '00') THEN(SNDPGMMSG +
MSGID(CPF9897) MSGF(QCPFMSG) +
MSGDTA('Object ' &PARM < ' not +
found.') MSGTYPE(*ESCAPE))
ENDPGM
FileExists was written by Nick RouxChkIfsObj and ChkIfsObjC was written by David Leland
17. Short Takes:
1. RETRIEVING OS/400 VERSION/RELEASE
Q. What is the best way to get the version/release of a system?
A. One way is to use the Retrieve Product Information (QSZRTVPR) API.
This CL program illustrates its use:
PGM
DCL &RELEASE *CHAR 6
DCL &RCVR *CHAR 128
DCL &RCVRLEN *CHAR 4 VALUE(X'00000080')
DCL &FORMAT *CHAR 8 VALUE('PRDR0100')
DCL &PRDINFO *CHAR 27 VALUE('*OPSYS *CUR 0000*CODE ')
DCL &ERRCODE *CHAR 4 VALUE(X'00000000')
CALL QSYS/QSZRTVPR PARM(&RCVR &RCVRLEN &FORMAT &PRDINFO &ERRCODE)
CHGVAR &RELEASE (%SST(&RCVR 20 6))
SNDPGMMSG MSG('This system is at release' > &RELEASE)
ENDPGM
The release level returned is in the format VxRxMy. Valid values for x are 0 through 9. Valid values for y are 0 through 9 and A through Z.
Adapted from an answer by Buck Calabro
2. REMOVING NUMBERS AND NAMES IN SOURCE MEMBERS
Suppose your assignment is to update a S/34 report program that hasn't been touched since its inception, and now you want to delete the worthless line numbers from columns 1 through 5 and the program name from columns 75 through 80. How can you automate this task?
First, let's get rid of the line numbers. The simplest way is to shift all the code five columns to the left and then shift it back to the right. Enter the command LLT5 (the left line block truncate command and the value 5) on the first and last lines of the program. Within the block these two commands demarcate, the first five characters of each line are deleted and the rest of each line is moved five places to the left. (If you omitted the truncation and data existed in columns 1 through 5, SEU would show an error.) After you perform this command, move the truncated lines back to their original spot using RRT5 (the right line block truncate command and the value 5) on the first and last lines. (The T is not strictly necessary at this point, but I've put it in to keep the commands parallel.)
To delete the omnipresent program name, use the C (change) command as follows (note that the set of spaces must be exactly as long as the program name):
SEU==> C 'program-name' ' ' 75 80 A
This command puts spaces in columns 75 through 80, deleting the program name column from the entire program.
Answer by Andrew Borts
3. CONVERTING STRING TO NUMBER
Q. Does anyone know how to convert a string variable to a numeric? For example:
string (10a) = "1,245.02 "
converts to:
numeric (9,2) = 000124502
IBM has provided RPG IV procedure C2N (character to numeric). You see this procedure at http://www.as400.ibm.com/QSYS.LIB/SNIPPETS.LIB/sendfile.pgm?File=QRPGLESRC&Member=XXXC2N
You'll also need thePROTOTYPES member to compile C2N, which you can obtain at http://www.as400.ibm.com/QSYS.LIB/SNIPPETS.LIB/sendfile.pgm?File=QRPGLESRC&Member=PROTOTYPES
More RPG and other sample code is available at http://www.as400.ibm.com/tstudio/workshop/snippets/snippet1.htm
4. DETERMINING WHETHER A JOB IS RUNNING INTERACTIVE OR BATCH IN CL
In the last issue of the Club Tech Programming Tips Newsletter, I showed an RPG IV solution for determining whether a job is running in interactive or batch mode. I heard from a couple of readers that I should have pointed out the CL solution, which uses RTVJOBA. Below is a code snippet, offered by Mark Olson:
PGM
DCL VAR(&JOBTYPE) TYPE(*CHAR) LEN(1)
RTVJOBA TYPE(&JOBTYPE)
IF COND(&JOBTYPE *EQ '0') THEN(GOTO START)
/* Interactive Program Section */
SBMJOB CMD(CALL PGM(ITSELFCL)) JOB(SBMITSELF)
SNDPGMMSG MSG('Tell user program Itself Submitted')
RETURN
START:
/* Mainline Batch Program */
If the Job Type is 0, it's running in batch, and if it's 1, it's interactive.
18. AS/400 DIR FOR IFS DIRECTORIES
Q. I'm trying to programmatically generate a list of objects in an IFS directory. I'm trying to use opendir() and readdir(), but since I am not a C programmer, I wasn't able to understand how to define these APIs' parameters in RPG. Any ideas?
A. There's a freeware DIR command for the IFS that will list the contents of an IFS directory on the screen, to a printer, or in an outfile. The program comes in two versions, one for V3R7 and one for V4R4, and each comes with source code.
You can download the DIR programs from http://www.ediconsulting.com/dir.zip.
Adapted from an answer by Carl J. Galgano, DIR was written by Peter Connell
19. Short Takes:
1. RETRIEVE AN IFS STREAM FILE'S SIZE
The RTVOBJD (Retrieve Object Description) command lets you retrieve the size of an object in the QSYS.LIB file system. However, no similar command exists for retrieving the size of a stream file.
You can use the CL code shown below in a program to retrieve the size of a stream file in the AS/400 integrated file system (IFS). The variable &PATH contains the path to the stream file, such as '/MYDIR/MYSUBDIR/FILE.EXT' or '/QDLS/MYFOLDER/MYDOC.EXT', and the size is returned in the variable &SIZEDEC.
DCL VAR(&PATH) TYPE(*CHAR) LEN(128)
DCL VAR(&SIZEDEC) TYPE(*DEC) LEN(15 0)
DCL VAR(&HANDLE) TYPE(*CHAR) LEN(16)
DCL VAR(&SIZEBIN) TYPE(*CHAR) LEN(4)
DCL VAR(&PATHLEN) TYPE(*CHAR) LEN(4)
DCL VAR(&ATTRTAB) TYPE(*CHAR) LEN(10)
DCL VAR(&ATTRLEN) TYPE(*CHAR) LEN(4)
CHGVAR VAR(%BIN(&PATHLEN)) VALUE(128)
CHGVAR VAR(%BIN(&ATTRLEN)) VALUE(10)
CALL PGM(QHFOPNSF) PARM(&HANDLE &PATH &PATHLEN +
'100 100 ' &ATTRTAB &ATTRLEN ' ' +
X'00000000') /* Open stream file */
CALL PGM(QHFGETSZ) PARM(&HANDLE &SIZEBIN +
X'00000000') /* Get stream file size */
CALL PGM(QHFCLOSF) PARM(&HANDLE X'00000000') /* +
Close stream file */
/* Retrieve the STMF size in decimal (15,0) */
CHGVAR VAR(&SIZEDEC) VALUE(%BIN(&SIZEBIN))
Answer by Herman Van der Staey
2. DETERMINING WHETHER A JOB IS RUNNING INTERACTIVE OR BATCH
The module below, INTERACT, determines whether your program is running in interactive or batch mode:
H NoMain
D pInteractive PR N
D DummyPrm 1 Options( *Omit )
P pInteractive B Export
D pInteractive PI N
D DummyPrm 1 Options( *Omit )
* Local variables
D RetdInfDs DS
D 4
D 10I 0 Inz( %Size( RetdInfDs ) )
D RiJobType 61 61
D RiTypeInteractive...
D C 'I'
D LenRetdInf S 10I 0 Inz( %Size( RetdInfDs ) )
D FmtName S 8 Inz( 'JOBI0100' )
D QlJobName S 26 Inz( '*' )
D IntJobId S 16 Inz( *Blank )
C Call 'QUSRJOBI'
C Parm RetdInfDs
C Parm LenRetdInf
C Parm FmtName
C Parm QlJobName
C Parm IntJobId
C If RiJobType = RiTypeInteractive
C Return *On
C Else
C Return *Off
C EndIf
P pInteractive E
Here are the steps for installing and using Interact:
a) Upload INTERACT to a source physical file with a record length of 112 bytes. Give the uploaded member a name of INTERACT and a PDM type of RPGLE.
b) Use option 15 in PDM to compile INTERACT.
c) Issue the command:CrtSrvPgm SrvPgm( INTERACT ) Export( *All ) ActGrp( WhateverYouWant )
To use this service program from an RPG IV program, follow these steps:
a) Include the following prototype in your source with the D-specs:
D pInteractive PR N
D DummyPrm 1 Options( *Omit )
If you expect to use this procedure in more than one program, you might consider using a /Copy member for this prototype.
b) Here are a couple of sample calls to INTERACT in the C-specs:
C If pInteractive( *Omit )
C 'Interactive' Dsply DummyVar
C EndIf
C If Not pInteractive( *Omit )
C 'Batch' Dsply
C Endif
c) Use PDM option 15 to compile your program.
d) Issue the following command to create your program (Note that the following assumes your program is a standalone program, i.e., a single module, named MYPGM):CrtPgm MyPgm Module( MYPGM ) BndSrvPgm( INTERACT ) ActGrp( Whatever )
Adapted from a utility by Mike Cravitz
3. BATCH FILE PROGRAMMING
In the last issue of the Club Tech Programming Tips newsletter, I published "Access Shared Folders via FTP," which used a DOS batch (.BAT) file. I received a few e-mails asking where the DOS batch file syntax is described. Oddly enough, I couldn't find any definitive documentation on Microsoft's site (it may be buried there; I just couldn't find it). There are plenty of resources on the Web, though, describing DOS batch file programming:
Batfiles: The DOS batch file programming handbook http://home7.inet.tele.dk/batfiles/Batch Programming Elements http://student.vub.ac.be/~dvandeun/batcoll.allBatch FAQs http://www.nc5.infi.net/~wtnewton/batch/batchfaq.htmlBatch Guide http://www.geocities.com/SiliconValley/Park/3742/bat.htm
4. EASY FIELD SEARCH WITH FNDSTRPDM
The next time you want to see where a field is used throughout your system, try this handy shortcut. Rather than search all your source members using option 25 (Find string) on Programming Development Manager's (PDM's) Work with Members display, use the FNDSTRPDM (Find String Using PDM) command. FNDSTRPDM lets you search for a string in a specified source file in a library, and you can search all the members in the file. The command lets you display, print, and edit the matching members. You can also create a report of matching members.
Answer by Bill Dudley
20. RANDOM NUMBER GENERATOR IN RPG III AND RPG/400
Q. The May 10 edition of Club Tech Programming Tips included a random number generator for RPG IV, but unfortunately, that won't work for me, as I'm using RPG/400. Do you have a solution?
A. I dug through the NEWS/400 archives and found an RPG III and RPG/400 routine published in September 1989 that generates random numbers. The RANDOM routine can be downloaded from http://www.as400network.com/noderesources/code/clubtechcode/random.rpg
A companion routine, RAN_DEMO, is available at http://www.as400network.com/noderesources/code/clubtechcode/ran_demo.rpg RAN_DEMO shows how to call routine RANDOM and generate (1) a random list of whole numbers from 1 to an upper limit, (2) a random list of whole numbers from a lower limit to an upper limit, and (3) a random identifier that can be used as an AS/400 password.
21. Short Takes:
1. IBM IFS UTILITIES ATTRIB, DELTREE, AND CHGAUTALL
IBM has three unsupported native AS/400 utilities that let you further manipulate IFS directories and files. These utilities, described below, are available as a V4R4 save file containing the compiled objects and the C source code at ftp://testcase.boulder.ibm.com/as400/fromibm/ApiSamples/ifstool.savf
Once you've downloaded the save file from IBM's site and uploaded it to your AS/400, enter the following command to restore the save file to your target library:
RSTOBJ OBJ(*ALL) SAVLIB(DDILLING) DEV(*SAVF) +
SAVF(yourlib/IFSTOOL) RSTLIB(targetlibrary)
The utilities are described below.
ATTRIB
Similar to DOS's ATTRIB command, the ATTRIB utility allows IFS file attributes to be updated from the AS/400 without requiring a network drive/PC connection. Note that this program uses the Qp0lSetAttr() API, which is supported only in V4R4 and later.
This example removes the read-only and hidden file attributes for all files in the /news400 directory:
CALL PGM(ATTRIB) PARM('-R' '-H' '/news400' '\S')
To list the possible parameters for the ATTRIB utility, type "help attrib" in a DOS window.
DELTREE
Similar to DOS's DELTREE command, the DELTREE utility deletes all files, directories, and subdirectories from the parent directory down.
USE WITH CAUTION, as there is no confirmation warning and there is no undelete.
This example deletes all files and subdirectories in the news400 directory and also deletes the news400 directory:
CALL PGM(DELTREE) PARM('/news400')
CHGAUTALL
Runs the CHGAUT command on all files and subdirectories in the specified directory.This example gives user Chuck *ALL object authority and *RWX data authority to all files in the news400 directory:
CALL PGM(CHGAUTALL) PARM('/news400 'USER(chuck) DTAAUT(*RWX) OBJAUT(*ALL)')
Adapted from an IBM Knowledgebase item.
2. ACCESSING SHARED FOLDERS VIA FTP
An easy way to transfer files between AS/400 shared folders and a PC without using Client Access is to use File Transfer Protocol (FTP).
One way to do this is to open a DOS window and start an FTP session by typing "FTP" and pressing Enter, which displays the FTP command line. Then, enter the following command at the ftp prompt:
open hostname.domain (hostname.domain is your AS/400 DNS name or its TCP/IP address)
Reply to the prompts for your log-in name and password.
Once you're logged in to the AS/400 FTP session, issue the following commands:
cd /qdls (changes to the AS/400 shared folder space)
cd xxxx (opens shared folder xxxx)
binary (requests a transfer in binary mode, which is required for QDLS)
After these commands have been executed, you can use the FTP GET and PUT commands to transfer files to and from the PC. GET downloads an AS/400 file to the PC, and PUT uploads a PC file to the AS/400 shared folder. Use binary mode for all transfers of documents in QDLS. Normally, you use binary mode for non-ASCII files such as spreadsheets, word processor documents, and graphics files and ASCII mode to transfer files that need to be readable on the AS/400 in text or database format, but QDLS is an exception.
To automate a batch transfer from your PC to an AS/400 shared folder, you can create a .BAT file that calls an FTP command file (which you create) that contains the transfer commands. To start the transfer, simply invoke the .BAT file with a couple of parameters, as in the following example:
upload hostname.domain command
Below is the sample upload.bat file:
@echo off
if not exist %2.ftp goto error_1
ftp -s %2.ftp %1
goto end:
:error_1
cls
echo File %2 not found
:end
Below is the sample FTP command file, command.ftp, which contains the commands that transfer the PC file to an AS/400 shared folder:
user_name (your AS/400 user name)
password (your password)
cd /qdls
mkdir xxx (creates a new folder, if you want one)
cd xxx (open shared folder xxx)
binary
put zzzz (transfer PC file zzzz to AS/400 shared folder xxxx)
quit (ends the routine)
You can also invoke an AS/400 command from this ftp command file with the QUOTE RCMD ftp command. For example:
quote rcmd CPYFRMPCD FROMFLR(xxxx) TOFILE(QGPL/wwww) FROMDOC(zzzz) TOMBR(zzzz) TRNTBL(*NONE)
The above command copies the transferred file from the folder to a physical file member.
One caveat: The user ID and password are stored in the command file as clear text, which means anyone with access to the command file can view them. In addition, they most likely flow over the network in clear text, so anyone monitoring your network may be able to read them.
3. LEARNING SQL/400
Q. Are there any online resources for learning SQL/400?
A. An excellent SQL/400 tutorial is available online at http://www.as400network.com/resources/tutorials/sql400tutorial/
The tutorial is taken from three chapters in Paul Conte's book Database Design and Programming for DB2/400. The tutorial consists of three parts: SQL/400 Data Definition Language, SQL/400 Data Manipulation Language, and Embedded SQL/400.
22. TECH TIP: BETTER ACCESS ODBC PERFORMANCE
http://www.as400network.com/nwn/story.cfm?ID=7896
Q. We're running Client Access Express and have used Microsoft Access to set up linked tables via ODBC to the AS/400 files we want to query. Then we created a set of reports using Access's Report Designer. This process works fine, although it slows our AS/400's performance and producing the report on the PC takes a long time. Is there a way to decrease the performance impact on the AS/400 and speed up the report processing?
A. Many factors influence the performance of Access applications connected to the AS/400, not the least of which is the AS/400 itself. Although you don't mention the model AS/400 you use, the newer RISC-based models and the server models provide substantially better ODBC performance than the older CISC-based AS/400s. You should also consider that the AS/400 processes ODBC jobs exactly as it does batch work, and the same factors (e.g., current CPU utilization, disk paging, object locks) that influence standard AS/400 jobs also affect ODBC jobs.
One of the biggest issues with connecting to the AS/400 from Access is the fact that Access uses the JET database engine as a local query processor. Although JET works well as a local PC database engine, it isn't optimized for ODBC connections. Some of the actions the JET engine performs cause its ODBC performance to be poor. For instance, one of the biggest "gotchas" is the fact the JET engine performs frequent file opens and closes, the most expensive operations on the S/400.
Fortunately, the Client Access ODBC driver has two settings that can help compensate for this behavior. The most important setting for Access and the JET Engine is the "Enable lazy close support" setting, located under the ODBC driver's Performance tab. This setting causes the Client Access ODBC driver to ignore Access's frequent file open and close requests and lets the ODBC driver reuse an open connection.
Also, if the Access report is typically run repeatedly using the same values, make sure to check the "Enable extended dynamic (package) support" setting under the ODBC driver's Packages tab. Doing this lets the ODBC driver create and save a data access plan on the AS/400. Then, when the query is rerun, the existing access plan can be reused, thus saving the time the AS/400 would otherwise take to dynamically create the access plan.
Another factor you should consider is the query itself. First, you should make sure the query uses the appropriate files. For instance, you may have a logical file that provides a view of the data that can take advantage of an existing index. This can keep your Access report from performing full table scans and then sorting the data locally, which would perform poorly. You might also consider building you report using passthrough queries. Passthrough queries can be efficient for AS/400 ODBC connections because they let you bypass the JET engine and take advantage of the AS/400's query processor.
To create a passthrough query in Access, open the Queries windows and then double-click the "Create query in design view" icon. Close the New Tables dialog box that automatically appears. Then, on the Query menu, select SQL Specific and then Pass-Through option. Next, set the ODBC connection string by selecting the Properties icon in the toolbar and then clicking on the ellipsis next to the ODBC Connect Str property. You're then prompted to select an existing data source to the AS/400, or you can create a new data source if an AS/400 data source doesn't already exist. After setting the connection properties, type your passthrough query in the SQL Pass-Through Query window and click the Execute icon to run the query.
Finally, if all else fails, consider copying the data from the linked tables to one or more local Access tables before running the reports. You can automate this process by building an Access macro.
Michael Otey, NEWS/400 Tech Editor
23. TECH TIP: REMOTE JOURNALING
http://www.as400network.com/nwn/story.cfm?ID=7936
Q. We're setting up remote journaling to replicate all database files from our production AS/400 to our front-end system (both on V4R3). The remote journals are operational, copies of the database files are on the front-end system, we've established a breakpoint, and the remote receivers are being created as expected. However, we've found a limitation with remote journaling: We can't use the APYJRNCHG command to update the database on the front-end system because the command doesn't work with remote journals. We could write our own program to retrieve journal entries using the RCVJRNE command and then create/rewrite/delete database records, but this involves significant development effort and is bound to be less efficient than using APYJRNCHG. Is there an easier method of applying journal changes to a remote system?
A. You can't use the APYJRNCHG command with remote journals. Remember that there could be a requirement to journal the remote file to which you're replicating data. Imagine the following scenario.
Presume SystemA has File1 that's journaled to YourJrn on SystemA and to remote journal YourJrn on SystemB and that you want to replicate the entries in YourJrn on SystemB to File2 on SystemB. Also presume that you want to journal File2 on SystemB, so you create YourJrn2 on SystemB. In this case, you'd use YourJrn2 to apply journaled changes to File2.
To apply journaled changes to a file, that file must be journaled. For obvious reasons, the system won't let you apply journaled changes to any file other than the one to which they pertain. In the case of remote journaling, the journaled changes pertain to the file on the source system.
If you don't want to buy a data replication application, you can code the function yourself. You've discovered the method I recommend, the RCVJRNE command. This command lets you write an exit program to process journal entries. The development effort may not be as gargantuan as you anticipate. You should be able to write a single program to handle all files using the following ingredients:
* embedded dynamic SQL to insert data into the file* API QDBRTVFD to retrieve field information used in constructing the SQL INSERT statement* journal entry format *TYPE3 (ENTFMT parameter on RCVJRNE) to obtain the null value map
Although coding such a program isn't a trivial task, it's manageable and has the added benefit of not requiring more development to handle additional files.
Gary Guthrie, NEWS/400 Tech Editor
24. BATCH CONVERSION OF OV/400 DOCUMENTS TO MS WORD
Q. I have hundreds of OfficeVision documents that I need to convert to Microsoft Word. Is there an automated way of converting them in batch?
A. Microsoft provides a VBA macro named CONVERT8.WIZ that converts all or selected files in a directory from one format to another in a single batch operation. In this case, we want to convert the OfficeVision documents in an AS/400 folder to Microsoft Word.
Before you can convert the documents, you need two things:
a. File CONVERT8.WIZ file, which can be found in the \Program Files\ Microsoft Office\Office\Macros folder. If you didn't perform a full install of Office 97, you'll need to run the Office 97 Setup program. In Setup, select "Add/Remove program items," and ensure that the "Wizards, Templates, and Letters" category is checked. Then proceed with the Setup operation, which will install CONVERT8.WIZ.
b. Microsoft's RFT-DCA conversion program for Word. If you don't see "Rich Text Format" in the "Files of Type" drop-down list when you open a file from within Word, you'll need to install it. You can download the conversion program from http://microsoft.com/office/ork/appa/appa.htm#dex18
Here are the steps to perform the batch operation:
a. Map a drive to the AS/400 directory that contains the OfficeVision documents with either AS/400 NetServer (in V4R2 and later) or Client Access. To map a drive to the OfficeVision directory on the AS/400, double-click Network Neighborhood, locate your AS/400, and expand it to the folder you want to map (OfficeVision documents and folders are in the QDLS directory). Right-click the folder for which you want to create a virtual drive, and select Map Network Drive from the menu. Select the drive letter you want to use, and click OK.
b. Open the CONVERT8.WIZ file, which displays an initial screen asking what task you want to perform.
c. Choose "A batch conversion of files."
d. Click on "From/To" and select "RFT-DCA" under "Convert from another format to Word."
e. Click "Folder Selection" and specify the mapped OfficeVision drive and the target drive in which to store your Word documents.
f. Click "File Selection" and choose the OfficeVision documents to convert. If you don't use DOS extensions in the OfficeVision names, you can display all the documents by selecting "*.* under "Type."
g. Click "Finish" to start the conversion.
25. Short Takes:
1. THIRD-PARTY OFFICEVISION-TO-WORD CONVERSION TOOLS
In addition to the method of converting OfficeVision documents to Microsoft Word described above, there are at least four third-party tools that perform this conversion:
DataJunction for WindowsDataJunction, Inc. http://www.datajunction.com
Filtrix for WindowsBlueberry Software http://www.blueberry.com/
TagWrite BookMaster TransformerTagWrite http://www.tagwrite.com/
WordPortAdvanced Computer Innovations http://www.acii.com/
2. IPL FREQUENCY FOR RISC SYSTEMS
Q. How often should I perform an IPL on RISC systems?
A. IBM hasn't published any requirements for IPL frequency. Some customers with large RISC systems choose to IPL quarterly or even less often, mostly to perform scheduled maintenance such as applying PTFs, installing a new release, and adding or changing hardware. Perhaps out of habit, most of IBM's large customers still IPL weekly.
IBM recommends that you IPL only occasionally in order to allow the system to clean up disk space used by jobs no longer in the system. The system also performs general system diagnostics during an IPL.
The following suggested IPL schedule is based on the percent of used system storage:
Percent used IPL Frequency
95% Daily90% Weekly<90 as="" br="" necessary="">Be aware that failure to perform regular IPLs can cause system problems, such as running out of disk space. If you are doing frequent IPLs because your system storage used percentage is high, you should really install additional system storage since the system may be unable to complete an IPL if it completely runs out of storage.
On RISC systems, it is no longer necessary to IPL to avoid running out of temporary addresses. Previously, large busy CISC systems may have had to be IPLed as often as weekly to avoid this problem.
Adapted from IBM Knowledgebase item 12065854
3. CALCULATING TCP/IP SUBNETS
IBM has provided a slick, simple online tool named the TCP/IP Subnet Calculator Advisor, which helps you calculate new equally sized subnets of IP addresses for class A, class B, and class C network addresses.
To use the calculator, go to http://publib.boulder.ibm.com/pubs/html/as400/v4r5/ic2924/info/index.htm, click "Networking," then "TCP/IP," and then click the fourth item down, "TCP/IP Subnet Calculator Advisor." Note that you must know your network address to use the calculator.
4. BACKUP/RESTORE RESOURCES
The following is a list of resources for backing up and restoring AS/400 systems:
a. IBM has published a lot of information on backup and restore strategies and products. If you need IBM manuals, Redbooks, or special documentation on this topic, check out the following Index400 categories:
System Management
This category includes a list of all of IBM's basic AS/400 backup and recovery manuals. http://www.as400network.com/index400/sysmgmt.htm
System View
This category includes IBM's Backup Recovery and Media Services/400 (BRMS/400) product. http://www.as400network.com/index400/sysview.htm
ADSTAR Distributed Storage Manager http://www.as400network.com/index400/adsm.htm
b. To view all backup and recovery articles and tips published by
NEWS/400 over the past several years, check out http://www.as400network.com/artarchive/index.cfm?fuseaction=ListArticlesByTopic&ID=8
c. If you can't find the backup and restore information you're looking for, you can always post a question in the System Management forum at http://www.as400network.com/Forums/Index.cfm?cfapp=60
26. CREATING A JOIN LOGICAL FILE
http://www.as400network.com/nwn/story.cfm?ID=7939
Q. I have two large physical files that I want to join as a logical file. What are the performance considerations for doing this? Is joining the files a more efficient method than reading one file and chaining to another?
A. You probably won't see a performance improvement using a join logical file. Efficiency isn't the primary purpose for creating such files. The reason for creating join logical files is to simplify program logic. Suppose I have to produce a report of all customers and their orders. It takes more program logic to sequentially read the Customer file and then use a SETLL (Set Lower Limit) and READE (Read Equal) loop with the Order file than to simply read sequentially through a join logical file comprising records from the Customer and Order files that were joined based on the common customer number field. The two programs will probably perform at about the same speed, but one will have simpler logic than the other.
You do pay a performance price for having join logicals (although not in the program that uses them). Any program that updates either of the base files also causes the access path for the join logical to be updated. Thus, those programs will suffer a performance penalty. This is similar to the penalty you pay whenever you add a new logical file to your system that doesn't share an access path with any other file.
You must decide how many logical files can be tolerated for each base physical file. This number depends on your in-house performance goals, mix of work, and the size of your processor and other computer resources (e.g., memory and disk).
Mike Cravitz, NEWS/400 Tech Editor
27. RESTORE CHANGES AUTHORITY
http://www.as400network.com/nwn/story.cfm?ID=7975
Q. We refresh data from our V3R2 production AS/400 to our V4R4 development AS/400. We perform a SAVLIB on the production system and then do a CLRLIB and RSTLIB on the development system. The restore runs fine, but no matter what we restore, we lose some of libraries' original authority. The owner of the library and *PUBLIC *USE retain their authority, but two other users who have *CHANGE authority lose theirs. The command we use is
RSTLIB SAVLIB(TEST) +
DEV(TAP01) +
MBROPT(*ALL) +
ALWOBJDIF(*ALL)
I'm stumped. Can you help?
A. Private authorities aren't stored with the object but with the user profile. Deleting an object removes the private authorities from the profile because the object no longer exists. Because you ran a CLRLIB command, the library's owner retains his or her private authorities, but you lose the private authorities for the objects in the library. When you restore the object, the private authorities aren't restored because they're not stored with the object.
To restore the private authorities, you must run the RSTUSRPRF command for the user profile that had the private authorities to the object, restore the object, and then run the RSTAUT command for that profile. The RSTAUT command returns the private authorities, but you must first restore the user profile because the RSTAUT command uses a table that's created when you run the RSTUSRPRF command.
Also, be aware that if you use authorization lists, the only way to restore them is to run a RSTUSRPRF USRPRF(*ALL) command to restore the object, followed by a RSTAUT for all user profiles. To run RSTUSRPRF, the AS/400 must be in a restricted state, so you can't run the command when users are signed on to the system.
Another option would be to run the GRTOBJAUT command to re-grant the private authorities after the restore.
Debbie Saugen, IBM Senior Business Recovery Specialist
28. Featured Tip:
QSPGETF AND QSPPUTF APIs AND COMMANDS
IBM Knowledgebase item 8011926 describes two APIs that are undocumented in the AS/400 manuals. The two APIs, Get Spooled File (QSPGETF) and Put Spooled File (QSPPUTF), copy spool files to and restore them from physical files, respectively. The advantage of QSPGETF and QSPPUTF over the well-documented Copy Spooled File command (CPYSPLF) is that the APIs are able to copy Advanced Function Printing Data Stream (AFPDS) and Intelligent Printer Data Stream (IPDS) spool files, whereas CPYSPLF cannot.
You can call the QSPGETF and QSPPUTF APIs directly, or you can call them using command wrappers over the APIs.
a. Calling the APIs Directly
The QSPGETF API call below saves spool file QPRINT to database file SPOOLDB in USER1LIB library, member MBR1, where the spool file number is 1 and the spool file job is 010160/user1/dsp03:
CALL PGM(QSYS/QSPGETF) PARM('QPRINT ' 'SPOOLDB USER1LIB ' +
'DSP03 USER1 010160' X'0001' 'MBR1 ')
The QSPPUTF API call below creates a spool file in USER1 output queue in QGPL library from the MBR1 member in the SPOOLDB database file:
CALL PGM(QSYS/QSPPUTF) PARM('SPOOLDB USER1LIB ' 'USER1 QGPL ' 'MBR1 ')
b. Calling the APIs from command wrappers
The two calls below correspond to the examples above, but these examples use the command calls instead of calls directly to the APIs:
GETSPLF FILE(QPRINT) TOFILE(USER1LIB/SPOOLDB) +
JOB(010160/USER1/DSP03) SPLNBR(1) TOMBR(MBR1)
PUTSPLF FROMFILE(USER1LIB/SPOOLDB) OUTQ(QGPL/USER1) +
FROMMBR(MBR1)
Although the QSPGETF and QSPPUTF APIs are included in every OS/400 release since V3R2, the commands are not included. Fortunately, you can obtain the compiled commands and the command source code from the Knowledgebase item, which can be found at http://as400service.ibm.com/8625680A007CA5C6/0/10AFE2F98C7F5FB9862565C2007D46A8?Open&Highlight=2,8011926
This item was adapted from IBM Knowledgebase item 8011926
29. Short Takes:
1. PASSING SUBFILE RECORDS TO A CALLED PROGRAM
Q. Is there any way to pass all the records in a subfile to a called program?
A. You can make subfile records available in a called program by defining the same display file in both the calling and called programs and sharing the open data path (ODP).
For example, suppose PgmA, which uses display file DspA, calls PgmB.
To make DspA's subfile records available to PgmB, define file DspA in PgmB. Then issue the command OVRDSPF FILE(DspA) SHARE(*YES) before calling PgmA. When PgmA calls PgmB, the ODP is shared and PgmB can read records from DspA. You don't need to write any of DspA's record formats from PgmB. However, for PgmB to compile, you need to reference at least one of them. Simply write an EXFMT statement and condition it so that it will never be executed.
From a Tech Corner answer by Gary Guthrie
2. SEU TIP: HIDING LINES WHILE EDITING
When you are working with source members that have many source lines, it is useful to exclude certain lines from the displayed member, allowing you to see lines from different areas of the source on the screen at the same time. Place X (Exclude) on any line you want to exclude from the display. This doesn't delete the line from the source member; it simply causes the excluded line(s) to be temporarily removed from the SEU display.
You can also use the X command in block format (XX). The example below shows how to exclude lines 3 through 6 (I entered a blank after the XX command to make it more readable):
*************** Beginning of data **************************
0001.00 111111111111111
0002.00 222222222222222
XX 3.00 333333333333333
0004.00 444444444444444
0005.00 555555555555555
XX 6.00 666666666666666
0007.00 777777777777777
****************** End of data *****************************
The result below shows that lines 3 through 6 have been hidden from view:
*************** Beginning of data **************************
0001.00 111111111111111
0002.00 222222222222222
- - - - ------------- 4 data records excluded ----------------------
0007.00 777777777777777
****************** End of data *****************************
To redisplay the lines, press F5 (Refresh) key, or use the SF or SL commands. SF (Show first) command shows the first excluded line, and SL (Show last) shows the last excluded line. You can also use SFn or SLn to show the first n lines or the last n lines of the excluded group of lines. The example below shows how to use the SF2 command to show the first two excluded lines:
*************** Beginning of data **************************
0001.00 111111111111111
0002.00 222222222222222
SF2 - - ------------- 4 data records excluded ----------------------
0007.00 777777777777777
****************** End of data *****************************
Notice below that the display shows the first two excluded lines and the text has changed to "2 data records excluded":
*************** Beginning of data **************************
0001.00 111111111111111
0002.00 222222222222222
0003.00 333333333333333
0004.00 444444444444444
- - - - ------------- 2 data records excluded ----------------------
0007.00 777777777777777
****************** End of data *****************************
One useful trick is to exclude all lines in an RPG source file in SEU by entering XX in the first and last lines of the member, then entering
F BEGSR
on the command line. This will exclude all lines except those containing "BEGSR". This is a great way to easily see all the subroutines in your program.
Adapted from "Desktop Guide to AS/400 Programmers' Tools" http://www.29thstreetpress.com
3. CONVERT STRING TO NUMBER USING C FUNCTIONS, PART II
In the July 14 Club Tech Programming Tips newsletter, I described how to convert a string to a number using C functions atoi (ASCII to Integer) and atof (ASCII to Floating point). Here is some follow-up information on those functions:
a. Several readers wrote asking why these functions weren't found on their system. The C functions are included in the "Common Programming APIs Toolkit," which comes free with OS/400. If it isn't on your system, install it from the OS/400 CD-ROM or tape.
b. In the July 14 item, I stated that the atoi function handles only digits. It also allows + and - signs. Oops.
c. IBM's Barbara Morris provided code that vastly improves the floating point number conversion with atof. The newer code also handles more input formats, including embedded commas and blanks, () and CR for negative values, leading or following +/- signs, as well as optionally allowing comma for the decimal point and period for the thousands separator. You can download her newer code from http://www.as400network.com/noderesources/code/clubtechcode/atof.txt
d. You can read more about the atoi and atof functions in the "ILE C for AS/400 Run-Time Library Reference" manual at http://publib.boulder.ibm.com/cgibin/bookmgr/bookmgr.cmd/BOOKS/QB3AT500/CCONTENTS
30. RETRIEVING DELETED RECORDS
I'm frequently asked how to retrieve deleted records from an unjournaled physical file when the deleted records have not yet been removed from the file.
Utility UNDEL lets you undelete records in a physical file. This public domain program is available in CISC and RISC versions, and the complete source code is available for download at:
UNDEL for AS/400 Save File (RISC): http://www.as400network.com/sharewarefiles/undelris.zip
UNDEL for AS/400 Save File (CISC): http://www.as400network.com/sharewarefiles/undel.zip
UNDEL for AS/400 Save File (Source code): http://www.as400network.com/sharewarefiles/undelsrc.zip
The utility takes advantage of the fact that deleted records in physical files are only flagged as deleted, and the record data still exists until it is overwritten or the file is reorganized with a utility such as RGZPFM. UNDEL simply reads the deleted record, then reuses the record by writing over it with the new record (thus eliminating the flag for the deleted record).
Some homegrown and commercial utilities copy the file containing undeleted records to a save file, then use a program to read the save file, which contains live and undeleted records, to a file to undelete the records. The UNDEL utility is superior to the SAVF technique because there's no need to copy the file to a save file, which is especially important for really large files.
When run, UNDEL displays the physical file records in their unformatted, raw text form. You can either position the display to a given relative record number or use F19 or F20 to find the previous and next deleted record, respectively. The utility also includes online help, which is almost unheard of for free utilities.
Other utilities include the ability to undelete records. You can use the RTVDLTRCD command in the old QUSRTOOL (no longer supported by IBM). QUSRTOOL is now a commercial product called TAA Productivity Tools ( http://www.taatool.com ). The free file editor WRKDBF has a built-in undelete capability ( http://www.wrkdbf.com ), and several commercial file editors can undelete records. For a complete list of file editors, go to http://www.sourcebook400.com, select "Programmer Tools" under "Product Category," then select "File Editors."
31. Short Takes:
1. FREE FAST PC SEARCH UTILITY
Your PC is overloaded with gigabytes of program code, e-mail messages, Word documents, and Adobe Acrobat versions of IBM manuals. How the heck do you search for text buried in all the data?
You could use the Find facility built in to Windows, but that means waiting for every file to be searched. And waiting. And waiting.
AltaVista, the search engine folks, have a free utility called AltaVista Discovery that you can download from the Internet. Once installed, the utility indexes any or all of your local or mapped disk volumes. It can index nearly any document type, including e-mail and PDF files, and any file you add (such as .RPG, .CL, .DDS, and so on). Discovery updates its index as often as you want, and it can be configured to run automatically any time and day of the week.
The Discovery search bar can be called from the Windows system tray, locked on a screen border or browser window, or configured to always stay on top of all windows. You enter search terms in the Discovery search bar in the same way you enter them in the AltaVista Internet search engine. The search results appear in a browser window in the same format as they do on the Web. You can click on any of the result links to run the associated program for the found file.
AltaVista Discover can be downloaded from http://discovery.altavista.com/
2. EXCEL DATA TRANSFER ADD-IN
Q. I used to have an option within Excel 97 to transfer data from the AS/400 directly into an Excel spreadsheet, but this option disappeared after I installed Microsoft Office 2000. I'm running Client Access V3R2 and OS/400 V4R4. Do you know how I can reinstate this option?
A. Upgrading to Office 2000 removes the Client Access Excel Data Transfer Add-In that the Client Access installation added to Excel 97. Although you could restore this add-in by reinstalling Client Access, there's an easier way to replace it. First, start Excel 2000, and then select the Tools menu and the Add-Ins option. Doing this displays Excel's Add-Ins dialog box. To add the Client Access Data Transfer Add-In to Excel 2000, click Browse and then navigate to the \Program Files\IBM\Client Access\Shared directory. Select the cwbtfxla.xll file, and then click OK.
Make sure that the Transfer Data From an AS/400 option is checked, and then click OK to add the Client Access Data Transfer Add-In to the Excel 2000 environment. Excel then adds a new Transfer Data from an AS/400 option to its toolbar and Data menu.
Incidentally, if you installed Excel 95 or 97 after installing Client Access Express, you will also have to manually install the add-in as described above.
Adapted from an answer by Michael Otey
3. MANAGING QSYS.LIB OBJECTS WITH WRKAUT AND CHGAUT
Q. Can I use WRKAUT and CHGAUT to manage objects in the QSYS.LIB file system?
A. Yes. Simply specify the QSYS object using a path name. For example, DSPAUT OBJ(/qsys.lib/cjw.lib/myfile.file) displays the authorities on the file CJW/MYFILE.
From a Tech Corner answer by Carol Woodbury
32. AUTOMATE REMOTE PRINTER STARTUP
http://www.as400network.com/nwn/story.cfm?ID=8012
Q. I want our remote printers to automatically start when I IPL our V4R4 AS/400. How can I do this?
A. At IPL time, the AS/400 runs its startup program, which is typically a CL program. You can add commands (such as STRRMTWTR to start remote writers) to this CL program. Presuming your startup program is a CL program, here's a short set of instructions for modifying your startup program.
1. Determine your startup program (and its library) using the command DSPSYSVAL QSTRUPPGM.
2. Retrieve the source for this program using the following command:
RTVCLSRC +
PGM(YourLib/StartupPgm) +
SRCF(YourLib/YourSrcFile)
3. Edit the source you just retrieved, adding your commands at the appropriate location as necessary.
4. Compile the program.
Now when you IPL, the startup program will execute the commands you've added. Note that if you change the startup program's name, you'll have to modify system value QSTRUPPGM to match.
Gary Guthrie, NEWS/400 Tech Editor
33. SAVSTG AND BACKUP
http://www.as400network.com/nwn/story.cfm?ID=8031
Q. Can I use the Save Storage (SAVSTG) command to back up my system?
A. The SAVSTG command, which copies the Licensed Internal Code (LIC) and all disk-unit data to tape, isn't a good backup strategy for today's AS/400 environment. The tape that's produced is a sector-by-sector copy of all permanent data on all configured disk units. But you can't restore individual objects from the SAVSTG media.
The SAVSTG process once provided a fast, one-step method for backing up an entire system's data. But with today's tape technology, faster system processors, and improved save processing, Save Menu Option 21 can provide an even faster way to save your entire system. And with Save Menu Option 21, you can restore individual objects.
The SAVSTG process has other important considerations. For example, on RISC processors, you must use the Save Configuration (SAVCFG) or Save System (SAVSYS) command to save the system's hardware configuration information. The Restore Storage process uses the SAVCFG or SAVSYS media to restore this information.
Also, in a disaster-recovery situation where you must restore your entire system data to a new system, the new system's disk configuration must be the same as that of the system on which the SAVSTG occurred. The disk types and models must be the same or equivalent with some additional devices. (Serial numbers and physical addresses don't have to be the same.) All the disk units that were saved are required for the restore operation.
One final, major drawback of the Save and Restore Storage process is that if you encounter a media error while restoring your system, there's no recovery from this situation. None of your data can be recovered.
If you still want to use SAVSTG, you must always complement it with either Save Menu Option 21 or the equivalent SAVSYS, SAVLIB (Save Library), SAVDLO (Save Document Library Object), and SAV (Save Object) commands. Also, you should have multiple levels of your backup media. For more information about implementing backup and recovery strategies, visit the AS/400 Information Center Web site at http://www.as400.ibm.com/infocenter
Debbie Saugen, IBM Senior Business Recovery Specialist
34. ASSIGNING A DEVICE NAME WITH CLIENT ACCESS
http://www.as400network.com/nwn/story.cfm?ID=8066
Q. When we use Client Access with a TCP/IP connection, how can we assign a permanent device name? The system currently selects a device named QPADEVxxxx (where xxxx varies), but it isn't the same each time we connect to the system.
A. Client Access Express lets you assign a permanent device name when you configure your session. To supply the device name, fill in the box for Workstation ID when you create a session.
Gary Guthrie, NEWS/400 Tech Editor
35. RETRIEVE CURRENT JOB'S CALL STACK
A glance at the AS/400 newsgroups and forums reveals many requests for a program to retrieve the current job's call stack. Although there is a way to do this via MI calls, it's complex. The RPG IV provided in this tip uses a simpler method to provide this function.
The program sends messages up the call stack one at a time (to a maximum of 10 entries) until the top is reached. For each send, a retrieve is also performed and the receiving program name is captured. The program has three parameters: PStack (call stack returned), PStartPoint (relative starting point), and PEntries (number of entries returned).
When you call the program, set the PStartPoint parameter to the call stack entry at which you want to start. Entries are returned starting with the latest entry in the first array element. You can easily modify the program to include more or fewer call stack entries.
You can download the RPG IV program from http://www.as400network.com/noderesources/code/clubtechcode/rtvcalstk.txt
This item was adapted from a NEWS/400 tip by Adam White
36. Short Takes:
1. RUNNING NT COMMANDS FROM THE AS/400
Q. How do I run a program on NT from the AS/400?
A. The most common method is to use the AS/400 RUNRMTCMD with the Client Access Remote Command Service, which is explained in depth in the IBM Knowledgebase document at http://as400service.ibm.com/8625680A007CA5C6/0/18F3F1C10E862A3D862565C2007CB4A3?Open&Highlight=2,9035356
If you don't have Client Access, you can purchase a third-party product that lets NT run remote commands. One product recommended often in the AS/400 newsgroups and forums is Denicomp Systems' REXECD/NT, which you can download from http://www.denicomp.com/
2. SEU TIP: MORE LINE HIDING
I received some suggestions on further using the technique in last issue's tip "Hiding Lines While Editing."
In the tip, I showed a way to exclude all lines except those containing "BEGSR". I said you enter XX in the first and last lines of the member and then enter
F BEGSR
on the command line. This shows only the first BEGSR. I should have used the following:
F BEGSR A
which shows all BEGSR statements. Also, an alternative to using XX in the first and last lines to hide all lines in a member is to use the Hide command as follows:
H ' '
which hides every line with a blank (this is usually every line in the member).
The Find command is not only useful for locating BEGSR statements but is very helpful in showing all the lines containing a specified field. So, for example, hiding all lines then entering the command
F BEGDAT A
will show every line containing the string BEGDAT.
The above techniques work when editing or browsing a source member.
One difference when using the above Hide and Find commands in browse mode is that the lines noting how many records have been excluded from display (e.g., "--- 39 records excluded ---") don't appear. This may be useful if you want to make the most use of your 24-line 5250 session.
Thanks to Bob Antaki, Clive Phelan, and Neil Cockburn for the suggestions
3. RECALLING COMMANDS IN NT'S FTP CLIENT
How many times has this happened to you: You've just entered a rather long PUT command to transfer a file to the AS/400 in the Windows ftp client, only to discover that you mistyped one character in the long command string. Doh!
If you're using ftp.exe in Windows 95 or 98, you're stuck either retyping the command or doing a copy/paste operation in the DOS window. In Windows NT, however, you can recall any previous ftp commands using the up arrow key, position the cursor within the recalled command using the left and right arrows, and edit the command. You can also select previous ftp commands from a pop-up window by pressing F7.
Incidentally, this command history is also built into the Windows NT command shell, and you can use the up arrow to recall previous DOS commands in the command shell prompt. In the Windows 95/98 DOS window, you can enter DOSKEY at the DOS prompt to invoke the command history function (note that although this lets you recall previous DOS commands in Windows 95/98, it won't work for ftp.exe commands).
4. OS/400 V4R5 LIMITS
The July 19 issue of this newsletter had a URL for "AS/400 V4R4 Maximum Capacities," which contains the limits on AS/400 communications, work management, file system, database, and so on. IBM has now published the V4R5 limits at ftp://www.redbooks.ibm.com/redbooks/GA195486/limitv45.pdf
37. DEBUGGING PROBLEM
http://www.as400network.com/nwn/story.cfm?ID=8088
Q. I'm having problems with the STRISDB tool when debugging an OPM Cobol or RPG program. When I compile my program with the debugging option, the line numbers are incremented by 100, and after line 99,999, the program lines all have the same number. When I try to set a breakpoint, it's lost on lines after 99,999. How can I work around this problem?
A. By default, the SEU editor sequences your lines starting at 1.00 by increments of one. When you insert lines, the editor uses the positions past the decimal point. For example, when you try to insert a line between line 1.00 and 2.00, the editor assigns a line number of 1.01 to that line. ISDB doesn't work with decimal points, so it treats line 1.00 as if it were line 100, line 2 as 200, and so on. In other words, ISDB uses these sequence numbers and ignores the decimal point. The result is that each sequence number in ISDB is a factor of 100. To circumvent your problem, perform the following steps:
1. Edit your program with SEU.
2. Press F3 to exit your edit session.
3. Specify Y for Change/Create member.
4. Specify Y for Resequence member.
5. Specify 0000.01 and .01 for Start and Increment, respectively.
6. Press Enter to resequence and save your program.
7. Recompile your program.
These steps force ISDB to sequence your program beginning with 1 and with an incremental factor of 1, allowing up to 999,999 source statements.
Mike Cravitz, NEWS/400 Tech Editor
38. SYSTEM RECOVERY
http://www.as400network.com/nwn/story.cfm?ID=8113
Q. I'm currently working on a backup and recovery plan. Where can I find the steps needed to recover my entire system?
A. See Chapter 9 ("Selecting the Right Recovery Strategy") of OS/400 Backup and Recovery (SC41-5304) to determine the best way to recover your system. Before beginning your recovery, you should do the following:
* If you must recover because of some system problem, make sure you understand how it occurred so you can choose the correct recovery procedures.
* Plan your recovery. If you had a disk failure, refer to the section titled "Choosing the Recovery Procedure for a Disk Failure or Disk Errors" (in Chapter 3 of OS/400 Backup and Recovery) to find the appropriate recovery checklist for your situation.
* Make a copy of this checklist and mark off each step as you complete it. Keep the checklist for future reference.
* Keep a record of every step you take during your recovery. This record is important if you need help later.
* If your problem requires hardware or software service, make sure you understand exactly what the service representative did. Don't be afraid to ask questions, such as:
- "Did you replace a disk unit? If so, which one?"
- "Did you restore the LIC? If so, what option from the Install LIC menu did you use?"
- "Did you need to recover the disk configuration? Was it successful?"
- "Could the failed disk unit be pumped? How successfully?"
OS/400 Backup and Recovery for V4R5 includes a new appendix called "Recovering Your AS/400 System," which provides step-by-step instructions for completely recovering your entire system to the same system (i.e., restoring to a system with the same serial number). You can use these steps only if you saved your entire system using either Save Menu Option 21 or the equivalent SAVSYS, SAVLIB, SAVDLO, and SAV commands.
For V4R1 through V4R4, you can find new step-by-step restore instructions titled "Checklist for Recovering your AS/400 at V4R1, V4R2, V4R3, and V4R4" at http://as400service.rochester.ibm.com/supporthome.nsf/Document/10000051 Select "OperatingSystem," and search for "Checklist" at the ensuing page.
Continue to use the checklist titled "Recovering Your Entire System After a Complete System Loss" in Chapter 3 of OS/400 Backup and Recovery to completely recover your system in any of the following situations:
* Your system has logical partitions.
* Your system uses the Alternate Installation Device Setup feature that you can define through Dedicated Service Tools.
* Your system has mounted user-defined file systems before the save.
* You're recovering to a different system (a system with a different serial number).
Debbie Saugen, IBM Senior Business Recovery Specialist
39. QZDASOINIT JOB PROBLEM
http://www.as400network.com/nwn/story.cfm?ID=8108
Q. One of our AS/400s has a third-party report-writing product installed on it. Whenever a user runs a query through the report writer, the QSERVER prestart job QZDASOINIT is initiated. This job eventually uses the system resources and locks up the AS/400. Do you know why this is occurring and how to correct it?
A. The most likely cause of a query that locks up your AS/400 is that the query builds either a large index or an index that exceeds the working limitations of the underlying file design. This can occur when a query is submitted from an AS/400 session or via a PC session using an ODBC driver (as indicated by the QZDASOINIT job). Double-check the request being submitted via the report-writing application to make sure it will use an existing index. If you can access the job after it's initiated but before the request is submitted, you can change the job's query attributes to diagnose the indexes and processing time that will be used. To do this, execute the command
CHGQRYA JOB(NBR/USER/JOB) +
QRYTIMLMT(0)
If you can't access the job before the request is submitted, you can also temporarily change the system value QQRYTIMLMT to zero. Either change causes the system to produce a job log that shows the data access plan that will be used and the estimated processing time.
If the query is submitted against a larger file (e.g., 4 GB) or if the query will result in a join of two smaller files that creates an index that approaches 4 GB, also make sure the indexes (and physical file) have the attribute set to allow processing of access paths of up to 1 TB. To do this, use the command
CHGLF FILE(LIB/FILE) +
ACCPTHSIZ(*MAX1TB)
Processing large files with the maximum access path set to the smaller value of 4 GB (the previous limit) also causes system lockups.
Terry Smith, NEWS/400 Tech Editor
40. RETRIEVING THE IP ADDRESS FROM A TELNET SESSION
Q. How do I retrieve the IP address of an AS/400 Telnet session?
A. The three solutions below use the QDCRDEVD (Retrieve Device Description) API to retrieve a Telnet session's IP address:
a) Retrieve an IP Address via a CL Program
This Tech Corner item, answered by Gary Guthrie in the July 2000 issue of NEWS/400, provides the RtvIPAddr command written in CL. You can read the article at http://www.as400network.com/article.cfm?ID=7559 and download the code from http://www.as400network.com/resources/code/ .(Note: To read the article, you must be a professional member of the AS400 Network.)
b) Retrieve an IP address via a C program
The V4 TCP/IP for AS/400: More Cool Things Than Ever (SG24-5190) Redbook contains a C program in Chapter 13 that retrieves the IP address. You can download the Redbook from http://www.redbooks.ibm.com/abstracts/sg245190.html and download the Redbook source code from ftp://www.redbooks.ibm.com/redbooks/SG245190/ .
c) SHOWIP utility
You can find this free utility at http://www.shareware400.com and download it directly from http://www.ignite400.org/software/showip.zip.The zip contains an AS/400 save file containing the compiled utility but no source. Here's a sample display from this utility:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
System . . . . : S1099999
Type options, press Enter.
5=Work with Device Status 8=Work with User Job
Opt Device UserId IpAddress HostName
_ QPADEV0001 HOOPES 69.999.99.196
_ QPADEV0003 CHUCK 208.99.99.52
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
41. Short Takes:
1. GUIDES TO AS/400 RISC PROCESSORS AND FEATURES
For some time now, IBM has made available a complimentary set of resources that let you configure AS/400s. It's a combination of two Redbooks and a PC-based AS/400 configuration program called PCAS400, described below.
AS/400e System Builder (SG24-2155-05)
The comprehensive guide for AS/400 configuration and installation support, this Redbook provides all AS/400 RISC model product numbers, feature codes, and prerequisites. http://www.Redbooks.ibm.com/abstracts/sg242155.html AS/400e System Handbook (GA19-5486-20)
A good reference when looking up all available AS/400 options. Think of the Handbook as providing a broader overview of AS/400 hardware and software offerings, with the system builder manual providing the configuration details. http://www.Redbooks.ibm.com/abstracts/ga195486.html IBM Portable Configurator for AS/400 (PCAS400)
This handy, free PC program configures any recent AS/400 RISC model. It walks you through the configuration with a wizard-like facility, which provides a list of all available features and error-checks the feature selections for needed prerequisites. One notable feature is that PCAS400 lists U.S. prices for the configured hardware and software.
You can download PCAS400 and the most recent U.S. price list from http://www.as400.ibm.com/configure/Pcas400.htm The price list is updated often, so check the site before configuring a system. The currently available price list was updated on August 17, 2000. Both Redbooks are also updated often, so it's a good idea to check every few months for a new edition.
2. GUIDE TO AS/400 CISC PROCESSORS AND FEATURES
For those of us stuck using old CISC AS/400s (aka "the white boxes"), we know all too well how difficult it is to find online resources with information about upgrade paths or product feature codes for our old systems. Fortunately, IBM has just released the AS/400 CISC System Builder Redpaper (REDP0042) at http://www.redbooks.ibm.com/redpapers/abstracts/redp0042.html . The book details the configurations and features of the 9401, 9402, 9404, and 9406 models and also helpfully lists the pricing group in which each model appears.
3. DHCP SERVER ADMINISTRATION PROGRAM FOR WINDOWS 95/NT
IBM buries little utility program gems around its Web site, and I've just dug one of them up. For those using Dynamic Host Configuration Protocol (DHCP) server on the AS/400, you might want to check out the DHCP Server Administration Program for Windows 95/NT at http://www.as400.ibm.com/tstudio/TECH_REF/tcp/dhcp/index.htm . It's a Java application that lets you request IP address, client, and server information.
If you're interested in DHCP, you can read more about it in AS/400 TCP/IP Autoconfiguration: DNS and DHCP Support, SG24-5147-00, and at http://www.redbooks.ibm.com/abstracts/sg245147.html
V4 TCP/IP for AS/400: More Cool Things Than Ever, SG24-5190-00 http://www.redbooks.ibm.com/abstracts/sg245190.html (Look in chapter 9, "Getting started with DHCP on the AS/400 system.")
DHCP FAQ http://www.dhcp-handbook.com/dhcp_faq.html
42. PRINTING TO A SPECIFIC DRAWER
http://www.as400network.com/nwn/story.cfm?ID=8161
Q. I need to copy a workstation customization object to a printer so I can choose a particular drawer for AS/400 print jobs. The printer is an HP8500 series. I can't find an existing WSCST description, and I'm unsure where to make changes.
A. Because the HP8500 is a color printer, it should respond similarly to the HP8000 or the HPCOLORLJ. You can use the RTVWSCST command to retrieve the source for these printers and then modify the source to see which one suits your needs. To find the commands to create, change, or override a printer's drawer specifications, issue the following command:
:DWRSLT +
DRAWER=DRAWER1 +
DATA ='1B266C3148'X.
You can print to extra drawers from the AS/400 if your printer has more than two drawers To do so, change the DATA line to the HPCL command in the HP8500 manual to select the extra drawer. After you modify the source, use the CRTWSCST command to compile it.
However, if you want to select only one of the existing two drawers, specify drawer selection under the OVRPRTF command without executing Host Print Transform.
Terry Silva, Systems Programmer, Ricks College
43. Short Takes:
1. INCORPORATE THE COMMAND LINE INTO AN APPLICATION
Q. I want to replace an AS/400 menu with a menu program that looks and works like the original menu. How can I replicate the AS/400 command line in my program, including the ability to retrieve previous commands using F9?
A. You should check out a NEWS/400 article published way back in May 1995 titled "A Command Line from Anywhere." The article includes CL program CMDLINE, which uses APIs QMHRTVRQ, QCAPCMD, and QMHMOVPM to provide a fully functional command line that you can incorporate into your application. CMDLINE, like the AS/400's command line, can do the following:
a. Provide an input field into which the user can type OS/400 command strings.
b. When the user presses F4, invoke the CL command prompter using the entered command string; add the changes entered through the prompter to the command string.
c. Check any entered command string for valid CL syntax.
d. Determine whether the current user profile has limited capability (LMTCPB(*YES)) and, if so, whether the entered command string is valid under limited capability.
e. Execute any command string that is valid under items 3 and 4.
f. Display on the screen's message line all messages returned from the command string execution.
g. Save all executed command strings, including the changes entered through the prompter, to the job message queue.
h. When the user presses F9, retrieve the previously executed command string from the job message queue and display it in the command line input field.
i. When the user presses F9 repeatedly, retrieve previous command strings in descending order of execution.
The NEWS/400 article also provides a sample RPG program that demonstrates how to integrate a fully functional command line into a standard work-with screen. Note that only AS400 Network professional members can read the above NEWS/400 article, but anyone can download the code at http://www.as400network.com/resources/code/ .
2. CHANGE SIZE PARAMETER DEFAULT TO *NOMAX
Q. Every time I create a physical file, I'd like the default value for the SIZE parameter to be *NOMAX. How do I do this?
A. Use the Change Command Default (CHGCMDDFT) command to change the default value for CRTPF's SIZE parameter. Beware, though, that if you specify *NOMAX without specifying the other two elements in the list, you'll run into a snag -- the attempt fails with diagnostic message CPD6273 ("Single value not valid default value"), which has a severity level of 40. You then get escape message CPF6260 ("Errors detected while changing defaults"), which aborts the attempt. The solution is to specify all three values for the SIZE parameter, like this:
CHGCMDDFT CMD(CRTPF) NEWDFT('SIZE(*NOMAX () ())')
or like this:
CHGCMDDFT CMD(CRTPF) NEWDFT('SIZE(*NOMAX *N *N)')
where *N represents a null value. *NOMAX is now the first of three values; although the other two values are null, they have been specified.
Use *NOMAX in the SIZE parameter with caution, as a runaway job could eat up all your DASD.
Answer adapted from a Tech Corner item by Gary Guthrie
3. DISPLAY THE COMMAND STRING
When you use CL command prompter (F4) to enter a command, you don't need to exit and press F9 to retrieve the command to view the command string. You can simply press F14 while you're still in the command's prompt screen to display the command string.
4. MODIFY IBM EDIT CODES
Q. Can I modify the IBM-shipped edit codes 5 through 9, or is that not permitted because an OS/400 program uses them? I want to use edit code 9 to display a YYMMD date format from a six-digit field.
A. Yes, you can modify edit codes 5 through 9 for your own purposes although IBM predefines them. To work with edit descriptions, type GO CMDEDTD at an AS/400 command line to display a list of the available edit description commands. Note that you can't actually modify the edit description; instead, you must delete it with the DLTEDTD command and then create a new one with the CRTEDTD command. You can find more information about creating user-defined edit descriptions in Application Display Programming (SC41-5715).
As an alternative to changing the user-defined edit descriptions, you might consider using edit words. Edit words provide maximum flexibility in creating edit masks.
Answered by Gary Guthrie
44. FTPING FROM THE AS/400
http://www.as400network.com/nwn/story.cfm?ID=8185
Q. I need to automate a file transfer from the AS/400 (V4R2) to my PC. I have no problems transferring the file manually using Client Access, but when using the FTP command from the AS/400, I receive this message: "Cannot connect to host 192.95.95.176 at address 192.95.95.176. . . Try again later." I can ping the PC device and can Telnet from the PC to the AS/400, among other things, but nothing helps.
A. To FTP to a computer, that computer has to be running an FTP server. Windows 3.1/9x doesn't provide FTP server capability out of the box; you have to add software. Microsoft's Personal Web Server provides an FTP server as well as an HTTP (Web) server. You can also try the War FTP Daemon, which is free and available at http://www.jgaa.com/tftpd.htm . After you set up the FTP server on your PC, you should be able to connect to it from your AS/400 to transfer files.
Bill Shaffer, IBM Brand Manager
45. PRINTING AFP FONT COLLECTION SAMPLES
If you're having a difficult time finding the fonts you need in the AFP Font Collection (5648-113 or 5648-B45) because of the overwhelming number of libraries, IBM has provided two free commands that load and print samples of all the fonts in the Font Collection.
The commands LOADFNTC and TESTFONT are provided in a save file, which can be downloaded from http://www.printers.ibm.com/r5psc.nsf/web/rdfont01
46. Short Takes:
1. SENDING MESSAGES THAT USERS CAN'T IGNORE
OS/400 is great at sending messages, but often users have better things to do than pay attention to every message that comes their way, and they may overlook important messages. The SNDWDWMSG utility helps ensure that busy users see - and acknowledge - messages you want to ensure aren't ignored.
SNDWDWMSG displays a message on the user's screen in a window with red borders. The user can't do anything until the message is acknowledged by pressing F21, to remove the message from the message queue, or F22, to keep the message in the queue. Either function key removes the message from the screen.
You can read more about the SNDWDWMSG at http://www.as400network.com/article.cfm?ID=1729, and you can download the May 1997 utility from http://www.as400network.com/resources/code/ . I've also packaged the compiled utility, with source code, in a save file you can download from http://www.as400network.com/noderesources/code/clubtechcode/sndwdwmsg.zip .
2. AS/400 REMOTE ACCESS CONFIGURATION EXAMPLES
IBM has just released a preliminary version of a Redbook titled AS/400 Remote Access Configuration Examples (SG24-6058-00). The Redbook helps you to install and configure the newer remote access hardware by showing a variety of examples, from simple to complex.
Here are the main chapters covered in the Redbook:
Introduction to ISDN and Integrated Modem SupportAnalog connections using 2761 modemISDN connections using 2751 ISDN cardISDN/Analog connections using 2761 modem and 2751 ISDN card7852 modem and 2761 modem SLIP connections Problem analysis and resolutionAdvanced topics (CHAP, Multiple connection profile, Data over voice, PPP dial-on-demand remote peer enabled)ISDN trace dataISDN cause codes
You can download a PDF version of the Redbook from http://www.redbooks.ibm.com/redpieces/abstracts/sg246058.html .
3. VIEWING LOCKS ON DLOS
Q. Do you know of any way to view locks on a Document Library Object (DLO) within a folder? For example, say you created a file in a shared folder using the CPYTOPCD command and you have a networked drive to that shared folder from a Windows NT Workstation running Client Access for Windows 95/NT. If a user opens the file from the NT PC, is some type of lock shown on the AS/400?
A. It's possible to view locks on DLO objects, but doing so requires a little effort. Follow these steps:
Use the DSPDLONAM command to find the "system object name" of the document. For example, if the path shown on the client is /QDLS/MYFOLDER/MYSUBDIR/MYDOC, use the following statement:
DSPDLONAM +
DLO(MYDOC) +
FLR(MYFOLDER/MYSUBDIR) +
OBJCLS(*DOC)
Several pieces of information should be displayed, including a system object name consisting of 10 characters and an auxiliary storage pool (ASP) ID. The system object name is the "real" name of the object in an AS/400 library. The library name is determined by the ASP. If the ASP ID is 1, the library name is simply QDOC. If the ASP ID is greater than 1, the library name takes the form QDOCnnnn, where nnnn represents the ASP. For example, if MYDOC is in ASP 2, the library name is QDOC0002.
Once you've determined the system object name and library name, use the WRKOBJLCK command to display object locks on the document. For example:
WRKOBJLCK +
OBJ(QDOC/LNM1453888) +
OBJTYPE(*DOC)
Lock information should be displayed for any job that currently has the document open. Additional locks might be displayed.
An important point to note is that a document need not be open nor the object be locked to be considered "in use." For example, there are other types of commonly used locking schemes, some as simple as setting a bit in a shared memory location. It would be difficult for a user to find such a "lock." And even when it's possible to see the lock, it may not be possible to determine the lock holder if no job information has been stored.
From a Tech Corner item by R.J. Traff
4. SETTING A HIGHER PRIORITY FOR OPERATORS
Q. How can I set a higher system priority for the system operator?
A. You can use work management techniques and principles to let your system operator run interactive jobs at a priority higher than other users on the system, which may be necessary at times so the system operator can respond to unusual system situations. One solution is to have the system operator sign on at the system console; console jobs automatically run at a higher priority because they run in the QCTL (Control) subsystem. QCTL routes console jobs using the QCTL class, which specifies a higher priority than default priorities usually assigned to other users.
To build a new routing entry that uses the QCTL class (or any other class you create), follow these steps:
a. Add a routing entry to the interactive subsystem with unique routing data, and specify the QSYS/QCTL class. For example:
ADDRTGE SBSD(QINTER) +
SEQNBR(8888) +
CMPVAL(SYSOPR) +
PGM(QSYS/QCMD) +
CLS(QSYS/QCTL)
b. Create a new job description for the operator, using the same routing data you used on the routing entry. For example:
CRTOBD JOBD(SYSOPR) +
RTGDATA(SYSOPR)
Other parameters may also be necessary. Consider creating a duplicate of the QDFTJOBD job description and then changing the routing data for the duplicate job description.
c. Change the operator's user profile to specify the new job description:
CHGUSRPRF USRPRF(DJONES) +
JOBD(SYSOPR)
Answer by Bryan Meyers
47. VIEWING MESSAGES SENT VIA SNDPGMMSG
http://www.as400network.com/nwn/story.cfm?ID=8188
Q. We have a program that's submitted in batch job through the job scheduler. This program sends messages via the command SNDPGMMSG MSG(&MSGDTA). Where can I see those messages?
A. Your messages are being sent to the program message queue. You can see these messages in the job log using the DSPJOBLOG (Display Job Log) command as long as the job is active. Interactively, a job is active until you sign off. For batch jobs, the job is no longer active when the job ends.
If you set your job's logging levels appropriately, a job log is spooled when the job ends. Because the job scheduler submits jobs to batch, you must set these logging levels in order to see the messages in a spooled file after the job is completed. You control the logging levels in the job description's LOG parameter or in the SBMJOB command. Typically, you use LOG(4 0 *SECLVL) whenyou want to always spool a job log upon job completion.
Gary Guthrie, NEWS/400 Tech Editor
48. ACCESSING OUTPUT QUEUE INFORMATION
http://www.as400network.com/nwn/story.cfm?ID=8190
Q. We're developing a GUI front end to AS/400 applications using Windows MFC. We're using Client Access ODBC to talk to the AS/400. How can we access output queue information?
A. ODBC was designed for working with relational databases and as such doesn't directly support output queue information. ODBC does support remote program invocation calls to AS/400 programs, so you can write your own AS/400 programs for output queue information.
The Client Access Express APIs represent an easier way to work with spool file and output queue information from your C++ program. These APIs let you read and write to spool files and manage output queue information. You'll find reference information at the IBM AS/400 Information Center (http://publib.boulder.ibm.com/pubs/html/as400/v4r4/ic2924/info/INFOCENT.HTM).You can find code samples showing how to use the Client Access APIs at http://www.as400.ibm.com/tstudio/workshop/snippets/snippets.htm.
Terry Smith, NEWS/400 Tech Editor
49. PRINTING FROM A REMOTE AS/400
http://www.as400network.com/nwn/story.cfm?ID=8309
Q. I have an AS/400 (A) connected to another AS/400 (B) over a frame relay network running TCP/IP on an Ethernet LAN. AS/400 A has users with local HP printers attached to their PCs. These users connect to AS/400 B to use an application that requires printing to local printers. We use PC5250. Can I set up remote output queues on AS/400 B and point them to the local PC printers on AS/400 A? If yes, which address do I specify when I specify the printer's IP address?
A. There are two ways to print from a remote AS/400 to printers on your local system. If the printers are attached to PCs, configuring a printer session from PC5250 creates an output queue on your local AS/400. You then create an output queue on your remote AS/400 that points to the output queue on the local AS/400 using the CRTOUTQ command as follows:
CRTOUTQ OUTQ(xxx) +
RMTSYS(xxxx) +
RMTPRTQ(xxx) +
CNNTYPE(*IP) +
DESTTYPE(*OS400) +
TRANSFORM(*N+O)
The output queue name can be anything. Your local AS/400's IP name is the remote system (RMTSYS), and the name of the output queue is the remote printq (RMTPRTQ). The output queue can use the STRRMTWTR command.
If the printers aren't attached to a PC but contain network cards that let them connect to the network, create a printer device or remote output queue on the remote AS/400 just as if the printer was attached to the same local network as the remote AS/400.
Terry Silva, Systems Programmer, Ricks College
50. Featured Tip:
CUSTOMIZING PRINTER SEPARATOR PAGES
Way back in May 1994, NEWS/400 published an article titled "Customizing Printer Separator Pages." The RPG program, SEPPAG, prints large block letters so that separator pages stand out easily from your production reports. The user profile name appears at the top of the page, followed by the job name and number. In smaller fonts, job separators (which are printed between jobs) show the job run date and time, and file separators (which are printed between different reports in the same job) show file name and number, the number of report copies, the number of pages in each copy, and any user data defined for the printer file.
Once you compile SEPPAG, you can indicate that a printer device use customized printer separator pages by entering SEPPAG in the SEPPGM parameter in the CRTDEVPRT (Create Device Description (Printer)) or CHGDEVPRT (Change Device Description (Printer)) commands.
You can download the SEPPAG RPG program from http://www.as400network.com/noderesources/code/clubtechcode/seppag.zip .
Adapted from a program and article by Bryan Meyers
51. Short Takes:
1. SAMPLE AFP RPG AND DDS SOURCE CODE
Buried deep within IBM's Printing Systems Web site ( http://www.printers.ibm.com ) are some programming resources for those who use Advanced Function Printing (AFP) on the AS/400. One such resource, called the "AFP AS/400 Programming Sampler," is a collection of RPG and DDS coding examples showing how to produce bar codes, Postnet mailing labels, invoices, page segments, scalable fonts, electronic overlays, and so on.
The Sampler can be downloaded from http://www.printers.ibm.com/R5PSC.NSF/Web/4sample . If you download the self-extracting zip file, you'll need to unzip it in DOS - real DOS, and not a Windows 9x or NT DOS command window. Obviously, not everyone can reboot their machines to run in DOS mode, so I've made the Sampler available as a Windows self-extracting zip file, at http://www.as400network.com/noderesources/code/clubtechcode/samplerw.exe .
2. TESTING FOR AN ACTIVE PROCEDURE
The IF ACTIVE function was used extensively in S/36 procedures to test whether another procedure was running. It was a very useful feature that has no direct counterpart on the AS/400.
One way to replicate the S/36 IF ACTIVE function in OS/400 is with data areas. In the following example, CL program PROCA is the program we want to test for, and PROCB tests to see whether PROCA is executing.
CL Program PROCA
CRTDTAARA DTAARA(MYLIB/PROCA) TYPE(*CHAR) LEN(1) +
VALUE('0') TEXT('DATA AREA FOR PROCA ACTIVE TEST')
CHGDTAARA DTAARA(MYLIB/PROCA) VALUE('1')
*
*
other CL code for PROCA
*
*
CHGDTAARA DTAARA(MYLIB/PROCA) VALUE('0')
CL Program PROCB
DCL VAR(&ACTEST) TYPE(*CHAR) LEN(1)
*
*
RTVDTAARA DTAARA(MYLIB/PROCA) RTNVAR(&ACTEST)
IF (&ACTEST *EQ '1') THEN(DO)
SNDUSRMSG MSG('PROCA IS EXECUTING')
ENDDO
Adapted from IBM Knowledgebase item 13762359, at http://as400service.ibm.com/8625680A007CA5C6/0/83972ADC4953A7AA862568CC0064409B?Open&Highlight=2,13762359.
2. TESTING FOR AN ACTIVE PROCEDURE - PART 2
In the last issue, I ran an item from IBM's Knowledgebase that replicated the S/36 IF ACTIVE function, which tests whether another procedure is running.
Minutes after the e-mail newsletter was distributed, I received many e-mails telling me IBM's suggestion was flawed and offering several alternative solutions. IBM's solution can cause problems if the program - for which the active state is being tested - terminates abnormally, in which case the program will appear to other programs as still active.
I'll be posting the solutions sent to me on the Club Tech Web site next week and will provide the URL in the next newsletter. Thanks to all the readers who responded!
3. PRINTING OR SAVING A DIRECTORY TREE
If you used the old DOS TREE.COM program, you know that it piped the directory and file structure to a file or printer. TREE.COM wasn't updated to handle long file names, and it wasn't offered with the release of Windows 95.
PC Magazine has released a handy Windows version of TREE.OM called PrintTree that lets you print or save a directory tree from within Windows Explorer. You simply right-click on a folder or drive, select TreePrint from the menu, and choose to save or print the directory tree. You can control the number of directory levels documented, the amount of indentation for each level, whether to include file names, and whether the tree is sorted alphabetically.
The utility can be especially helpful in mapping out IFS directories. Here's just a few lines from the AS/400 QIBM directory:
+---ProdData
+---HTTP
+---Public
+---TC1
\---ICSS
\---HTML
Welcome.html
graphic4.gif
sampmast.gif
+---OS400
\---Icons
+---HTTPSVR
sample_search.ndm
QSF614115769DG10004R05M00505000000000
+---HTML
Welcome.html
fdoc0001.html
TreePrint is free and available for download from http://www.zdnet.com/downloads/stories/info/0,,0012RF,.html .
52. CONTROLLING USER ACCESS TO CRTLIB
http://www.as400network.com/nwn/story.cfm?ID=8314
Q. What must I change to stop users and programmers from creating libraries on the AS/400?
A. If your system is operating at security level 30 or higher, you can use object authority to control access to command CRTLIB. The EDTOBJAUT command can prevent a user from using a command. You can specify a user with an authority of *EXCLUDE. In your case, edit object authority for command (object type (*CMD) CRTLIB.
Group profiles, special authorities, and such may continue giving your users access to the CRTLIB command even though you've excluded them. In such a case, you can resort to adding a validity-checking program to CRTLIB to check the user and then exit when appropriate, without allowing the command to continue.
Gary Guthrie, NEWS/400 Tech Editor
53. OBTAINING AS/400 RESIDENT FONTS
http://www.as400network.com/nwn/story.cfm?ID=8341
Q. How do I get a list of the resident fonts shipped with an AS/400? Does the list differ based on OS/400 version or AS/400 model? Can I buy non-AFP (HP PCL-compatible) fonts? Are there any HP- or PCL-compatible fonts resident on the AS/400, or are they resident only on the HP printer itself?
A: OS/400 contains a set of 240-dpi fonts (character sets, code pages, and coded font objects) , which are *FNTRSC objects and are normally in library QFNTCPL. The fonts include Gothic, Roman, OCR, APL, Book, Courier, Essay, Orator, Prestige, and ProPrinter. You use the WRKOBJ command to list all the *FNTRSC objects in the library. Note that OS/400 V4R3 and higher contains several additional fonts to support the Euro.
Because PCL is created only through Host Print Transform and not natively on the AS/400, PCL fonts are unavailable on the AS/400. The AFP Font Collection CD, which includes all the AFP fonts for AS/400, is included, free of charge, with Print Services Facility/400 (PSF/400). PCL fonts are resident only on the PCL printer.
Bill Shaffer, IBM Brand Manager
54. NONDISRUPTIVE QUSRSYS BACKUP
http://www.as400network.com/nwn/story.cfm?ID=8348
Q. How do I manage backup and recovery of library QUSRSYS to meet the needs of a full system restore (to another box) and not affect users or operations too much?
A. The QUSRSYS library must be completely backed up for a successful system recovery. Putting the system in a semi-restricted state by ending QINTER if using save-while-active and ending QSNADS, QSYSWRK, and QSERVER is also a good way to ensure that QUSRSYS is completely saved.
However, this approach doesn't provide unattended operations or reduce the impact to end users. In the past, if a *MSGQ was in break mode during a backup, OS/400 couldn't obtain a lock to save it. The Save/Restore group at IBM has written new functions for a future release to avoid this problem. IBM has also added PTFs for V4R1 and higher to help its existing customers. The following PTFs let OS/400 successfully save a *MSGQ, even when in *BREAK mode:
V4R1 -- SF49860 V4R2 -- SF49848 V4R3 -- SF49800
Check out IBM's Technical Support center at http://as400service.ibm.com/ for the latest information on PTFs and PTF downloads.
Debbie Saugen, IBM Senior Business Recovery Specialist
55. Featured Tip:
SAVING OBJECTS IN IFS DIRECTORIES
Q. Do I need to include the SAV (Save Objects in Directories) command in my save strategy to back up my system?
A. Starting with V3R1, your save strategy must use the SAV command to save objects in AS/400 integrated file system (IFS) directories. If you're not using the SAV command, your system backup may not save objects in directories for:
* Client Access/400 * LAN Server/400 * Lotus Domino for AS/400 * some vendor applications * many licensed programs beyond V3R1
To save all objects in directories, include the following command in your save strategy:
SAV DEV('/QSYS.LIB/+
tape-device-name.DEVD') +
OBJ(('/*') +
('/QSYS.LIB' *OMIT) +
('/QDLS' *OMIT)) +
UPDHST(*YES)
Options 21 and 23 on the Save menu include the SAV command. If you use Operational Assistant for backup, the SAV command is included in option 11 on the Backup menu. (For more information about the SAV command, see "Is Your Entire System Backed Up?" from the April 1998 NEWS/400, at http://www.as400network.com/article.cfm?ID=2536 )
Incidentally, with the release early this year of PTF SF57986 for V4R4, IBM has improved performance when you are saving large number of objects in IFS directories.
Adapted from a NEWS/400 Tech Corner item by IBM's Debbie Saugen
Short Takes:
1. MIGRATING FROM OFFICEVISION/400
If you're an OfficeVision/400 (OV/400) user and unsure of what to do after IBM withdraws OV/400 after V4R5, IBM has some resources to help you find an alternative to OV/400:
a. The OfficeVision/400 Migration Web Site, at http://www.dominodotoffice.com , provides a list of IBM and third-party OV/400 migration tools and migration vendors, an OV/400 events calendar, and OV/400 discussion forums.
b. The Redbook "How to Replace OfficeVision/400 in Your Applications:Looking at Domino for AS/400 and AS/400 Alternatives" (SG24-5406-00) is an excellent guide to OV/400 migration. The Redbook can be downloaded from http://www.redbooks.ibm.com/abstracts/sg245406.html .
c. The "OfficeVision/400 Withdrawal Update" Web page at http://www.as400.ibm.com/developer/ov400/index.html has the latest OV/400 news.
One vendor offers a free AS/400 utility, called DTM Analysis Tool, that helps you determine the usage of OV/400 Data/Text Merge functions by analyzing your OV/400 documents and AS/400 programs. You can read more about the utility and download it at http://www.inventivedesigners.be/dtm/anzdtm.html .
And last, all of IBM's OV/400 manuals and Redbooks are listed at http://www.as400network.com/index400/ov.htm .
2. FUNCTION OF LIBRARY QRPLOBJ
Q. What is system library QRPLOBJ's purpose?
A. QRPLOBJ is a repository for replaced objects.
Each time you use a command that runs a compiler (such as CRTPF (Create Physical File) or CRTCLPGM (Create CL Program)), you supply a value to parameter REPLACE, which tells the command whether to replace the earlier version of the created object, if one exists. The default value is *YES, but REPLACE also accepts *NO. When you specify REPLACE (*YES), OS/400 automatically replaces the old version of the compiled object with the new version and moves the old version to library QRPLOBJ. (If you specify *NO and the system finds an earlier version of the same object, the compile command fails with an *ESCAPE message.)
Note that objects moved to QRPLOBJ don't keep their original names; OS/400 assigns them new (and unintelligible) ones but stores the original name in the object's text description, which you can use to identify them.
Because QRPLOBJ collects lots of objects over time, you need to clean it up periodically. You could delete objects individually after careful examination of each one's necessity, but it's much easier (and usually smarter) to simply clear the library once in a while by using the CLRLIB (Clear Library) command when the objects are not in use. An IPL also deletes and re-creates QRPLOBJ.
Answered by Ernie Malaga
3. INTRODUCTION TO PTFS
The July issue of NEWS/400 contains an excellent article detailing the step-by-step process for ordering and installing PTFs, as well as information about determining when you need them. The article addresses the following issues:
When Do You Need a PTF?How Do You Order a PTF?SNDPTFORD BasicsOrdering PTFs on the InternetHow Do You Install and Apply a PTF?Installing Licensed Internal Code PTFsInstalling Licensed Program Product PTFsVerifying Your PTF InstallationHow Current Are You?
The online article can be viewed by all AS400Network associate (free) and professional (paid) members at http://www.as400network.com/article.cfm?ID=7519 .
4. DISPLAYING PTF COVER LETTERS
The July 2000 article mentioned above shows how to obtain PTF cover letters using the SNDPTFORD command and displaying them with the DSPPTF command. You can also read cover letters online at http://as400service.rochester.ibm.com/supporthome.nsf/home/PTF+Cover+Letters .
5. SYSTEMS MANAGEMENT DOC WATCH
In the past month, IBM has released the following Redbooks:
Lotus Domino for AS/400 Internet Mail TopicsSG24-5990-00http://www.redbooks.ibm.com/redpieces/abstracts/sg245990.htmlThis Redbook helps you set up Lotus Domino for AS/400 to exchange mail with other SMTP servers, including those within the Internet.
AS/400 MigrationSG24-6055-00http://www.redbooks.ibm.com/redpieces/abstracts/sg246055.htmlThis Redbook helps planners and implementors understand the new PCI architecture and how to integrate or move to it.
AS/400 Clusters: A Guide to Achieving Higher AvailabilitySG24-5194-00http://www.redbooks.ibm.com/abstracts/sg245194.htmlThis Redbook presents an overview of a generic cluster and the basic terminology surrounding clusters. It examines the AS/400 cluster and its implementation and introduces ClusterProven for AS/400.
56. DUPLEX PRINTING FROM THE AS/400
http://www.as400network.com/nwn/story.cfm?ID=8385
Q. Can I print on two sides of a page using an AS/400?
A. Yes, the AS/400 supports printing on two sides of a page, which is often called duplex printing. For example, there's a Duplex parameter on the OVRPRTF (Override with Printer File) command. On V4R5 (the version I'm running), the Duplex parameter has the following valid values:
*No: The output is printed on one side of the paper.
*Yes: The output is printed on both sides of the paper, with the top of each printed page corresponding to the top of the previous printed page.
*Tumble: The output is printed on both sides of the paper, with the top of one printed page at the opposite end from the top of the previous printed page. This is usually used for output that will be bound at the top.
*Formdf: The output is printed on both sides of the paper if the duplex value is specified in the form definition. If a form definition isn't specified, then the output is printed on one side of the paper.
Duplex printing is printer-dependent, and not all printers support duplex printing. Typically, low-end laser printers don't support duplex printing, but mid- to high-end laser printers may support it. To determine whether your printer supports duplex printing on the AS/400, check the printer's documentation or contact the manufacturer. IBM, for example, has numerous printer models that support duplex printing on the AS/400.
Jim Hoopes, NEWS/400 Senior Tech Editor
57. Featured Tip:
VIEWING ANOTHER JOB'S QTEMP
I noticed a discussion in a midrange mailing list in which some AS/400 programmers were looking for a method for peering into another user's QTEMP library to help in debugging programs. There are two commercial tools that I'm aware of:
PeekPlusBytware, Inc.http://www.bytware.com[See the upcoming November 2000 issue of NEWS/400 for an article about PeekPlus.]JOB Talk utility, which is part of TAA Productivity Tools (the follow-on product to QUSRTOOL)
Jim Sloan, Inc.http://www.taatool.com
The other method for viewing a user's QTEMP is to use a utility published in NEWS/400 in July 1994. Although the code is available online, the article text isn't. I decided to dust off the article, make some minor tweaks, and present it here.The source files for the utility can be downloaded from http://www.as400network.com/noderesources/code/clubtechcode/RunJobCmd.zip .
Looking into Someone Else's QTEMPBy Ernie Malaga Reprinted from NEWS/400, July 1994Copyright c 2000 Duke Communications International, Inc.ALL RIGHTS RESERVED
QTEMP, the temporary library, is unlike other AS/400 libraries in that each job has its own QTEMP. This is great because you can create objects that are "local" to your job, meaning that no other jobs can see them and that you don't have to worry about duplicating the name of similar objects created in other jobs. In addition, QTEMP automatically vanishes when your job ends, eliminating the possibility of leftover objects that clutter your system and consume valuable disk space.
Along with these advantages, however, comes a major inconvenience: You can't access another job's QTEMP. Say, for example, that a shipping program created objects in QTEMP, as many in-house and purchased software products do. Let's then suppose the program blows up, and the shipping clerk calls you for help. You need to investigate the DEFAULTS data area in the clerk's QTEMP to find out what went wrong. However, running the DSPDTAARA (Display Data Area) command from your display station would display only the data areas in your copy of QTEMP - which would contain different data, if the same data areas existed at all. Instead, you must run DSPDTAARA at the clerk's display station in the shipping department. There must be an easier way.
An Easier Way
With MI, you could fool the AS/400 into believing that your QTEMP is the clerk's QTEMP. You could then run commands into the remote user's interactive job from the comfort of your own desk. MI solutions, however, are difficult and seldom work at security levels higher than 30. Here, I present an easy-to-implement non-MI solution that will work at any security level. It consists of a single command: RUNJOBCMD.
To see how to use command RUNJOBCMD, let's revisit the shipping-clerk scenario. Let's say you're signed on to SYSDSP02 in the computer room, and the shipping clerk, Brad, is signed on to display station SHPDSP03. From Brad's description, you determine the problem must be in the DEFAULTS data area in his QTEMP. To look at the DEFAULTS data area in Brad's QTEMP from your display station, you run
RUNJOBCMD
JOB(SHPDSP03) +
CMD(DSPDTAARA +
qtemp/Defaults +
OUTPUT(*PRINT))
The RUNJOBCMD command tells the system to run the DSPDTAARA command as if it had been requested from SHPDSP03. The *PRINT option lets you look at the DSPDTAARA output by displaying the generated spooled file; without the OUTPUT(*PRINT) parameter, the output would simply go to Brad's display station.
When you press Enter, Brad's display station beeps and presents a panel that shows him the command you've requested and lets him approve or reject the request. If he presses Enter, your DSPDTAARA command will run on his job, displaying the DEFAULT data area in his QTEMP. If he presses F3 or F12, however, DSPDTAARA doesn't run. Either way, utility RUNJOBCMD sends you a break message that tells you which action Brad has taken.
How It Works
Central to utility RUNJOBCMD is a break-handling program that receives messages coming into the remote display station's message queue and, if they're request messages (*RQS), interprets them as commands and executes them via QCMDEXC. (For details about how break-handling programs work, see Chapter 8 of the CL Programming manual, SC41-5721, http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/QB3AUO03/CCONTENTS .)
For this break-handling program to work, the remote display station's message queue must be in *BREAK mode. To ensure this, it's a good idea to use a user profile initial program such as that shown below:
/* Sample User Profile Initial Program */
/* */
/* From "Looking Iinto Someone Else's QTEMP */
/* NEWS3X/400, July 1994 */
/* */
/* Copyright (c) 1994 Duke Communications Int'l. */
/* ALL RIGHTS RESERVED */
PGM
DCL &dspstn *CHAR 10
/* +
Place the display station's message queue in *BREAK mode. +
First, get the display station's name and then run CHGMSGQ. +
*/
RTVJOBA JOB( &dspstn )
CHGMSGQ MSGQ( &dspstn ) +
DLVRY( *BREAK ) +
PGM( jobcmdbhp )
ENDPGM
This program, executed when a user signs on, uses the CHGMSGQ (Change Message Queue) command to automatically place the display station's message queue in *BREAK mode, with JOBCMDBHP as the break-handling program. From this point on, RUNJOBCMD is ready whenever you need it.
Let's dig a little deeper into the utility's details. When you run command RUNJOBCMD, you enter the name of the remote display station and the command you want to execute. Because the CMD parameter is defined as a command string (*CMDSTR), you can prompt the command you want to run by typing RUNJOBCMD and pressing F4.
All that command processing program (CPP) RUNJOBCMDC does is send the command string as a *RQS message to the remote display station's message queue. Notice that RUNJOBCMDC does not use the standard SNDMSG (Send Message) command to send this message because SNDMSG cannot send *RQS messages. Instead, it uses the more complicated SNDPGMMSG (Send Program Message) command.
When the *RQS message arrives at the message queue, break-handling program JOBCMDBHP receives the message, extracting from the sender information parameter the names of the user profile who sent the message and of the display station from which it was sent. When JOBCMDBHP determines that the message is a *RQS message (which has a return type of '08' or '10'), it uses display file JOBCMDBHPD to present the Job Command Request panel, which lets the remote user approve or reject the requested command. To approve the request, the user presses Enter, and JOBCMDBHP executes the command. To reject the request, the user presses F3 or F12. JOBCMDBHP then reports the user's action back to the requester in the form of a break message.
Security Risks
Although convenient, this utility does pose some security risks. If you compile the break-handling program so that it adopts QSECOFR authority, anyone who has access to RUNJOBCMD (and who has a willing accomplice signed on at another display station) can run any command on the system. The same exposure exists if someone uses RUNJOBCMD to run commands from QSECOFR's interactive job; however, this can't be done unless QSECOFR (or someone at the station QSECOFR is signed on to) authorizes each command request by pressing Enter.
To minimize your security exposure, follow common-sense security rules. For example, don't compile the break-handling program while adopting QSECOFR's authority, and don't disclose QSECOFR's password. Also, make sure QSECOFR knows how RUNJOBCMD works and the possible security risks. In addition, you can use the AS/400's journaling feature to keep a permanent record of who's using RUNJOBCMD and how.
Implementation Issues
Implementing utility RUNJOBCMD is easy. You need only create command RUNJOBCMD, CPP RUNJOBCMDC, break-handling program JOBCMDBHP, and display file JOBCMDBHPD. To install utility RUNJOBCMD, run the following commands in sequence:
CRTCMD
CMD(MYLIB/RUNJOBCMD) +
PGM(MYLIB/RUNJOBCMDC) +
SRCFILE(MYLIB/QCMDSRC) +
AUT(*EXCLUDE)
CRTCLPGM
CMD(MYLIB/RUNJOBCMDC) +
SRCFILE(MYLIB/QCLSRC) +
AUT(*EXCLUDE)
CRTDSPF
FILE(MYLIB/JOBCMDBHPD) +
SRCFILE(MYLIB/QDDSSRC)
CRTCLPGM
PGM(MYLIB/JOBCMDBHP) +
SRCFILE(MYLIB/QCLSRC)
Last, give *USE authority for command RUNJOBCMD and program RUNJOBCMDC to authorized users.
You cannot use RUNJOBCMD to run interactive commands, such as WRKOBJPDM (Work with Objects Using PDM). That's why, in our shipping-clerk example, we had the DSPDTAARA command send its output to the printer, which lets the command run in batch mode. Otherwise, DSPDTAARA's output would go to the screen, making DSPDTAARA an interactive command. If you must run an interactive command, first use RUNJOBCMD to execute the CRTDUPOBJ (Create Duplicate Object) command to copy the necessary objects from the remote display station's QTEMP to any other library. You can then operate on the objects using standard commands.
The next time a user calls with a problem in QTEMP, run utility RUNJOBCMD instead of running up the stairs. Your legs and lungs will thank you.
58. USING BINDING DIRECTORIES
http://www.as400network.com/nwn/story.cfm?ID=8400
Q. Should BNDDIR be program-specific or application-specific? If it's application specific, is a particular module still available in a program, even if I'm not using that module? What happens to the object size? Doesn't adding modules that aren't used in that program unnecessarily increase the object size? Do we still have to update the *PGM when we change a particular module from the BNDDIR?
A. There are two main approaches to using binding directories:
1. Use a separate binding directory to define the modules and service programs needed to create each program.
2. Use one binding directory to define the common modules and service programs that may be bound to the programs in an application.
I prefer the second approach because it simplifies program creation. I scope binding directories to libraries; each application library has its own binding directory. For example, a Finance library (FINLIB) may have a binding directory (FINBNDDIR) that contains entries for service programs, which include common financial procedures. Each program in FINLIB is created by specifying the FINBNDDIR binding directory.
A program's size depends on the modules and service programs to which it's bound. The program object contains a copy of each bound module and a reference to each bound service program. The program's size isn't affected by other entries in a binding directory specified at compilation.
Where possible, I recommend using service programs in preference to modules. Let's assume you always want your programs to use the latest versions of your service programs and modules. If you change the contents of a service program procedure but not its parameters or return value, programs will pick up the latest version of the service program at runtime. Other changes to service programs normally require the rebinding of the programs that use them. Changes to a module always require the rebinding of programs to create a new copy of the module in each program.
Julian Monypenny, NEWS/400 Tech Editor
59. RETRIEVING QSYS COMMAND OBJECTS
http://www.as400network.com/nwn/story.cfm?ID=8467
Q. I'm an AS/400 security administrator. I accidentally deleted certain system commands when I mistakenly typed DLTCMD WRK* instead of SLTCMD WRK* on the command line. As a result, the system deleted six command objects from the QSYS library. Is there any way to restore the command objects? We save our system regularly using SAVSYS (Option 21 on the Save menu).
A. Unfortunately, you can't restore these commands from your save.
Though the SAVSYS command saves library QSYS (where the commands are located), it doesn't permit a restore of individual objects using RSTOBJ. Because of this fact, I typically recommend that a backup strategy include a SAVOBJ command that saves all objects in library QSYS so that they can be subsequently restored.
To fix your problem, you need to restore OS/400 from the most recent SAVSYS media that contains the deleted commands. Be careful not to restore configuration or user profile information. Also, if you've applied any PTFs since the time of the creation of the SAVSYS media used in restoring OS/400, you need to reapply those PTFs.
Gary Guthrie, NEWS/400 Tech Editor
60. CUSTOM QUERY OPTIONS BUILDER
Before V4R4, query attributes were scattered across CL commands, system values, and data areas. This made it difficult to set all the different values or to determine the attributes' values, many of which directly affect the query optimizer's implementation decisions.
Starting with V4R4, all the attributes that potentially affect the performance of the DB2 UDB for AS/400 database engine have been centralized in the query options file QAQQINI. You can use QAQQINI to control a query's performance and save and apply configuration settings (attributes) across multiple executions of a query request.
IBM has recently made available a Web-based tool called the Custom Query Options Builder that lets you easily update your own QAQQINI file. Based on values you enter in the Web form, the tool generates an SQL script that you can execute several ways, two of which are with the RUNSQLSTM CL command or the Operations Navigator SQL Script Center.
The Custom Query Options Builder and instructions on its use are at http://www.as400.ibm.com/developer/bi/tuner.html .
You can learn more about QAQQINI in the January 2000 NEWS/400 article "Query Performance Tuner Consolidates Query Options." You can read this article online at http://www.as400network.com/article.cfm?ID=3292 if you are an AS400 Network professional member. IBM's DB2 UDB for AS/400 Database Performance and Query Optimization manual also has QAQQINI information, which you can view at http://publib.boulder.ibm.com/pubs/html/as400/v4r5/ic2924/info/db2/rzajqmst02.htm .
61. Short Takes:
1. FINDING COMMANDS AND MENUS
Despite the logical naming convention for OS/400 commands and menus, it's easy to get stymied groping for the proper name.
Here are a few ways to easily find the command you're looking for:
a. Enter SLTCMD *ALL to display a list of all commands.
b. Enter SLTCMD and a generic name to display a list of all commands that contain one or more characters. For example, SLTCMD dspf* will display all commands starting with DSPF, such as DSPF, DSPFAX, DSPFD, and so on.
c. Enter a generic name on the OS/400 command line (SLTCMD is assumed by the system). For example, entering dspf* on the command line is identical to entering SLTCMD dspf*.
It's preferable to use method (c) and not (b), since the "S" in SLTCMD is close to the "D" on the keyboard, and with the right authority, you could inadvertently perform a DLTCMD (Delete Command) operation. That would be a bad thing :(.
Here are two easy ways to locate a menu:
a. Enter GO *ALL, which displays all menus.
b. Enter GO and a generic name to display a list of all menus that contain one or more characters. For example, GO file* will display all menus starting with FILE, such as FILE, FILESYS, FILETFR, and so on.
2. VIEWING THE IPL PROCESS
If you want to know how the last IPL on your machine progressed, what steps were performed, and how long they took, you can call program QSYS/QWCCRTEC. Doing so produces a dump in spooled file QPSRVDMP that specifies the source panel code, which identifies each IPL step and a corresponding timestamp.
The AS/400 Service Functions manual (SY44-5902), which accompanies the hardware, describes the source panel codes. Unfortunately, the manual is not online.
From a NEWS/400 Tip by Carsten Flensburg
3. IDENTIFYING JOBS IN QSYSWRK
Ever wonder what all those jobs are in subsystem QSYSWRK? Here are descriptions of some of the more common ones (a * indicates additional characters that vary from job to job):
a. TCP/IP server jobs
ADMIN Administrative Web server
DEFAULT Default Web server
QMSF Mail server framework
QRWTLSTN Distributed Data Management (DDM)/Distributed Relational Database Architecture (DRDA) TCP/IP server, daemon
QRWTSRVR DDM/DRDA TCP/IP server
QTBOOTP Bootstrap Protocol (BOOTP) server
QTCPIP TCP/IP interface, daemon
QTFTP* File Transfer Protocol (FTP) server
QTGTELNETS Telnet server
QTLPD* Line Printer Daemon (LPD) server
QTOBDNS Domain Name System (DNS) server
QTODDHCPS Dynamic Host Configuration Protocol (DHCP) server
QTPP* Point-to-point session
QTRTD* Routing daemon (RouteD) server
QTRXC* Remote Execution (REXEC) server
QTSMTPSVSR Simple Mail Transfer Protocol (SMTP) server
QTTFT* Trivial FTP server
b. Client Access host server jobs
QNPSERVD Network print server for TCP/IP, daemon
QNPSERVS Network print server for TCP/IP
QZHQSRVD Data queue server for TCP/IP, daemon
QZHQSSRV Data queue server for TCP/IP
QZRCSRVS Remote command server for TCP/IP
QZSCSRVS Central server for TCP/IP
QZRCSRVSD Remote command server for TCP/IP, daemon
QZSCSRVSD Central server for TCP/IP, daemon
QZSOSGND Sign-on server for TCP/IP, daemon
QZSOSIGN Sign-on server for TCP/IP
QZSOSMAPD Server port mapper for TCP/IP
c. 5250 Display Station Passthrough jobs
QPASVRP Primary passthrough server
QPASVRS Secondary passthrough server
For more information about TCP/IP server jobs, see TCP/IP Configuration and Reference (SC41-5420).For more information about Client Access host server jobs, see AS/400 Client Access Host Servers (SC41-5740).For more information about 5250 Display Station Passthrough servers, see Remote Work Station Support (SC41-5402).
NEWS/400 Tip by Dawn May, Advisory Software Engineer, IBM
4. CONFIGURING A LAN CONNECTION ON YOUR AS/400
IBM has a simple Web-based wizard that walks you through the steps to configure your AS/400 LAN hardware and assign a TCP/IP network connection. You can use the wizard at http://www.as400.ibm.com/tstudio/lan/lanstart.htm .
5. FUNCTION OF LIBRARY QRPLOBJ, PART 2
The item in the last issue on Library QRPLOBJ stated that "each time you use a command that runs a compiler (such as CRTPF (Create Physical File) or CRTCLPGM (Create CL Program)), you supply a value to parameter REPLACE, which tells the command whether to replace the earlier version of the created object, if one exists.. When you specify REPLACE (*YES), OS/400 automatically replaces the old version of the compiled object with the new version and moves the old version to library QRPLOBJ."
Two readers pointed out that although this applies to CRTCLPGM and similar commands, it does not apply to CRTPF or CRTLF, as neither has a REPLACE parameter. Creating a file over an existing file didn't place the older file in QRPGOBJ either.
Thanks to Richard Theis and Michael Smith for pointing this out.
62. PREVENTING INCOMING MESSAGES
http://www.as400network.com/nwn/story.cfm?ID=8568
Q. Is there a way to prevent incoming messages from interrupting me while I'm working on a project? I'm a student at a community college, and other students send inquiry messages that come up on my workstation, bringing everything to a temporary halt.
A. To prevent messages (inquiry and break) from interrupting you at your workstation, set your job's Break Message Handling attribute to value *NOTIFY or *HOLD. To change the value, issue command CHGJOB BRKMSG(*NOTIFY) or CHGJOB BRKMSG(*HOLD) from the command line. If you want to reinstate the interruptions, execute CHGJOB BRKMSG(*NORMAL).
Gary Guthrie, NEWS/400 Tech Editor
63. ELIMINATING PHANTOM SESSIONS
http://www.as400network.com/nwn/story.cfm?ID=8638
Q. Our associates perform their daily duties either on our IBM mainframe or on the AS/400. They can access the AS/400 either via a product called N/VISION TPX (provided by a vendor named LEGENT) or straight 5250 using Client Access.Unfortunately, our associates sometimes exit their AS/400 sessions by Xing out of the application (pointing their mouse to the X on the Windows client and clicking) as opposed to signing off. When they do this, a phantom session remains on the AS/400, and it's probable that the next associate accessing the AS/400 picks up this phantom session. This practice presents a security breach, among other things. How can we eliminate phantom sessions altogether?
A. You need to set the QINACTITV system value, which is explained in full when you go to http://as400service.rochester.ibm.com/supporthome.nsf/Document/10000051 ,select Communications, TCP, and then Telnet. From there, select QINACTITV System Value Explained.
Chuck Lundgren, NEWS/400 Tech Editor
64. Featured Tip:
SOUNDEX AND OTHER NEW SQL FUNCTIONS
The August NEWS/400 article "Extreme V4R5 Enhancements for DB2 UDB" discussed SQL enhancements, including the addition of the functions Soundex and Difference. Unfortunately, IBM's documentation hasn't kept up with these enhancements. Neither the HTML nor the PDF version of the "DB2 UDB for AS/400 SQL Reference" manual in IBM's InfoCenter contains the enhancements. Until IBM corrects the problem, the only way to learn more about Soundex and Difference, and the other new functions Atan2, Radians, and Rand, is to download the newer difficult-to-locate PDF file at http://ibm.com/as400/db2/rbafzmst.pdf .
Just so you don't have to download the PDF file right away, here's IBM's documentation on Soundex:
The Soundex function returns a 4-character code representing the sound of the words in the argument. The result can be compared with the sound of other strings.
The argument can be any string, but not a BLOB.
The data type of the result is CHAR(4). If the argument can be null, the result can be null; if the argument is null, the result is the null value.
The Soundex function is useful for finding strings for which the sound is known but the precise spelling is not. It makes assumptions about the way that letters and combinations of letters sound that can help to search out words with similar sounds. The comparison can be done directly or by passing the strings as arguments to the Difference function.
Example:
Using the EMPLOYEE table, find the EMPNO and LASTNAME of the employee with a surname that sounds like 'Loucesy'.
SELECT EMPNO,LASTNAME
FROM EMPLOYEE
WHERE SOUNDEX (LASTNAME)=SOUNDEX ('Loucesy')
Returns row:
000110 LUCCHESSI
For a description of Soundex and to see a working online demonstration, go to http://www.geocities.com/Heartland/Hills/3916/soundex.html .
65. Short Takes:
1. TESTING SQL FUNCTIONS
One way to try out an SQL function without a lot of effort is to create a single row table just to use for testing. To show how this works, I've included a sample interactive SQL session that creates a test table named DummyTab and tests the Soundex function:
a. On the OS/400 command line, enter STRSQL and press Enter.
b. Enter:
create table dummytab (col1 int)
c. Enter:
insert into dummytab values(0)
d. Enter:
select soundex('Kathy')
What you'll see is that Kathy results in a Soundex value of K300 (which is also the Soundex value of similar names Kate and Katie).
e. Enter:
select dayofweek(date('2000-10-11')) from dummytab
This test uses two functions: date, which converts the date string to an internal date forum, and dayofweek, which converts the date into a number between 1-7 (1=Sunday, etc.). This test would result in the number 4, for Wednesday.
Thanks to Mike Cravitz for suggesting the above technique
2. CHANGING DEFAULTS IN PDM
Q. How do I change option 14 in PDM so that the compile takes place interactively instead of being submitted to the job queue?
A. You can change many PDM defaults by pressing F18= (Change Defaults) at any PDM "Work with . . ." display. The resulting Change Defaults display lets you change several options; in your case, you would change the "Compile in batch" option to "N". This display also offers you the option to save the session defaults so they'll be used the next time you access PDM. These defaults are stored in a space associated with your user profile.
3. MORE SAMPLE SOCKET CODE FOR SOCKET PROGRAMS
Last January I published a list of resources where you could find RPG sample socket source code. Since then, I've learned of three resources provided by AS/400 programmers:
Chris Bipes' RPG IV sample source codehttp://www.cableone.net/ckb62/TCPIP%20Sockets.htm
Nick Roux's RPG IV sample source codehttp://home.yebo.co.za/~10302602/download1.html
Joerg Egger's Cobol sample source code http://www.as400network.com/cobol/CobolCode/SampleSocketsPgm.zip
And just so you don't have to look back in the January issue, here are the other sources:
IBM's Redbook "Who Knew You Could Do That with RPG IV? A Sorcerer's
Guide to System Access and More" (SG24-5402-00)http://www.redbooks.ibm.com/abstracts/sg245402.html
IBM's "OS/400 Sockets Programming V4R4"http://publib.boulder.ibm.com/cgi-bin/bookmgr/DOCNUM/SC41-5422-03
NEWS/400's March 1999 article "Anatomy of a Sockets API"http://www.as400network.com/article.cfm?ID=2927
NEWS/400's June 1999 article "SCKTPROC Eases RPG Socket Programming"http://www.as400network.com/article.cfm?ID=3042
4. MORE PRODUCTS THAT VIEW OTHER'S QTEMP
In the last issue, I mentioned two products that let you peer into another user's QTEMP library when debugging programs: Byteware's PeekPlus and Jim Sloan's JOB Talk utility. I've since learned there are three more products that perform this function:
OpCenter Job InterventionAdvanced Systems Conceptshttp://www.asc-as400.com/
VISUAL Support Pro and VISUAL Debugger for WindowsTango/04http://www.tango04.com/
WideScopeMillennium Systems Products, Inc.http://msp.ibmbp.com/
5. INSIDE THE AS/400
Have you always wanted to know the life story of the AS/400, along with a comprehensive look at the system's architecture? Now you can - for free. The first four chapters of Frank Soltis's biography of the AS/400, "Inside the AS/400," are online at http://www.as400network.com/ibm/insideas400/ . The online chapters include:
Advanced Application Architecture
The Power PC Technology
The System Licensed Internal Code
The Technology-Independent Machine Interface
66. PASSING VALUES VIA PARAMETERS
http://www.as400network.com/nwn/story.cfm?ID=8670
Q. I wrote a CL program to execute an SQL statement as follows:
PGM
RUNSQLSTM SRCFILE(DAVIES/QSQLSRC)
SRCMBR(GYRUN)
ENDPGM
This is the SQL statement in the GYRUN source member:
INSERT INTO GYPF
SELECT USER, 1000725, SCAA
FROM SCPF
WHERE SCAS BETWEEN `210' AND `215'
Instead of using the literals (1000725, `210', and `215' ), I'd like to pass values via the CL program's parameters. How can I do this?
A. The RUNSQLTM command doesn't support variable substitution.
However, there is a solution if you want to continue using RUNSQLSTM. You could code a shell SQL statement in your source member that looks something like this:
INSERT INTO GYPF
SELECT USER, %P1%, SCAA
FROM SCPF
WHERE SCAS BETWEEN `%P2%' AND `%P3%'
Notice that for the three parameters you want to use, I removed the literals and replaced them with placeholders %P1%, %P2%, and %P3.
You then write a program that accepts your parameters, reads the shell source member, and generates a new source member with the appropriate parameter substitutions made for the placeholders. Next, specify the newly generated source member as the source member to use on the RUNSQLSTM command.
If you don't want to generate a source member, consider using embedded SQL. CL doesn't support embedded SQL, but you can embed SQL in an RPG or Cobol program and use host variables instead of literals. The embedded INSERT statement would look like this:
INSERT INTO GYPF
SELECT USER, :Var1, SCAA
FROM SCPF
WHERE SCAS BETWEEN :Var2 AND :Var3
Another solution is to use the Query Manager utility's StrQmQry command to set parameter values in an SQL statement. The StrQmQry command can be coded in a CL program, and you can use CL variables to supply values for the command's SetVar parameter. You can learn more about this approach in "Pass Parameters to Queries with DB2/400's Query Manager" (NEWS/400, May 1997).
Paul Conte, Senior Tech Editor, and Gary Guthrie, Tech Editor
67. CONTROLLING CATALOG FILE SIZE
http://www.as400network.com/nwn/story.cfm?ID=8731
Q. We have a perennial battle to keep our AS/400 disk storage use under control. The single biggest file on our system is QSYS/QADBIFLD. This has been the case for some time, and being an IBM object, I've taken it as normal. However, I've noticed over the past six months (since we've been on our new S20) that this file continues to grow and contains a huge number of deleted records, none of which are cleaned up at IPL.
Currently QSYS/QADBIFLD contains more than 3 million records and 8.5 million deleted records and occupies around 3.5 GB. I understand this is one of the catalog files used in SQL and ODBC and contains cross-reference information on system tables and fields, which reflects that we have numerous objects on our system. We're implementing new applications that replace all our old systems, so over the next year, we should be able to steadily remove most of them.
In the meantime, can we do anything about the size of the catalog files, considering they are QSYS objects? Can we reclaim the deleted record space? I assume RGZPFM isn't viable for obvious reasons.
A. QADBIFLD is one of several database cross-reference files. This file reuses deleted records as necessary. There are times, though, when some additional action is warranted. It sounds like you have such a situation.
Consider an environment that adds and deletes a large number of files and fields to database and then remains fairly static in the number of files and fields that are added to the database. The result in such a case is a large number of deleted records that are never reused. To reclaim the space consumed by these deleted records, use RCLSTG SELECT(*DBXREF). Note that you must execute this command while the system is in restricted state.
Gary Guthrie, NEWS/400 Tech Editor
68. Featured Tip:
ASCII PRINTER SUPPORT
IBM Knowledgebase document 17690939 contains information about how hundreds of ASCII printers from various manufacturers are supported on the AS/400. The following information is specified for each printer:
a. Printer Data Stream. Specifies the printer data stream(s) supported by the printer.
b. PDT File for PC5250. Specifies the Printer Definition Table (PDT) File that can be used when configuring a Personal Communications 5250 (or PC5250) printer session.
c. MFRTYPMDL for HPT. Specifies the Manufacturer Type and Model (MFRTYPMDL) setting that can be used with Host Print Transform (HPT) in order to select the appropriate data stream for the printer.
d. RMTOUTQ. Specifies whether a Remote Output Queue (RMTOUTQ) can be used to print to the printer when directly connected to the LAN.
e. PJL. Specifies whether a *LAN 3812 PJL Device Description can be used to print to the printer when directly connected to the LAN.
f. SNMP. Specifies whether a *LAN 3812 SNMP Device Description can be used to print to this printer when directly connected to the LAN.
The printer manufacturers listed include AMT, Brother, Canon, Compaq, Decision Data, Epson, HP, GENICOM, IBM, Intermec, Ithaca Peripherals, Kyocera, Lanier, Lexmark, Mita, Minolta, MINOLTA-QMS, NEC, Okidata, OTC, Olympus, Panasonic, Printek, Printronix, Ricoh, Savin, Sharp, Tally, Tektronix, Toshiba, Unisys, and Xerox. Whew!
The IBM Knowledgebase item can be viewed at http://www.as400service.ibm.com/s_dir/slkbase.NSF/acf2ee1e9d64b16e8625680b00020389/b44a2cf4ba778d83862568250053649f?OpenDocument.
69. Short Takes:
1. CHANGING TABLE, VIEW, AND COLUMN LABELS WITH SQL
If you're tired of deleting and re-creating files to change column-level information, such as column headings, it's time you considered the SQL LABEL ON statement. LABEL ON lets you add and easily change labels for tables, views, and columns.
LABEL ON supports the following label types:
a. Column headings. Tools such as STRSQL (Start SQL) and STRQM (Start Query Manager) use column headings when displaying or printing query results. A user may specify up to three column-heading segments (or words) as part of a single string that can be a maximum of 60 characters. Each segment can be a maximum of 20 characters, and each segment will appear on a separate line. If a segment is less than 20 characters, you must pad it out with blanks so that the subsequent segment begins in the 21st or 41st position. The following LABEL ON statement adds a two-segment column heading (Employee Number) to the EMPNO column of table Employee in library CorpData:
LABEL ON COLUMN CORPDATA.EMPLOYEE.EMPNO
IS 'Employee Number'
You can also specify column headings for more than one column in a single LABEL ON statement, such as:
LABEL ON CORPDATA.EMPLOYEE
(EMPNO IS 'Employee Number',
EDLEVEL IS 'Education Level')
b. Column-level text. You can enter a character string of up to 50 characters describing a column. The following LABEL ON statement adds text for the EMPNO column:
LABEL ON COLUMN CORPDATA.EMPLOYEE.EMPNO
TEXT IS
'Employee number (6 character digits)'
c. Object-level text for tables and views. Object-level labels describe tables and views. The following LABEL ON statement adds the string "Employee data" as object-level text to table EMPLOYEE:
LABEL ON TABLE CORPDATA.EMPLOYEE IS
'Employee data'
You can display column headings and text by using various CL commands, such as DSPFFD (Display File Field Description), or by querying the system catalogs.
From a tip by IBM's Carol Ramler
2. MANAGING DISK SPACE
To help you manage disk use on your AS/400, OS/400 includes the RtvDskInf (Retrieve Disk Information) and PrtDskInf (Print Disk Information) commands. You can use these two commands to monitor the utilization of your disks, or you can write your own queries over the data captured by RtvDskInf to analyze changes in disk use.
You use command RtvDskInf to gather information about all the objects on your system. The command outputs the information to member QCurrent in file QAEZDisk in library QUsrSys. For a large system with many thousands of objects, running RtvDskInf can take several hours, so IBM requires you to run the command in batch. The easiest way to do this is to use the SbmJob (Submit Job) command:
SbmJob Cmd(RtvDskInf)
You use command PrtDskInf to print the information that command RtvDskInf generates in file QAEZDisk. PrtDskInf lets you print a summary of your system information or print details of disk use by library, folder, owner, or object. For example, to print a list of libraries that are more than 1,000 K in size in descending order by size, you run the command
PrtDskInf RptType(*Lib) +
Obj(*None) +
MinSize(1000) +
Sort(*Size)
The online help for PrtDskInf explains all the available options.
If the standard PrtDskInf report options don't meet your needs, you can write your own queries over file QAEZDisk. In addition, you can save the data in member QCurrent in QAEZDisk to a file and write queries to compare the output from different runs of RtvDskInf.
From a tip by Julian Monypenny
3. CHANGING SYSTEM REQUEST MENU 3 FROM DSPJOB TO WRKJOB
Q. There is (or was) a message in the QCPFMSG message file that controls whether System Request menu item 3 is Display Job (the default) or Work Job. Does this feature still exist, and, if so, what is the message ID? Is the feature documented somewhere in the IBM manuals, or is it undocumented?
A. The system uses message CPX2313 from message file QCPFMSG in determining commands executed when a user selects the associated option from the system request panel. You can change the command that will be executed for an option by changing the first-level text of message CPX2313.
If you choose to make such a change, be careful not to alter the position within the text where the commands appear. To help ensure you maintain the commands' positions, avoid using the CHGMSGD command and instead use option 2 (Change) from the panel produced by the WRKMSGD command, which lets you see the message's current text.
From a Tech Corner item by Gary Guthrie
70. CREATING A HELP FUNCTION KEY
http://www.as400network.com/nwn/story.cfm?ID=8761
Q. Can I create a Help function key for a field in an SDA screen? When I create my screen using SDA, it uses the fields from a physical file I created. How can I position to a field on the screen and select a Help function key to retrieve information on that specific field?
A. You can use DDS keyword RTNCSRLOC (Return Cursor Location) to help with your requirement. This keyword supplies your program with cursor location information when the user performs a display file function. You can choose from two formats using RTNCSRLOC: retrieve the cursor's row and column or retrieve the field name in which the cursor is located.
You'll probably want to retrieve the field name in which the cursor is located so that your program can execute the help routine appropriate for the field. You can find more about keyword RTNCSRLOC in OS/400 DDS Reference (SC41 5712).
71. Featured Tip:
WORK WITH ILE AND OPM PROGRAM REFERENCES UTILITY
The Work with Program References (WRKPGMREF) utility is a handy program maintenance tool published in NEWS/400 back in September 1997. WRKPGMREF presents a work-with panel listing all the objects - files, programs, modules, service programs, and data areas - referenced by the ILE or OPM program you specify. You can perform tasks on the listed objects using numeric options and on the referencing program using function keys. The numeric options and function keys are described briefly below.
WRKPGMREF Numeric Options
1 = Invokes the STRSEU (Start SEU) command to edit the source code of the referenced object.
2 = Executes a CHGxxx command to change the referenced object depending on the
object type; e.g., CHGPGM (Change Program) is invoked if the referenced object is
a program (*PGM) object.
5 = Invokes a DSPxxx command, depending on the object type; e.g., DSPPGM (Display Program) is invoked if the referenced object is a program (*PGM) object.
8 = Executes the DSPOBJD (Display Object Description) command.
9 = Lists all the record formats referenced in a file.
10 = Changes the referenced object's source code information that was supplied byOS/400 at compile time. This is useful when you move the source file to adifferent library or rename the source file or the member.
12 = Invokes WRKPGMREF recursively for the referenced program.
13 = Executes the CHGOBJD (Change Object Description) command to let you change the referenced object's text description.
WRKPGMREF Function Keys
F1 = Displays help.
F3 = Exits WRKPGMREF.
F4 = Invokes the command prompter for the command you enter on the command line.
F5 = Refreshes the detail lines in the panel.
F6 = Prompts the appropriate command to re-create the referencing program or module without requiring you to edit the source member.
F7 = Executes the CHGPGM command to change the program being analyzed.
F8 = Prompts the UPDPGM (Update Program) or UPDSRVPGM (Update Service Program) command for the referencing of an ILE program or service program. The update command includes all modules you re-created or changed using WRKPGMREF.
F9 = Retrieves the last command entered on the command line.
F10 = Invokes STRSEU so you can edit the source code of the program being analyzed.
F11 = Toggles between two views of the detail lines. By default, the rightmost data column shows text descriptions; by pressing F11, you can have it display source code information.
F12 = Cancels the WRKPGMREF panel.
F13 = Executes the RNMOBJ (Rename Object) command to change the name of the program being analyzed.
F14 = Invokes the MOVOBJ (Move Object) command to move the program being analyzed into a different library.
F15 = Changes the source code information of the program being analyzed.
F21 = Prints the referenced-objects list shown on the main panel. The resulting hard copy of the references contains more information than the output of the DSPPGMREF (Display Program References) command.
F24 = Displays more function keys.
To learn more about WRKPGMREF, read the article "The ILE WRKPGMREF Utility" at http://www.as400network.com/article.cfm?ID=1991 . You can download the code from http://www.as400network.com/resources/code/index.cfm?fuseaction=ShowAllIssueCode&IssueSelect=Past&IssueYear=1997&IssueMonth=09 .
The code is extensive: it includes more than 20 objects from more than 10,000 lines of source code comprising two panel groups, 16 modules (bound into three ILE programs), and one command. By far the easiest way to get WRKPGMREF to your system is by downloading the save file version of the utility.
You must be an AS400Network professional member to download the code or read the online article.
72. Short Takes:
1. RECOVERING AN INTERRUPTED SEU SESSION
Q. I was in the process of creating a new member while editing a source file with SEU. After an interrupted emulation session, I can't remember the name, and I hadn't yet saved the member. Where does OS/400 store the details of interrupted SEU Edit sessions?
A. You don't have to bother with the recovery tables for this type of abend to solve your problem. When you create a new source member, SEU automatically adds it to the source file. Your new member is empty, but it is there. If you pressed Enter while in SEU, the code typed in or changes made will be reflected in the source member. Bear in mind, though, that certain abends (such as the system going down) can prevent recovery of the source.
If you know the name of the source file and library you were using at the time you were interrupted, the failure was recent, and you pressed Enter while in SEU, then these steps should find your lost member:
a. Execute the STRPDM (Start Programming Development Manager) command.
b. Select option 3 to work with members.
c. Fill in source file and library names, and for member name and type, select *ALL.
d. From the panel listing members, look for the member's name. If there are many names, press F15 to sort the members by date. This displays the most recently changed members first.
e. Once you locate the member, select option 2 to edit; if any records were saved, you'll get the SEU recovery screen; select option 1 to recover the member. If no records were saved, you'll get the message that the member has no records, in which case you're out of luck.
From a Tech Corner item by Gary Guthrie
2. TESTING FOR AN ACTIVE PROCEDURE - FEEDBACK
The September 13 issue of this newsletter included a tip "Testing for an Active Procedure." I received several replies that included improved solutions, which are now displayed at http://www.as400network.com/ClubTech/index.cfm?fuseaction=ShowNewsletterIssue&ID=8623 .Check back periodically for more feedback updates.
3. FREE ONLINE IBM AS/400 EDUCATION
IBM offers free online education courses on a variety of AS/400 topics, including Client Access, HTTP Server, Java, Domino, and much more.
To see the courses, go to http://www-3.ibm.com/servlet/com.ibm.ls.lsow.servlets.SearchByChapterServlet?CATALOG_ID=6&CHAPTER_ID=3&ROW_COLOR1=C8D8F8&ROW_COLOR2=FFFFFF ,scroll about halfway down the list, and you'll see the list of 65 free onlinecourses.
4. TALK TO THE IBM TORONTO RPG DEVELOPERS
Now's your chance to give George Farr, Barbara Morris, and Hans Boldt your feedback regarding RPG enhancements in the next release via a special forum at http://www.as400network.com/forums/Main.cfm?CFApp=71 . You can also read about the future of RPG IV in the November article "RPG IV: Free Format and More" by IBM RPG Technical Manager George N. Farr at http://www.as400network.com/article.cfm?ID=8642 .
5. CHECK IT OUT AT CLUB TECH: ILE RESOURCES
The Club Tech ILE Resources page at http://www.as400network.com/ClubTech/ILE is the launching point for information and code for all aspects of ILE programming. Among the resources listed are downloadable utilities (such as WRKPGMREF, discussed in this newsletter), shareware, recent articles and NEWS/400 Q&A, IBM manuals, books, and forums.
73. VIEWING PROGRAM MESSAGES
http://www.as400network.com/nwn/story.cfm?ID=8809
Q. We have a program that's submitted in batch job through a job scheduler. This program sends messages via the command SNDPGMMSG MSG(&MSGDTA). Where will I be able to see those messages? I've tried using DSPLOG QHST, which gives job started and ended messages but not the messages that program has sent. When we run that program in interactive mode, those messages are seen in job log.
A. Your messages are being sent to the program message queue, and you can see them in the job log. You're able to see them using command DSPJOBLOG (Display Job Log) as long as the job is active. Interactively, a job is active until you sign off. For batch jobs, the job is no longer active when the job ends. If you set your job logging levels appropriately, a job log will be spooled when the job ends. Because the job scheduler submits jobs to batch, you must do this to see the messages in a spooled file after the job is completed. You control the logging levels in the LOG parameter of the job description or in the SBMJOB command. Typically, you'll use LOG(4 0 *SECLVL) when you want to always spool a job log upon job completion.
Gary Guthrie, NEWS/400 Tech Editor
74. DELETING OLD SPOOL FILES
A common question asked in the forums and newsgroups is how to automatically delete older spool files. There are commercial products that perform this function, which you can find at http://www.sourcebook400.com . Select "System Software" under "Product Category," then select "Spool Utilities" under the "Operations" category.
Several free utilities and techniques allow automatic deletion of older spool files:
a. NEWS/400's CLNUPOUTQ Utility
The CLNUPOUTQ utility lets you archive or delete spool files from the output queues on your system. The command supports the following parameters:
* Output queue (OUTQ) specifies the names and libraries of the output queues you want to include in or omit from the cleanup.
* Include or omit output queues (OPTION) specifies whether the output queues are to be included in (*INCLUDE) or omitted from (*OMIT) the cleanup.
* User ID (USRID) specifies the ID of the user whose spool files are to be cleaned up.
* Retention days (RETAIN) specifies how long spool files are retained.
* Delete or archive spool files (ACTION) determines whether the spool files are deleted or archived.
The CLNUPOUTQ utility was published in the July 1999 issue of NEWS/400 and can be read online at http://www.as400network.com/article.cfm?ID=3073 . The easiest way to get the utility to your AS/400 is by obtaining the save file from http://www.as400network.com/code/index.cfm?fuseaction=DownloadFile&type=save&yyyy=1999&file=svfToolsV4R3.zip.
You must be an AS400 Network professional member to read the article and obtain the code.
b. Henrik Krebs' Delete Old Spoolfiles (DLTOLDSPLF) Utility
This freeware utility includes the ability to delete spool files in one or more output queues that are a given number of days or minutes old. Source is included. You can download the utility from http://hkrebs.dk/dltoldsplf.html .
c. Tom Liotta's Process Spool File (PRCSPLF) Utility
This freeware utility moves spool files older than seven days into output queues named for each day of the week. You can then write a CL program to automatically delete the archived files in those output queues before running PRCSPLF. Source is included. You can download the utility from http://home.earthlink.net/~tliotta/Files/Age_Spool_Files/Age_Spool_Files_README.htm.
d. QUSRTOOL DLTOLDSPLF Utility
This utility was included in the TAA tools in library QUSRTOOL, which was bundled with OS/400 up until V3R1. If you still have access to this utility, you need to be aware that DLTOLDSPLF must be modified to make it Y2K compliant, or you may delete all your spool files instead of just aged files.
e. OS/400 Cleanup Tasks (CLEANUP) menu
You can automatically delete old printer output created by system functions (not by user programs). The Cleanup Tasks are described in the AS/400 System Operation at http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/QBJAGD00/8.4 .
f. IBM System API Reference manual DLTOLDSPLF Utility
IBM includes the DLTOLDSPLF utility in Appendix 2 of the System API Reference manual. There are three versions of DLTOLDSPLF: OPM RPG, OPM COBOL, and ILE C. You can view the code at http://publib.boulder.ibm.com/cgi-bin/bookmgr/bookmgr.cmd/BOOKS/QB3APD03/A.2 .
75. Short Takes:
1. CONTROLLING WHEN TCP/IP APPLICATION CONNECTION ENDS
Q. TCP/IP applications such as File Transfer Protocol (FTP) and Telnet are not affected by the QINACTITV system value. (This system value controls how long a job can be "inactive" before some action is taken against it, such as ending it.) How do I control how long a TCP/IP application connection is inactive before it's ended?
A. You can control how quickly a TCP/IP connection is ended through the TCP/IP application's INACTTIMO attribute. For example, to change the inactivity time-out attribute for FTP, run the following command:
CHGFTPA INACTTIMO(60)
This causes an inactive FTP server session to time out in 60 seconds. As of V4R2, both Telnet and Workstation Gateway (WSG) use the QINACTITV system value to end connections. (If a value is specified for both the QINACTITV system value and the INACTTIMO attribute, the application uses the shorter time to end connections.)
Answered in NEWS/400 by Carol Woodbury
2. SAVING ALL OBJECTS IN QUSRSYS
Q. When I save the QUSRSYS library, not all objects in QUSRSYS are saved. Is this a problem?
A. Always make sure library QUSRSYS is completely saved. If the system isn't in a restricted state (with all subsystems ended), objects in QUSRSYS that begin with the letter Q may be in use and therefore not saved. These objects contain critical recovery data and must be saved for a complete system recovery.To save objects that begin with the letter Q, do one of the following when saving QUSRSYS:
* End all subsystems (with ENDSBS SBS(*ALL)).
* End subsystems QSNADS, QSYSWRK, and QSERVER.
* Use Save menu option 21 or 23.
* Use the save-while-active feature. (Refer to the book OS/400 Backup and Recovery (SC41-5304) at http://publib.boulder.ibm.com/cgi-bin/bookmgr/DOCNUM/SC41-5304-04 for more information about the save-while-active feature.)
Answered in NEWS/400 by IBM Senior Business Recovery Specialist Debbie Saugen
3. NONDISRUPTIVE QUSRSYS BACKUP
Q. How do I manage backup and recovery of library QUSRSYS to meet the needs of a full system restore (to another box) and not affect users or operations too much?
A. The QUSRSYS library must be completely backed up for a successful system recovery. Putting the system in a semi-restricted state by ending QINTER if using save-while-active and ending QSNADS, QSYSWRK, and QSERVER is also a good way to ensure that QUSRSYS is completely saved.
However, this approach doesn't provide unattended operations or reduce the impact to end users. In the past, if a *MSGQ was in break mode during a backup, OS/400 couldn't obtain a lock to save it. The Save/Restore group at IBM has written new functions for a future release to avoid this problem. IBM has also added PTFs for V4R1 and higher to help its existing customers. The following PTFs let OS/400 successfully save a *MSGQ, even when in *BREAK mode:
V4R1 - SF49860V4R2 - SF49848V4R3 - SF49800
Check out IBM's Technical Support center at http://as400service.ibm.com/ for the latest information on PTFs and PTF downloads.
Answered in NEWS/400 by IBM Senior Business Recovery Specialist Debbie Saugen
76. NUMERICAL FORMATS
http://www.as400network.com/nwn/story.cfm?ID=8835
Q. What's the advantage of performing calculations in an RPG IV program in packed decimal format? Why not use binary integer or floating point for storing numbers, as they occupy less space?
A. One advantage of packed decimal format is that it gives you more digits than binary integer. Before V4R4, you had a maximum of nine digits reliably available. You could define a field as 10 digits, but you still had only the range of values available to a four-byte binary number. As of V4R4, you can now define an integer field to have up to 20 digits, which is implemented under the covers as an eight-byte binary field. Packed fields give you a greater range of up to 30 digits. If you don't need this greater range, the integer data type is acceptable.
You can't define binary fields of 20 digits in DDS, although you can in SQL. Some people like to use packed fields because it's easier to decipher the contents when displaying a field's hexadecimal contents, though I personally don't find this argument compelling.
Floating point is a dangerous encoding method for storing ordinary business data (e.g., currency and other types of amount fields) because it gives arithmetic results that are accurate to a certain precision. For example, in floating point arithmetic, if the "true" result is 10, you run the risk of obtaining a result of 9.9999999 or 10.00000001. Floating point is typically used for scientific calculations.
Floating point can be appropriate in business when you need to produce the result of a complicated calculation (e.g., a mortgage interest calculation). Nevertheless, once such calculations have been made, results stored on disk (such as monthly payments, principal, interest, and so on) aren't normally floating point. Floating point is essential if you want to make C function calls from an RPG IV program to a function (e.g., sine, cosine) that requires floating point parameters or returns a floating point result.
Mike Cravitz, NEWS/400 Tech Editor
77. BARCODES AND PRINTER FORMATS
http://www.as400network.com/nwn/story.cfm?ID=8930
Q. I have an O-spec command stream that, when printed to a laser printer, prints a barcode. When we print this O-spec to an impact printer, it prints only the characters. I recently discovered that the command string is PCL5 format. What format do the QMS cards in an impact (dot matrix) printer require? We have no *IPDS printers, so IBM's manuals haven't been helpful. Can you suggest any Web sites, information, or books that provide a command string to replace my existing command string to print a barcode?
A. There are three key elements of coding for bar codes:
1. Does the printer support bar codes, and what type?
2. What is the interface, and will the AS/400 apply any transforms?
3. Who controls the printer language (AS/400 or printer)?
Your current laser printer is using HP's PCL, and therefore the specifications for the language are controlled by HP, which provides the manuals. The QMS interface is controlled by QMS, which should provide documentation on its print language and information on the printer's capability. QMS provides support for Code V.
The IBM 6400 Line Matrix printer supports Code V and IGP in addition to the IPDS capabilities. The 6400 also has Proprinter and Epson FX emulation. IBM provides the appropriate manuals when you buy the printer with those features. You can also buy the manuals separately.
The IBM Proprinter can print a few barcodes, and the ProPrinter documentation provides the hexadecimal values required to enable barcode printing. The configuration of the printer and the writer used can also result in the hex values being transformed or ignored. Your printer vendor should be able to provide guidance in this area.
OS/400 provides numerous Host Print Transforms for IBM and non-IBM printers. The AS/400 Support Line can help you connect non-IBM printers.
Bill Shaffer, IBM Brand Manager for AS/400 Printing Solutions
78. SPELL-CHECKING WITH APIS
Q. How can I spell-check database character fields? Is there an OS/400 API that can check the spelling of a string?
A. API QTWCHKSP spell-checks one or more words for you, and API QTWAIDSP returns a list of words spelled similarly. You use QTWCHKSP to determine whether a word is spelled correctly, and if it isn't, you use QTWAIDSP to list possible replacements.
Both APIs require language dictionaries to be installed on your system; a language dictionary exists for each national language that IBM supports. To find the language dictionaries installed on your system, enter GO LICPGM from any command line, and then choose option 10 from the menu. The product number for the IBM Dictionary and Linguistics Tools for AS/400 V4R5 is 5769-DL1, and it's 5716-DCT for V3R2 through V4R4.
For example, if you have OS/400 V4R4, when you enter GO LICPGM and choose option 10, you get 5716DCT. When you select 5716DCT, you can scroll through the list to find the U.S. English dictionary, which is the last one listed. Because the list contains 20 or 30 dictionaries (Russian, French, French-Canadian, and so on), it's worth checking to see that an English version is loaded -- on rare occasions, it isn't.
The documentation for the Check Spelling (QTWCHKSP) API is online at http://publib.boulder.ibm.com/pubs/html/as400/v4r5/ic2978/info/apis/QTWCHKSP.htm ,and the Aid Spelling (QTWAIDSP) API is at http://as400bks.rochester.ibm.com/pubs/html/as400/v4r5/ic2924/info/apis/QTWAIDSP.htm.
You can download a demonstration application that shows how to use QTWCHKSP and QTWAIDSP from Tom Liotta's Web site at http://home.earthlink.net/~tliotta/Files/User_Interface_Manager/User_Interface_Manager_README.htm.
There are also at least two third-party products that offer either spell-check APIs or RPG source code that uses IBM's Spell Check APIs:
Spelling AssistantGeneric Software, Inc.http://www.genericsoftware.com/
TAA Productivity ToolsJim Sloan, Inc.http://www.taatool.com/
Adapted and updated from a Tech Corner item by John Earl and Gary Guthrie
79. Short Takes:
1. CHECKING FOR A RECORD-LOCK CONDITION IN RPG
Q. How can I check for a locked-record condition in an RPG program?
A. The general answer to your question is to check for status code 01218 in the file information data structure (INFDS). The code below shows how to do this in an RPG/400 program:
(A) FCUSTOMERUF E K DISK KINFDS CUSTDS
*
(B) ICUSTDS DS
I *STATUS STS
*
C Z-ADD1 CUNUM
C CUNUM CHAINCUSTOMER 9998
*
(C) * HERE IS THE TEST FOR LOCKED RECORD
C *IN98 IFEQ *ON
C STS ANDEQ01218
C EXSR PRCTO
C MOVE *ON *INLR
C RETRN
C ENDIF
Notice at (A) that CUSTDS is defined as the name of the data structure containing the file feedback information for the CUSTOMER file. At (B), I define an INFDS data structure for the CUSTOMER file. I named the file status field STS.
Notice that the CHAIN instruction just above (C) codes 98 as the LO resulting indicator. All I/O opcodes in RPG/400 use the LO resulting indicator to trap file errors. A record-lock timeout is considered a file error. Therefore, at (C), I test indicator 98 and the STS field to determine whether a timeout has occurred. If I hadn't coded the LO resulting indicator in the CHAIN instruction, the program would abnormally terminate when a record-lock timeout occurs.
In RPG IV, the most effective way to handle a record-lock timeout is with ILE condition handlers, explained in "Handle It - With RPG Exception Handlers!" ( http://www.as400network.com/article.cfm?ID=2919 ).Instead of describing the exception-handler technique here, I demonstrate how to perform the RPG IV equivalent to the technique described for RPG/400 lockouts. The code below illustrates this technique:
FCustomer UF E K Disk
C Z-Add 1 CuNum
(A) C CuNum Chain (E) Customer
* Here is the test for timeout
(B) C If %Status = 01218
C ExSr ProcTimeOut
C Eval *INLR = *On
C Return
C EndIf
The first thing to notice is that we don't need an INFDS feedback data structure to test for a record lockout in RPG IV. The RPG IV built-in function (BIF) %Status is sufficient for our purposes. Notice at (A) that I don't code any indicators for the Chain instruction. Instead, I code the "(E)" extender. This tells RPG I want to use error-checking BIFs such as %Error and %Status. In this example, I use only %Status. As in the RPG/400 example, I check for a timeout by testing for status code 01218 (at B).
One final word about record-lock timeouts. If you think you'll test for timeouts in your programs, you might consider shortening the timeout period. By default, the CRTPF command sets the WAITRCD attribute to 60 seconds. The WAITRCD attribute determines how long the system will wait for a locked record upon access. Sixty seconds is too long for your users to wait for a timeout message. You can change the timeout associated with a file by specifying a value for the WAITRCD parameter on commands CRTPF, CRTLF, CHGPF, and CHGLF. For example, to change the timeout on the Customer file to 10 seconds, you'd code the following:
CHGPF
FILE(YOURLIB/CUSTOMER)
WAITRCD(10)
From a Tech Corner answer by Mike Cravitz
2. DISPLAYING RECORD-LOCK MESSAGES IN RPG
When a user tries to update a record being held for update by another job, an error occurs. (The record wait default value is 60 seconds, so it often literally takes a minute before the error is detected.) You can capture this error and display the name of the user who caused the record lock so that the user being inconvenienced can solve the problem herself instead of calling you.
The sample I- and C-specs below illustrate this technique:
I SDS
I 91 170 MSGTXT
.
.
.
C KEY CHAINFILE 9990
C *IN90 IFEQ '1'
C MOVELMSGTXT ERRMSG
C END
On the CHAIN operation, put an indicator in columns 56 and 57 to capture the record allocation error. If the indicator comes on, retrieve the error message text from positions 91 through 170 of the program status data structure (PSDS). The message will say "Record &REC# in use by job &JOBNO/&USER/&JOBNAME."
If that message is too cryptic for your users, you can write a program to pull the user name from the message and display it in a more understandable error message. Your users can then ask the user causing the lock to release the record.
From a Tech Corner answer by Bryan Meyers
3. DISPLAYING RECORD-LOCK MESSAGES IN COBOL
Cobol subroutine WhoHasLock has recently been made available in the AS400 Network Cobol Community, which you can visit at http://www.as400network.com/communities/cobol/ . The subroutine returns a 28-character field (as a parameter) that is the jobname/user/number of the job holding a lock. The routine looks for a CPF5027 message in the caller's message queue. If it finds it, it uses it to return the pertinent information. If it doesn't find it, or if it encounters any unexpected errors in the process of searching for the message, it returns Low-Values in the 28-byte parameter.
You can download the subroutine from http://www.as400network.com/cobol/CobolCode/SubrtnLkRecHldr.zip .
4. STRING-HANDLING SIMPLIFIED WITH VARIABLE-LENGTH FIELDS
The RPG Style Guide at http://www.as400network.com/article.cfm?ID=2461 recommends using built-in functions instead of arrays to handle strings. The varying-length character type (available in V4R2 and above) can also simplify string-handling code as well as make it more efficient. I recommend using varying-length fields as CONST or VALUE parameters to every string-handling subprocedure as well as for string temporaries. (I recently worked with an RPG programmer, and we reduced the number of lines in a subprocedure from about 10 icky lines to two simple and straightforward lines, mostly through the use of varying-length parameters.) Here's a little example; not only does it look better, but it's also faster (no %TRIMs). Instead of:
C EVAL Name = %TRIMR(Lib) + '/' +
C %TRIMR(File) + '(' +
C %TRIMR(Mbr) + ')'
with variable-length fields, you can use:
C EVAL Name = Lib + '/' +
C File + '(' +
C Mbr + ')'
I thought I should check my claim that this approach is faster, and it turns out it's more than twice as fast to produce "Lib/File(Mbr)", where all variables (except "Name") are 10 characters long.
Adapted from a forum message by IBM Toronto's Barbara Morris
80. ZONED DECIMAL FIELDS CHANGED TO PACKED
http://www.as400network.com/nwn/story.cfm?ID=8933
Q. I've seen instances when RPG changes a zoned decimal field to packed. Under what conditions does RPG do this?
A. The program version F-spec zoned decimal fields will always be presented as packed decimal within the program itself. RPG does this because packed is a better encoding method on the AS/400 for performing arithmetic operations. You can override this by specifying an externally described data structure for the file used in the F-spec. The following example shows how this is done in an RPG IV program:
FMyFile IF E K Disk
D MyFileDs E DS ExtName( MyFile )
This externally described data structure causes RPG to use zoned decimal for all fields defined as zoned decimal in your program.
Mike Cravitz, NEWS/400 Tech Editor
Dieses Buch wird laufend erweitert!90>
In the July 5 Club Tech Programming Tips newsletter, I described how to convert a string to a number using IBM-supplied RPG code. Mike Kienenberger wrote me about another method: calling functions in the C runtime library from RPG IV.
The code below shows how to use C functions atoi (ASCII to Integer) and atof (ASCII to Floating point) to convert an alphameric string to a number. Note that atoi expects only digits (no decimals, signs, or commas), while atof can convert numbers containing a decimal, +/- sign, and commas.
h bnddir('QC2LE')
D atoi pr 10i 0 extproc('atoi')
D num * options(*string) value
D atof pr 8f extproc('atof')
D num * options(*string) value
D i s 10i 0
D p s 13p 7
C movel '-100 ' num 6
C eval i = atoi(%trim(num))
* > EVAL i
* I = -100
C eval(h) p = atof(%trim(num))
* > EVAL i
* P = -000100.0000000
C movel '-5.67 ' num 6
C eval(h) p = atof(%trim(num))
* > EVAL p
* P = -000005.6700000
C return
Code provided by IBM's Barbara Morris
2.ALLOCATE OBJECT
http://www.as400network.com/nwn/story.cfm?ID=7826
Q. We wrote and use our own change management system. The problem is that when we move the changed objects to the production system, we can't use the ALCOBJ command to lock a display file, temporarily preventing its use. Is there a way to lock a display file in a CL program so we can compile the display file?
A. The ALCOBJ command doesn't work with device files. However, you can mimic an exclusive object lock in a number of ways. One way is to use the MOVOBJ command to move the display file to a temporary library. You then compile the new version of the display file and delete the original file from the temporary library. The advantage of this approach is that you can restore the original display file if an exception occurs.
Julian Monypenny, NEWS/400 Tech Editor
3.BINDING PROBLEM
http://www.as400network.com/nwn/story.cfm?ID=7861
Q. I have a module (let's call it X) that I bind by copy into several different programs. If I ever have to change module X, I must rebind all programs in which it occurs. How can I keep track of which programs use a particular module?
A. Most third-party change management systems have this capability. If you want to do this yourself, you can use the DSPOBJD command specifying you want the output to go to an *OUTFILE to produce a list of all program objects in a database file. You can then read each record in this database file and use the QBNLPGMI (List ILE Program Information) API to determine what modules are contained in each program.
Actually, all of this pretty much misses the point. If you have a module, which is potentially usable in more than one program, you should place that module into a service program. ILE programs can access procedures in a service program without binding them by copy into the program object. If you change a module in a service program without changing the exports (i.e., procedures and data that are available outside the service program), you don't have to rebind all the programs that use the service program. Modules bound to ILE programs are bound by copy because a copy of the module is placed into the program object itself. Modules contained in a service program are bound by reference because the program object, which uses them, contains only a reference to the service program and not a copy of any of its modules.
Mike Cravitz, NEWS/400 Tech Editor
4.RPG, CL, AND Java
http://www.as400network.com/nwn/story.cfm?ID=7814
Q. I want to learn more about RPG and CL programs calling Java programs. I've read about this and am aware of commands such as RUNJVA and also that RPG can use the QCMDEXC API. However, in my reading I didn't see much information about passing parameters. Can you explain more about this?
A. You can pass parameters to a Java class by using the RUNJVA command in a CL program. These parameters end up as the array of string arguments to a Java class's main method. Note, however, that these parameters are input only; a Java class can't return values to a CL program. To execute a Java class with a CL program and pass parameters in both directions, look to IBM's AS/400 Toolbox for Java. Using the Toolbox, you can use AS/400 data area or data queue objects as a means to accommodate a bidirectional data exchange.
You might be interested to know that a Java class can directly call an RPG or a CL program and exchange data with the program by using the AS/400 Toolbox for Java's program call facility. A Java class using the Toolbox can call an RPG or a CL program and pass data as input, output, and input/output parameters.
Dan Darnell, NEWS/400 Tech Editor
5.TRACKING FILE USAGE
http://www.as400network.com/nwn/story.cfm?ID=7775
Q. Is there an AS/400 file that stores the activity or characteristics of all AS/400 objects? I want to run a query on this file to determine an object's size and last-used date.
A. There's no AS/400 file that holds this information, but you can create one using the DSPOBJD command. Issue the following command:
DSPOBJD
OBJ(*ALL/*ALL) +
OBJTYPE(*ALL) +
OUTPUT(*OUTFILE) +
OUTFILE(YourLib/YourFile)
For performance reasons, be sure to run this command in batch. Once the command has finished executing, you can query file YourLib/YourFile for the information you want.
Gary Guthrie, NEWS/400 Tech Editor
6.BATCH FILE TRANSFER VIA FTP
http://www.as400network.com/nwn/story.cfm?ID=7719
Q. I'm trying to automate the transfer of a PC .txt file to our AS/400 and then automatically trigger a conversion program to integrate the data into our data files. I wrote a .bat file that uses Rumba AS/400 file transfer to upload the file to the AS/400. I now must call a CL program from within the .bat file. Can I do this and, if so, how?
A. Although you can't do this with Rumba's file transfer, you can easily do it with FTP. Although FTP's primary function is to perform file transfers, you can use its RCMD subcommand to execute commands and programs on the AS/400. RCMD is handy for launching AS/400 jobs that process the transferred files. The following sample FTP command line shows how you can execute under Windows NT a batch FTP job that performs a file transfer and calls an AS/400 program.
ftp -n -i -s:ftp400cmd.txt S101AA0A
The ftp command starts the Windows FTP application, and the -n and -i switches indicate that the program will run in batch mode and won't perform any interactive prompting. At the end of the line, S101AA0A specifies the name of the AS/400 host system. The -s: switch specifies a file that contains the FTP subcommands to be executed.
The contents of the ftp400cmd.txt file are as follows:
USER myID
myPWD
cd QGPL
put myfile.txt
quote rcmd call pgm(mylib/mypgm)
quit
The first line supplies the user ID used to connect to the AS/400, and the second line supplies the password. Note that by default these values are sent across the network in clear text. Although this is probably fine for most internal networks, you shouldn't do this for public Internet access. The cd subcommand changes the AS/400's current library to QGPL. The put subcommand sends the file myfile.txt from the Windows NT system to the AS/400's QGPL library. Next, the quote rcmd subcommands execute AS/400 program mypgm in mylib. Finally, the quit subcommand terminates the FTP session.
Michael Otey, NEWS/400 Senior Technical Editor
7.OBTAINING AS/400 COMMAND INFORMATION
http://www.as400network.com/nwn/story.cfm?ID=7644
Q. I'm working on a project to supply a graphical front end to our AS/400 software product. Our system uses the QCMDCHK command to prompt for command details. I need to provide the information QCMDCHK uses to let my GUI client rather than the AS/400 prompt for the file information. Specifically, I must obtain the information as specified by the command PARM in the command source file (e.g., KWD, TYPE, LEN, PROMPT). Unfortunately, the DSPCMD command doesn't provide this information. My server programs are written in ILE RPG and the graphical client with Java.Given that the source files aren't shipped with our product, how can I retrieve this information from "compiled commands?"
A. You might find Dave McKenzie's RTVCMDSRC freeware utility helpful.This handy utility retrieves from the command object source that reflects the command's structure. Remember, IBM could at some point change the command object's structure, thereby causing the utility to fail or produce unpredictable results. On the bright side, this utility has been stable for some time, and it's quite possible that IBM won't introduce problematic changes. You can download RTVCMDSRC from http://www.as400network.com/sharewarefiles/rtvcmd.zip
Gary Guthrie, NEWS/400 Tech Editor
8.GETTING TO THE ROOT OF 63A0
http://www.as400network.com/nwn/story.cfm?ID=7638
Q. When I perform a WRKCFGSTS (Work with Configuration Status) command, my tape device appears as a 63A0 tape device. I know this is a generic tape device name; how can I learn the actual model of my tape device?
A. To find out whether your 63A0 is a model 6380, 6381, 6382, 6385, 6386, or other tape device that appears as a 63A0, perform the following steps:
1. Type the command STRSST (Start System Service Tools) and press Enter.
2. Type 1 to Start a service tool and press Enter.
3. Type 7 to select Hardware service manager and press Enter.
4. Type 2 to select Logical hardware resources and press Enter.
5. Type 1 to select System bus resources and press Enter.
6. Find the resource name where the tape device is located (usually CMB01 for 63A0), type 9 to select Resources associated with IOP, and press Enter.
7. Find the description of the tape device with type 63A0, type 8 to select Associated packaging resources, and press Enter.
8. Type 5 to Display detail and press Enter. The actual model type of the tape device is listed on the Type-Model line.
Debbie Saugen, IBM Senior Backup and Recovery Specialist
9.ASSIGNING 5250 WORKSTATION DEVICE ID
http://www.as400network.com/nwn/story.cfm?ID=7605
Q. Does PC5250 display emulation let me assign a unique workstation device ID, or does TN5250 assign it randomly when I connect to an AS/400?
A. You can select your workstation device ID when using either Client Access for Windows 95/NT or Client Access Express PC5250 emulation. However, many additional PC5250 capabilities have been available for Client Access Express since January 2000 via Service Pack SF60698 or later.
Many emulation programs don't handle 5250 workstation IDs over TCP/IP very well, and users and administrators want more control over how workstation IDs are assigned and maintained. The Express client has improved this area so that you can select your workstation ID, have multiple 5250 sessions, and maintain everything in one workstation (.WS) profile. A .WS profile is where information about a 5250 session is stored. AS/400 administrators can choose to maintain only one .WS profile on an AS/400 and have it shared by all PC5250 sessions, thus enabling standardization of settings. Alternatively, users can save their .WS profiles on their PCs and change them to suit their preferences.
IBM has added a new parameter for setting up the workstation ID name.
The format of this parameter is
Workstation ID=[+][%](Workstation + _Name/&COMPN/&USERN)[*][=]
* + indicates to truncate the workstation ID from the end if it's longer than 10 characters
* % adds P (Printer) or S (diSplay) to the front of the workstation's name
* Workstation_Name is the "hard-code device name" (e.g., "WS1")
* &COMPN is the Computer name (this is the name identified in the Windows Network Identification area)
* &USERN is the Windows User name
* * means add a suffix (e.g., A, B, C) to the workstation ID
* = means auto-increment the workstation ID if additional sessions are started (increments go from 1 to 9, then A-Z)
By establishing guidelines for naming the workstation ID for display and printer sessions, AS/400 operators and administrators can more easily determine what's attached to their AS/400 at any time.
Carole Miner, IBM Senior Software Engineer
10. MESSAGE CPI1466
http://www.as400network.com/nwn/story.cfm?ID=7600
Q. Why do I sometimes see message CPI1466 -- "Job holds large number of locks" -- in my job log during save operations?
A. Message CPI1466, which sometimes appears in the job log during save operations, is sent to message queue QSYSOPR and to the history log (QHST) when a specific job obtains a suspiciously large number of locks. This message is meant to draw your attention to any application that holds a large number of locks so you don't overlook any of them. A typical save operation obtains and releases many locks as it processes objects, so it's not unusual to see message CPI1466 at this time. During save operations, you don't need to take any action when you see message CPI1466.
The number of locks required to trigger message CPI1466 is release-dependent, so you may see it at one release but no longer see it after you upgrade. Sometimes message CPI1466 will appear every time a save is run except the first time after an IPL. This is because after an IPL, objects have been paged out to disk, which slows the preprocessing on the next save because the objects must be brought back into memory. Therefore, the system won't hold as many locks.
Debbie Saugen IBM Senior Business Recovery Specialist
11. DISPLAY FILE ERROR MESSAGE
http://www.as400network.com/nwn/story.cfm?ID=7563
Q. I want to know why I've been getting this error message: "SDA3659: Extract description is not allowed for file QDPTDSP in QSYS." I get the error when I try to use the STRSDA command's option 3 on file QDPTDSP for testing the record formats and selecting a record for testing.
A. Display file QDPTDSP in library QSYS is an IBM-supplied system file. Sometimes, IBM-supplied objects aren't quite "what they seem." Although QDPTDSP is a display file, it differs from the display files you create. It doesn't contain everything that user-created display files contain. This is true of most IBM-supplied display files. For instance, when you use the DSPFFD command on file QDPTDSP, you don't see a record format list displayed, unlike when you invoke DSPFFD on a user-created display file.
Although IBM states the missing information has been removed to save space, I suspect other motives. IBM often likes to "hide" a few things from customers. The bottom line is that this behavior isn't unique to file QDPTDSP. Because IBM-supplied display files don't contain the information SDA requires, you can't use them in an SDA session.
Gary Guthrie, NEWS/400 Tech Editor
12. MANAGING DISK USE
To help you manage disk use on your AS/400, OS/400 includes the RTVDSKINF (Retrieve Disk Information) and PRTDSKINF (Print Disk Information) commands. You can use these two commands to monitor the utilization of your disks, or you can write your own queries over the data captured by RTVDSKINF to analyze changes in disk use.
You use command RTVDSKINF to gather information about all the objects on your system. The command outputs the information to member QCURRENT in file QAEZDISK in library QUSRSYS. For a large system with many thousands of objects, running RTVDSKINF can take many hours, so IBM requires you to run the command in batch. The easiest way to do this is to use the SBMJOB (Submit Job) command:
SBMJOB CMD(RTVDSKINF)
You use command PRTDSKINF to print the information that command RTVDSKINF generates in file QAEZDISK. PRTDSKINF lets you print a summary of your system information or print details of disk use by library, folder, owner, or object. For example, to print a list of libraries that are more than 1,000 K in size in descending order by size, you run the command
PRTDSKINF RPTTYPE(*LIB) +
OBJ(*NONE) +
MINSIZE(1000) +
SORT(*SIZE)
The online help for PRTDSKINF explains all the available options.
If the standard PRTDSKINF report options don't meet your needs, you can write your own queries over file QAEZDISK. In addition, you can save the data in member QCURRENT in QAEZDISK to a file and write queries to compare the output from different runs of RTVDSKINF.
From a NEWS/400 Tech Corner item by Julian Monypenny
13. Short Takes:
1. STORAGE USED BY ALL USER PROFILES
To get a list of all user profiles and the amount of storage they use, you first use the DSPUSRPRF command to create an outfile, then create a query over that outfile. IBM has provided simple instructions on this process at http://as400service.ibm.com/8625680A007CA5C6/0/9E2935A65DC72239862565C2007D2F24?Open&Highlight=2,4664258
2. FINDING DEFAULT IBM PASSWORDS
Q. What command or utility checks for IBM-supplied user IDs that haven't had their passwords changed from their default values?
A. The command is ANZDFTPWD. You can either enter the command or enter GO SECTOOLS and select menu option 1. When run, ANZDFTPWD prints a report named QPSECPWD that shows all the user profiles on the system with default passwords. ANZDFTPWD optionally lets you disable or expire the password for user profiles with default passwords.
3. READABLE FONT FOR 132-COLUMN 5250 DISPLAYS
If you're not happy with the font used in your Rumba or other 5250 emulation software, Microsoft offers a free font that you might try. The font, Andale Mono, can be downloaded from http://www.microsoft.com/OpenType/fontpack/default.htm. I've tried it in MochaSoft's TN5250 product in both 80-column and 132-column modes, and it is very readable.
14. ALLOW DESIGNATED PERSONNEL TO CHANGE PASSWORDS WITHOUT QSECOFR
How many times in a month does a user who has forgotten his or her password interrupt your security officer? Although resetting a user's password is not a complicated task, the command it requires, CHGUSRPRF (Change User Profile), calls for QSECOFR authority. It would be nice to be able to shift the responsibility for resetting user passwords to others -- such as help desk personnel -- without compromising the system's security. Command SETPWD does just that: It lets an authorized operator quickly, easily, and securely reset a user's password.
SETPWD prompts for a single parameter: the user profile whose password needs to be reset. You can download the SETPWRD program from http://www.as400network.com/noderesources/code/clubtechcode/setpwd.cmd .
CL program SC002CL is the command processing program (CPP) for SETPWD and can be downloaded from http://www.as400network.com/noderesources/code/clubtechcode/sc002cl.clp . The program begins by retrieving the identifier attributes of the authorized operator's current job and profile information about the user whose password is to be changed. The program checks the profile information, and if it determines that the profile belongs to the security officer or to a user whose group profile is QSECOFR (hence, changing the password could breach your system's security), it sends control to label SECERROR. Otherwise, the program continues by issuing a DSPUSRPRF (Display User Profile) command for the profile. The program then stores the command's output in a new record added to SC002AF, a file in a member that has the same name as the user profile. File SC002AF serves as a log of password changes.
Next, the program sets up a loop to retrieve the most recent record added to the appropriate member of SC002AF. As another security check, at label PROCESS, the CPP uses QCLSCAN to make sure the profile does not have special authority *ALLOBJ or *SECADM. If it has either, control drops to label SECERROR.
When the program finds no potential security breach, it resets the user profile's password to the user profile name, sets password expiration to *YES (so the user will have to change the password immediately after signing on), and enables the profile. The program also sends a message to the system operator, to the person who issued the SETPWD command, and to the user whose password has been changed, informing them that the password has been reset. The message includes the date of the last successful sign-on and the number of invalid sign-on attempts since then. Control then drops to label EXIT, and the CPP ends.
If either security check fails, the code at label SECERROR sends a message to QSYSOPR, to the user who issued the command, and to the user whose password the program tried to reset. The message details who was trying to reset whose password and confirms that the password was not reset. Control then drops to EXIT, and the program ends without changing the password.
Installation instructions for the SETPWD utility can be found at http://www.as400network.com/noderesources/code/clubtechcode/setpwd.txt
Adapted from an October 1993 NEWS/400 article by Judy Yaeger and John Earl
15. Short Takes:
1. RETRIEVING THE PERCENTAGE OF SYSTEM ASP USED
When you want to automatically monitor for available disk space or transfer very large files on your system (e.g., copy a library or duplicate large objects), you can run a CL program to check whether your AS/400 has enough available storage space before you start the job. The simple CL program, below, retrieves the percentage of disk space used in the system auxiliary storage pool (ASP), the total storage capacity of the system ASP in megabytes, and the total auxiliary storage capacity on the system in megabytes.
DCL &APIASP TYPE(*DEC) LEN(7 0)
DCL &SYSASPPERC TYPE(*DEC) LEN(4 1)
DCL &SYSASPTOT TYPE(*DEC) LEN(7 0)
DCL &TOTAUX TYPE(*DEC) LEN(7 0)
DCL &RCV TYPE(*CHAR) LEN(100)
DCL &RCV_LEN TYPE(*CHAR) LEN(4)
CHGVAR VAR(%BIN(&RCV_LEN)) VALUE(100)
CALL PGM(QWCRSSTS) PARM(&RCV &RCV_LEN +
'SSTS0200' '*NO' X'00000000')
CHGVAR &APIASP VALUE(%BIN(&RCV 53 4))
/* retrieve the % system ASP used */
CHGVAR &SYSASPPERC VALUE(&APIASP / 10000)
/* retrieve the total system ASP in MB */
CHGVAR &SYSASPTOT VALUE(%BIN(&RCV 49 4))
/* retrieve the total auxiliary storage +
capacity in MB */
CHGVAR &TOTAUX VALUE(%BIN(&RCV 57 4))
Adapted from a NEWS/400 Tech Corner item by Herman Van der Staey
2. MONITORING PERCENTAGE OF SYSTEM ASP USED
The following CL program programmatically monitors ASP and sends a message to QSYSOPR message queue when the ASP percentage exceeds 90%.
PGM
DCL VAR(&FORMAT) TYPE(*CHAR) LEN(8) VALUE('SSTS0200')
DCL VAR(&LENFLD) TYPE(*DEC) LEN(4) VALUE(68)
DCL VAR(&SYSUSEC) TYPE(*CHAR) LEN(4)
DCL VAR(&SYSUSE) TYPE(*DEC) LEN(9 2)
DCL VAR(&SYSINFO) TYPE(*CHAR) LEN(68)
DCL VAR(&ERRCODE) TYPE(*CHAR) LEN(8) +
VALUE(X'0000000000000000')
DCL VAR(&RESETSY) TYPE(*CHAR) LEN(10) VALUE(*YES)
DCL &Q90PER TYPE(*DEC) LEN(9 2) VALUE(900000)
PROCED1: CALL PGM(QWCRSSTS) PARM( &SYSINFO &LENFLD &FORMAT &RESETSY +
&ERRCODE )
MONMSG MSGID(CPF0000) +
EXEC(GOTO PROCED2)
CHGVAR &SYSUSEC VALUE(%SST(&SYSINFO 53 4))
CHGVAR &SYSUSE %BINARY(&SYSUSEC)
IF (&SYSUSE > &Q90PER) (DO)
SNDPGMMSG MSG('**SYSTEM OVER 90% ASP**') +
TOMSGQ(QSYSOPR) MSGTYPE(*INFO)
RETURN
ENDDO
SNDPGMMSG MSG('**SYSTEM UNDER 90% ASP**') +
TOMSGQ(QSYSOPR) MSGTYPE(*INFO)
RETURN
PROCED2: SNDPGMMSG MSG('GETTING ERROR ON SYS CALL') TOMSGQ(QSYSOPR) +
MSGTYPE(*INFO)
ENDPGM
Adapted from an IBM Knowledgebase document
3. PRINTING A LIST OF ALL INSTALLED IBM SOFTWARE
You probably already know that if you enter GO LICPGM and select option 10, you can display a list of IBM software packages installed on your system. Unfortunately, this method might not display all IBM software packages installed, and it also doesn't let you print this list. You could, of course, simply use the Print Screen key, but you might have to print 15 different screens with messy formats, and you could inadvertently truncate data or forget to print a screen. There's a better solution. The following DSPSFWRSC (Display Software Resources) command
DSPSFWRSC OUTPUT(*PRINT)
not only prints out all your software package names, but it also prints the library name in which each package is located.
From a NEWS/400 Tech Corner item by Jean-Jacques Risch
16. EXISTENCE OF AN IFS FILE
Q. For objects in the QSYS.LIB system, I can use CHKOBJ to determine command existence. What is the equivalent for items in the IFS?
A. Here are two solutions, one in RPG IV and one in CL.
(a) RPG IV program FileExists:
* NOTE: Compile with DFTACTGRP(*NO)
*
* IFS API prototypes
*
* Access
*
Daccess PR 10I 0 extproc('access')
Dpathptr1 * value
Dmode1 10I 0 value
*
* IFS API Constants
*
DF_OK S 10I 0 inz(0)
*
* Some working environment for us
*
DFile_exists S 10I 0
Dpathptr S *
Dpathname S 21
DExists C 'File Exists'
DNotExists C 'File does not exist'
*
* Main{}
*
C *entry plist
C parm filename 20
* Set a character pointer to the file name string
C eval pathname = %trim(filename)+x'00'
C eval pathptr = %addr(pathname)
* Call the IFS API
C eval File_Exists = access(pathptr:F_OK)
* Did we find it?
C File_exists ifeq 0
C Exists dsply
C else
C NotExists dsply
C endif
* That's all, folks
C move *on *inlr
The filename should be supplied as //dir/dir/file, so a valid call would be:
CALL FILEEXISTS ('//etc/pmap')
(b) The ChkIfsObj command is
CMD PROMPT('Validate an IFS Object')
PARM KWD(OBJECT) TYPE(*PNAME) LEN(256) MIN(1) +
EXPR(*YES) PROMPT('IFS object')
The ChkIfsObj command uses CL program ChkIfsObjC, shown below:
PGM PARM(&PARM)
DCL VAR(&PARM) TYPE(*CHAR) LEN(256)
DCL VAR(&RTNVALINT) TYPE(*CHAR) LEN(4)
DCL VAR(&RTNVAL) TYPE(*CHAR) LEN(2)
DCL VAR(&PATH) TYPE(*CHAR) LEN(100)
DCL VAR(&NULL) TYPE(*CHAR) LEN(1) VALUE(X'00')
DCL VAR(&BUF) TYPE(*CHAR) LEN(4096)
CHGVAR VAR(&PATH) VALUE(&PARM *TCAT &NULL)
CALLPRC PRC('stat') PARM(&PATH &BUF) +
RTNVAL(%BIN(&RTNVALINT 1 4))
CHGVAR VAR(&RTNVAL) VALUE(%BIN(&RTNVALINT))
IF COND(&RTNVAL *NE '00') THEN(SNDPGMMSG +
MSGID(CPF9897) MSGF(QCPFMSG) +
MSGDTA('Object ' &PARM < ' not +
found.') MSGTYPE(*ESCAPE))
ENDPGM
FileExists was written by Nick RouxChkIfsObj and ChkIfsObjC was written by David Leland
17. Short Takes:
1. RETRIEVING OS/400 VERSION/RELEASE
Q. What is the best way to get the version/release of a system?
A. One way is to use the Retrieve Product Information (QSZRTVPR) API.
This CL program illustrates its use:
PGM
DCL &RELEASE *CHAR 6
DCL &RCVR *CHAR 128
DCL &RCVRLEN *CHAR 4 VALUE(X'00000080')
DCL &FORMAT *CHAR 8 VALUE('PRDR0100')
DCL &PRDINFO *CHAR 27 VALUE('*OPSYS *CUR 0000*CODE ')
DCL &ERRCODE *CHAR 4 VALUE(X'00000000')
CALL QSYS/QSZRTVPR PARM(&RCVR &RCVRLEN &FORMAT &PRDINFO &ERRCODE)
CHGVAR &RELEASE (%SST(&RCVR 20 6))
SNDPGMMSG MSG('This system is at release' > &RELEASE)
ENDPGM
The release level returned is in the format VxRxMy. Valid values for x are 0 through 9. Valid values for y are 0 through 9 and A through Z.
Adapted from an answer by Buck Calabro
2. REMOVING NUMBERS AND NAMES IN SOURCE MEMBERS
Suppose your assignment is to update a S/34 report program that hasn't been touched since its inception, and now you want to delete the worthless line numbers from columns 1 through 5 and the program name from columns 75 through 80. How can you automate this task?
First, let's get rid of the line numbers. The simplest way is to shift all the code five columns to the left and then shift it back to the right. Enter the command LLT5 (the left line block truncate command and the value 5) on the first and last lines of the program. Within the block these two commands demarcate, the first five characters of each line are deleted and the rest of each line is moved five places to the left. (If you omitted the truncation and data existed in columns 1 through 5, SEU would show an error.) After you perform this command, move the truncated lines back to their original spot using RRT5 (the right line block truncate command and the value 5) on the first and last lines. (The T is not strictly necessary at this point, but I've put it in to keep the commands parallel.)
To delete the omnipresent program name, use the C (change) command as follows (note that the set of spaces must be exactly as long as the program name):
SEU==> C 'program-name' ' ' 75 80 A
This command puts spaces in columns 75 through 80, deleting the program name column from the entire program.
Answer by Andrew Borts
3. CONVERTING STRING TO NUMBER
Q. Does anyone know how to convert a string variable to a numeric? For example:
string (10a) = "1,245.02 "
converts to:
numeric (9,2) = 000124502
IBM has provided RPG IV procedure C2N (character to numeric). You see this procedure at http://www.as400.ibm.com/QSYS.LIB/SNIPPETS.LIB/sendfile.pgm?File=QRPGLESRC&Member=XXXC2N
You'll also need thePROTOTYPES member to compile C2N, which you can obtain at http://www.as400.ibm.com/QSYS.LIB/SNIPPETS.LIB/sendfile.pgm?File=QRPGLESRC&Member=PROTOTYPES
More RPG and other sample code is available at http://www.as400.ibm.com/tstudio/workshop/snippets/snippet1.htm
4. DETERMINING WHETHER A JOB IS RUNNING INTERACTIVE OR BATCH IN CL
In the last issue of the Club Tech Programming Tips Newsletter, I showed an RPG IV solution for determining whether a job is running in interactive or batch mode. I heard from a couple of readers that I should have pointed out the CL solution, which uses RTVJOBA. Below is a code snippet, offered by Mark Olson:
PGM
DCL VAR(&JOBTYPE) TYPE(*CHAR) LEN(1)
RTVJOBA TYPE(&JOBTYPE)
IF COND(&JOBTYPE *EQ '0') THEN(GOTO START)
/* Interactive Program Section */
SBMJOB CMD(CALL PGM(ITSELFCL)) JOB(SBMITSELF)
SNDPGMMSG MSG('Tell user program Itself Submitted')
RETURN
START:
/* Mainline Batch Program */
If the Job Type is 0, it's running in batch, and if it's 1, it's interactive.
18. AS/400 DIR FOR IFS DIRECTORIES
Q. I'm trying to programmatically generate a list of objects in an IFS directory. I'm trying to use opendir() and readdir(), but since I am not a C programmer, I wasn't able to understand how to define these APIs' parameters in RPG. Any ideas?
A. There's a freeware DIR command for the IFS that will list the contents of an IFS directory on the screen, to a printer, or in an outfile. The program comes in two versions, one for V3R7 and one for V4R4, and each comes with source code.
You can download the DIR programs from http://www.ediconsulting.com/dir.zip.
Adapted from an answer by Carl J. Galgano, DIR was written by Peter Connell
19. Short Takes:
1. RETRIEVE AN IFS STREAM FILE'S SIZE
The RTVOBJD (Retrieve Object Description) command lets you retrieve the size of an object in the QSYS.LIB file system. However, no similar command exists for retrieving the size of a stream file.
You can use the CL code shown below in a program to retrieve the size of a stream file in the AS/400 integrated file system (IFS). The variable &PATH contains the path to the stream file, such as '/MYDIR/MYSUBDIR/FILE.EXT' or '/QDLS/MYFOLDER/MYDOC.EXT', and the size is returned in the variable &SIZEDEC.
DCL VAR(&PATH) TYPE(*CHAR) LEN(128)
DCL VAR(&SIZEDEC) TYPE(*DEC) LEN(15 0)
DCL VAR(&HANDLE) TYPE(*CHAR) LEN(16)
DCL VAR(&SIZEBIN) TYPE(*CHAR) LEN(4)
DCL VAR(&PATHLEN) TYPE(*CHAR) LEN(4)
DCL VAR(&ATTRTAB) TYPE(*CHAR) LEN(10)
DCL VAR(&ATTRLEN) TYPE(*CHAR) LEN(4)
CHGVAR VAR(%BIN(&PATHLEN)) VALUE(128)
CHGVAR VAR(%BIN(&ATTRLEN)) VALUE(10)
CALL PGM(QHFOPNSF) PARM(&HANDLE &PATH &PATHLEN +
'100 100 ' &ATTRTAB &ATTRLEN ' ' +
X'00000000') /* Open stream file */
CALL PGM(QHFGETSZ) PARM(&HANDLE &SIZEBIN +
X'00000000') /* Get stream file size */
CALL PGM(QHFCLOSF) PARM(&HANDLE X'00000000') /* +
Close stream file */
/* Retrieve the STMF size in decimal (15,0) */
CHGVAR VAR(&SIZEDEC) VALUE(%BIN(&SIZEBIN))
Answer by Herman Van der Staey
2. DETERMINING WHETHER A JOB IS RUNNING INTERACTIVE OR BATCH
The module below, INTERACT, determines whether your program is running in interactive or batch mode:
H NoMain
D pInteractive PR N
D DummyPrm 1 Options( *Omit )
P pInteractive B Export
D pInteractive PI N
D DummyPrm 1 Options( *Omit )
* Local variables
D RetdInfDs DS
D 4
D 10I 0 Inz( %Size( RetdInfDs ) )
D RiJobType 61 61
D RiTypeInteractive...
D C 'I'
D LenRetdInf S 10I 0 Inz( %Size( RetdInfDs ) )
D FmtName S 8 Inz( 'JOBI0100' )
D QlJobName S 26 Inz( '*' )
D IntJobId S 16 Inz( *Blank )
C Call 'QUSRJOBI'
C Parm RetdInfDs
C Parm LenRetdInf
C Parm FmtName
C Parm QlJobName
C Parm IntJobId
C If RiJobType = RiTypeInteractive
C Return *On
C Else
C Return *Off
C EndIf
P pInteractive E
Here are the steps for installing and using Interact:
a) Upload INTERACT to a source physical file with a record length of 112 bytes. Give the uploaded member a name of INTERACT and a PDM type of RPGLE.
b) Use option 15 in PDM to compile INTERACT.
c) Issue the command:CrtSrvPgm SrvPgm( INTERACT ) Export( *All ) ActGrp( WhateverYouWant )
To use this service program from an RPG IV program, follow these steps:
a) Include the following prototype in your source with the D-specs:
D pInteractive PR N
D DummyPrm 1 Options( *Omit )
If you expect to use this procedure in more than one program, you might consider using a /Copy member for this prototype.
b) Here are a couple of sample calls to INTERACT in the C-specs:
C If pInteractive( *Omit )
C 'Interactive' Dsply DummyVar
C EndIf
C If Not pInteractive( *Omit )
C 'Batch' Dsply
C Endif
c) Use PDM option 15 to compile your program.
d) Issue the following command to create your program (Note that the following assumes your program is a standalone program, i.e., a single module, named MYPGM):CrtPgm MyPgm Module( MYPGM ) BndSrvPgm( INTERACT ) ActGrp( Whatever )
Adapted from a utility by Mike Cravitz
3. BATCH FILE PROGRAMMING
In the last issue of the Club Tech Programming Tips newsletter, I published "Access Shared Folders via FTP," which used a DOS batch (.BAT) file. I received a few e-mails asking where the DOS batch file syntax is described. Oddly enough, I couldn't find any definitive documentation on Microsoft's site (it may be buried there; I just couldn't find it). There are plenty of resources on the Web, though, describing DOS batch file programming:
Batfiles: The DOS batch file programming handbook http://home7.inet.tele.dk/batfiles/Batch Programming Elements http://student.vub.ac.be/~dvandeun/batcoll.allBatch FAQs http://www.nc5.infi.net/~wtnewton/batch/batchfaq.htmlBatch Guide http://www.geocities.com/SiliconValley/Park/3742/bat.htm
4. EASY FIELD SEARCH WITH FNDSTRPDM
The next time you want to see where a field is used throughout your system, try this handy shortcut. Rather than search all your source members using option 25 (Find string) on Programming Development Manager's (PDM's) Work with Members display, use the FNDSTRPDM (Find String Using PDM) command. FNDSTRPDM lets you search for a string in a specified source file in a library, and you can search all the members in the file. The command lets you display, print, and edit the matching members. You can also create a report of matching members.
Answer by Bill Dudley
20. RANDOM NUMBER GENERATOR IN RPG III AND RPG/400
Q. The May 10 edition of Club Tech Programming Tips included a random number generator for RPG IV, but unfortunately, that won't work for me, as I'm using RPG/400. Do you have a solution?
A. I dug through the NEWS/400 archives and found an RPG III and RPG/400 routine published in September 1989 that generates random numbers. The RANDOM routine can be downloaded from http://www.as400network.com/noderesources/code/clubtechcode/random.rpg
A companion routine, RAN_DEMO, is available at http://www.as400network.com/noderesources/code/clubtechcode/ran_demo.rpg RAN_DEMO shows how to call routine RANDOM and generate (1) a random list of whole numbers from 1 to an upper limit, (2) a random list of whole numbers from a lower limit to an upper limit, and (3) a random identifier that can be used as an AS/400 password.
21. Short Takes:
1. IBM IFS UTILITIES ATTRIB, DELTREE, AND CHGAUTALL
IBM has three unsupported native AS/400 utilities that let you further manipulate IFS directories and files. These utilities, described below, are available as a V4R4 save file containing the compiled objects and the C source code at ftp://testcase.boulder.ibm.com/as400/fromibm/ApiSamples/ifstool.savf
Once you've downloaded the save file from IBM's site and uploaded it to your AS/400, enter the following command to restore the save file to your target library:
RSTOBJ OBJ(*ALL) SAVLIB(DDILLING) DEV(*SAVF) +
SAVF(yourlib/IFSTOOL) RSTLIB(targetlibrary)
The utilities are described below.
ATTRIB
Similar to DOS's ATTRIB command, the ATTRIB utility allows IFS file attributes to be updated from the AS/400 without requiring a network drive/PC connection. Note that this program uses the Qp0lSetAttr() API, which is supported only in V4R4 and later.
This example removes the read-only and hidden file attributes for all files in the /news400 directory:
CALL PGM(ATTRIB) PARM('-R' '-H' '/news400' '\S')
To list the possible parameters for the ATTRIB utility, type "help attrib" in a DOS window.
DELTREE
Similar to DOS's DELTREE command, the DELTREE utility deletes all files, directories, and subdirectories from the parent directory down.
USE WITH CAUTION, as there is no confirmation warning and there is no undelete.
This example deletes all files and subdirectories in the news400 directory and also deletes the news400 directory:
CALL PGM(DELTREE) PARM('/news400')
CHGAUTALL
Runs the CHGAUT command on all files and subdirectories in the specified directory.This example gives user Chuck *ALL object authority and *RWX data authority to all files in the news400 directory:
CALL PGM(CHGAUTALL) PARM('/news400 'USER(chuck) DTAAUT(*RWX) OBJAUT(*ALL)')
Adapted from an IBM Knowledgebase item.
2. ACCESSING SHARED FOLDERS VIA FTP
An easy way to transfer files between AS/400 shared folders and a PC without using Client Access is to use File Transfer Protocol (FTP).
One way to do this is to open a DOS window and start an FTP session by typing "FTP" and pressing Enter, which displays the FTP command line. Then, enter the following command at the ftp prompt:
open hostname.domain (hostname.domain is your AS/400 DNS name or its TCP/IP address)
Reply to the prompts for your log-in name and password.
Once you're logged in to the AS/400 FTP session, issue the following commands:
cd /qdls (changes to the AS/400 shared folder space)
cd xxxx (opens shared folder xxxx)
binary (requests a transfer in binary mode, which is required for QDLS)
After these commands have been executed, you can use the FTP GET and PUT commands to transfer files to and from the PC. GET downloads an AS/400 file to the PC, and PUT uploads a PC file to the AS/400 shared folder. Use binary mode for all transfers of documents in QDLS. Normally, you use binary mode for non-ASCII files such as spreadsheets, word processor documents, and graphics files and ASCII mode to transfer files that need to be readable on the AS/400 in text or database format, but QDLS is an exception.
To automate a batch transfer from your PC to an AS/400 shared folder, you can create a .BAT file that calls an FTP command file (which you create) that contains the transfer commands. To start the transfer, simply invoke the .BAT file with a couple of parameters, as in the following example:
upload hostname.domain command
Below is the sample upload.bat file:
@echo off
if not exist %2.ftp goto error_1
ftp -s %2.ftp %1
goto end:
:error_1
cls
echo File %2 not found
:end
Below is the sample FTP command file, command.ftp, which contains the commands that transfer the PC file to an AS/400 shared folder:
user_name (your AS/400 user name)
password (your password)
cd /qdls
mkdir xxx (creates a new folder, if you want one)
cd xxx (open shared folder xxx)
binary
put zzzz (transfer PC file zzzz to AS/400 shared folder xxxx)
quit (ends the routine)
You can also invoke an AS/400 command from this ftp command file with the QUOTE RCMD ftp command. For example:
quote rcmd CPYFRMPCD FROMFLR(xxxx) TOFILE(QGPL/wwww) FROMDOC(zzzz) TOMBR(zzzz) TRNTBL(*NONE)
The above command copies the transferred file from the folder to a physical file member.
One caveat: The user ID and password are stored in the command file as clear text, which means anyone with access to the command file can view them. In addition, they most likely flow over the network in clear text, so anyone monitoring your network may be able to read them.
3. LEARNING SQL/400
Q. Are there any online resources for learning SQL/400?
A. An excellent SQL/400 tutorial is available online at http://www.as400network.com/resources/tutorials/sql400tutorial/
The tutorial is taken from three chapters in Paul Conte's book Database Design and Programming for DB2/400. The tutorial consists of three parts: SQL/400 Data Definition Language, SQL/400 Data Manipulation Language, and Embedded SQL/400.
22. TECH TIP: BETTER ACCESS ODBC PERFORMANCE
http://www.as400network.com/nwn/story.cfm?ID=7896
Q. We're running Client Access Express and have used Microsoft Access to set up linked tables via ODBC to the AS/400 files we want to query. Then we created a set of reports using Access's Report Designer. This process works fine, although it slows our AS/400's performance and producing the report on the PC takes a long time. Is there a way to decrease the performance impact on the AS/400 and speed up the report processing?
A. Many factors influence the performance of Access applications connected to the AS/400, not the least of which is the AS/400 itself. Although you don't mention the model AS/400 you use, the newer RISC-based models and the server models provide substantially better ODBC performance than the older CISC-based AS/400s. You should also consider that the AS/400 processes ODBC jobs exactly as it does batch work, and the same factors (e.g., current CPU utilization, disk paging, object locks) that influence standard AS/400 jobs also affect ODBC jobs.
One of the biggest issues with connecting to the AS/400 from Access is the fact that Access uses the JET database engine as a local query processor. Although JET works well as a local PC database engine, it isn't optimized for ODBC connections. Some of the actions the JET engine performs cause its ODBC performance to be poor. For instance, one of the biggest "gotchas" is the fact the JET engine performs frequent file opens and closes, the most expensive operations on the S/400.
Fortunately, the Client Access ODBC driver has two settings that can help compensate for this behavior. The most important setting for Access and the JET Engine is the "Enable lazy close support" setting, located under the ODBC driver's Performance tab. This setting causes the Client Access ODBC driver to ignore Access's frequent file open and close requests and lets the ODBC driver reuse an open connection.
Also, if the Access report is typically run repeatedly using the same values, make sure to check the "Enable extended dynamic (package) support" setting under the ODBC driver's Packages tab. Doing this lets the ODBC driver create and save a data access plan on the AS/400. Then, when the query is rerun, the existing access plan can be reused, thus saving the time the AS/400 would otherwise take to dynamically create the access plan.
Another factor you should consider is the query itself. First, you should make sure the query uses the appropriate files. For instance, you may have a logical file that provides a view of the data that can take advantage of an existing index. This can keep your Access report from performing full table scans and then sorting the data locally, which would perform poorly. You might also consider building you report using passthrough queries. Passthrough queries can be efficient for AS/400 ODBC connections because they let you bypass the JET engine and take advantage of the AS/400's query processor.
To create a passthrough query in Access, open the Queries windows and then double-click the "Create query in design view" icon. Close the New Tables dialog box that automatically appears. Then, on the Query menu, select SQL Specific and then Pass-Through option. Next, set the ODBC connection string by selecting the Properties icon in the toolbar and then clicking on the ellipsis next to the ODBC Connect Str property. You're then prompted to select an existing data source to the AS/400, or you can create a new data source if an AS/400 data source doesn't already exist. After setting the connection properties, type your passthrough query in the SQL Pass-Through Query window and click the Execute icon to run the query.
Finally, if all else fails, consider copying the data from the linked tables to one or more local Access tables before running the reports. You can automate this process by building an Access macro.
Michael Otey, NEWS/400 Tech Editor
23. TECH TIP: REMOTE JOURNALING
http://www.as400network.com/nwn/story.cfm?ID=7936
Q. We're setting up remote journaling to replicate all database files from our production AS/400 to our front-end system (both on V4R3). The remote journals are operational, copies of the database files are on the front-end system, we've established a breakpoint, and the remote receivers are being created as expected. However, we've found a limitation with remote journaling: We can't use the APYJRNCHG command to update the database on the front-end system because the command doesn't work with remote journals. We could write our own program to retrieve journal entries using the RCVJRNE command and then create/rewrite/delete database records, but this involves significant development effort and is bound to be less efficient than using APYJRNCHG. Is there an easier method of applying journal changes to a remote system?
A. You can't use the APYJRNCHG command with remote journals. Remember that there could be a requirement to journal the remote file to which you're replicating data. Imagine the following scenario.
Presume SystemA has File1 that's journaled to YourJrn on SystemA and to remote journal YourJrn on SystemB and that you want to replicate the entries in YourJrn on SystemB to File2 on SystemB. Also presume that you want to journal File2 on SystemB, so you create YourJrn2 on SystemB. In this case, you'd use YourJrn2 to apply journaled changes to File2.
To apply journaled changes to a file, that file must be journaled. For obvious reasons, the system won't let you apply journaled changes to any file other than the one to which they pertain. In the case of remote journaling, the journaled changes pertain to the file on the source system.
If you don't want to buy a data replication application, you can code the function yourself. You've discovered the method I recommend, the RCVJRNE command. This command lets you write an exit program to process journal entries. The development effort may not be as gargantuan as you anticipate. You should be able to write a single program to handle all files using the following ingredients:
* embedded dynamic SQL to insert data into the file* API QDBRTVFD to retrieve field information used in constructing the SQL INSERT statement* journal entry format *TYPE3 (ENTFMT parameter on RCVJRNE) to obtain the null value map
Although coding such a program isn't a trivial task, it's manageable and has the added benefit of not requiring more development to handle additional files.
Gary Guthrie, NEWS/400 Tech Editor
24. BATCH CONVERSION OF OV/400 DOCUMENTS TO MS WORD
Q. I have hundreds of OfficeVision documents that I need to convert to Microsoft Word. Is there an automated way of converting them in batch?
A. Microsoft provides a VBA macro named CONVERT8.WIZ that converts all or selected files in a directory from one format to another in a single batch operation. In this case, we want to convert the OfficeVision documents in an AS/400 folder to Microsoft Word.
Before you can convert the documents, you need two things:
a. File CONVERT8.WIZ file, which can be found in the \Program Files\ Microsoft Office\Office\Macros folder. If you didn't perform a full install of Office 97, you'll need to run the Office 97 Setup program. In Setup, select "Add/Remove program items," and ensure that the "Wizards, Templates, and Letters" category is checked. Then proceed with the Setup operation, which will install CONVERT8.WIZ.
b. Microsoft's RFT-DCA conversion program for Word. If you don't see "Rich Text Format" in the "Files of Type" drop-down list when you open a file from within Word, you'll need to install it. You can download the conversion program from http://microsoft.com/office/ork/appa/appa.htm#dex18
Here are the steps to perform the batch operation:
a. Map a drive to the AS/400 directory that contains the OfficeVision documents with either AS/400 NetServer (in V4R2 and later) or Client Access. To map a drive to the OfficeVision directory on the AS/400, double-click Network Neighborhood, locate your AS/400, and expand it to the folder you want to map (OfficeVision documents and folders are in the QDLS directory). Right-click the folder for which you want to create a virtual drive, and select Map Network Drive from the menu. Select the drive letter you want to use, and click OK.
b. Open the CONVERT8.WIZ file, which displays an initial screen asking what task you want to perform.
c. Choose "A batch conversion of files."
d. Click on "From/To" and select "RFT-DCA" under "Convert from another format to Word."
e. Click "Folder Selection" and specify the mapped OfficeVision drive and the target drive in which to store your Word documents.
f. Click "File Selection" and choose the OfficeVision documents to convert. If you don't use DOS extensions in the OfficeVision names, you can display all the documents by selecting "*.* under "Type."
g. Click "Finish" to start the conversion.
25. Short Takes:
1. THIRD-PARTY OFFICEVISION-TO-WORD CONVERSION TOOLS
In addition to the method of converting OfficeVision documents to Microsoft Word described above, there are at least four third-party tools that perform this conversion:
DataJunction for WindowsDataJunction, Inc. http://www.datajunction.com
Filtrix for WindowsBlueberry Software http://www.blueberry.com/
TagWrite BookMaster TransformerTagWrite http://www.tagwrite.com/
WordPortAdvanced Computer Innovations http://www.acii.com/
2. IPL FREQUENCY FOR RISC SYSTEMS
Q. How often should I perform an IPL on RISC systems?
A. IBM hasn't published any requirements for IPL frequency. Some customers with large RISC systems choose to IPL quarterly or even less often, mostly to perform scheduled maintenance such as applying PTFs, installing a new release, and adding or changing hardware. Perhaps out of habit, most of IBM's large customers still IPL weekly.
IBM recommends that you IPL only occasionally in order to allow the system to clean up disk space used by jobs no longer in the system. The system also performs general system diagnostics during an IPL.
The following suggested IPL schedule is based on the percent of used system storage:
Percent used IPL Frequency
95% Daily90% Weekly<90 as="" br="" necessary="">Be aware that failure to perform regular IPLs can cause system problems, such as running out of disk space. If you are doing frequent IPLs because your system storage used percentage is high, you should really install additional system storage since the system may be unable to complete an IPL if it completely runs out of storage.
On RISC systems, it is no longer necessary to IPL to avoid running out of temporary addresses. Previously, large busy CISC systems may have had to be IPLed as often as weekly to avoid this problem.
Adapted from IBM Knowledgebase item 12065854
3. CALCULATING TCP/IP SUBNETS
IBM has provided a slick, simple online tool named the TCP/IP Subnet Calculator Advisor, which helps you calculate new equally sized subnets of IP addresses for class A, class B, and class C network addresses.
To use the calculator, go to http://publib.boulder.ibm.com/pubs/html/as400/v4r5/ic2924/info/index.htm, click "Networking," then "TCP/IP," and then click the fourth item down, "TCP/IP Subnet Calculator Advisor." Note that you must know your network address to use the calculator.
4. BACKUP/RESTORE RESOURCES
The following is a list of resources for backing up and restoring AS/400 systems:
a. IBM has published a lot of information on backup and restore strategies and products. If you need IBM manuals, Redbooks, or special documentation on this topic, check out the following Index400 categories:
System Management
This category includes a list of all of IBM's basic AS/400 backup and recovery manuals. http://www.as400network.com/index400/sysmgmt.htm
System View
This category includes IBM's Backup Recovery and Media Services/400 (BRMS/400) product. http://www.as400network.com/index400/sysview.htm
ADSTAR Distributed Storage Manager http://www.as400network.com/index400/adsm.htm
b. To view all backup and recovery articles and tips published by
NEWS/400 over the past several years, check out http://www.as400network.com/artarchive/index.cfm?fuseaction=ListArticlesByTopic&ID=8
c. If you can't find the backup and restore information you're looking for, you can always post a question in the System Management forum at http://www.as400network.com/Forums/Index.cfm?cfapp=60
26. CREATING A JOIN LOGICAL FILE
http://www.as400network.com/nwn/story.cfm?ID=7939
Q. I have two large physical files that I want to join as a logical file. What are the performance considerations for doing this? Is joining the files a more efficient method than reading one file and chaining to another?
A. You probably won't see a performance improvement using a join logical file. Efficiency isn't the primary purpose for creating such files. The reason for creating join logical files is to simplify program logic. Suppose I have to produce a report of all customers and their orders. It takes more program logic to sequentially read the Customer file and then use a SETLL (Set Lower Limit) and READE (Read Equal) loop with the Order file than to simply read sequentially through a join logical file comprising records from the Customer and Order files that were joined based on the common customer number field. The two programs will probably perform at about the same speed, but one will have simpler logic than the other.
You do pay a performance price for having join logicals (although not in the program that uses them). Any program that updates either of the base files also causes the access path for the join logical to be updated. Thus, those programs will suffer a performance penalty. This is similar to the penalty you pay whenever you add a new logical file to your system that doesn't share an access path with any other file.
You must decide how many logical files can be tolerated for each base physical file. This number depends on your in-house performance goals, mix of work, and the size of your processor and other computer resources (e.g., memory and disk).
Mike Cravitz, NEWS/400 Tech Editor
27. RESTORE CHANGES AUTHORITY
http://www.as400network.com/nwn/story.cfm?ID=7975
Q. We refresh data from our V3R2 production AS/400 to our V4R4 development AS/400. We perform a SAVLIB on the production system and then do a CLRLIB and RSTLIB on the development system. The restore runs fine, but no matter what we restore, we lose some of libraries' original authority. The owner of the library and *PUBLIC *USE retain their authority, but two other users who have *CHANGE authority lose theirs. The command we use is
RSTLIB SAVLIB(TEST) +
DEV(TAP01) +
MBROPT(*ALL) +
ALWOBJDIF(*ALL)
I'm stumped. Can you help?
A. Private authorities aren't stored with the object but with the user profile. Deleting an object removes the private authorities from the profile because the object no longer exists. Because you ran a CLRLIB command, the library's owner retains his or her private authorities, but you lose the private authorities for the objects in the library. When you restore the object, the private authorities aren't restored because they're not stored with the object.
To restore the private authorities, you must run the RSTUSRPRF command for the user profile that had the private authorities to the object, restore the object, and then run the RSTAUT command for that profile. The RSTAUT command returns the private authorities, but you must first restore the user profile because the RSTAUT command uses a table that's created when you run the RSTUSRPRF command.
Also, be aware that if you use authorization lists, the only way to restore them is to run a RSTUSRPRF USRPRF(*ALL) command to restore the object, followed by a RSTAUT for all user profiles. To run RSTUSRPRF, the AS/400 must be in a restricted state, so you can't run the command when users are signed on to the system.
Another option would be to run the GRTOBJAUT command to re-grant the private authorities after the restore.
Debbie Saugen, IBM Senior Business Recovery Specialist
28. Featured Tip:
QSPGETF AND QSPPUTF APIs AND COMMANDS
IBM Knowledgebase item 8011926 describes two APIs that are undocumented in the AS/400 manuals. The two APIs, Get Spooled File (QSPGETF) and Put Spooled File (QSPPUTF), copy spool files to and restore them from physical files, respectively. The advantage of QSPGETF and QSPPUTF over the well-documented Copy Spooled File command (CPYSPLF) is that the APIs are able to copy Advanced Function Printing Data Stream (AFPDS) and Intelligent Printer Data Stream (IPDS) spool files, whereas CPYSPLF cannot.
You can call the QSPGETF and QSPPUTF APIs directly, or you can call them using command wrappers over the APIs.
a. Calling the APIs Directly
The QSPGETF API call below saves spool file QPRINT to database file SPOOLDB in USER1LIB library, member MBR1, where the spool file number is 1 and the spool file job is 010160/user1/dsp03:
CALL PGM(QSYS/QSPGETF) PARM('QPRINT ' 'SPOOLDB USER1LIB ' +
'DSP03 USER1 010160' X'0001' 'MBR1 ')
The QSPPUTF API call below creates a spool file in USER1 output queue in QGPL library from the MBR1 member in the SPOOLDB database file:
CALL PGM(QSYS/QSPPUTF) PARM('SPOOLDB USER1LIB ' 'USER1 QGPL ' 'MBR1 ')
b. Calling the APIs from command wrappers
The two calls below correspond to the examples above, but these examples use the command calls instead of calls directly to the APIs:
GETSPLF FILE(QPRINT) TOFILE(USER1LIB/SPOOLDB) +
JOB(010160/USER1/DSP03) SPLNBR(1) TOMBR(MBR1)
PUTSPLF FROMFILE(USER1LIB/SPOOLDB) OUTQ(QGPL/USER1) +
FROMMBR(MBR1)
Although the QSPGETF and QSPPUTF APIs are included in every OS/400 release since V3R2, the commands are not included. Fortunately, you can obtain the compiled commands and the command source code from the Knowledgebase item, which can be found at http://as400service.ibm.com/8625680A007CA5C6/0/10AFE2F98C7F5FB9862565C2007D46A8?Open&Highlight=2,8011926
This item was adapted from IBM Knowledgebase item 8011926
29. Short Takes:
1. PASSING SUBFILE RECORDS TO A CALLED PROGRAM
Q. Is there any way to pass all the records in a subfile to a called program?
A. You can make subfile records available in a called program by defining the same display file in both the calling and called programs and sharing the open data path (ODP).
For example, suppose PgmA, which uses display file DspA, calls PgmB.
To make DspA's subfile records available to PgmB, define file DspA in PgmB. Then issue the command OVRDSPF FILE(DspA) SHARE(*YES) before calling PgmA. When PgmA calls PgmB, the ODP is shared and PgmB can read records from DspA. You don't need to write any of DspA's record formats from PgmB. However, for PgmB to compile, you need to reference at least one of them. Simply write an EXFMT statement and condition it so that it will never be executed.
From a Tech Corner answer by Gary Guthrie
2. SEU TIP: HIDING LINES WHILE EDITING
When you are working with source members that have many source lines, it is useful to exclude certain lines from the displayed member, allowing you to see lines from different areas of the source on the screen at the same time. Place X (Exclude) on any line you want to exclude from the display. This doesn't delete the line from the source member; it simply causes the excluded line(s) to be temporarily removed from the SEU display.
You can also use the X command in block format (XX). The example below shows how to exclude lines 3 through 6 (I entered a blank after the XX command to make it more readable):
*************** Beginning of data **************************
0001.00 111111111111111
0002.00 222222222222222
XX 3.00 333333333333333
0004.00 444444444444444
0005.00 555555555555555
XX 6.00 666666666666666
0007.00 777777777777777
****************** End of data *****************************
The result below shows that lines 3 through 6 have been hidden from view:
*************** Beginning of data **************************
0001.00 111111111111111
0002.00 222222222222222
- - - - ------------- 4 data records excluded ----------------------
0007.00 777777777777777
****************** End of data *****************************
To redisplay the lines, press F5 (Refresh) key, or use the SF or SL commands. SF (Show first) command shows the first excluded line, and SL (Show last) shows the last excluded line. You can also use SFn or SLn to show the first n lines or the last n lines of the excluded group of lines. The example below shows how to use the SF2 command to show the first two excluded lines:
*************** Beginning of data **************************
0001.00 111111111111111
0002.00 222222222222222
SF2 - - ------------- 4 data records excluded ----------------------
0007.00 777777777777777
****************** End of data *****************************
Notice below that the display shows the first two excluded lines and the text has changed to "2 data records excluded":
*************** Beginning of data **************************
0001.00 111111111111111
0002.00 222222222222222
0003.00 333333333333333
0004.00 444444444444444
- - - - ------------- 2 data records excluded ----------------------
0007.00 777777777777777
****************** End of data *****************************
One useful trick is to exclude all lines in an RPG source file in SEU by entering XX in the first and last lines of the member, then entering
F BEGSR
on the command line. This will exclude all lines except those containing "BEGSR". This is a great way to easily see all the subroutines in your program.
Adapted from "Desktop Guide to AS/400 Programmers' Tools" http://www.29thstreetpress.com
3. CONVERT STRING TO NUMBER USING C FUNCTIONS, PART II
In the July 14 Club Tech Programming Tips newsletter, I described how to convert a string to a number using C functions atoi (ASCII to Integer) and atof (ASCII to Floating point). Here is some follow-up information on those functions:
a. Several readers wrote asking why these functions weren't found on their system. The C functions are included in the "Common Programming APIs Toolkit," which comes free with OS/400. If it isn't on your system, install it from the OS/400 CD-ROM or tape.
b. In the July 14 item, I stated that the atoi function handles only digits. It also allows + and - signs. Oops.
c. IBM's Barbara Morris provided code that vastly improves the floating point number conversion with atof. The newer code also handles more input formats, including embedded commas and blanks, () and CR for negative values, leading or following +/- signs, as well as optionally allowing comma for the decimal point and period for the thousands separator. You can download her newer code from http://www.as400network.com/noderesources/code/clubtechcode/atof.txt
d. You can read more about the atoi and atof functions in the "ILE C for AS/400 Run-Time Library Reference" manual at http://publib.boulder.ibm.com/cgibin/bookmgr/bookmgr.cmd/BOOKS/QB3AT500/CCONTENTS
30. RETRIEVING DELETED RECORDS
I'm frequently asked how to retrieve deleted records from an unjournaled physical file when the deleted records have not yet been removed from the file.
Utility UNDEL lets you undelete records in a physical file. This public domain program is available in CISC and RISC versions, and the complete source code is available for download at:
UNDEL for AS/400 Save File (RISC): http://www.as400network.com/sharewarefiles/undelris.zip
UNDEL for AS/400 Save File (CISC): http://www.as400network.com/sharewarefiles/undel.zip
UNDEL for AS/400 Save File (Source code): http://www.as400network.com/sharewarefiles/undelsrc.zip
The utility takes advantage of the fact that deleted records in physical files are only flagged as deleted, and the record data still exists until it is overwritten or the file is reorganized with a utility such as RGZPFM. UNDEL simply reads the deleted record, then reuses the record by writing over it with the new record (thus eliminating the flag for the deleted record).
Some homegrown and commercial utilities copy the file containing undeleted records to a save file, then use a program to read the save file, which contains live and undeleted records, to a file to undelete the records. The UNDEL utility is superior to the SAVF technique because there's no need to copy the file to a save file, which is especially important for really large files.
When run, UNDEL displays the physical file records in their unformatted, raw text form. You can either position the display to a given relative record number or use F19 or F20 to find the previous and next deleted record, respectively. The utility also includes online help, which is almost unheard of for free utilities.
Other utilities include the ability to undelete records. You can use the RTVDLTRCD command in the old QUSRTOOL (no longer supported by IBM). QUSRTOOL is now a commercial product called TAA Productivity Tools ( http://www.taatool.com ). The free file editor WRKDBF has a built-in undelete capability ( http://www.wrkdbf.com ), and several commercial file editors can undelete records. For a complete list of file editors, go to http://www.sourcebook400.com, select "Programmer Tools" under "Product Category," then select "File Editors."
31. Short Takes:
1. FREE FAST PC SEARCH UTILITY
Your PC is overloaded with gigabytes of program code, e-mail messages, Word documents, and Adobe Acrobat versions of IBM manuals. How the heck do you search for text buried in all the data?
You could use the Find facility built in to Windows, but that means waiting for every file to be searched. And waiting. And waiting.
AltaVista, the search engine folks, have a free utility called AltaVista Discovery that you can download from the Internet. Once installed, the utility indexes any or all of your local or mapped disk volumes. It can index nearly any document type, including e-mail and PDF files, and any file you add (such as .RPG, .CL, .DDS, and so on). Discovery updates its index as often as you want, and it can be configured to run automatically any time and day of the week.
The Discovery search bar can be called from the Windows system tray, locked on a screen border or browser window, or configured to always stay on top of all windows. You enter search terms in the Discovery search bar in the same way you enter them in the AltaVista Internet search engine. The search results appear in a browser window in the same format as they do on the Web. You can click on any of the result links to run the associated program for the found file.
AltaVista Discover can be downloaded from http://discovery.altavista.com/
2. EXCEL DATA TRANSFER ADD-IN
Q. I used to have an option within Excel 97 to transfer data from the AS/400 directly into an Excel spreadsheet, but this option disappeared after I installed Microsoft Office 2000. I'm running Client Access V3R2 and OS/400 V4R4. Do you know how I can reinstate this option?
A. Upgrading to Office 2000 removes the Client Access Excel Data Transfer Add-In that the Client Access installation added to Excel 97. Although you could restore this add-in by reinstalling Client Access, there's an easier way to replace it. First, start Excel 2000, and then select the Tools menu and the Add-Ins option. Doing this displays Excel's Add-Ins dialog box. To add the Client Access Data Transfer Add-In to Excel 2000, click Browse and then navigate to the \Program Files\IBM\Client Access\Shared directory. Select the cwbtfxla.xll file, and then click OK.
Make sure that the Transfer Data From an AS/400 option is checked, and then click OK to add the Client Access Data Transfer Add-In to the Excel 2000 environment. Excel then adds a new Transfer Data from an AS/400 option to its toolbar and Data menu.
Incidentally, if you installed Excel 95 or 97 after installing Client Access Express, you will also have to manually install the add-in as described above.
Adapted from an answer by Michael Otey
3. MANAGING QSYS.LIB OBJECTS WITH WRKAUT AND CHGAUT
Q. Can I use WRKAUT and CHGAUT to manage objects in the QSYS.LIB file system?
A. Yes. Simply specify the QSYS object using a path name. For example, DSPAUT OBJ(/qsys.lib/cjw.lib/myfile.file) displays the authorities on the file CJW/MYFILE.
From a Tech Corner answer by Carol Woodbury
32. AUTOMATE REMOTE PRINTER STARTUP
http://www.as400network.com/nwn/story.cfm?ID=8012
Q. I want our remote printers to automatically start when I IPL our V4R4 AS/400. How can I do this?
A. At IPL time, the AS/400 runs its startup program, which is typically a CL program. You can add commands (such as STRRMTWTR to start remote writers) to this CL program. Presuming your startup program is a CL program, here's a short set of instructions for modifying your startup program.
1. Determine your startup program (and its library) using the command DSPSYSVAL QSTRUPPGM.
2. Retrieve the source for this program using the following command:
RTVCLSRC +
PGM(YourLib/StartupPgm) +
SRCF(YourLib/YourSrcFile)
3. Edit the source you just retrieved, adding your commands at the appropriate location as necessary.
4. Compile the program.
Now when you IPL, the startup program will execute the commands you've added. Note that if you change the startup program's name, you'll have to modify system value QSTRUPPGM to match.
Gary Guthrie, NEWS/400 Tech Editor
33. SAVSTG AND BACKUP
http://www.as400network.com/nwn/story.cfm?ID=8031
Q. Can I use the Save Storage (SAVSTG) command to back up my system?
A. The SAVSTG command, which copies the Licensed Internal Code (LIC) and all disk-unit data to tape, isn't a good backup strategy for today's AS/400 environment. The tape that's produced is a sector-by-sector copy of all permanent data on all configured disk units. But you can't restore individual objects from the SAVSTG media.
The SAVSTG process once provided a fast, one-step method for backing up an entire system's data. But with today's tape technology, faster system processors, and improved save processing, Save Menu Option 21 can provide an even faster way to save your entire system. And with Save Menu Option 21, you can restore individual objects.
The SAVSTG process has other important considerations. For example, on RISC processors, you must use the Save Configuration (SAVCFG) or Save System (SAVSYS) command to save the system's hardware configuration information. The Restore Storage process uses the SAVCFG or SAVSYS media to restore this information.
Also, in a disaster-recovery situation where you must restore your entire system data to a new system, the new system's disk configuration must be the same as that of the system on which the SAVSTG occurred. The disk types and models must be the same or equivalent with some additional devices. (Serial numbers and physical addresses don't have to be the same.) All the disk units that were saved are required for the restore operation.
One final, major drawback of the Save and Restore Storage process is that if you encounter a media error while restoring your system, there's no recovery from this situation. None of your data can be recovered.
If you still want to use SAVSTG, you must always complement it with either Save Menu Option 21 or the equivalent SAVSYS, SAVLIB (Save Library), SAVDLO (Save Document Library Object), and SAV (Save Object) commands. Also, you should have multiple levels of your backup media. For more information about implementing backup and recovery strategies, visit the AS/400 Information Center Web site at http://www.as400.ibm.com/infocenter
Debbie Saugen, IBM Senior Business Recovery Specialist
34. ASSIGNING A DEVICE NAME WITH CLIENT ACCESS
http://www.as400network.com/nwn/story.cfm?ID=8066
Q. When we use Client Access with a TCP/IP connection, how can we assign a permanent device name? The system currently selects a device named QPADEVxxxx (where xxxx varies), but it isn't the same each time we connect to the system.
A. Client Access Express lets you assign a permanent device name when you configure your session. To supply the device name, fill in the box for Workstation ID when you create a session.
Gary Guthrie, NEWS/400 Tech Editor
35. RETRIEVE CURRENT JOB'S CALL STACK
A glance at the AS/400 newsgroups and forums reveals many requests for a program to retrieve the current job's call stack. Although there is a way to do this via MI calls, it's complex. The RPG IV provided in this tip uses a simpler method to provide this function.
The program sends messages up the call stack one at a time (to a maximum of 10 entries) until the top is reached. For each send, a retrieve is also performed and the receiving program name is captured. The program has three parameters: PStack (call stack returned), PStartPoint (relative starting point), and PEntries (number of entries returned).
When you call the program, set the PStartPoint parameter to the call stack entry at which you want to start. Entries are returned starting with the latest entry in the first array element. You can easily modify the program to include more or fewer call stack entries.
You can download the RPG IV program from http://www.as400network.com/noderesources/code/clubtechcode/rtvcalstk.txt
This item was adapted from a NEWS/400 tip by Adam White
36. Short Takes:
1. RUNNING NT COMMANDS FROM THE AS/400
Q. How do I run a program on NT from the AS/400?
A. The most common method is to use the AS/400 RUNRMTCMD with the Client Access Remote Command Service, which is explained in depth in the IBM Knowledgebase document at http://as400service.ibm.com/8625680A007CA5C6/0/18F3F1C10E862A3D862565C2007CB4A3?Open&Highlight=2,9035356
If you don't have Client Access, you can purchase a third-party product that lets NT run remote commands. One product recommended often in the AS/400 newsgroups and forums is Denicomp Systems' REXECD/NT, which you can download from http://www.denicomp.com/
2. SEU TIP: MORE LINE HIDING
I received some suggestions on further using the technique in last issue's tip "Hiding Lines While Editing."
In the tip, I showed a way to exclude all lines except those containing "BEGSR". I said you enter XX in the first and last lines of the member and then enter
F BEGSR
on the command line. This shows only the first BEGSR. I should have used the following:
F BEGSR A
which shows all BEGSR statements. Also, an alternative to using XX in the first and last lines to hide all lines in a member is to use the Hide command as follows:
H ' '
which hides every line with a blank (this is usually every line in the member).
The Find command is not only useful for locating BEGSR statements but is very helpful in showing all the lines containing a specified field. So, for example, hiding all lines then entering the command
F BEGDAT A
will show every line containing the string BEGDAT.
The above techniques work when editing or browsing a source member.
One difference when using the above Hide and Find commands in browse mode is that the lines noting how many records have been excluded from display (e.g., "--- 39 records excluded ---") don't appear. This may be useful if you want to make the most use of your 24-line 5250 session.
Thanks to Bob Antaki, Clive Phelan, and Neil Cockburn for the suggestions
3. RECALLING COMMANDS IN NT'S FTP CLIENT
How many times has this happened to you: You've just entered a rather long PUT command to transfer a file to the AS/400 in the Windows ftp client, only to discover that you mistyped one character in the long command string. Doh!
If you're using ftp.exe in Windows 95 or 98, you're stuck either retyping the command or doing a copy/paste operation in the DOS window. In Windows NT, however, you can recall any previous ftp commands using the up arrow key, position the cursor within the recalled command using the left and right arrows, and edit the command. You can also select previous ftp commands from a pop-up window by pressing F7.
Incidentally, this command history is also built into the Windows NT command shell, and you can use the up arrow to recall previous DOS commands in the command shell prompt. In the Windows 95/98 DOS window, you can enter DOSKEY at the DOS prompt to invoke the command history function (note that although this lets you recall previous DOS commands in Windows 95/98, it won't work for ftp.exe commands).
4. OS/400 V4R5 LIMITS
The July 19 issue of this newsletter had a URL for "AS/400 V4R4 Maximum Capacities," which contains the limits on AS/400 communications, work management, file system, database, and so on. IBM has now published the V4R5 limits at ftp://www.redbooks.ibm.com/redbooks/GA195486/limitv45.pdf
37. DEBUGGING PROBLEM
http://www.as400network.com/nwn/story.cfm?ID=8088
Q. I'm having problems with the STRISDB tool when debugging an OPM Cobol or RPG program. When I compile my program with the debugging option, the line numbers are incremented by 100, and after line 99,999, the program lines all have the same number. When I try to set a breakpoint, it's lost on lines after 99,999. How can I work around this problem?
A. By default, the SEU editor sequences your lines starting at 1.00 by increments of one. When you insert lines, the editor uses the positions past the decimal point. For example, when you try to insert a line between line 1.00 and 2.00, the editor assigns a line number of 1.01 to that line. ISDB doesn't work with decimal points, so it treats line 1.00 as if it were line 100, line 2 as 200, and so on. In other words, ISDB uses these sequence numbers and ignores the decimal point. The result is that each sequence number in ISDB is a factor of 100. To circumvent your problem, perform the following steps:
1. Edit your program with SEU.
2. Press F3 to exit your edit session.
3. Specify Y for Change/Create member.
4. Specify Y for Resequence member.
5. Specify 0000.01 and .01 for Start and Increment, respectively.
6. Press Enter to resequence and save your program.
7. Recompile your program.
These steps force ISDB to sequence your program beginning with 1 and with an incremental factor of 1, allowing up to 999,999 source statements.
Mike Cravitz, NEWS/400 Tech Editor
38. SYSTEM RECOVERY
http://www.as400network.com/nwn/story.cfm?ID=8113
Q. I'm currently working on a backup and recovery plan. Where can I find the steps needed to recover my entire system?
A. See Chapter 9 ("Selecting the Right Recovery Strategy") of OS/400 Backup and Recovery (SC41-5304) to determine the best way to recover your system. Before beginning your recovery, you should do the following:
* If you must recover because of some system problem, make sure you understand how it occurred so you can choose the correct recovery procedures.
* Plan your recovery. If you had a disk failure, refer to the section titled "Choosing the Recovery Procedure for a Disk Failure or Disk Errors" (in Chapter 3 of OS/400 Backup and Recovery) to find the appropriate recovery checklist for your situation.
* Make a copy of this checklist and mark off each step as you complete it. Keep the checklist for future reference.
* Keep a record of every step you take during your recovery. This record is important if you need help later.
* If your problem requires hardware or software service, make sure you understand exactly what the service representative did. Don't be afraid to ask questions, such as:
- "Did you replace a disk unit? If so, which one?"
- "Did you restore the LIC? If so, what option from the Install LIC menu did you use?"
- "Did you need to recover the disk configuration? Was it successful?"
- "Could the failed disk unit be pumped? How successfully?"
OS/400 Backup and Recovery for V4R5 includes a new appendix called "Recovering Your AS/400 System," which provides step-by-step instructions for completely recovering your entire system to the same system (i.e., restoring to a system with the same serial number). You can use these steps only if you saved your entire system using either Save Menu Option 21 or the equivalent SAVSYS, SAVLIB, SAVDLO, and SAV commands.
For V4R1 through V4R4, you can find new step-by-step restore instructions titled "Checklist for Recovering your AS/400 at V4R1, V4R2, V4R3, and V4R4" at http://as400service.rochester.ibm.com/supporthome.nsf/Document/10000051 Select "OperatingSystem," and search for "Checklist" at the ensuing page.
Continue to use the checklist titled "Recovering Your Entire System After a Complete System Loss" in Chapter 3 of OS/400 Backup and Recovery to completely recover your system in any of the following situations:
* Your system has logical partitions.
* Your system uses the Alternate Installation Device Setup feature that you can define through Dedicated Service Tools.
* Your system has mounted user-defined file systems before the save.
* You're recovering to a different system (a system with a different serial number).
Debbie Saugen, IBM Senior Business Recovery Specialist
39. QZDASOINIT JOB PROBLEM
http://www.as400network.com/nwn/story.cfm?ID=8108
Q. One of our AS/400s has a third-party report-writing product installed on it. Whenever a user runs a query through the report writer, the QSERVER prestart job QZDASOINIT is initiated. This job eventually uses the system resources and locks up the AS/400. Do you know why this is occurring and how to correct it?
A. The most likely cause of a query that locks up your AS/400 is that the query builds either a large index or an index that exceeds the working limitations of the underlying file design. This can occur when a query is submitted from an AS/400 session or via a PC session using an ODBC driver (as indicated by the QZDASOINIT job). Double-check the request being submitted via the report-writing application to make sure it will use an existing index. If you can access the job after it's initiated but before the request is submitted, you can change the job's query attributes to diagnose the indexes and processing time that will be used. To do this, execute the command
CHGQRYA JOB(NBR/USER/JOB) +
QRYTIMLMT(0)
If you can't access the job before the request is submitted, you can also temporarily change the system value QQRYTIMLMT to zero. Either change causes the system to produce a job log that shows the data access plan that will be used and the estimated processing time.
If the query is submitted against a larger file (e.g., 4 GB) or if the query will result in a join of two smaller files that creates an index that approaches 4 GB, also make sure the indexes (and physical file) have the attribute set to allow processing of access paths of up to 1 TB. To do this, use the command
CHGLF FILE(LIB/FILE) +
ACCPTHSIZ(*MAX1TB)
Processing large files with the maximum access path set to the smaller value of 4 GB (the previous limit) also causes system lockups.
Terry Smith, NEWS/400 Tech Editor
40. RETRIEVING THE IP ADDRESS FROM A TELNET SESSION
Q. How do I retrieve the IP address of an AS/400 Telnet session?
A. The three solutions below use the QDCRDEVD (Retrieve Device Description) API to retrieve a Telnet session's IP address:
a) Retrieve an IP Address via a CL Program
This Tech Corner item, answered by Gary Guthrie in the July 2000 issue of NEWS/400, provides the RtvIPAddr command written in CL. You can read the article at http://www.as400network.com/article.cfm?ID=7559 and download the code from http://www.as400network.com/resources/code/ .(Note: To read the article, you must be a professional member of the AS400 Network.)
b) Retrieve an IP address via a C program
The V4 TCP/IP for AS/400: More Cool Things Than Ever (SG24-5190) Redbook contains a C program in Chapter 13 that retrieves the IP address. You can download the Redbook from http://www.redbooks.ibm.com/abstracts/sg245190.html and download the Redbook source code from ftp://www.redbooks.ibm.com/redbooks/SG245190/ .
c) SHOWIP utility
You can find this free utility at http://www.shareware400.com and download it directly from http://www.ignite400.org/software/showip.zip.The zip contains an AS/400 save file containing the compiled utility but no source. Here's a sample display from this utility:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
System . . . . : S1099999
Type options, press Enter.
5=Work with Device Status 8=Work with User Job
Opt Device UserId IpAddress HostName
_ QPADEV0001 HOOPES 69.999.99.196
_ QPADEV0003 CHUCK 208.99.99.52
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
41. Short Takes:
1. GUIDES TO AS/400 RISC PROCESSORS AND FEATURES
For some time now, IBM has made available a complimentary set of resources that let you configure AS/400s. It's a combination of two Redbooks and a PC-based AS/400 configuration program called PCAS400, described below.
AS/400e System Builder (SG24-2155-05)
The comprehensive guide for AS/400 configuration and installation support, this Redbook provides all AS/400 RISC model product numbers, feature codes, and prerequisites. http://www.Redbooks.ibm.com/abstracts/sg242155.html AS/400e System Handbook (GA19-5486-20)
A good reference when looking up all available AS/400 options. Think of the Handbook as providing a broader overview of AS/400 hardware and software offerings, with the system builder manual providing the configuration details. http://www.Redbooks.ibm.com/abstracts/ga195486.html IBM Portable Configurator for AS/400 (PCAS400)
This handy, free PC program configures any recent AS/400 RISC model. It walks you through the configuration with a wizard-like facility, which provides a list of all available features and error-checks the feature selections for needed prerequisites. One notable feature is that PCAS400 lists U.S. prices for the configured hardware and software.
You can download PCAS400 and the most recent U.S. price list from http://www.as400.ibm.com/configure/Pcas400.htm The price list is updated often, so check the site before configuring a system. The currently available price list was updated on August 17, 2000. Both Redbooks are also updated often, so it's a good idea to check every few months for a new edition.
2. GUIDE TO AS/400 CISC PROCESSORS AND FEATURES
For those of us stuck using old CISC AS/400s (aka "the white boxes"), we know all too well how difficult it is to find online resources with information about upgrade paths or product feature codes for our old systems. Fortunately, IBM has just released the AS/400 CISC System Builder Redpaper (REDP0042) at http://www.redbooks.ibm.com/redpapers/abstracts/redp0042.html . The book details the configurations and features of the 9401, 9402, 9404, and 9406 models and also helpfully lists the pricing group in which each model appears.
3. DHCP SERVER ADMINISTRATION PROGRAM FOR WINDOWS 95/NT
IBM buries little utility program gems around its Web site, and I've just dug one of them up. For those using Dynamic Host Configuration Protocol (DHCP) server on the AS/400, you might want to check out the DHCP Server Administration Program for Windows 95/NT at http://www.as400.ibm.com/tstudio/TECH_REF/tcp/dhcp/index.htm . It's a Java application that lets you request IP address, client, and server information.
If you're interested in DHCP, you can read more about it in AS/400 TCP/IP Autoconfiguration: DNS and DHCP Support, SG24-5147-00, and at http://www.redbooks.ibm.com/abstracts/sg245147.html
V4 TCP/IP for AS/400: More Cool Things Than Ever, SG24-5190-00 http://www.redbooks.ibm.com/abstracts/sg245190.html (Look in chapter 9, "Getting started with DHCP on the AS/400 system.")
DHCP FAQ http://www.dhcp-handbook.com/dhcp_faq.html
42. PRINTING TO A SPECIFIC DRAWER
http://www.as400network.com/nwn/story.cfm?ID=8161
Q. I need to copy a workstation customization object to a printer so I can choose a particular drawer for AS/400 print jobs. The printer is an HP8500 series. I can't find an existing WSCST description, and I'm unsure where to make changes.
A. Because the HP8500 is a color printer, it should respond similarly to the HP8000 or the HPCOLORLJ. You can use the RTVWSCST command to retrieve the source for these printers and then modify the source to see which one suits your needs. To find the commands to create, change, or override a printer's drawer specifications, issue the following command:
:DWRSLT +
DRAWER=DRAWER1 +
DATA ='1B266C3148'X.
You can print to extra drawers from the AS/400 if your printer has more than two drawers To do so, change the DATA line to the HPCL command in the HP8500 manual to select the extra drawer. After you modify the source, use the CRTWSCST command to compile it.
However, if you want to select only one of the existing two drawers, specify drawer selection under the OVRPRTF command without executing Host Print Transform.
Terry Silva, Systems Programmer, Ricks College
43. Short Takes:
1. INCORPORATE THE COMMAND LINE INTO AN APPLICATION
Q. I want to replace an AS/400 menu with a menu program that looks and works like the original menu. How can I replicate the AS/400 command line in my program, including the ability to retrieve previous commands using F9?
A. You should check out a NEWS/400 article published way back in May 1995 titled "A Command Line from Anywhere." The article includes CL program CMDLINE, which uses APIs QMHRTVRQ, QCAPCMD, and QMHMOVPM to provide a fully functional command line that you can incorporate into your application. CMDLINE, like the AS/400's command line, can do the following:
a. Provide an input field into which the user can type OS/400 command strings.
b. When the user presses F4, invoke the CL command prompter using the entered command string; add the changes entered through the prompter to the command string.
c. Check any entered command string for valid CL syntax.
d. Determine whether the current user profile has limited capability (LMTCPB(*YES)) and, if so, whether the entered command string is valid under limited capability.
e. Execute any command string that is valid under items 3 and 4.
f. Display on the screen's message line all messages returned from the command string execution.
g. Save all executed command strings, including the changes entered through the prompter, to the job message queue.
h. When the user presses F9, retrieve the previously executed command string from the job message queue and display it in the command line input field.
i. When the user presses F9 repeatedly, retrieve previous command strings in descending order of execution.
The NEWS/400 article also provides a sample RPG program that demonstrates how to integrate a fully functional command line into a standard work-with screen. Note that only AS400 Network professional members can read the above NEWS/400 article, but anyone can download the code at http://www.as400network.com/resources/code/ .
2. CHANGE SIZE PARAMETER DEFAULT TO *NOMAX
Q. Every time I create a physical file, I'd like the default value for the SIZE parameter to be *NOMAX. How do I do this?
A. Use the Change Command Default (CHGCMDDFT) command to change the default value for CRTPF's SIZE parameter. Beware, though, that if you specify *NOMAX without specifying the other two elements in the list, you'll run into a snag -- the attempt fails with diagnostic message CPD6273 ("Single value not valid default value"), which has a severity level of 40. You then get escape message CPF6260 ("Errors detected while changing defaults"), which aborts the attempt. The solution is to specify all three values for the SIZE parameter, like this:
CHGCMDDFT CMD(CRTPF) NEWDFT('SIZE(*NOMAX () ())')
or like this:
CHGCMDDFT CMD(CRTPF) NEWDFT('SIZE(*NOMAX *N *N)')
where *N represents a null value. *NOMAX is now the first of three values; although the other two values are null, they have been specified.
Use *NOMAX in the SIZE parameter with caution, as a runaway job could eat up all your DASD.
Answer adapted from a Tech Corner item by Gary Guthrie
3. DISPLAY THE COMMAND STRING
When you use CL command prompter (F4) to enter a command, you don't need to exit and press F9 to retrieve the command to view the command string. You can simply press F14 while you're still in the command's prompt screen to display the command string.
4. MODIFY IBM EDIT CODES
Q. Can I modify the IBM-shipped edit codes 5 through 9, or is that not permitted because an OS/400 program uses them? I want to use edit code 9 to display a YYMMD date format from a six-digit field.
A. Yes, you can modify edit codes 5 through 9 for your own purposes although IBM predefines them. To work with edit descriptions, type GO CMDEDTD at an AS/400 command line to display a list of the available edit description commands. Note that you can't actually modify the edit description; instead, you must delete it with the DLTEDTD command and then create a new one with the CRTEDTD command. You can find more information about creating user-defined edit descriptions in Application Display Programming (SC41-5715).
As an alternative to changing the user-defined edit descriptions, you might consider using edit words. Edit words provide maximum flexibility in creating edit masks.
Answered by Gary Guthrie
44. FTPING FROM THE AS/400
http://www.as400network.com/nwn/story.cfm?ID=8185
Q. I need to automate a file transfer from the AS/400 (V4R2) to my PC. I have no problems transferring the file manually using Client Access, but when using the FTP command from the AS/400, I receive this message: "Cannot connect to host 192.95.95.176 at address 192.95.95.176. . . Try again later." I can ping the PC device and can Telnet from the PC to the AS/400, among other things, but nothing helps.
A. To FTP to a computer, that computer has to be running an FTP server. Windows 3.1/9x doesn't provide FTP server capability out of the box; you have to add software. Microsoft's Personal Web Server provides an FTP server as well as an HTTP (Web) server. You can also try the War FTP Daemon, which is free and available at http://www.jgaa.com/tftpd.htm . After you set up the FTP server on your PC, you should be able to connect to it from your AS/400 to transfer files.
Bill Shaffer, IBM Brand Manager
45. PRINTING AFP FONT COLLECTION SAMPLES
If you're having a difficult time finding the fonts you need in the AFP Font Collection (5648-113 or 5648-B45) because of the overwhelming number of libraries, IBM has provided two free commands that load and print samples of all the fonts in the Font Collection.
The commands LOADFNTC and TESTFONT are provided in a save file, which can be downloaded from http://www.printers.ibm.com/r5psc.nsf/web/rdfont01
46. Short Takes:
1. SENDING MESSAGES THAT USERS CAN'T IGNORE
OS/400 is great at sending messages, but often users have better things to do than pay attention to every message that comes their way, and they may overlook important messages. The SNDWDWMSG utility helps ensure that busy users see - and acknowledge - messages you want to ensure aren't ignored.
SNDWDWMSG displays a message on the user's screen in a window with red borders. The user can't do anything until the message is acknowledged by pressing F21, to remove the message from the message queue, or F22, to keep the message in the queue. Either function key removes the message from the screen.
You can read more about the SNDWDWMSG at http://www.as400network.com/article.cfm?ID=1729, and you can download the May 1997 utility from http://www.as400network.com/resources/code/ . I've also packaged the compiled utility, with source code, in a save file you can download from http://www.as400network.com/noderesources/code/clubtechcode/sndwdwmsg.zip .
2. AS/400 REMOTE ACCESS CONFIGURATION EXAMPLES
IBM has just released a preliminary version of a Redbook titled AS/400 Remote Access Configuration Examples (SG24-6058-00). The Redbook helps you to install and configure the newer remote access hardware by showing a variety of examples, from simple to complex.
Here are the main chapters covered in the Redbook:
Introduction to ISDN and Integrated Modem SupportAnalog connections using 2761 modemISDN connections using 2751 ISDN cardISDN/Analog connections using 2761 modem and 2751 ISDN card7852 modem and 2761 modem SLIP connections Problem analysis and resolutionAdvanced topics (CHAP, Multiple connection profile, Data over voice, PPP dial-on-demand remote peer enabled)ISDN trace dataISDN cause codes
You can download a PDF version of the Redbook from http://www.redbooks.ibm.com/redpieces/abstracts/sg246058.html .
3. VIEWING LOCKS ON DLOS
Q. Do you know of any way to view locks on a Document Library Object (DLO) within a folder? For example, say you created a file in a shared folder using the CPYTOPCD command and you have a networked drive to that shared folder from a Windows NT Workstation running Client Access for Windows 95/NT. If a user opens the file from the NT PC, is some type of lock shown on the AS/400?
A. It's possible to view locks on DLO objects, but doing so requires a little effort. Follow these steps:
Use the DSPDLONAM command to find the "system object name" of the document. For example, if the path shown on the client is /QDLS/MYFOLDER/MYSUBDIR/MYDOC, use the following statement:
DSPDLONAM +
DLO(MYDOC) +
FLR(MYFOLDER/MYSUBDIR) +
OBJCLS(*DOC)
Several pieces of information should be displayed, including a system object name consisting of 10 characters and an auxiliary storage pool (ASP) ID. The system object name is the "real" name of the object in an AS/400 library. The library name is determined by the ASP. If the ASP ID is 1, the library name is simply QDOC. If the ASP ID is greater than 1, the library name takes the form QDOCnnnn, where nnnn represents the ASP. For example, if MYDOC is in ASP 2, the library name is QDOC0002.
Once you've determined the system object name and library name, use the WRKOBJLCK command to display object locks on the document. For example:
WRKOBJLCK +
OBJ(QDOC/LNM1453888) +
OBJTYPE(*DOC)
Lock information should be displayed for any job that currently has the document open. Additional locks might be displayed.
An important point to note is that a document need not be open nor the object be locked to be considered "in use." For example, there are other types of commonly used locking schemes, some as simple as setting a bit in a shared memory location. It would be difficult for a user to find such a "lock." And even when it's possible to see the lock, it may not be possible to determine the lock holder if no job information has been stored.
From a Tech Corner item by R.J. Traff
4. SETTING A HIGHER PRIORITY FOR OPERATORS
Q. How can I set a higher system priority for the system operator?
A. You can use work management techniques and principles to let your system operator run interactive jobs at a priority higher than other users on the system, which may be necessary at times so the system operator can respond to unusual system situations. One solution is to have the system operator sign on at the system console; console jobs automatically run at a higher priority because they run in the QCTL (Control) subsystem. QCTL routes console jobs using the QCTL class, which specifies a higher priority than default priorities usually assigned to other users.
To build a new routing entry that uses the QCTL class (or any other class you create), follow these steps:
a. Add a routing entry to the interactive subsystem with unique routing data, and specify the QSYS/QCTL class. For example:
ADDRTGE SBSD(QINTER) +
SEQNBR(8888) +
CMPVAL(SYSOPR) +
PGM(QSYS/QCMD) +
CLS(QSYS/QCTL)
b. Create a new job description for the operator, using the same routing data you used on the routing entry. For example:
CRTOBD JOBD(SYSOPR) +
RTGDATA(SYSOPR)
Other parameters may also be necessary. Consider creating a duplicate of the QDFTJOBD job description and then changing the routing data for the duplicate job description.
c. Change the operator's user profile to specify the new job description:
CHGUSRPRF USRPRF(DJONES) +
JOBD(SYSOPR)
Answer by Bryan Meyers
47. VIEWING MESSAGES SENT VIA SNDPGMMSG
http://www.as400network.com/nwn/story.cfm?ID=8188
Q. We have a program that's submitted in batch job through the job scheduler. This program sends messages via the command SNDPGMMSG MSG(&MSGDTA). Where can I see those messages?
A. Your messages are being sent to the program message queue. You can see these messages in the job log using the DSPJOBLOG (Display Job Log) command as long as the job is active. Interactively, a job is active until you sign off. For batch jobs, the job is no longer active when the job ends.
If you set your job's logging levels appropriately, a job log is spooled when the job ends. Because the job scheduler submits jobs to batch, you must set these logging levels in order to see the messages in a spooled file after the job is completed. You control the logging levels in the job description's LOG parameter or in the SBMJOB command. Typically, you use LOG(4 0 *SECLVL) whenyou want to always spool a job log upon job completion.
Gary Guthrie, NEWS/400 Tech Editor
48. ACCESSING OUTPUT QUEUE INFORMATION
http://www.as400network.com/nwn/story.cfm?ID=8190
Q. We're developing a GUI front end to AS/400 applications using Windows MFC. We're using Client Access ODBC to talk to the AS/400. How can we access output queue information?
A. ODBC was designed for working with relational databases and as such doesn't directly support output queue information. ODBC does support remote program invocation calls to AS/400 programs, so you can write your own AS/400 programs for output queue information.
The Client Access Express APIs represent an easier way to work with spool file and output queue information from your C++ program. These APIs let you read and write to spool files and manage output queue information. You'll find reference information at the IBM AS/400 Information Center (http://publib.boulder.ibm.com/pubs/html/as400/v4r4/ic2924/info/INFOCENT.HTM).You can find code samples showing how to use the Client Access APIs at http://www.as400.ibm.com/tstudio/workshop/snippets/snippets.htm.
Terry Smith, NEWS/400 Tech Editor
49. PRINTING FROM A REMOTE AS/400
http://www.as400network.com/nwn/story.cfm?ID=8309
Q. I have an AS/400 (A) connected to another AS/400 (B) over a frame relay network running TCP/IP on an Ethernet LAN. AS/400 A has users with local HP printers attached to their PCs. These users connect to AS/400 B to use an application that requires printing to local printers. We use PC5250. Can I set up remote output queues on AS/400 B and point them to the local PC printers on AS/400 A? If yes, which address do I specify when I specify the printer's IP address?
A. There are two ways to print from a remote AS/400 to printers on your local system. If the printers are attached to PCs, configuring a printer session from PC5250 creates an output queue on your local AS/400. You then create an output queue on your remote AS/400 that points to the output queue on the local AS/400 using the CRTOUTQ command as follows:
CRTOUTQ OUTQ(xxx) +
RMTSYS(xxxx) +
RMTPRTQ(xxx) +
CNNTYPE(*IP) +
DESTTYPE(*OS400) +
TRANSFORM(*N+O)
The output queue name can be anything. Your local AS/400's IP name is the remote system (RMTSYS), and the name of the output queue is the remote printq (RMTPRTQ). The output queue can use the STRRMTWTR command.
If the printers aren't attached to a PC but contain network cards that let them connect to the network, create a printer device or remote output queue on the remote AS/400 just as if the printer was attached to the same local network as the remote AS/400.
Terry Silva, Systems Programmer, Ricks College
50. Featured Tip:
CUSTOMIZING PRINTER SEPARATOR PAGES
Way back in May 1994, NEWS/400 published an article titled "Customizing Printer Separator Pages." The RPG program, SEPPAG, prints large block letters so that separator pages stand out easily from your production reports. The user profile name appears at the top of the page, followed by the job name and number. In smaller fonts, job separators (which are printed between jobs) show the job run date and time, and file separators (which are printed between different reports in the same job) show file name and number, the number of report copies, the number of pages in each copy, and any user data defined for the printer file.
Once you compile SEPPAG, you can indicate that a printer device use customized printer separator pages by entering SEPPAG in the SEPPGM parameter in the CRTDEVPRT (Create Device Description (Printer)) or CHGDEVPRT (Change Device Description (Printer)) commands.
You can download the SEPPAG RPG program from http://www.as400network.com/noderesources/code/clubtechcode/seppag.zip .
Adapted from a program and article by Bryan Meyers
51. Short Takes:
1. SAMPLE AFP RPG AND DDS SOURCE CODE
Buried deep within IBM's Printing Systems Web site ( http://www.printers.ibm.com ) are some programming resources for those who use Advanced Function Printing (AFP) on the AS/400. One such resource, called the "AFP AS/400 Programming Sampler," is a collection of RPG and DDS coding examples showing how to produce bar codes, Postnet mailing labels, invoices, page segments, scalable fonts, electronic overlays, and so on.
The Sampler can be downloaded from http://www.printers.ibm.com/R5PSC.NSF/Web/4sample . If you download the self-extracting zip file, you'll need to unzip it in DOS - real DOS, and not a Windows 9x or NT DOS command window. Obviously, not everyone can reboot their machines to run in DOS mode, so I've made the Sampler available as a Windows self-extracting zip file, at http://www.as400network.com/noderesources/code/clubtechcode/samplerw.exe .
2. TESTING FOR AN ACTIVE PROCEDURE
The IF ACTIVE function was used extensively in S/36 procedures to test whether another procedure was running. It was a very useful feature that has no direct counterpart on the AS/400.
One way to replicate the S/36 IF ACTIVE function in OS/400 is with data areas. In the following example, CL program PROCA is the program we want to test for, and PROCB tests to see whether PROCA is executing.
CL Program PROCA
CRTDTAARA DTAARA(MYLIB/PROCA) TYPE(*CHAR) LEN(1) +
VALUE('0') TEXT('DATA AREA FOR PROCA ACTIVE TEST')
CHGDTAARA DTAARA(MYLIB/PROCA) VALUE('1')
*
*
other CL code for PROCA
*
*
CHGDTAARA DTAARA(MYLIB/PROCA) VALUE('0')
CL Program PROCB
DCL VAR(&ACTEST) TYPE(*CHAR) LEN(1)
*
*
RTVDTAARA DTAARA(MYLIB/PROCA) RTNVAR(&ACTEST)
IF (&ACTEST *EQ '1') THEN(DO)
SNDUSRMSG MSG('PROCA IS EXECUTING')
ENDDO
Adapted from IBM Knowledgebase item 13762359, at http://as400service.ibm.com/8625680A007CA5C6/0/83972ADC4953A7AA862568CC0064409B?Open&Highlight=2,13762359.
2. TESTING FOR AN ACTIVE PROCEDURE - PART 2
In the last issue, I ran an item from IBM's Knowledgebase that replicated the S/36 IF ACTIVE function, which tests whether another procedure is running.
Minutes after the e-mail newsletter was distributed, I received many e-mails telling me IBM's suggestion was flawed and offering several alternative solutions. IBM's solution can cause problems if the program - for which the active state is being tested - terminates abnormally, in which case the program will appear to other programs as still active.
I'll be posting the solutions sent to me on the Club Tech Web site next week and will provide the URL in the next newsletter. Thanks to all the readers who responded!
3. PRINTING OR SAVING A DIRECTORY TREE
If you used the old DOS TREE.COM program, you know that it piped the directory and file structure to a file or printer. TREE.COM wasn't updated to handle long file names, and it wasn't offered with the release of Windows 95.
PC Magazine has released a handy Windows version of TREE.OM called PrintTree that lets you print or save a directory tree from within Windows Explorer. You simply right-click on a folder or drive, select TreePrint from the menu, and choose to save or print the directory tree. You can control the number of directory levels documented, the amount of indentation for each level, whether to include file names, and whether the tree is sorted alphabetically.
The utility can be especially helpful in mapping out IFS directories. Here's just a few lines from the AS/400 QIBM directory:
+---ProdData
+---HTTP
+---Public
+---TC1
\---ICSS
\---HTML
Welcome.html
graphic4.gif
sampmast.gif
+---OS400
\---Icons
+---HTTPSVR
sample_search.ndm
QSF614115769DG10004R05M00505000000000
+---HTML
Welcome.html
fdoc0001.html
TreePrint is free and available for download from http://www.zdnet.com/downloads/stories/info/0,,0012RF,.html .
52. CONTROLLING USER ACCESS TO CRTLIB
http://www.as400network.com/nwn/story.cfm?ID=8314
Q. What must I change to stop users and programmers from creating libraries on the AS/400?
A. If your system is operating at security level 30 or higher, you can use object authority to control access to command CRTLIB. The EDTOBJAUT command can prevent a user from using a command. You can specify a user with an authority of *EXCLUDE. In your case, edit object authority for command (object type (*CMD) CRTLIB.
Group profiles, special authorities, and such may continue giving your users access to the CRTLIB command even though you've excluded them. In such a case, you can resort to adding a validity-checking program to CRTLIB to check the user and then exit when appropriate, without allowing the command to continue.
Gary Guthrie, NEWS/400 Tech Editor
53. OBTAINING AS/400 RESIDENT FONTS
http://www.as400network.com/nwn/story.cfm?ID=8341
Q. How do I get a list of the resident fonts shipped with an AS/400? Does the list differ based on OS/400 version or AS/400 model? Can I buy non-AFP (HP PCL-compatible) fonts? Are there any HP- or PCL-compatible fonts resident on the AS/400, or are they resident only on the HP printer itself?
A: OS/400 contains a set of 240-dpi fonts (character sets, code pages, and coded font objects) , which are *FNTRSC objects and are normally in library QFNTCPL. The fonts include Gothic, Roman, OCR, APL, Book, Courier, Essay, Orator, Prestige, and ProPrinter. You use the WRKOBJ command to list all the *FNTRSC objects in the library. Note that OS/400 V4R3 and higher contains several additional fonts to support the Euro.
Because PCL is created only through Host Print Transform and not natively on the AS/400, PCL fonts are unavailable on the AS/400. The AFP Font Collection CD, which includes all the AFP fonts for AS/400, is included, free of charge, with Print Services Facility/400 (PSF/400). PCL fonts are resident only on the PCL printer.
Bill Shaffer, IBM Brand Manager
54. NONDISRUPTIVE QUSRSYS BACKUP
http://www.as400network.com/nwn/story.cfm?ID=8348
Q. How do I manage backup and recovery of library QUSRSYS to meet the needs of a full system restore (to another box) and not affect users or operations too much?
A. The QUSRSYS library must be completely backed up for a successful system recovery. Putting the system in a semi-restricted state by ending QINTER if using save-while-active and ending QSNADS, QSYSWRK, and QSERVER is also a good way to ensure that QUSRSYS is completely saved.
However, this approach doesn't provide unattended operations or reduce the impact to end users. In the past, if a *MSGQ was in break mode during a backup, OS/400 couldn't obtain a lock to save it. The Save/Restore group at IBM has written new functions for a future release to avoid this problem. IBM has also added PTFs for V4R1 and higher to help its existing customers. The following PTFs let OS/400 successfully save a *MSGQ, even when in *BREAK mode:
V4R1 -- SF49860 V4R2 -- SF49848 V4R3 -- SF49800
Check out IBM's Technical Support center at http://as400service.ibm.com/ for the latest information on PTFs and PTF downloads.
Debbie Saugen, IBM Senior Business Recovery Specialist
55. Featured Tip:
SAVING OBJECTS IN IFS DIRECTORIES
Q. Do I need to include the SAV (Save Objects in Directories) command in my save strategy to back up my system?
A. Starting with V3R1, your save strategy must use the SAV command to save objects in AS/400 integrated file system (IFS) directories. If you're not using the SAV command, your system backup may not save objects in directories for:
* Client Access/400 * LAN Server/400 * Lotus Domino for AS/400 * some vendor applications * many licensed programs beyond V3R1
To save all objects in directories, include the following command in your save strategy:
SAV DEV('/QSYS.LIB/+
tape-device-name.DEVD') +
OBJ(('/*') +
('/QSYS.LIB' *OMIT) +
('/QDLS' *OMIT)) +
UPDHST(*YES)
Options 21 and 23 on the Save menu include the SAV command. If you use Operational Assistant for backup, the SAV command is included in option 11 on the Backup menu. (For more information about the SAV command, see "Is Your Entire System Backed Up?" from the April 1998 NEWS/400, at http://www.as400network.com/article.cfm?ID=2536 )
Incidentally, with the release early this year of PTF SF57986 for V4R4, IBM has improved performance when you are saving large number of objects in IFS directories.
Adapted from a NEWS/400 Tech Corner item by IBM's Debbie Saugen
Short Takes:
1. MIGRATING FROM OFFICEVISION/400
If you're an OfficeVision/400 (OV/400) user and unsure of what to do after IBM withdraws OV/400 after V4R5, IBM has some resources to help you find an alternative to OV/400:
a. The OfficeVision/400 Migration Web Site, at http://www.dominodotoffice.com , provides a list of IBM and third-party OV/400 migration tools and migration vendors, an OV/400 events calendar, and OV/400 discussion forums.
b. The Redbook "How to Replace OfficeVision/400 in Your Applications:Looking at Domino for AS/400 and AS/400 Alternatives" (SG24-5406-00) is an excellent guide to OV/400 migration. The Redbook can be downloaded from http://www.redbooks.ibm.com/abstracts/sg245406.html .
c. The "OfficeVision/400 Withdrawal Update" Web page at http://www.as400.ibm.com/developer/ov400/index.html has the latest OV/400 news.
One vendor offers a free AS/400 utility, called DTM Analysis Tool, that helps you determine the usage of OV/400 Data/Text Merge functions by analyzing your OV/400 documents and AS/400 programs. You can read more about the utility and download it at http://www.inventivedesigners.be/dtm/anzdtm.html .
And last, all of IBM's OV/400 manuals and Redbooks are listed at http://www.as400network.com/index400/ov.htm .
2. FUNCTION OF LIBRARY QRPLOBJ
Q. What is system library QRPLOBJ's purpose?
A. QRPLOBJ is a repository for replaced objects.
Each time you use a command that runs a compiler (such as CRTPF (Create Physical File) or CRTCLPGM (Create CL Program)), you supply a value to parameter REPLACE, which tells the command whether to replace the earlier version of the created object, if one exists. The default value is *YES, but REPLACE also accepts *NO. When you specify REPLACE (*YES), OS/400 automatically replaces the old version of the compiled object with the new version and moves the old version to library QRPLOBJ. (If you specify *NO and the system finds an earlier version of the same object, the compile command fails with an *ESCAPE message.)
Note that objects moved to QRPLOBJ don't keep their original names; OS/400 assigns them new (and unintelligible) ones but stores the original name in the object's text description, which you can use to identify them.
Because QRPLOBJ collects lots of objects over time, you need to clean it up periodically. You could delete objects individually after careful examination of each one's necessity, but it's much easier (and usually smarter) to simply clear the library once in a while by using the CLRLIB (Clear Library) command when the objects are not in use. An IPL also deletes and re-creates QRPLOBJ.
Answered by Ernie Malaga
3. INTRODUCTION TO PTFS
The July issue of NEWS/400 contains an excellent article detailing the step-by-step process for ordering and installing PTFs, as well as information about determining when you need them. The article addresses the following issues:
When Do You Need a PTF?How Do You Order a PTF?SNDPTFORD BasicsOrdering PTFs on the InternetHow Do You Install and Apply a PTF?Installing Licensed Internal Code PTFsInstalling Licensed Program Product PTFsVerifying Your PTF InstallationHow Current Are You?
The online article can be viewed by all AS400Network associate (free) and professional (paid) members at http://www.as400network.com/article.cfm?ID=7519 .
4. DISPLAYING PTF COVER LETTERS
The July 2000 article mentioned above shows how to obtain PTF cover letters using the SNDPTFORD command and displaying them with the DSPPTF command. You can also read cover letters online at http://as400service.rochester.ibm.com/supporthome.nsf/home/PTF+Cover+Letters .
5. SYSTEMS MANAGEMENT DOC WATCH
In the past month, IBM has released the following Redbooks:
Lotus Domino for AS/400 Internet Mail TopicsSG24-5990-00http://www.redbooks.ibm.com/redpieces/abstracts/sg245990.htmlThis Redbook helps you set up Lotus Domino for AS/400 to exchange mail with other SMTP servers, including those within the Internet.
AS/400 MigrationSG24-6055-00http://www.redbooks.ibm.com/redpieces/abstracts/sg246055.htmlThis Redbook helps planners and implementors understand the new PCI architecture and how to integrate or move to it.
AS/400 Clusters: A Guide to Achieving Higher AvailabilitySG24-5194-00http://www.redbooks.ibm.com/abstracts/sg245194.htmlThis Redbook presents an overview of a generic cluster and the basic terminology surrounding clusters. It examines the AS/400 cluster and its implementation and introduces ClusterProven for AS/400.
56. DUPLEX PRINTING FROM THE AS/400
http://www.as400network.com/nwn/story.cfm?ID=8385
Q. Can I print on two sides of a page using an AS/400?
A. Yes, the AS/400 supports printing on two sides of a page, which is often called duplex printing. For example, there's a Duplex parameter on the OVRPRTF (Override with Printer File) command. On V4R5 (the version I'm running), the Duplex parameter has the following valid values:
*No: The output is printed on one side of the paper.
*Yes: The output is printed on both sides of the paper, with the top of each printed page corresponding to the top of the previous printed page.
*Tumble: The output is printed on both sides of the paper, with the top of one printed page at the opposite end from the top of the previous printed page. This is usually used for output that will be bound at the top.
*Formdf: The output is printed on both sides of the paper if the duplex value is specified in the form definition. If a form definition isn't specified, then the output is printed on one side of the paper.
Duplex printing is printer-dependent, and not all printers support duplex printing. Typically, low-end laser printers don't support duplex printing, but mid- to high-end laser printers may support it. To determine whether your printer supports duplex printing on the AS/400, check the printer's documentation or contact the manufacturer. IBM, for example, has numerous printer models that support duplex printing on the AS/400.
Jim Hoopes, NEWS/400 Senior Tech Editor
57. Featured Tip:
VIEWING ANOTHER JOB'S QTEMP
I noticed a discussion in a midrange mailing list in which some AS/400 programmers were looking for a method for peering into another user's QTEMP library to help in debugging programs. There are two commercial tools that I'm aware of:
PeekPlusBytware, Inc.http://www.bytware.com[See the upcoming November 2000 issue of NEWS/400 for an article about PeekPlus.]JOB Talk utility, which is part of TAA Productivity Tools (the follow-on product to QUSRTOOL)
Jim Sloan, Inc.http://www.taatool.com
The other method for viewing a user's QTEMP is to use a utility published in NEWS/400 in July 1994. Although the code is available online, the article text isn't. I decided to dust off the article, make some minor tweaks, and present it here.The source files for the utility can be downloaded from http://www.as400network.com/noderesources/code/clubtechcode/RunJobCmd.zip .
Looking into Someone Else's QTEMPBy Ernie Malaga Reprinted from NEWS/400, July 1994Copyright c 2000 Duke Communications International, Inc.ALL RIGHTS RESERVED
QTEMP, the temporary library, is unlike other AS/400 libraries in that each job has its own QTEMP. This is great because you can create objects that are "local" to your job, meaning that no other jobs can see them and that you don't have to worry about duplicating the name of similar objects created in other jobs. In addition, QTEMP automatically vanishes when your job ends, eliminating the possibility of leftover objects that clutter your system and consume valuable disk space.
Along with these advantages, however, comes a major inconvenience: You can't access another job's QTEMP. Say, for example, that a shipping program created objects in QTEMP, as many in-house and purchased software products do. Let's then suppose the program blows up, and the shipping clerk calls you for help. You need to investigate the DEFAULTS data area in the clerk's QTEMP to find out what went wrong. However, running the DSPDTAARA (Display Data Area) command from your display station would display only the data areas in your copy of QTEMP - which would contain different data, if the same data areas existed at all. Instead, you must run DSPDTAARA at the clerk's display station in the shipping department. There must be an easier way.
An Easier Way
With MI, you could fool the AS/400 into believing that your QTEMP is the clerk's QTEMP. You could then run commands into the remote user's interactive job from the comfort of your own desk. MI solutions, however, are difficult and seldom work at security levels higher than 30. Here, I present an easy-to-implement non-MI solution that will work at any security level. It consists of a single command: RUNJOBCMD.
To see how to use command RUNJOBCMD, let's revisit the shipping-clerk scenario. Let's say you're signed on to SYSDSP02 in the computer room, and the shipping clerk, Brad, is signed on to display station SHPDSP03. From Brad's description, you determine the problem must be in the DEFAULTS data area in his QTEMP. To look at the DEFAULTS data area in Brad's QTEMP from your display station, you run
RUNJOBCMD
JOB(SHPDSP03) +
CMD(DSPDTAARA +
qtemp/Defaults +
OUTPUT(*PRINT))
The RUNJOBCMD command tells the system to run the DSPDTAARA command as if it had been requested from SHPDSP03. The *PRINT option lets you look at the DSPDTAARA output by displaying the generated spooled file; without the OUTPUT(*PRINT) parameter, the output would simply go to Brad's display station.
When you press Enter, Brad's display station beeps and presents a panel that shows him the command you've requested and lets him approve or reject the request. If he presses Enter, your DSPDTAARA command will run on his job, displaying the DEFAULT data area in his QTEMP. If he presses F3 or F12, however, DSPDTAARA doesn't run. Either way, utility RUNJOBCMD sends you a break message that tells you which action Brad has taken.
How It Works
Central to utility RUNJOBCMD is a break-handling program that receives messages coming into the remote display station's message queue and, if they're request messages (*RQS), interprets them as commands and executes them via QCMDEXC. (For details about how break-handling programs work, see Chapter 8 of the CL Programming manual, SC41-5721, http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/QB3AUO03/CCONTENTS .)
For this break-handling program to work, the remote display station's message queue must be in *BREAK mode. To ensure this, it's a good idea to use a user profile initial program such as that shown below:
/* Sample User Profile Initial Program */
/* */
/* From "Looking Iinto Someone Else's QTEMP */
/* NEWS3X/400, July 1994 */
/* */
/* Copyright (c) 1994 Duke Communications Int'l. */
/* ALL RIGHTS RESERVED */
PGM
DCL &dspstn *CHAR 10
/* +
Place the display station's message queue in *BREAK mode. +
First, get the display station's name and then run CHGMSGQ. +
*/
RTVJOBA JOB( &dspstn )
CHGMSGQ MSGQ( &dspstn ) +
DLVRY( *BREAK ) +
PGM( jobcmdbhp )
ENDPGM
This program, executed when a user signs on, uses the CHGMSGQ (Change Message Queue) command to automatically place the display station's message queue in *BREAK mode, with JOBCMDBHP as the break-handling program. From this point on, RUNJOBCMD is ready whenever you need it.
Let's dig a little deeper into the utility's details. When you run command RUNJOBCMD, you enter the name of the remote display station and the command you want to execute. Because the CMD parameter is defined as a command string (*CMDSTR), you can prompt the command you want to run by typing RUNJOBCMD and pressing F4.
All that command processing program (CPP) RUNJOBCMDC does is send the command string as a *RQS message to the remote display station's message queue. Notice that RUNJOBCMDC does not use the standard SNDMSG (Send Message) command to send this message because SNDMSG cannot send *RQS messages. Instead, it uses the more complicated SNDPGMMSG (Send Program Message) command.
When the *RQS message arrives at the message queue, break-handling program JOBCMDBHP receives the message, extracting from the sender information parameter the names of the user profile who sent the message and of the display station from which it was sent. When JOBCMDBHP determines that the message is a *RQS message (which has a return type of '08' or '10'), it uses display file JOBCMDBHPD to present the Job Command Request panel, which lets the remote user approve or reject the requested command. To approve the request, the user presses Enter, and JOBCMDBHP executes the command. To reject the request, the user presses F3 or F12. JOBCMDBHP then reports the user's action back to the requester in the form of a break message.
Security Risks
Although convenient, this utility does pose some security risks. If you compile the break-handling program so that it adopts QSECOFR authority, anyone who has access to RUNJOBCMD (and who has a willing accomplice signed on at another display station) can run any command on the system. The same exposure exists if someone uses RUNJOBCMD to run commands from QSECOFR's interactive job; however, this can't be done unless QSECOFR (or someone at the station QSECOFR is signed on to) authorizes each command request by pressing Enter.
To minimize your security exposure, follow common-sense security rules. For example, don't compile the break-handling program while adopting QSECOFR's authority, and don't disclose QSECOFR's password. Also, make sure QSECOFR knows how RUNJOBCMD works and the possible security risks. In addition, you can use the AS/400's journaling feature to keep a permanent record of who's using RUNJOBCMD and how.
Implementation Issues
Implementing utility RUNJOBCMD is easy. You need only create command RUNJOBCMD, CPP RUNJOBCMDC, break-handling program JOBCMDBHP, and display file JOBCMDBHPD. To install utility RUNJOBCMD, run the following commands in sequence:
CRTCMD
CMD(MYLIB/RUNJOBCMD) +
PGM(MYLIB/RUNJOBCMDC) +
SRCFILE(MYLIB/QCMDSRC) +
AUT(*EXCLUDE)
CRTCLPGM
CMD(MYLIB/RUNJOBCMDC) +
SRCFILE(MYLIB/QCLSRC) +
AUT(*EXCLUDE)
CRTDSPF
FILE(MYLIB/JOBCMDBHPD) +
SRCFILE(MYLIB/QDDSSRC)
CRTCLPGM
PGM(MYLIB/JOBCMDBHP) +
SRCFILE(MYLIB/QCLSRC)
Last, give *USE authority for command RUNJOBCMD and program RUNJOBCMDC to authorized users.
You cannot use RUNJOBCMD to run interactive commands, such as WRKOBJPDM (Work with Objects Using PDM). That's why, in our shipping-clerk example, we had the DSPDTAARA command send its output to the printer, which lets the command run in batch mode. Otherwise, DSPDTAARA's output would go to the screen, making DSPDTAARA an interactive command. If you must run an interactive command, first use RUNJOBCMD to execute the CRTDUPOBJ (Create Duplicate Object) command to copy the necessary objects from the remote display station's QTEMP to any other library. You can then operate on the objects using standard commands.
The next time a user calls with a problem in QTEMP, run utility RUNJOBCMD instead of running up the stairs. Your legs and lungs will thank you.
58. USING BINDING DIRECTORIES
http://www.as400network.com/nwn/story.cfm?ID=8400
Q. Should BNDDIR be program-specific or application-specific? If it's application specific, is a particular module still available in a program, even if I'm not using that module? What happens to the object size? Doesn't adding modules that aren't used in that program unnecessarily increase the object size? Do we still have to update the *PGM when we change a particular module from the BNDDIR?
A. There are two main approaches to using binding directories:
1. Use a separate binding directory to define the modules and service programs needed to create each program.
2. Use one binding directory to define the common modules and service programs that may be bound to the programs in an application.
I prefer the second approach because it simplifies program creation. I scope binding directories to libraries; each application library has its own binding directory. For example, a Finance library (FINLIB) may have a binding directory (FINBNDDIR) that contains entries for service programs, which include common financial procedures. Each program in FINLIB is created by specifying the FINBNDDIR binding directory.
A program's size depends on the modules and service programs to which it's bound. The program object contains a copy of each bound module and a reference to each bound service program. The program's size isn't affected by other entries in a binding directory specified at compilation.
Where possible, I recommend using service programs in preference to modules. Let's assume you always want your programs to use the latest versions of your service programs and modules. If you change the contents of a service program procedure but not its parameters or return value, programs will pick up the latest version of the service program at runtime. Other changes to service programs normally require the rebinding of the programs that use them. Changes to a module always require the rebinding of programs to create a new copy of the module in each program.
Julian Monypenny, NEWS/400 Tech Editor
59. RETRIEVING QSYS COMMAND OBJECTS
http://www.as400network.com/nwn/story.cfm?ID=8467
Q. I'm an AS/400 security administrator. I accidentally deleted certain system commands when I mistakenly typed DLTCMD WRK* instead of SLTCMD WRK* on the command line. As a result, the system deleted six command objects from the QSYS library. Is there any way to restore the command objects? We save our system regularly using SAVSYS (Option 21 on the Save menu).
A. Unfortunately, you can't restore these commands from your save.
Though the SAVSYS command saves library QSYS (where the commands are located), it doesn't permit a restore of individual objects using RSTOBJ. Because of this fact, I typically recommend that a backup strategy include a SAVOBJ command that saves all objects in library QSYS so that they can be subsequently restored.
To fix your problem, you need to restore OS/400 from the most recent SAVSYS media that contains the deleted commands. Be careful not to restore configuration or user profile information. Also, if you've applied any PTFs since the time of the creation of the SAVSYS media used in restoring OS/400, you need to reapply those PTFs.
Gary Guthrie, NEWS/400 Tech Editor
60. CUSTOM QUERY OPTIONS BUILDER
Before V4R4, query attributes were scattered across CL commands, system values, and data areas. This made it difficult to set all the different values or to determine the attributes' values, many of which directly affect the query optimizer's implementation decisions.
Starting with V4R4, all the attributes that potentially affect the performance of the DB2 UDB for AS/400 database engine have been centralized in the query options file QAQQINI. You can use QAQQINI to control a query's performance and save and apply configuration settings (attributes) across multiple executions of a query request.
IBM has recently made available a Web-based tool called the Custom Query Options Builder that lets you easily update your own QAQQINI file. Based on values you enter in the Web form, the tool generates an SQL script that you can execute several ways, two of which are with the RUNSQLSTM CL command or the Operations Navigator SQL Script Center.
The Custom Query Options Builder and instructions on its use are at http://www.as400.ibm.com/developer/bi/tuner.html .
You can learn more about QAQQINI in the January 2000 NEWS/400 article "Query Performance Tuner Consolidates Query Options." You can read this article online at http://www.as400network.com/article.cfm?ID=3292 if you are an AS400 Network professional member. IBM's DB2 UDB for AS/400 Database Performance and Query Optimization manual also has QAQQINI information, which you can view at http://publib.boulder.ibm.com/pubs/html/as400/v4r5/ic2924/info/db2/rzajqmst02.htm .
61. Short Takes:
1. FINDING COMMANDS AND MENUS
Despite the logical naming convention for OS/400 commands and menus, it's easy to get stymied groping for the proper name.
Here are a few ways to easily find the command you're looking for:
a. Enter SLTCMD *ALL to display a list of all commands.
b. Enter SLTCMD and a generic name to display a list of all commands that contain one or more characters. For example, SLTCMD dspf* will display all commands starting with DSPF, such as DSPF, DSPFAX, DSPFD, and so on.
c. Enter a generic name on the OS/400 command line (SLTCMD is assumed by the system). For example, entering dspf* on the command line is identical to entering SLTCMD dspf*.
It's preferable to use method (c) and not (b), since the "S" in SLTCMD is close to the "D" on the keyboard, and with the right authority, you could inadvertently perform a DLTCMD (Delete Command) operation. That would be a bad thing :(.
Here are two easy ways to locate a menu:
a. Enter GO *ALL, which displays all menus.
b. Enter GO and a generic name to display a list of all menus that contain one or more characters. For example, GO file* will display all menus starting with FILE, such as FILE, FILESYS, FILETFR, and so on.
2. VIEWING THE IPL PROCESS
If you want to know how the last IPL on your machine progressed, what steps were performed, and how long they took, you can call program QSYS/QWCCRTEC. Doing so produces a dump in spooled file QPSRVDMP that specifies the source panel code, which identifies each IPL step and a corresponding timestamp.
The AS/400 Service Functions manual (SY44-5902), which accompanies the hardware, describes the source panel codes. Unfortunately, the manual is not online.
From a NEWS/400 Tip by Carsten Flensburg
3. IDENTIFYING JOBS IN QSYSWRK
Ever wonder what all those jobs are in subsystem QSYSWRK? Here are descriptions of some of the more common ones (a * indicates additional characters that vary from job to job):
a. TCP/IP server jobs
ADMIN Administrative Web server
DEFAULT Default Web server
QMSF Mail server framework
QRWTLSTN Distributed Data Management (DDM)/Distributed Relational Database Architecture (DRDA) TCP/IP server, daemon
QRWTSRVR DDM/DRDA TCP/IP server
QTBOOTP Bootstrap Protocol (BOOTP) server
QTCPIP TCP/IP interface, daemon
QTFTP* File Transfer Protocol (FTP) server
QTGTELNETS Telnet server
QTLPD* Line Printer Daemon (LPD) server
QTOBDNS Domain Name System (DNS) server
QTODDHCPS Dynamic Host Configuration Protocol (DHCP) server
QTPP* Point-to-point session
QTRTD* Routing daemon (RouteD) server
QTRXC* Remote Execution (REXEC) server
QTSMTPSVSR Simple Mail Transfer Protocol (SMTP) server
QTTFT* Trivial FTP server
b. Client Access host server jobs
QNPSERVD Network print server for TCP/IP, daemon
QNPSERVS Network print server for TCP/IP
QZHQSRVD Data queue server for TCP/IP, daemon
QZHQSSRV Data queue server for TCP/IP
QZRCSRVS Remote command server for TCP/IP
QZSCSRVS Central server for TCP/IP
QZRCSRVSD Remote command server for TCP/IP, daemon
QZSCSRVSD Central server for TCP/IP, daemon
QZSOSGND Sign-on server for TCP/IP, daemon
QZSOSIGN Sign-on server for TCP/IP
QZSOSMAPD Server port mapper for TCP/IP
c. 5250 Display Station Passthrough jobs
QPASVRP Primary passthrough server
QPASVRS Secondary passthrough server
For more information about TCP/IP server jobs, see TCP/IP Configuration and Reference (SC41-5420).For more information about Client Access host server jobs, see AS/400 Client Access Host Servers (SC41-5740).For more information about 5250 Display Station Passthrough servers, see Remote Work Station Support (SC41-5402).
NEWS/400 Tip by Dawn May, Advisory Software Engineer, IBM
4. CONFIGURING A LAN CONNECTION ON YOUR AS/400
IBM has a simple Web-based wizard that walks you through the steps to configure your AS/400 LAN hardware and assign a TCP/IP network connection. You can use the wizard at http://www.as400.ibm.com/tstudio/lan/lanstart.htm .
5. FUNCTION OF LIBRARY QRPLOBJ, PART 2
The item in the last issue on Library QRPLOBJ stated that "each time you use a command that runs a compiler (such as CRTPF (Create Physical File) or CRTCLPGM (Create CL Program)), you supply a value to parameter REPLACE, which tells the command whether to replace the earlier version of the created object, if one exists.. When you specify REPLACE (*YES), OS/400 automatically replaces the old version of the compiled object with the new version and moves the old version to library QRPLOBJ."
Two readers pointed out that although this applies to CRTCLPGM and similar commands, it does not apply to CRTPF or CRTLF, as neither has a REPLACE parameter. Creating a file over an existing file didn't place the older file in QRPGOBJ either.
Thanks to Richard Theis and Michael Smith for pointing this out.
62. PREVENTING INCOMING MESSAGES
http://www.as400network.com/nwn/story.cfm?ID=8568
Q. Is there a way to prevent incoming messages from interrupting me while I'm working on a project? I'm a student at a community college, and other students send inquiry messages that come up on my workstation, bringing everything to a temporary halt.
A. To prevent messages (inquiry and break) from interrupting you at your workstation, set your job's Break Message Handling attribute to value *NOTIFY or *HOLD. To change the value, issue command CHGJOB BRKMSG(*NOTIFY) or CHGJOB BRKMSG(*HOLD) from the command line. If you want to reinstate the interruptions, execute CHGJOB BRKMSG(*NORMAL).
Gary Guthrie, NEWS/400 Tech Editor
63. ELIMINATING PHANTOM SESSIONS
http://www.as400network.com/nwn/story.cfm?ID=8638
Q. Our associates perform their daily duties either on our IBM mainframe or on the AS/400. They can access the AS/400 either via a product called N/VISION TPX (provided by a vendor named LEGENT) or straight 5250 using Client Access.Unfortunately, our associates sometimes exit their AS/400 sessions by Xing out of the application (pointing their mouse to the X on the Windows client and clicking) as opposed to signing off. When they do this, a phantom session remains on the AS/400, and it's probable that the next associate accessing the AS/400 picks up this phantom session. This practice presents a security breach, among other things. How can we eliminate phantom sessions altogether?
A. You need to set the QINACTITV system value, which is explained in full when you go to http://as400service.rochester.ibm.com/supporthome.nsf/Document/10000051 ,select Communications, TCP, and then Telnet. From there, select QINACTITV System Value Explained.
Chuck Lundgren, NEWS/400 Tech Editor
64. Featured Tip:
SOUNDEX AND OTHER NEW SQL FUNCTIONS
The August NEWS/400 article "Extreme V4R5 Enhancements for DB2 UDB" discussed SQL enhancements, including the addition of the functions Soundex and Difference. Unfortunately, IBM's documentation hasn't kept up with these enhancements. Neither the HTML nor the PDF version of the "DB2 UDB for AS/400 SQL Reference" manual in IBM's InfoCenter contains the enhancements. Until IBM corrects the problem, the only way to learn more about Soundex and Difference, and the other new functions Atan2, Radians, and Rand, is to download the newer difficult-to-locate PDF file at http://ibm.com/as400/db2/rbafzmst.pdf .
Just so you don't have to download the PDF file right away, here's IBM's documentation on Soundex:
The Soundex function returns a 4-character code representing the sound of the words in the argument. The result can be compared with the sound of other strings.
The argument can be any string, but not a BLOB.
The data type of the result is CHAR(4). If the argument can be null, the result can be null; if the argument is null, the result is the null value.
The Soundex function is useful for finding strings for which the sound is known but the precise spelling is not. It makes assumptions about the way that letters and combinations of letters sound that can help to search out words with similar sounds. The comparison can be done directly or by passing the strings as arguments to the Difference function.
Example:
Using the EMPLOYEE table, find the EMPNO and LASTNAME of the employee with a surname that sounds like 'Loucesy'.
SELECT EMPNO,LASTNAME
FROM EMPLOYEE
WHERE SOUNDEX (LASTNAME)=SOUNDEX ('Loucesy')
Returns row:
000110 LUCCHESSI
For a description of Soundex and to see a working online demonstration, go to http://www.geocities.com/Heartland/Hills/3916/soundex.html .
65. Short Takes:
1. TESTING SQL FUNCTIONS
One way to try out an SQL function without a lot of effort is to create a single row table just to use for testing. To show how this works, I've included a sample interactive SQL session that creates a test table named DummyTab and tests the Soundex function:
a. On the OS/400 command line, enter STRSQL and press Enter.
b. Enter:
create table dummytab (col1 int)
c. Enter:
insert into dummytab values(0)
d. Enter:
select soundex('Kathy')
What you'll see is that Kathy results in a Soundex value of K300 (which is also the Soundex value of similar names Kate and Katie).
e. Enter:
select dayofweek(date('2000-10-11')) from dummytab
This test uses two functions: date, which converts the date string to an internal date forum, and dayofweek, which converts the date into a number between 1-7 (1=Sunday, etc.). This test would result in the number 4, for Wednesday.
Thanks to Mike Cravitz for suggesting the above technique
2. CHANGING DEFAULTS IN PDM
Q. How do I change option 14 in PDM so that the compile takes place interactively instead of being submitted to the job queue?
A. You can change many PDM defaults by pressing F18= (Change Defaults) at any PDM "Work with . . ." display. The resulting Change Defaults display lets you change several options; in your case, you would change the "Compile in batch" option to "N". This display also offers you the option to save the session defaults so they'll be used the next time you access PDM. These defaults are stored in a space associated with your user profile.
3. MORE SAMPLE SOCKET CODE FOR SOCKET PROGRAMS
Last January I published a list of resources where you could find RPG sample socket source code. Since then, I've learned of three resources provided by AS/400 programmers:
Chris Bipes' RPG IV sample source codehttp://www.cableone.net/ckb62/TCPIP%20Sockets.htm
Nick Roux's RPG IV sample source codehttp://home.yebo.co.za/~10302602/download1.html
Joerg Egger's Cobol sample source code http://www.as400network.com/cobol/CobolCode/SampleSocketsPgm.zip
And just so you don't have to look back in the January issue, here are the other sources:
IBM's Redbook "Who Knew You Could Do That with RPG IV? A Sorcerer's
Guide to System Access and More" (SG24-5402-00)http://www.redbooks.ibm.com/abstracts/sg245402.html
IBM's "OS/400 Sockets Programming V4R4"http://publib.boulder.ibm.com/cgi-bin/bookmgr/DOCNUM/SC41-5422-03
NEWS/400's March 1999 article "Anatomy of a Sockets API"http://www.as400network.com/article.cfm?ID=2927
NEWS/400's June 1999 article "SCKTPROC Eases RPG Socket Programming"http://www.as400network.com/article.cfm?ID=3042
4. MORE PRODUCTS THAT VIEW OTHER'S QTEMP
In the last issue, I mentioned two products that let you peer into another user's QTEMP library when debugging programs: Byteware's PeekPlus and Jim Sloan's JOB Talk utility. I've since learned there are three more products that perform this function:
OpCenter Job InterventionAdvanced Systems Conceptshttp://www.asc-as400.com/
VISUAL Support Pro and VISUAL Debugger for WindowsTango/04http://www.tango04.com/
WideScopeMillennium Systems Products, Inc.http://msp.ibmbp.com/
5. INSIDE THE AS/400
Have you always wanted to know the life story of the AS/400, along with a comprehensive look at the system's architecture? Now you can - for free. The first four chapters of Frank Soltis's biography of the AS/400, "Inside the AS/400," are online at http://www.as400network.com/ibm/insideas400/ . The online chapters include:
Advanced Application Architecture
The Power PC Technology
The System Licensed Internal Code
The Technology-Independent Machine Interface
66. PASSING VALUES VIA PARAMETERS
http://www.as400network.com/nwn/story.cfm?ID=8670
Q. I wrote a CL program to execute an SQL statement as follows:
PGM
RUNSQLSTM SRCFILE(DAVIES/QSQLSRC)
SRCMBR(GYRUN)
ENDPGM
This is the SQL statement in the GYRUN source member:
INSERT INTO GYPF
SELECT USER, 1000725, SCAA
FROM SCPF
WHERE SCAS BETWEEN `210' AND `215'
Instead of using the literals (1000725, `210', and `215' ), I'd like to pass values via the CL program's parameters. How can I do this?
A. The RUNSQLTM command doesn't support variable substitution.
However, there is a solution if you want to continue using RUNSQLSTM. You could code a shell SQL statement in your source member that looks something like this:
INSERT INTO GYPF
SELECT USER, %P1%, SCAA
FROM SCPF
WHERE SCAS BETWEEN `%P2%' AND `%P3%'
Notice that for the three parameters you want to use, I removed the literals and replaced them with placeholders %P1%, %P2%, and %P3.
You then write a program that accepts your parameters, reads the shell source member, and generates a new source member with the appropriate parameter substitutions made for the placeholders. Next, specify the newly generated source member as the source member to use on the RUNSQLSTM command.
If you don't want to generate a source member, consider using embedded SQL. CL doesn't support embedded SQL, but you can embed SQL in an RPG or Cobol program and use host variables instead of literals. The embedded INSERT statement would look like this:
INSERT INTO GYPF
SELECT USER, :Var1, SCAA
FROM SCPF
WHERE SCAS BETWEEN :Var2 AND :Var3
Another solution is to use the Query Manager utility's StrQmQry command to set parameter values in an SQL statement. The StrQmQry command can be coded in a CL program, and you can use CL variables to supply values for the command's SetVar parameter. You can learn more about this approach in "Pass Parameters to Queries with DB2/400's Query Manager" (NEWS/400, May 1997).
Paul Conte, Senior Tech Editor, and Gary Guthrie, Tech Editor
67. CONTROLLING CATALOG FILE SIZE
http://www.as400network.com/nwn/story.cfm?ID=8731
Q. We have a perennial battle to keep our AS/400 disk storage use under control. The single biggest file on our system is QSYS/QADBIFLD. This has been the case for some time, and being an IBM object, I've taken it as normal. However, I've noticed over the past six months (since we've been on our new S20) that this file continues to grow and contains a huge number of deleted records, none of which are cleaned up at IPL.
Currently QSYS/QADBIFLD contains more than 3 million records and 8.5 million deleted records and occupies around 3.5 GB. I understand this is one of the catalog files used in SQL and ODBC and contains cross-reference information on system tables and fields, which reflects that we have numerous objects on our system. We're implementing new applications that replace all our old systems, so over the next year, we should be able to steadily remove most of them.
In the meantime, can we do anything about the size of the catalog files, considering they are QSYS objects? Can we reclaim the deleted record space? I assume RGZPFM isn't viable for obvious reasons.
A. QADBIFLD is one of several database cross-reference files. This file reuses deleted records as necessary. There are times, though, when some additional action is warranted. It sounds like you have such a situation.
Consider an environment that adds and deletes a large number of files and fields to database and then remains fairly static in the number of files and fields that are added to the database. The result in such a case is a large number of deleted records that are never reused. To reclaim the space consumed by these deleted records, use RCLSTG SELECT(*DBXREF). Note that you must execute this command while the system is in restricted state.
Gary Guthrie, NEWS/400 Tech Editor
68. Featured Tip:
ASCII PRINTER SUPPORT
IBM Knowledgebase document 17690939 contains information about how hundreds of ASCII printers from various manufacturers are supported on the AS/400. The following information is specified for each printer:
a. Printer Data Stream. Specifies the printer data stream(s) supported by the printer.
b. PDT File for PC5250. Specifies the Printer Definition Table (PDT) File that can be used when configuring a Personal Communications 5250 (or PC5250) printer session.
c. MFRTYPMDL for HPT. Specifies the Manufacturer Type and Model (MFRTYPMDL) setting that can be used with Host Print Transform (HPT) in order to select the appropriate data stream for the printer.
d. RMTOUTQ. Specifies whether a Remote Output Queue (RMTOUTQ) can be used to print to the printer when directly connected to the LAN.
e. PJL. Specifies whether a *LAN 3812 PJL Device Description can be used to print to the printer when directly connected to the LAN.
f. SNMP. Specifies whether a *LAN 3812 SNMP Device Description can be used to print to this printer when directly connected to the LAN.
The printer manufacturers listed include AMT, Brother, Canon, Compaq, Decision Data, Epson, HP, GENICOM, IBM, Intermec, Ithaca Peripherals, Kyocera, Lanier, Lexmark, Mita, Minolta, MINOLTA-QMS, NEC, Okidata, OTC, Olympus, Panasonic, Printek, Printronix, Ricoh, Savin, Sharp, Tally, Tektronix, Toshiba, Unisys, and Xerox. Whew!
The IBM Knowledgebase item can be viewed at http://www.as400service.ibm.com/s_dir/slkbase.NSF/acf2ee1e9d64b16e8625680b00020389/b44a2cf4ba778d83862568250053649f?OpenDocument.
69. Short Takes:
1. CHANGING TABLE, VIEW, AND COLUMN LABELS WITH SQL
If you're tired of deleting and re-creating files to change column-level information, such as column headings, it's time you considered the SQL LABEL ON statement. LABEL ON lets you add and easily change labels for tables, views, and columns.
LABEL ON supports the following label types:
a. Column headings. Tools such as STRSQL (Start SQL) and STRQM (Start Query Manager) use column headings when displaying or printing query results. A user may specify up to three column-heading segments (or words) as part of a single string that can be a maximum of 60 characters. Each segment can be a maximum of 20 characters, and each segment will appear on a separate line. If a segment is less than 20 characters, you must pad it out with blanks so that the subsequent segment begins in the 21st or 41st position. The following LABEL ON statement adds a two-segment column heading (Employee Number) to the EMPNO column of table Employee in library CorpData:
LABEL ON COLUMN CORPDATA.EMPLOYEE.EMPNO
IS 'Employee Number'
You can also specify column headings for more than one column in a single LABEL ON statement, such as:
LABEL ON CORPDATA.EMPLOYEE
(EMPNO IS 'Employee Number',
EDLEVEL IS 'Education Level')
b. Column-level text. You can enter a character string of up to 50 characters describing a column. The following LABEL ON statement adds text for the EMPNO column:
LABEL ON COLUMN CORPDATA.EMPLOYEE.EMPNO
TEXT IS
'Employee number (6 character digits)'
c. Object-level text for tables and views. Object-level labels describe tables and views. The following LABEL ON statement adds the string "Employee data" as object-level text to table EMPLOYEE:
LABEL ON TABLE CORPDATA.EMPLOYEE IS
'Employee data'
You can display column headings and text by using various CL commands, such as DSPFFD (Display File Field Description), or by querying the system catalogs.
From a tip by IBM's Carol Ramler
2. MANAGING DISK SPACE
To help you manage disk use on your AS/400, OS/400 includes the RtvDskInf (Retrieve Disk Information) and PrtDskInf (Print Disk Information) commands. You can use these two commands to monitor the utilization of your disks, or you can write your own queries over the data captured by RtvDskInf to analyze changes in disk use.
You use command RtvDskInf to gather information about all the objects on your system. The command outputs the information to member QCurrent in file QAEZDisk in library QUsrSys. For a large system with many thousands of objects, running RtvDskInf can take several hours, so IBM requires you to run the command in batch. The easiest way to do this is to use the SbmJob (Submit Job) command:
SbmJob Cmd(RtvDskInf)
You use command PrtDskInf to print the information that command RtvDskInf generates in file QAEZDisk. PrtDskInf lets you print a summary of your system information or print details of disk use by library, folder, owner, or object. For example, to print a list of libraries that are more than 1,000 K in size in descending order by size, you run the command
PrtDskInf RptType(*Lib) +
Obj(*None) +
MinSize(1000) +
Sort(*Size)
The online help for PrtDskInf explains all the available options.
If the standard PrtDskInf report options don't meet your needs, you can write your own queries over file QAEZDisk. In addition, you can save the data in member QCurrent in QAEZDisk to a file and write queries to compare the output from different runs of RtvDskInf.
From a tip by Julian Monypenny
3. CHANGING SYSTEM REQUEST MENU 3 FROM DSPJOB TO WRKJOB
Q. There is (or was) a message in the QCPFMSG message file that controls whether System Request menu item 3 is Display Job (the default) or Work Job. Does this feature still exist, and, if so, what is the message ID? Is the feature documented somewhere in the IBM manuals, or is it undocumented?
A. The system uses message CPX2313 from message file QCPFMSG in determining commands executed when a user selects the associated option from the system request panel. You can change the command that will be executed for an option by changing the first-level text of message CPX2313.
If you choose to make such a change, be careful not to alter the position within the text where the commands appear. To help ensure you maintain the commands' positions, avoid using the CHGMSGD command and instead use option 2 (Change) from the panel produced by the WRKMSGD command, which lets you see the message's current text.
From a Tech Corner item by Gary Guthrie
70. CREATING A HELP FUNCTION KEY
http://www.as400network.com/nwn/story.cfm?ID=8761
Q. Can I create a Help function key for a field in an SDA screen? When I create my screen using SDA, it uses the fields from a physical file I created. How can I position to a field on the screen and select a Help function key to retrieve information on that specific field?
A. You can use DDS keyword RTNCSRLOC (Return Cursor Location) to help with your requirement. This keyword supplies your program with cursor location information when the user performs a display file function. You can choose from two formats using RTNCSRLOC: retrieve the cursor's row and column or retrieve the field name in which the cursor is located.
You'll probably want to retrieve the field name in which the cursor is located so that your program can execute the help routine appropriate for the field. You can find more about keyword RTNCSRLOC in OS/400 DDS Reference (SC41 5712).
71. Featured Tip:
WORK WITH ILE AND OPM PROGRAM REFERENCES UTILITY
The Work with Program References (WRKPGMREF) utility is a handy program maintenance tool published in NEWS/400 back in September 1997. WRKPGMREF presents a work-with panel listing all the objects - files, programs, modules, service programs, and data areas - referenced by the ILE or OPM program you specify. You can perform tasks on the listed objects using numeric options and on the referencing program using function keys. The numeric options and function keys are described briefly below.
WRKPGMREF Numeric Options
1 = Invokes the STRSEU (Start SEU) command to edit the source code of the referenced object.
2 = Executes a CHGxxx command to change the referenced object depending on the
object type; e.g., CHGPGM (Change Program) is invoked if the referenced object is
a program (*PGM) object.
5 = Invokes a DSPxxx command, depending on the object type; e.g., DSPPGM (Display Program) is invoked if the referenced object is a program (*PGM) object.
8 = Executes the DSPOBJD (Display Object Description) command.
9 = Lists all the record formats referenced in a file.
10 = Changes the referenced object's source code information that was supplied byOS/400 at compile time. This is useful when you move the source file to adifferent library or rename the source file or the member.
12 = Invokes WRKPGMREF recursively for the referenced program.
13 = Executes the CHGOBJD (Change Object Description) command to let you change the referenced object's text description.
WRKPGMREF Function Keys
F1 = Displays help.
F3 = Exits WRKPGMREF.
F4 = Invokes the command prompter for the command you enter on the command line.
F5 = Refreshes the detail lines in the panel.
F6 = Prompts the appropriate command to re-create the referencing program or module without requiring you to edit the source member.
F7 = Executes the CHGPGM command to change the program being analyzed.
F8 = Prompts the UPDPGM (Update Program) or UPDSRVPGM (Update Service Program) command for the referencing of an ILE program or service program. The update command includes all modules you re-created or changed using WRKPGMREF.
F9 = Retrieves the last command entered on the command line.
F10 = Invokes STRSEU so you can edit the source code of the program being analyzed.
F11 = Toggles between two views of the detail lines. By default, the rightmost data column shows text descriptions; by pressing F11, you can have it display source code information.
F12 = Cancels the WRKPGMREF panel.
F13 = Executes the RNMOBJ (Rename Object) command to change the name of the program being analyzed.
F14 = Invokes the MOVOBJ (Move Object) command to move the program being analyzed into a different library.
F15 = Changes the source code information of the program being analyzed.
F21 = Prints the referenced-objects list shown on the main panel. The resulting hard copy of the references contains more information than the output of the DSPPGMREF (Display Program References) command.
F24 = Displays more function keys.
To learn more about WRKPGMREF, read the article "The ILE WRKPGMREF Utility" at http://www.as400network.com/article.cfm?ID=1991 . You can download the code from http://www.as400network.com/resources/code/index.cfm?fuseaction=ShowAllIssueCode&IssueSelect=Past&IssueYear=1997&IssueMonth=09 .
The code is extensive: it includes more than 20 objects from more than 10,000 lines of source code comprising two panel groups, 16 modules (bound into three ILE programs), and one command. By far the easiest way to get WRKPGMREF to your system is by downloading the save file version of the utility.
You must be an AS400Network professional member to download the code or read the online article.
72. Short Takes:
1. RECOVERING AN INTERRUPTED SEU SESSION
Q. I was in the process of creating a new member while editing a source file with SEU. After an interrupted emulation session, I can't remember the name, and I hadn't yet saved the member. Where does OS/400 store the details of interrupted SEU Edit sessions?
A. You don't have to bother with the recovery tables for this type of abend to solve your problem. When you create a new source member, SEU automatically adds it to the source file. Your new member is empty, but it is there. If you pressed Enter while in SEU, the code typed in or changes made will be reflected in the source member. Bear in mind, though, that certain abends (such as the system going down) can prevent recovery of the source.
If you know the name of the source file and library you were using at the time you were interrupted, the failure was recent, and you pressed Enter while in SEU, then these steps should find your lost member:
a. Execute the STRPDM (Start Programming Development Manager) command.
b. Select option 3 to work with members.
c. Fill in source file and library names, and for member name and type, select *ALL.
d. From the panel listing members, look for the member's name. If there are many names, press F15 to sort the members by date. This displays the most recently changed members first.
e. Once you locate the member, select option 2 to edit; if any records were saved, you'll get the SEU recovery screen; select option 1 to recover the member. If no records were saved, you'll get the message that the member has no records, in which case you're out of luck.
From a Tech Corner item by Gary Guthrie
2. TESTING FOR AN ACTIVE PROCEDURE - FEEDBACK
The September 13 issue of this newsletter included a tip "Testing for an Active Procedure." I received several replies that included improved solutions, which are now displayed at http://www.as400network.com/ClubTech/index.cfm?fuseaction=ShowNewsletterIssue&ID=8623 .Check back periodically for more feedback updates.
3. FREE ONLINE IBM AS/400 EDUCATION
IBM offers free online education courses on a variety of AS/400 topics, including Client Access, HTTP Server, Java, Domino, and much more.
To see the courses, go to http://www-3.ibm.com/servlet/com.ibm.ls.lsow.servlets.SearchByChapterServlet?CATALOG_ID=6&CHAPTER_ID=3&ROW_COLOR1=C8D8F8&ROW_COLOR2=FFFFFF ,scroll about halfway down the list, and you'll see the list of 65 free onlinecourses.
4. TALK TO THE IBM TORONTO RPG DEVELOPERS
Now's your chance to give George Farr, Barbara Morris, and Hans Boldt your feedback regarding RPG enhancements in the next release via a special forum at http://www.as400network.com/forums/Main.cfm?CFApp=71 . You can also read about the future of RPG IV in the November article "RPG IV: Free Format and More" by IBM RPG Technical Manager George N. Farr at http://www.as400network.com/article.cfm?ID=8642 .
5. CHECK IT OUT AT CLUB TECH: ILE RESOURCES
The Club Tech ILE Resources page at http://www.as400network.com/ClubTech/ILE is the launching point for information and code for all aspects of ILE programming. Among the resources listed are downloadable utilities (such as WRKPGMREF, discussed in this newsletter), shareware, recent articles and NEWS/400 Q&A, IBM manuals, books, and forums.
73. VIEWING PROGRAM MESSAGES
http://www.as400network.com/nwn/story.cfm?ID=8809
Q. We have a program that's submitted in batch job through a job scheduler. This program sends messages via the command SNDPGMMSG MSG(&MSGDTA). Where will I be able to see those messages? I've tried using DSPLOG QHST, which gives job started and ended messages but not the messages that program has sent. When we run that program in interactive mode, those messages are seen in job log.
A. Your messages are being sent to the program message queue, and you can see them in the job log. You're able to see them using command DSPJOBLOG (Display Job Log) as long as the job is active. Interactively, a job is active until you sign off. For batch jobs, the job is no longer active when the job ends. If you set your job logging levels appropriately, a job log will be spooled when the job ends. Because the job scheduler submits jobs to batch, you must do this to see the messages in a spooled file after the job is completed. You control the logging levels in the LOG parameter of the job description or in the SBMJOB command. Typically, you'll use LOG(4 0 *SECLVL) when you want to always spool a job log upon job completion.
Gary Guthrie, NEWS/400 Tech Editor
74. DELETING OLD SPOOL FILES
A common question asked in the forums and newsgroups is how to automatically delete older spool files. There are commercial products that perform this function, which you can find at http://www.sourcebook400.com . Select "System Software" under "Product Category," then select "Spool Utilities" under the "Operations" category.
Several free utilities and techniques allow automatic deletion of older spool files:
a. NEWS/400's CLNUPOUTQ Utility
The CLNUPOUTQ utility lets you archive or delete spool files from the output queues on your system. The command supports the following parameters:
* Output queue (OUTQ) specifies the names and libraries of the output queues you want to include in or omit from the cleanup.
* Include or omit output queues (OPTION) specifies whether the output queues are to be included in (*INCLUDE) or omitted from (*OMIT) the cleanup.
* User ID (USRID) specifies the ID of the user whose spool files are to be cleaned up.
* Retention days (RETAIN) specifies how long spool files are retained.
* Delete or archive spool files (ACTION) determines whether the spool files are deleted or archived.
The CLNUPOUTQ utility was published in the July 1999 issue of NEWS/400 and can be read online at http://www.as400network.com/article.cfm?ID=3073 . The easiest way to get the utility to your AS/400 is by obtaining the save file from http://www.as400network.com/code/index.cfm?fuseaction=DownloadFile&type=save&yyyy=1999&file=svfToolsV4R3.zip.
You must be an AS400 Network professional member to read the article and obtain the code.
b. Henrik Krebs' Delete Old Spoolfiles (DLTOLDSPLF) Utility
This freeware utility includes the ability to delete spool files in one or more output queues that are a given number of days or minutes old. Source is included. You can download the utility from http://hkrebs.dk/dltoldsplf.html .
c. Tom Liotta's Process Spool File (PRCSPLF) Utility
This freeware utility moves spool files older than seven days into output queues named for each day of the week. You can then write a CL program to automatically delete the archived files in those output queues before running PRCSPLF. Source is included. You can download the utility from http://home.earthlink.net/~tliotta/Files/Age_Spool_Files/Age_Spool_Files_README.htm.
d. QUSRTOOL DLTOLDSPLF Utility
This utility was included in the TAA tools in library QUSRTOOL, which was bundled with OS/400 up until V3R1. If you still have access to this utility, you need to be aware that DLTOLDSPLF must be modified to make it Y2K compliant, or you may delete all your spool files instead of just aged files.
e. OS/400 Cleanup Tasks (CLEANUP) menu
You can automatically delete old printer output created by system functions (not by user programs). The Cleanup Tasks are described in the AS/400 System Operation at http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/QBJAGD00/8.4 .
f. IBM System API Reference manual DLTOLDSPLF Utility
IBM includes the DLTOLDSPLF utility in Appendix 2 of the System API Reference manual. There are three versions of DLTOLDSPLF: OPM RPG, OPM COBOL, and ILE C. You can view the code at http://publib.boulder.ibm.com/cgi-bin/bookmgr/bookmgr.cmd/BOOKS/QB3APD03/A.2 .
75. Short Takes:
1. CONTROLLING WHEN TCP/IP APPLICATION CONNECTION ENDS
Q. TCP/IP applications such as File Transfer Protocol (FTP) and Telnet are not affected by the QINACTITV system value. (This system value controls how long a job can be "inactive" before some action is taken against it, such as ending it.) How do I control how long a TCP/IP application connection is inactive before it's ended?
A. You can control how quickly a TCP/IP connection is ended through the TCP/IP application's INACTTIMO attribute. For example, to change the inactivity time-out attribute for FTP, run the following command:
CHGFTPA INACTTIMO(60)
This causes an inactive FTP server session to time out in 60 seconds. As of V4R2, both Telnet and Workstation Gateway (WSG) use the QINACTITV system value to end connections. (If a value is specified for both the QINACTITV system value and the INACTTIMO attribute, the application uses the shorter time to end connections.)
Answered in NEWS/400 by Carol Woodbury
2. SAVING ALL OBJECTS IN QUSRSYS
Q. When I save the QUSRSYS library, not all objects in QUSRSYS are saved. Is this a problem?
A. Always make sure library QUSRSYS is completely saved. If the system isn't in a restricted state (with all subsystems ended), objects in QUSRSYS that begin with the letter Q may be in use and therefore not saved. These objects contain critical recovery data and must be saved for a complete system recovery.To save objects that begin with the letter Q, do one of the following when saving QUSRSYS:
* End all subsystems (with ENDSBS SBS(*ALL)).
* End subsystems QSNADS, QSYSWRK, and QSERVER.
* Use Save menu option 21 or 23.
* Use the save-while-active feature. (Refer to the book OS/400 Backup and Recovery (SC41-5304) at http://publib.boulder.ibm.com/cgi-bin/bookmgr/DOCNUM/SC41-5304-04 for more information about the save-while-active feature.)
Answered in NEWS/400 by IBM Senior Business Recovery Specialist Debbie Saugen
3. NONDISRUPTIVE QUSRSYS BACKUP
Q. How do I manage backup and recovery of library QUSRSYS to meet the needs of a full system restore (to another box) and not affect users or operations too much?
A. The QUSRSYS library must be completely backed up for a successful system recovery. Putting the system in a semi-restricted state by ending QINTER if using save-while-active and ending QSNADS, QSYSWRK, and QSERVER is also a good way to ensure that QUSRSYS is completely saved.
However, this approach doesn't provide unattended operations or reduce the impact to end users. In the past, if a *MSGQ was in break mode during a backup, OS/400 couldn't obtain a lock to save it. The Save/Restore group at IBM has written new functions for a future release to avoid this problem. IBM has also added PTFs for V4R1 and higher to help its existing customers. The following PTFs let OS/400 successfully save a *MSGQ, even when in *BREAK mode:
V4R1 - SF49860V4R2 - SF49848V4R3 - SF49800
Check out IBM's Technical Support center at http://as400service.ibm.com/ for the latest information on PTFs and PTF downloads.
Answered in NEWS/400 by IBM Senior Business Recovery Specialist Debbie Saugen
76. NUMERICAL FORMATS
http://www.as400network.com/nwn/story.cfm?ID=8835
Q. What's the advantage of performing calculations in an RPG IV program in packed decimal format? Why not use binary integer or floating point for storing numbers, as they occupy less space?
A. One advantage of packed decimal format is that it gives you more digits than binary integer. Before V4R4, you had a maximum of nine digits reliably available. You could define a field as 10 digits, but you still had only the range of values available to a four-byte binary number. As of V4R4, you can now define an integer field to have up to 20 digits, which is implemented under the covers as an eight-byte binary field. Packed fields give you a greater range of up to 30 digits. If you don't need this greater range, the integer data type is acceptable.
You can't define binary fields of 20 digits in DDS, although you can in SQL. Some people like to use packed fields because it's easier to decipher the contents when displaying a field's hexadecimal contents, though I personally don't find this argument compelling.
Floating point is a dangerous encoding method for storing ordinary business data (e.g., currency and other types of amount fields) because it gives arithmetic results that are accurate to a certain precision. For example, in floating point arithmetic, if the "true" result is 10, you run the risk of obtaining a result of 9.9999999 or 10.00000001. Floating point is typically used for scientific calculations.
Floating point can be appropriate in business when you need to produce the result of a complicated calculation (e.g., a mortgage interest calculation). Nevertheless, once such calculations have been made, results stored on disk (such as monthly payments, principal, interest, and so on) aren't normally floating point. Floating point is essential if you want to make C function calls from an RPG IV program to a function (e.g., sine, cosine) that requires floating point parameters or returns a floating point result.
Mike Cravitz, NEWS/400 Tech Editor
77. BARCODES AND PRINTER FORMATS
http://www.as400network.com/nwn/story.cfm?ID=8930
Q. I have an O-spec command stream that, when printed to a laser printer, prints a barcode. When we print this O-spec to an impact printer, it prints only the characters. I recently discovered that the command string is PCL5 format. What format do the QMS cards in an impact (dot matrix) printer require? We have no *IPDS printers, so IBM's manuals haven't been helpful. Can you suggest any Web sites, information, or books that provide a command string to replace my existing command string to print a barcode?
A. There are three key elements of coding for bar codes:
1. Does the printer support bar codes, and what type?
2. What is the interface, and will the AS/400 apply any transforms?
3. Who controls the printer language (AS/400 or printer)?
Your current laser printer is using HP's PCL, and therefore the specifications for the language are controlled by HP, which provides the manuals. The QMS interface is controlled by QMS, which should provide documentation on its print language and information on the printer's capability. QMS provides support for Code V.
The IBM 6400 Line Matrix printer supports Code V and IGP in addition to the IPDS capabilities. The 6400 also has Proprinter and Epson FX emulation. IBM provides the appropriate manuals when you buy the printer with those features. You can also buy the manuals separately.
The IBM Proprinter can print a few barcodes, and the ProPrinter documentation provides the hexadecimal values required to enable barcode printing. The configuration of the printer and the writer used can also result in the hex values being transformed or ignored. Your printer vendor should be able to provide guidance in this area.
OS/400 provides numerous Host Print Transforms for IBM and non-IBM printers. The AS/400 Support Line can help you connect non-IBM printers.
Bill Shaffer, IBM Brand Manager for AS/400 Printing Solutions
78. SPELL-CHECKING WITH APIS
Q. How can I spell-check database character fields? Is there an OS/400 API that can check the spelling of a string?
A. API QTWCHKSP spell-checks one or more words for you, and API QTWAIDSP returns a list of words spelled similarly. You use QTWCHKSP to determine whether a word is spelled correctly, and if it isn't, you use QTWAIDSP to list possible replacements.
Both APIs require language dictionaries to be installed on your system; a language dictionary exists for each national language that IBM supports. To find the language dictionaries installed on your system, enter GO LICPGM from any command line, and then choose option 10 from the menu. The product number for the IBM Dictionary and Linguistics Tools for AS/400 V4R5 is 5769-DL1, and it's 5716-DCT for V3R2 through V4R4.
For example, if you have OS/400 V4R4, when you enter GO LICPGM and choose option 10, you get 5716DCT. When you select 5716DCT, you can scroll through the list to find the U.S. English dictionary, which is the last one listed. Because the list contains 20 or 30 dictionaries (Russian, French, French-Canadian, and so on), it's worth checking to see that an English version is loaded -- on rare occasions, it isn't.
The documentation for the Check Spelling (QTWCHKSP) API is online at http://publib.boulder.ibm.com/pubs/html/as400/v4r5/ic2978/info/apis/QTWCHKSP.htm ,and the Aid Spelling (QTWAIDSP) API is at http://as400bks.rochester.ibm.com/pubs/html/as400/v4r5/ic2924/info/apis/QTWAIDSP.htm.
You can download a demonstration application that shows how to use QTWCHKSP and QTWAIDSP from Tom Liotta's Web site at http://home.earthlink.net/~tliotta/Files/User_Interface_Manager/User_Interface_Manager_README.htm.
There are also at least two third-party products that offer either spell-check APIs or RPG source code that uses IBM's Spell Check APIs:
Spelling AssistantGeneric Software, Inc.http://www.genericsoftware.com/
TAA Productivity ToolsJim Sloan, Inc.http://www.taatool.com/
Adapted and updated from a Tech Corner item by John Earl and Gary Guthrie
79. Short Takes:
1. CHECKING FOR A RECORD-LOCK CONDITION IN RPG
Q. How can I check for a locked-record condition in an RPG program?
A. The general answer to your question is to check for status code 01218 in the file information data structure (INFDS). The code below shows how to do this in an RPG/400 program:
(A) FCUSTOMERUF E K DISK KINFDS CUSTDS
*
(B) ICUSTDS DS
I *STATUS STS
*
C Z-ADD1 CUNUM
C CUNUM CHAINCUSTOMER 9998
*
(C) * HERE IS THE TEST FOR LOCKED RECORD
C *IN98 IFEQ *ON
C STS ANDEQ01218
C EXSR PRCTO
C MOVE *ON *INLR
C RETRN
C ENDIF
Notice at (A) that CUSTDS is defined as the name of the data structure containing the file feedback information for the CUSTOMER file. At (B), I define an INFDS data structure for the CUSTOMER file. I named the file status field STS.
Notice that the CHAIN instruction just above (C) codes 98 as the LO resulting indicator. All I/O opcodes in RPG/400 use the LO resulting indicator to trap file errors. A record-lock timeout is considered a file error. Therefore, at (C), I test indicator 98 and the STS field to determine whether a timeout has occurred. If I hadn't coded the LO resulting indicator in the CHAIN instruction, the program would abnormally terminate when a record-lock timeout occurs.
In RPG IV, the most effective way to handle a record-lock timeout is with ILE condition handlers, explained in "Handle It - With RPG Exception Handlers!" ( http://www.as400network.com/article.cfm?ID=2919 ).Instead of describing the exception-handler technique here, I demonstrate how to perform the RPG IV equivalent to the technique described for RPG/400 lockouts. The code below illustrates this technique:
FCustomer UF E K Disk
C Z-Add 1 CuNum
(A) C CuNum Chain (E) Customer
* Here is the test for timeout
(B) C If %Status = 01218
C ExSr ProcTimeOut
C Eval *INLR = *On
C Return
C EndIf
The first thing to notice is that we don't need an INFDS feedback data structure to test for a record lockout in RPG IV. The RPG IV built-in function (BIF) %Status is sufficient for our purposes. Notice at (A) that I don't code any indicators for the Chain instruction. Instead, I code the "(E)" extender. This tells RPG I want to use error-checking BIFs such as %Error and %Status. In this example, I use only %Status. As in the RPG/400 example, I check for a timeout by testing for status code 01218 (at B).
One final word about record-lock timeouts. If you think you'll test for timeouts in your programs, you might consider shortening the timeout period. By default, the CRTPF command sets the WAITRCD attribute to 60 seconds. The WAITRCD attribute determines how long the system will wait for a locked record upon access. Sixty seconds is too long for your users to wait for a timeout message. You can change the timeout associated with a file by specifying a value for the WAITRCD parameter on commands CRTPF, CRTLF, CHGPF, and CHGLF. For example, to change the timeout on the Customer file to 10 seconds, you'd code the following:
CHGPF
FILE(YOURLIB/CUSTOMER)
WAITRCD(10)
From a Tech Corner answer by Mike Cravitz
2. DISPLAYING RECORD-LOCK MESSAGES IN RPG
When a user tries to update a record being held for update by another job, an error occurs. (The record wait default value is 60 seconds, so it often literally takes a minute before the error is detected.) You can capture this error and display the name of the user who caused the record lock so that the user being inconvenienced can solve the problem herself instead of calling you.
The sample I- and C-specs below illustrate this technique:
I SDS
I 91 170 MSGTXT
.
.
.
C KEY CHAINFILE 9990
C *IN90 IFEQ '1'
C MOVELMSGTXT ERRMSG
C END
On the CHAIN operation, put an indicator in columns 56 and 57 to capture the record allocation error. If the indicator comes on, retrieve the error message text from positions 91 through 170 of the program status data structure (PSDS). The message will say "Record &REC# in use by job &JOBNO/&USER/&JOBNAME."
If that message is too cryptic for your users, you can write a program to pull the user name from the message and display it in a more understandable error message. Your users can then ask the user causing the lock to release the record.
From a Tech Corner answer by Bryan Meyers
3. DISPLAYING RECORD-LOCK MESSAGES IN COBOL
Cobol subroutine WhoHasLock has recently been made available in the AS400 Network Cobol Community, which you can visit at http://www.as400network.com/communities/cobol/ . The subroutine returns a 28-character field (as a parameter) that is the jobname/user/number of the job holding a lock. The routine looks for a CPF5027 message in the caller's message queue. If it finds it, it uses it to return the pertinent information. If it doesn't find it, or if it encounters any unexpected errors in the process of searching for the message, it returns Low-Values in the 28-byte parameter.
You can download the subroutine from http://www.as400network.com/cobol/CobolCode/SubrtnLkRecHldr.zip .
4. STRING-HANDLING SIMPLIFIED WITH VARIABLE-LENGTH FIELDS
The RPG Style Guide at http://www.as400network.com/article.cfm?ID=2461 recommends using built-in functions instead of arrays to handle strings. The varying-length character type (available in V4R2 and above) can also simplify string-handling code as well as make it more efficient. I recommend using varying-length fields as CONST or VALUE parameters to every string-handling subprocedure as well as for string temporaries. (I recently worked with an RPG programmer, and we reduced the number of lines in a subprocedure from about 10 icky lines to two simple and straightforward lines, mostly through the use of varying-length parameters.) Here's a little example; not only does it look better, but it's also faster (no %TRIMs). Instead of:
C EVAL Name = %TRIMR(Lib) + '/' +
C %TRIMR(File) + '(' +
C %TRIMR(Mbr) + ')'
with variable-length fields, you can use:
C EVAL Name = Lib + '/' +
C File + '(' +
C Mbr + ')'
I thought I should check my claim that this approach is faster, and it turns out it's more than twice as fast to produce "Lib/File(Mbr)", where all variables (except "Name") are 10 characters long.
Adapted from a forum message by IBM Toronto's Barbara Morris
80. ZONED DECIMAL FIELDS CHANGED TO PACKED
http://www.as400network.com/nwn/story.cfm?ID=8933
Q. I've seen instances when RPG changes a zoned decimal field to packed. Under what conditions does RPG do this?
A. The program version F-spec zoned decimal fields will always be presented as packed decimal within the program itself. RPG does this because packed is a better encoding method on the AS/400 for performing arithmetic operations. You can override this by specifying an externally described data structure for the file used in the F-spec. The following example shows how this is done in an RPG IV program:
FMyFile IF E K Disk
D MyFileDs E DS ExtName( MyFile )
This externally described data structure causes RPG to use zoned decimal for all fields defined as zoned decimal in your program.
Mike Cravitz, NEWS/400 Tech Editor
Dieses Buch wird laufend erweitert!90>