No Need to Recompile
You’ve just made a minor change to your display file. Now, you must recompile all the programs that use it to avoid getting level check errors, right? Or do you?
The system assigns a unique level identifier to each record format when the display file is created. When you compile a program that uses the file, the compiler includes the format level identifiers in the compiled program.
Use the Display File Description (DSPFD) command to display the record format level identifiers for the file. Use the Display Program References (DSPPGMREF) command to display the record format level identifiers that were used when the program was created. If they are the same, you do not need to recompile the program to avoid a level check error.
Only changes to the following will affect the record format level identifier:
• Record format name
• Field names
• Length of the record format
• Number of fields in the record format
• Field attributes such as length and decimal positions
• Order of the fields in the record format You can change field attributes such as highlight, underline, reverse image, and colors without recompiling programs. Constants such as headings or labels can be added, changed, or deleted. The screen locations of fields and constants can be changed as long as the order of the fields or length of the record format is not changed. This means that you can actually change the location and order of fields on the screen as long as you don’t change their order in the DDS source member for the display file.
— Christopher Andrle
So You Thought You Knew the *LIBL
If you have the same file name in two different libraries in your library list and you reference the file with *LIBL and a specific member, the system searches the first library
looking for the file and member. If the file is found in the first library but it doesn’t contain the requested member, the search continues without notification.
We were expecting to get a “Member not found” error when the system found the file without the correct member in the first library. It didn’t, but rather continued the search, finding the file and member in the second library, and using that occurrence.
— Gary M. Mayfield
Editor’s note: Keep in mind that certain commands ignore the library list. For example, this works with the Override with Database File (OVRDBF) and the Display Physical File Member (DSPPFM) commands, but not with the Clear Physical File Member (CLRPFM) command.
Universal Graphical Debugger
Confused by the difference in function keys between the Start Debug (STRDBG) command for ILE programs and the Start Interactive Source Debugger (STRISDB) command for Original Program Model (OPM) programs? Frustrated because you need to debug a combination of OPM and ILE programs? Relax. IBM has rationalized its graphical debugger offerings.
STRDBG is the survivor, and if you set everything up correctly, it will debug a program that is OPM, ILE, or mixed program model.
To use STRDBG as your universal debugger, you must compile your program correctly and start STRDBG correctly.
To compile correctly, do the following:
• For RPG OPM programs, specify either OPTION(*SRCDBG) or OPTION(*LSTDBG) on the Create RPG Program (CRTRPG-PGM) command.
• For CLP programs, specify OPTION(*SRCDBG) on the Create CL Program (CRTCLPGM) command.
• For RPGLE, CLLE, or CBLLE programs, specify either DBGVIEW(*SOURCE) or DBGVIEW(*LIST) or DBGVIEW(*ALL) on the Create Bound xxx Program (CRTBNDxxx) or Create xxx Module (CRTxxxMOD) commands (xxx is the language abbreviation).
To start STRDBG correctly, include OPMSRC(*YES) on the STRDBG command if you are debugging an OPM program.
— Sam Lennon
Use DSPMODSRC to Redisplay Source Code in Debugger
You’ve loaded four programs, you’ve set seven breakpoints, you’ve pressed F12 and are about to invoke your program when you pound your forehead in frustration. You should have set eight breakpoints, and without the eighth, the whole debugging session will be a waste of time. With no way to get back into the debugger setup, you simply ENDDBG and start all over....
No! Wait! Just issue the Display Module Source (DSPMODSRC) command. No parameters are required. DSPMODSRC will take you right back into the debugger, and you can set that one essential breakpoint and continue.
— Sam Lennon
For Longer Field and File Names, Use SQL
One benefit of using SQL is that it allows you to create database column (field) and table (file) names longer than 10 characters. Of course, not all AS/400 interfaces support these longer names. The FOR COLUMN clause on the CREATE TABLE statement allows you to specify a short name for your long column names. This short name can be used on the interfaces that can’t support field names longer than 10 characters (if a short name is not specified, the system will automatically generate one). The CREATE TABLE statement, however, does not allow you to specify a short name for the table name. Again, the system does generate a short name automatically, but the short name is not user friendly (e.g., the system short name for customer_master is CUSTO00001) and is not guaranteed to have the same short name if you re-create the database file object multiple times.
You need to use the RENAME TABLE SQL statement in conjunction with the SQL CREATE TABLE statement to control the long and short files names for your database files. The example in Figure 1 shows how to first use the CREATE TABLE statement to specify the short name (cusmst) and then the RENAME TABLE statement to also assign a longer, more descriptive name (customer_master).
— Kent Milligan IBM Partners in Development
PDM Option 25 Does Outfiles
I often wished that PDM option 25 (Find String) would output to a disk file, so I designed a couple of PDM options of my own. Both require the Execute SQL Statement (EXCSQLSTM) command, published in the December 1994 issue of Midrange Computing.
Option XZ creates a file called MBRLIST to hold data about members containing the search string. Option XD stores the member name, file name, library name, member type, date the member was last changed, and member text in the MBRLIST file. Figure 2 shows how these options are to be defined to PDM.
From the Work with Members Using PDM display, enter option 25 beside one or more members. (You can use F13 to repeat an option through the end of the list.) Then, press Enter. In the first prompt line, enter the string for which you’re searching. In the Option prompt, enter XD. Press Enter to begin the search. The members containing the search string will be listed in the MBRLIST file.
The date of the last change is stored in job format, complete with editing characters. You may want to change the job format to *YMD before loading MBRLIST. Use the Change Job (CHGJOB) command, like this:
CHGJOB DATFMT(*YMD)
If a member’s text description contains an apostrophe, the scan will halt, displaying an error message. If that happens, either replace the apostrophe with another character, double the apostrophe, or remove the apostrophe; then, restart the scan.
— Chuck Wakelee Cardone Industries
Service Program Catch-22
We have a number of service programs that correspond to business “classes.” They have names like CUSTOMER, PART, and ORDER. If programmers want a procedure that returns a fully formatted customer name, with title, initials, and full name, they expect to find it in service program CUSTOMER.
We are constantly adding new procedures to these service programs. Over time, many of these programs have come to reference each other. Two examples of this might be (1) a procedure named RtvPartName that resides in PART and is called by service program ORDER and (2) a procedure in ORDER named IsPartOrdered that is called by PART.
An outcome of this is that re-creating these service programs from source (i.e., no existing service program objects exist) is not as straightforward as you would think. We can create the modules without any difficulty, but as soon as we try to create service program ORDER, it fails because it needs PART. Likewise, PART can’t be created because it needs ORDER.
We found the solution to our problem in the OPTION(*UNRSLVREF) parameter in the Create Service Program (CRTSRVPGM) command. If you specify it, the service program will be created even if procedures and field names that are imported from other service programs can’t be located. In our example, ORDER could be created without the need for PART. The procedure RtvPartName would be an unresolved reference as far as ORDER is concerned, but the ORDER service program object would be created nonetheless.
Of course, ORDER couldn’t be expected to work at runtime if any attempt to call RtvPartName was made. However, you can create PART in the normal way since ORDER now exists. And once you’ve done that, you can return to ORDER and re-create it without the OPTION(*UNRSLVREF) parameter.
If you want to create an entire ILE environment from source, first create all service programs with the OPTION(*UNRSLVREF) parameter, and then re-create them without it.
— John V. Thompson Honda, New Zealand
— Derek Butland
Automatically Replying to Inquiry Messages
Programs send escape messages when something goes wrong. The CL Monitor Message (MONMSG) command lets you trap these error messages so that you don’t have to handle them manually.
However, MONMSG does not work for inquiry messages. Suppose you try to delete a journal receiver that has not been saved to disk. As your AS/400 is shipped, you’ll receive inquiry message CPA7025 [Receiver &1 in &2 never fully saved. (I C)].
You can use the Inquiry Message Reply (INQMSGRPY) parameter of the Change Job (CHGJOB) command to answer these messages automatically.
The default reply to CPA7025 is I, which means the system should delete the journal receiver, even though it has not been saved. In that case, you could use code like this in a CL program:
CHGJOB INQMSGRPY(*DFT)
DLTJRNRCV JRNRCV(&RCV)
Another possible setting of INQMSGRPY is *SYSRPYL, which makes the job use the system reply list. Add reply list entries for the messages you want answered automatically, like this:
ADDRPYLE SEQNBR(80) +
MSGID(CPA7025) RPY(‘I’)
Make your program use the system reply list like this:
CHGJOB INQMSGRPY(*SYSRPYL)
DLTJRNRCV JRNRCV(&RCV)
Of course, this changes the way the job handles inquiry messages from this point. If you’d like to use the default reply for only one command, save the current setting and restore it after deleting the journal receiver, like this:
DCL &INQMSGRPY *CHAR 10
RTVJOBA INQMSGRPY(&INQMSGRPY)
CHGJOB INQMSGRPY(*DFT)
DLTJRNRCV JRNRCV(&RCV)
CHGJOB INQMSGRPY(&INQMSGRPY)
— Ted Holt Senior Technical Editor Midrange Computing
Print Parts of a Source Member
When debugging, you may need to print parts of a source member rather than the entire source member. To print a range of source statements from within SEU, key LLP over the sequence numbers of the first and last lines to print and press Enter.
— Harry Morris Bristol-Myers Squibb
Editor’s note: If you use the X or XX commands to exclude lines from view on the display, the lines will also be excluded when printed.
CREATE TABLE dbtest/cusmst
(customer_name FOR COLUMN cusnam CHAR (20) ,
customer_city FOR COLUMN cuscty CHAR(40))
RENAME TABLE dbtest/cusmst TO customer_master
FOR SYSTEM NAME cusmst
Figure 1: Specifying both long and short names with SQL
XZ
EXCSQLSTM SQLSTM(‘create table XXX/ mbrlist (member char(10), file char(10), library char(10), type char(10),
chgdate char(8), text char(50))’)
XD
EXCSQLSTM SQLSTM(‘insert into XXX/mbrlist values (‘’&N’’,’’&F’’,’’&L’’,’’&T’’,’’&D’’,’&X’)’)
Figure 2: These options allow you to log PDM search results to a disk file
LATEST COMMENTS
MC Press Online