Odds and Ends
January 9, 2008 Ted Holt
Happy New Year, distinguished colleagues! I hope everybody enjoyed the holidays and got to take some time off. Christmas was wonderful for me. I am blessed more than I deserve to be. To start off a brand new year is this collection of odds and ends. I hope you find something useful. –Ted Put FTP Information in One Place 1. Most shops do batch FTP this way: OVRDBF FILE(INPUT) TOFILE(QFTPSRC) MBR(mbr_name) OVRDBF FILE(OUTPUT) TOFILE(FTPLOG) MBR(nbr_name) STRTCPFTP RMTSYS(ftp_server) DLTOVR FILE(OUTPUT) LVL(*JOB) DLTOVR FILE(INPUT) LVL(*JOB) where QFTPSRC(mbr_name) looks something like: user_name password ftp command(s) quit This forces you to maintain the destination FTP server’s name in one source member and the user profile and password in another source member. I prefer to put the FTP server’s name in the QFTPSRC(mbr_name) file: open ftp_server user user_name password ftp command(s) quit Then, all CL programs have the same STRTCPFTP command, with a dummy FTP server name: OVRDBF FILE(INPUT) TOFILE(QFTPSRC) MBR(mbr_name) OVRDBF FILE(OUTPUT) TOFILE(FTPLOG) MBR(nbr_name) STRTCPFTP RMTSYS('found in input file') DLTOVR FILE(OUTPUT) LVL(*JOB) DLTOVR FILE(INPUT) LVL(*JOB) And the CL program does not have to be changed if the name of the FTP server changes. Editor’s note: This makes a lot of sense to me. I like simple little tips like this one.
Debugger Displays Blanks or Zeros Question: I am debugging a program with the full-screen (green-screen) debugger. After a read, I use F11 to view the values of the fields in the record just read. I see the values of some of the fields, but other fields display as blanks or zero, even though they are not blank or zero in the database. Why? Answer: If you look at the compiler listing, you will see that some fields were flagged with error 7031. This error indicates that the fields are not used in the program, therefore the compiler did not allocate memory for them. For this reason, the debugger cannot display their values.
Another Way to Count IFS Files I have a recommendation on other ways to obtain a file count in the IFS. The ls command is in many ways the match to the DOS dir command many are familiar with, but at times the better alternative may be to use the find command. Using find allows more flexibility if one wants to specify specific patterns to count. The command find * | wc -l provides a count of all objects in the current directory as well as any subdirectories. Be aware that the subdirectories themselves each count as one object. The base of the count can be changed from the current directory by justifying the desired directory in the find command, i.e. find /home/mydir | wc -l. If you only wanted to count files in that tree with 2007 in the file name, the command would be changed to find /home/mydir -name *2007* | wc -l. The find command has a number of other switches that can be useful. IBM lists these in the Info Center documents. Here is the link to the v5r3 version: http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzahz/find.htm –Craig Editor’s note: Craig’s tip is in response to the second tip in the November 14, 2007, .
Yet Another Way to Count IFS Files The task of checking to see if a directory contains files or not can be accomplished in CL with the CHECK IN (CHKIN) command. Just monitor for message CPFA093. (Name matching pattern not found.) –Jørn Editor’s note: I don’t doubt that this works, but what if someone checks in something that should remain checked out?(Inquiring minds want to know.)
Query Can’t Allocate a Printer Question: Query/400 sent two messages we’ve never seen before.
To our knowledge, we have not changed the query or the RUNQRY command. Can you tell us how to fix the problem? Answer: You can fix it with a few simple steps.
Someone must have accidentally changed this setting. This can be a tough problem to find if you’ve never seen it before.
RPG Character-to-Numeric Conversion Question: My RPG program is working with data from another system. One of the fields, a 21-byte character field, contains a dollar amount that may include a dollar sign and commas (to separate thousands). I need to extract only the numeric data from the field–not the $ sign, not the comma, not the period, not the “00” at the end–and load the value into a numeric variable. I’ve tried the %DEC function and the %TRIM function, but no luck. Can you help? Answer: One of the features of the %DEC function is that it ignores all blanks, embedded ones as well as leading and trailing ones. Therefore, I suggest you use the %XLATE function to convert the dollar signs and commas to blanks. NumVar = %dec(%xlate('$,':' ':CharVar):7:0); There are two spaces in the second parameter of %xlate.
Copying Between Data Members and Source Members Question: I want to copy a source member to a physical file, modify the data, and then copy back to the source member. I know I have seen this discussed in the past. Would you please provide a cursory view on the step to accomplish this task? Answer: In your COPY FILE (CPYF) commands, specify FMTOPT(*CVTSRC) when copying a data file to a source physical file and vice versa.
|