06
Mon, May
6 New Articles

TechTalk December 1998

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

Don’t Believe Every V4R3 Automatic Installation Message

Last week, I installed V4R3 on our test machine using the automatic installation option. If you use automatic installation, one of the tasks you must perform before you actually install the software is to create and customize an installation list.

This procedure is explained in detail in the Software Installation Guide (SC41- 5120-01, in my case). Producing the installation list is accomplished using the Work with Licensed Programs (LICPGM) menu. The steps include the following:

• Select option 5: Prepare for Install
• Select Work with Licensed Programs for Target Release
• Load the first CD-ROM in your optical drive and specify Generate List Form Distribution Media

• After all CD-ROMs have been read, select the option to List Licensed Programs Not Found on Media When I listed the programs not found on media, one program product was listed: 5769AC3 Cryptographic Provider 128-bit. I thought this a bit strange, but knew I could get the product and install it later. I proceeded with the automatic installation steps. The last step is to reload all the CD-ROMs during a special IPL. After I completed the process, the message Automatic installation not complete appeared—not a friendly message. The manual states that you should go to recovery procedures when you receive this message.

After investigating the problem thoroughly, I found that the installation had, in fact, completed properly. Evidently, the system isn’t intelligent enough to know that the program product listed as missing had already been discovered during the production of the installation list and was not crucial to system operation. If the product had been part of the base operating system (5769SS1), I can see how there would be a problem. But why the system responds as if any program product not installed will interfere with system operation is a mystery to me.

If you do find that you’re missing a program product when you produce your installation list, you can either call IBM and get the product before the installation or do what I did: Install the system and get the software later. There’s no problem installing a program product after you upgrade to a new release as long as it’s not part of the base operating system. So, if you’re under time constraints, you can install the system first and the missing program product later.

— D. Ellis Green

Senior Technical Editor Midrange Computing

Code Snippets

If you’ve ever been assigned a project and thought, “Man! I wish I had an example of how to do that!” or even, “Gee, wouldn’t it be great if someone had already written this routine so I could just copy it into my program?” you’re in luck! Midrange Computing isn’t the only place where you can find code samples (although it is the best source!). IBM also provides code samples in several languages on its Developer’s Resource Web site.

For example, if you’re looking for a way to format an RPG IV numeric field with its edit word so that it can be properly viewed in a browser, it’s here! Looking for an RPG IV prototype that will let you execute CL commands from within your RPG IV programs?

It’s here! Looking for a Common Gateway Interface (CGI) program example that reads HTML statements from a database and writes it to a browser? It’s here! Examples are given for the following: C, CL, CMD Macros, COBOL, DDS, HTML, NET.Data macros, REXX, RNHLIB Menu source, RPG, and Service Procedures. This information can be found at the following URL: http://www.as400service.ibm.com. Once you get there, click on Technical Studio and then scroll down the left frame to Developers Resource and click on Code Snippets.

— Shannon O’Donnell Associate Technical Editor Midrange Computing

Dumping an Object’s Contents

Want a quick way to find out what’s inside an object? Use the Dump Object (DMPOBJ) command. This command dumps the contents or the attributes of most AS/400 objects to a spooled file named QPSRVDMP. You can display the spooled file to see the object’s contents.

This command is especially useful for dumping the contents of objects that have no display command, like data queues. DMPOBJ is much easier to use than the Retrieve Data Queue Message (QMHRDQM) API, and is not destructive like the Receive Data Queue (QRCVDTAQ) API. Whether it’s the contents or the attributes of the object that get dumped depends on the object type. You might use this command to dump other objects as well, such as directories, modules, user spaces, journal receivers, and even entire libraries.

— Brian O’Gara This email address is being protected from spambots. You need JavaScript enabled to view it. 507-625-2828 ext.127

Natural Partners: %editc & %dec

The %dec and %dech built-in-functions (BIFs) have been around for a while, but, until recently, I had never put them to any use. As it turns out, this was my loss. I’ve come to realize that the %dec and %dech BIFs, in partnership with the %editc and %editw BIFs, are very effective.

In the past, whenever I wanted to use an edit code on a number, but the number was too big or had too many decimal places, I moved it to a field of the correct size; then, I did the %editc on the correctly sized field. I hated having to do this—it made a simple operation span three separate lines of code: a D-spec for the temporary field, and two evals.

The %dec function allows you to adjust a numeric field’s size without using a temporary field. (The %dech function is similar; the difference is that it half-adjusts.) For example, suppose you had a field called BigField that was defined as being 13-packed with

three decimal places but you wanted to print it on a report as a rounded 6-packed with one decimal place. The code fragments in Figure 1 demonstrate how you can easily do this using the %dech and %editc BIFs.

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

Editor’s note: If significant digits get truncated when copying a larger variable to a smaller one, you’ll get an error. Be sure the values in the large variable are no bigger than the size parameter of %dec and %dech.

Avoiding MCH1202 Errors

One of COBOL’s limitations is that it does not automatically initialize numeric fields to zeros when writing data to a file, something that RPG does very well. Instead, by default, it places blanks in numeric fields. When another program tries to read a numeric field containing invalid data, it receives the infamous MCH1202 error.

You can make sure that you move zero values to empty numeric fields when writing data to a file in programs that you are working on, but how can you avoid getting the MCH1202 error when working with data written by other COBOL programs? As more and more mainframe shops migrate to the AS/400, the occurrence of this error message has become more prevalent.

Using the IF NUMERIC command phrase in COBOL (see the code fragment in Figure 2), you can perform a simple test to determine if a field contains numeric data. IF NUMERIC is similar to the TESTN operation code in RPG. If the test fails, perform the appropriate routine to take corrective action.

— Jeff Mileham Levi, Ray & Shoup, Inc. This email address is being protected from spambots. You need JavaScript enabled to view it.

Converting Hexadecimal to Decimal in COBOL

If you’ve ever had to migrate data from a mainframe or a UNIX box, you’ve probably been exposed to data that was stored as hexadecimal. Generally, when you migrate it to the AS/400, you may find that you have a problem showing that data on a display screen or report. Here’s an easy solution.

With a simple move statement, a character field containing a hex value can be converted to a decimal number for display purposes (see Figure 3). The hex value is moved to the low-order byte of a 2-byte binary field (which, in COBOL, is created by defining a 4-decimal digit binary field). Since the field has been redefined as alpha, the move statement is legal, and the decimal equivalent can now be displayed.

If, for some reason, you want to display a decimal number as a hexadecimal number on a screen, use the “remainder method” (Figure 4). To use this method, first divide the decimal number by 16 (HEX is in base 16); place the quotient in byte 1 and the remainder in byte 2. Next, check the numeric value of each byte. Values less than 10 can be moved, while values 10 through 16 must be first evaluated as characters A through F and then moved accordingly. The converted hex value can now be displayed.

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

Locking Down Your Network Drive

Looking for a quick way to keep your Client Access/400 users from getting into your sensitive document files stored in the QDLS directory in the AS/400 Integrated File

System (AS/400 IFS)? One method to do so is to create a generic user ID that does not have a directory entry on the AS/400. When the client connects to the AS/400, it cannot access QDLS since it does not have a directory entry. The other method is to rename the Client Access/400 network drivers executable program (CWBBS.EXE). Renaming the executable will keep the client from being able to use the CA/400 Operations Navigator to get to your AS/400. Before you can rename the executable, you’ll need to stop it. To do so, press ctrl+alt+del once, and you’ll be presented with the Close Program window. Click on the CWBBS.EXE program to highlight it, and then click on the End Task button. This will stop the program. After it’s stopped, you can then rename it.

— Gerald R. Posey Caddo Parish Sheriff’s Office This email address is being protected from spambots. You need JavaScript enabled to view it.

Editor’s note: Renaming or removing CWBBS.EXE should be done only after careful consideration, as it could negatively impact your user’s client-side connection since you will no longer be able to use drives mapped to your AS/400. If you don’t want to rename CWBBS.EXE, you can keep it from running by moving it from its default folder. Of course, any PC-literate user might find the program in its new folder and move it back. Perhaps a better approach would be to remove its reference from the Windows 95/NT Registry. Removing the reference will not only keep CWBBS.EXE from starting when Windows 95/NT starts, it will also keep most users from being able to restore CWBBS.EXE’s use by moving the program back to its original folder or renaming it to its original name.

To remove it from the Windows 95/NT Registry, do the following:
• From the Windows 95/NT Run box, type REGEDIT and click on OK.
• Double-click the folder named HKEY_ LOCAL_MACHINE.
• Double-click Software.
• Double-click Microsoft.
• Double-click Windows.
• Double-click CurrentVersion.
• Double-click RunServices.
• In the right-side panel, you’ll see a key entry for Client Access Network Drive. Double-click on this and you’ll see a box like the one shown in Figure 5. To remove this key value, press the Delete key. In the bottom of the REGEDIT window, the path to the key value that you are deleting is displayed. This is useful information to know and record, if you ever want to manually restore this key.

