05
Sun, May
5 New Articles

TOP TIPS: Programming September 1998

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

 

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
This email address is being protected from spambots. You need JavaScript enabled to view it.

 

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

This email address is being protected from spambots. You need JavaScript enabled to view it.

 

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 This email address is being protected from spambots. You need JavaScript enabled to view it.

 

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 This email address is being protected from spambots. You need JavaScript enabled to view it.

 

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 This email address is being protected from spambots. You need JavaScript enabled to view it.

— 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

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: