Odds and Ends
September 18, 2002 Timothy Prickett Morgan
Here are more miscellaneous short tips. I hope you enjoy them.
Our shop has a junior programmer who, by not using our change management system, messed up an RPG Source member, . He then tried to correct his own mistake, and he only proceeded to make things worse.
Can I restore a specified member from tape from the QRPGSRC file? I know how to restore the whole library, but I really only need one member from the QRPGSRC File.
The Restore Object (RSTOBJ) command can restore a single file member. Here is an example.
RSTOBJ OBJ(QRPGSRC) SAVLIB(library-name) DEV(TAP01) OBJTYPE(*FILE) FILEMBR((QRPGSRC (source-member-name))) RSTLIB(another-library)
In the SAVLIB parameter, put the name of the library where the source member resides. In the RSTLIB parameter, put the name of a work library. Restore to the work library, make sure the restore was successful, and only then copy the RPG member from the work library to the regular library
We have an RPG II program that accesses an externally described file. The key in the F spec is ten bytes long, beginning at position 1. The key in the file is ten bytes long, but it really begins at position 2. This is a programming error, but when it is run, it appears the external key description is overriding the internal key description, as we are getting correct outcome. Does this sound right?
If you were running your program on a System/36, you would get an error, but the iSeries is not so picky. When externally described files are described internally in RPG programs, the key location does not have to match. The system uses the external key, regardless of what you put in the F spec. If you read the file sequentially, key size does not have to match. The record length has to match if the program is compiled as RPG36, but not when compiled as RPG.
Before reading your tip, “Edit with Parentheses in Query/400,” I had never realized that Query/400 would let you put the minus sign (-) on the left side of a negative number. By also leaving the leading zeros in, the transfer to Excel worked so much better. I was impressed. Can the same edit features be used in RPG output?
Look at edit codes N, O, P, and Q. These codes–especially P, which prints zero values but doesn’t insert thousands separators–may do what you want, .
All four edit codes suppress leading zeros. If you want leading zeros, you’ll have to use an edit word to get a trailing minus sign and do a little finagling to move the minus sign around to the front.
Here’s some code that might get you started.
D NumValue s 7p 2 D Alpha s 10 C eval alpha = %editw(NumValue: '0 . -') C eval alpha = %subst(alpha: %size(alpha): 1) C + '0' C + %subst(alpha: 2)
The leading zero on the edit word keeps leading zeros on the edited value. The trailing minus sign puts either a space (for positive numbers) or minus (for edited numbers) on the end of the edited value. The second eval places the blank or minus sign on the front of the edit word. I defined Alpha as 10 bytes long to accommodate the seven digits in NumValue, the leading zero indicator, the decimal point, and the trailing minus sign.
Can the ILE debugger be used to view/debug a trigger program?
Yes it can.
- Specify DBGVIEW(*SOURCE) when you create the trigger program.
- To debug, run the Start Debug (STRDBG) command, naming the trigger program in the PGM parameter.
- Use F6 to set a breakpoint.
- Start a program to update the file. (I used DFU.)
When the trigger fires, the debugger will kick in.
With a System/36 menu, the command SEU ARMENU##,S,,,LIBRARY will get me a list of the commands behind the menu. Is there a quick way to see the commands behind a native menu without using PDM or SDA?
For native menu ARMENU, try this command:
DSPMSGD RANGE(*ALL) MSGF(ARMENU)
Press Enter to page through the options.
ADVANCED SYSTEMS CONCEPTS
SEQUEL meets all your iSeries and AS/400 data access needs in a single, integrated solution:
Take 6 minutes to view a SEQUEL ViewPoint ScreenCam movie to see how simple Windows-based AS/400 and iSeries data access can be! In just a few short minutes, you can find out ways to make your job easier and improve data access throughout your organization. Download the ViewPoint movie here .
For more information or a FREE trial of SEQUEL, call 847/605-1311 or visit Advanced Systems Concepts.