You should always back up the Registry before making any changes to it. One way to do this is to make copies of the system.dat and user.dat files. Another way is to export the file from REGEDIT before any changes are made. (The Registry can be exported in its entirety or any part of a key thereof.) That way, if you make a mistake, you can restore the Registry back to its original configuration.

OPNQRYF Converts Invalid Date Values to Valid Ones

One of the most pervasive Y2K problems is the fact that two-digit years do not sort correctly. Year “00,” representing 2000, sorts before “99,” representing 1999. Open Query File (OPNQRYF) can sort such values correctly if you convert them to the date data type.

If your data contains invalid date values, such as 000000 or 999999, you have a problem. OPNQRYF cannot convert these special values to the date data type. However, if you can convert these values to other valid values, you can still use OPNQRYF to sort the data correctly.

Assume an existing OPNQRYF command is correctly sorting field SOPSDT, a six- digit numeric date field in MMDDYY format. You need to make it work for Y2K. First,

create a dummy physical file for OPNQRYF’s use, as in Figure 6. The file contains all the fields from the production file, plus a field of the date data type for sorting. The dummy file does not need a member. Second, change the high-level language (HLL) program that runs under OPNQRYF to read this dummy file rather than the file containing the data. Third, change the OPNQRYF command to convert invalid values to valid ones, and change numeric dates to the date data type, as in Figure 7. This code converts dates of 000000 to 010140 and dates of 999999 to 123139.

For a brief explanation of how the invalid values are converted to valid ones, see Figure 8.

— Ted Holt Senior Technical Editor Midrange Computing

Editor’s note: This tip comes from the book Y2K Survival Kit for AS/400 Programmers, soon to be published by Midrange Computing.

C eval PrintString=%editc(%dech(BigField:6:1)
C :'4')

C eval PrintString=%editc(%dech((BigField*TaxRate):6:1)
C :'4')

Figure 1: Using %dech and %editc to edit non-like fields

IF NUMERIC-VARIABLE NOT NUMERIC

MOVE ZEROS TO NUMERIC-VARIABLE.

Figure 2: Use the NUMERIC test to avoid COBOL decimal data errors

*****************************************************************

*

* To Create: CRTCBLPGM PGM(xxx/CVTHEXDEC) SRCFILE(xxx/QLBLSRC) +
* SRCMBR(CVTHEXDEC)

*

*****************************************************************

IDENTIFICATION DIVISION.

PROGRAM-ID. CVTHEXDEC.

DATA DIVISION.

WORKING-STORAGE SECTION.

* CHARACTER FIELD HEX-CHAR-INPUT CONTAINS THE LETTER "A"

01 HEX-CHAR-INPUT PIC X VALUE X"C1".

01 BINARY-VALUE PIC S9(4) BINARY VALUE 0.

01 BINARY-VALUE-CHAR REDEFINES BINARY-VALUE.

05 HIGH-ORDER-BYTE PIC X.

05 LOW-ORDER-BYTE PIC X.

*

PROCEDURE DIVISION.

MAINLINE.

* ===> CONVERT HEX TO DECIMAL FOR DISPLAY

MOVE HEX-CHAR-INPUT TO LOW-ORDER-BYTE.

DISPLAY BINARY-VALUE.

* BINARY-VALUE WILL = 193

Figure 3: Converting hexadecimal to decimal in for a display in COBOL

*****************************************************************

* * To Create: CRTCBLPGM PGM(xxx/CVTDECHEX) SRCFILE(xxx/QLBLSRC) +

* SRCMBR(CVTDECHEX) *

*****************************************************************

IDENTIFICATION DIVISION.

PROGRAM-ID. CVTDECHEX.

DATA DIVISION.

WORKING-STORAGE SECTION.

01 BINARY-VALUE PIC S9(4) BINARY VALUE 193.

01 BINARY-VALUE-CHAR REDEFINES BINARY-VALUE.

05 HIGH-ORDER-BYTE PIC X.

05 LOW-ORDER-BYTE PIC X.

*

01 BYTE-1 PIC S9(3) COMP-3 VALUE 0.

01 BYTE-2 PIC S9(3) COMP-3 VALUE 0.

01 BYTE-HOLD PIC S9(3) COMP-3 VALUE 0.

01 SINGLE-DIGIT PIC S9 COMP-3 VALUE 0.

01 START-POS PIC S9 COMP-3 VALUE 0.

01 HEX-CHAR-DISPLAY PIC X(2) VALUE SPACES.

PROCEDURE DIVISION.

MAINLINE.

* ===> CONVERT DECIMAL TO HEX FOR DISPLAY

DIVIDE 16 INTO BINARY-VALUE

GIVING BYTE-1

REMAINDER BYTE-2.

IF BYTE-1 < 10

MOVE BYTE-1 TO SINGLE-DIGIT

MOVE SINGLE-DIGIT TO HEX-CHAR-DISPLAY(1:1)

ELSE

MOVE 1 TO START-POS

MOVE BYTE-1 TO BYTE-HOLD

PERFORM CONVERT-BYTE-HOLD

END-IF.

IF BYTE-2 < 10

MOVE BYTE-2 TO SINGLE-DIGIT

MOVE SINGLE-DIGIT TO HEX-CHAR-DISPLAY(2:1)

ELSE

MOVE 2 TO START-POS

MOVE BYTE-2 TO BYTE-HOLD

PERFORM CONVERT-BYTE-HOLD

END-IF.

DISPLAY HEX-CHAR-DISPLAY.

* HEX-CHAR-DISPLAY WILL = C1

GOBACK.

CONVERT-BYTE-HOLD.

EVALUATE BYTE-HOLD

WHEN 10 MOVE "A" TO HEX-CHAR-DISPLAY(START-POS:1)

WHEN 11 MOVE "B" TO HEX-CHAR-DISPLAY(START-POS:1)

WHEN 12 MOVE "C" TO HEX-CHAR-DISPLAY(START-POS:1)

WHEN 13 MOVE "D" TO HEX-CHAR-DISPLAY(START-POS:1)

WHEN 14 MOVE "E" TO HEX-CHAR-DISPLAY(START-POS:1)

WHEN 15 MOVE "F" TO HEX-CHAR-DISPLAY(START-POS:1)

END-EVALUATE.

Figure 4: Converting decimal to hexadecimal for a display in COBOL





Tech_Talk06-00.png 900x437

Figure 5: Remove this key value from the Windows Registry to keep CWBBS.EXE from starting

*===============================================================

* To compile:

*

* CRTPF FILE(XXX/SLSORDW3) SRCFILE(XXX/QDDSSRC) +

* MBR(*NONE)

*

*===============================================================

A REF(SLSORD)

A UNIQUE

A R SLSORDR

A SOORNO R

A SOORDT R

A SOCUST R

A SOPSDT R

A XXPSDT L TEXT('PROJECTED SHIP DATE')

A DATFMT(*ISO)

A SOASDT R

A K SOORNO

Figure 6: This dummy file enables numeric date fields to be the temporarily converted to the date data type

OVRDBF FILE(SLSORDW3) TOFILE(SLSORD) SHARE(*YES)

OPNQRYF FILE((SLSORD)) +

KEYFLD((XXPSDT)) +

FORMAT(SLSORDW3) +

MAPFLD(+

(PSDT00 '1/SOPSDT') +

(PSDT01 'PSDT00 / %MAX(PSDT00 0.1)' *DEC 1 0) +

(PSDT02 '%ABSVAL((PSDT01 - 1))' *DEC 1 0) +

(PSDT03 'PSDT00 + PSDT02 * 010140' *DEC 6 0) +

(PSDT04 '%MIN((999998 / PSDT03) 1)' *DEC 1 0) +

(PSDT05 '%ABSVAL((PSDT04 - 1))' *DEC 1 0) +

(PSDT06 '(PSDT03 * PSDT04) + (123139 * PSDT05)' +

*DEC 6 0) +

(PSDT07 '%DIGITS(PSDT06)') +

(XXPSDT '%DATE((%SST(PSDT07 1 2) *CAT ''/'' *CAT +

%SST(PSDT07 3 2) *CAT ''/'' *CAT +

%SST(PSDT07 5 2)))'))

CALL PGM(SORT1RGF)

CLOF OPNID(SLSORD)

DLTOVR FILE(SLSORDW3)

Figure 7: OPNQRYF converts invalid dates of all zeros or nines to valid dates

PSDT00 PSDT00 gets a copy of the original date value. PSDT01 Yields a zero for dates of all zeros, and a one for nonzero dates. PSDT02 Converts zeros of the previous step to ones, and ones to zeros. PSDT03 Changes dates of all zeros to 010140, and leaves dates of nonzero values unchanged. PSDT04 Yields a zero for dates of 999999, and a one for all other dates.

PSDT05 Converts zeros of the previous step to ones, and ones to zeros. PSDT06 Changes dates of 999999 to 123139, and leaves dates of other values unchanged. PSDT07 Converts the six-digit numeric value in PSDT06 to a character string.

XXPSDT Builds a date of the date data type from the value in PSDT07.

Figure 8: How OPNQRYF converts invalid dates to valid ones

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: