21
Thu, Nov
1 New Articles

TechTalk March 1999

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

Temporary Files May Cause Permanent Printing Problems

General protection faults (GPFs), page faults, and stack faults that occur when printing are often caused by garbage on the hard drive. Problems include leftover temp files, lost allocation units, cross-linked files, and defragmentation. Therefore, before pursuing a defect in one of the Client Access/400 printer emulators, it is best to clean up the hard drive. This up-front work may resolve the problem and relieve you from having to deal with PTFs, Service Packs, printer drivers, traces, and so on.

Following are the steps to take to clean up your hard drive. When Using Windows 95/98 or Windows NT
1. Close all applications.
2. Click on the Windows 95 or Windows NT Start button, select Programs and MS-DOS Prompt.

3. At the DOS prompt, type SET to find out the name of the TEMP directory. For example, it might say TEMP=C:WINDOWS TEMP or TEMP=C:DOS.

4. Bring up the Windows Explorer, and check the temp directory for any leftover temp files or temp folders. Anything in the TEMP folder is, by default, a temporary file. If you find any, delete them by selecting all of them and then selecting File/Delete on the menu bar (or by pressing the Delete key on your keyboard).

5. From inside Windows Explorer, right-click on the hard drive and select Properties from the pop-up menu.

6. From the Properties dialog box for the hard drive, click on the Tools tab and then click on the Check Now button. This process brings up the ScanDisk utility, which scans the hard drive for lost allocation units and cross-linked files. Select which hard drives you wish to scan, select the type of test you wish to run (usually, a standard test is sufficient), make sure that Automatically fix errors is checked, and click on the Start button. Go back to your hard drive properties again when the program finishes.

7. From the Properties dialog box for the hard drive, click on the Tools tab and then click on the Defragment Now button. This process brings up the Disk Defragmenter utility, which improves the performance of your hard drive. You can use the Select Drive button to choose which hard drive to defragment (it is recommended that you defragment all of your hard drives at this point). Once a hard drive has been selected, click on the Start button to defragment that hard drive.

8. If running the ScanDisk utility reveals any problems, reinstall Client Access/400 for Windows 95/NT (including PC5250) and the Windows 95 or Windows NT printer driver.

When Using Windows 3.1 or Windows for Workgroups 3.11

1. Exit Windows 3.1 or Windows for Workgroups 3.11.
2. At the DOS prompt, type SET to find out the name of the TEMP directory. For example, it might say TEMP=C:WINDOWSTEMP or TEMP=C:DOS.

3. Type CD followed by the temp directory name (for example, CD C:WINDOWS TEMP or CD C:DOS).

4. Go to the temp directory and type DIR*.TMP to check for any leftover temp files. If you find any, type DEL *.TMP.
5. Type either SCANDISK or CHKDSK /F to scan the hard drive for lost allocation units and cross-linked files.

6. Type DEFRAG C: /F /R /H /SE /B to defragment the hard drive. Note: This command automatically reboots the PC when finished.

7. If you do not have SCANDISK, CHKDSK, or DEFRAG, obtain a third-party utility such as Norton Disk Doctor to ensure that the hard drive is cleaned up.

8. If running SCANDISK, CHKDSK, or a third-party utility reveals any problems, reinstall Client Access for Windows 3.1 (including RUMBA/400 or PC5250) and the Windows printer driver.

Note: In either case, you may need to reinstall the operating system to replace important modules that may have been damaged.

— Shannon O’Donnell Associate Technical Editor Midrange Computing

TCP/IP Printer Address Problems

When you add a printer to your TCP/IP network, one of the parameters you have to add in your Domain Name System (DNS) server configuration is the IP address for that printer. If you give that printer device a new IP address at some future time, you may be in for an unexpected surprise. Your AS/400 may continue to use the old IP address instead of your new one. This is because the AS/400 caches the DNS information for a period of time, determined by the DNS server, of up to 24 hours. If you need to use this device with the new address, you have only two choices: You can wait until the DNS server cache time expires and resets itself, or you can IPL the AS/400.

— Shannon O’Donnell Associate Technical Editor Midrange Computing

Microsoft’s Visual Basic (VB) is the premier tool for corporate Windows development. Unfortunately, Version 5, the version in widespread use, has had a troubled existence since its rollout just over a year ago. During that short span, Microsoft has released three Service Packs (what we in the midrange world call PTFs), each with dire warnings about neglecting to download and install them. Fortunately, the final service pack, Service Pack 3, includes all the functionality of the preceding two (plus bug fixes for problems introduced by the preceding two). You can download SP 3 from Microsoft’s Web site at www.microsoft.com/ msdownload/vstudio/sp97/vb.asp. Be warned, though: It’s over 15 MB!

After you download this Service Pack, running the file will find and update your VB installation. If you’re unsure what version of VB you are currently on, click on the Help-About icon from within the VB environment. It should say Visual Basic 5 (SP 3). If you have a lower SP level, or no service level at all, you may want to download the latest Service Pack upgrade as soon as possible.

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

Help for Those Who Want to Escape from It All

To write functional, well-behaved CL programs, it is necessary to monitor for escape messages sent to CL commands. But trying to remember the message IDs of all those escape messages is impossible.

Tell me again: What is the CPF message for end-of-file with Receive File (RCVF)? What is the message for an object not found with Check Object (CHKOBJ)?

With Version 4 Release 1 of OS/400, you don’t need to consult hopelessly obsolete manuals or plagiarize other programs or run the command from a command line to determine which escape messages need to be monitored. Simply prompt a command, move the cursor to the top line (where the command name is), and press F1. Roll through the help text, and you will find every escape message that applies to that command.

— Mark Strong BeautiControl Cosmetics This email address is being protected from spambots. You need JavaScript enabled to view it.

Let’s Make a Date for the End of Month

Q: Is there a way to get an End of Month date from a date data type in RPG ILE? — Alex Fishbein
This email address is being protected from spambots. You need JavaScript enabled to view it.

A: Here’s a three-line solution (Figure 1) that ought to do the trick. This code will add a month, then subtract the *DAYS part, giving you the End of Month date.

— Barbara Morris IBM Toronto Lab, RPG Compiler Development

API Really Means “Apply Patch Immediately”

The AS/400’s HTTP server provides an excellent way to gather information from your customers and suppliers. To make this task easier, IBM provides several APIs that allow you to process data entered on a form on a Web page with the languages most familiar to AS/400 programmers, such as RPG and COBOL. Unfortunately, if you have upgraded to V4R1 or higher, you have probably discovered that the API QtmhCvtDb (Convert to Database) no longer processes form data correctly.

QtmhCvtDb is used in conjunction with another API, QtmhStdIn (Standard Input), to map data entered into a Web page form to fields in a physical file. Figure 2 shows the code for a simple form that allows a customer to enter name and address information in order to be added to a mailing list that is stored in a physical file. (For this example, Name and Address serve as the name and address.) Clicking on the Process Form button initiates a call to the CGI program TESTRPG001. (This is specified as the action on the form tag.)

A call to QtmhStdIn retrieves the data from the standard input buffer of the HTTP server and returns the following string to the CGI program:

name=Anyone&address=Anywhere

The API QtmhCvtDb is then called to map the data entered into the corresponding fields of a physical file. At this point, the physical file field “name” should have a value of “Anyone” and the field “address” should have a value of “Anywhere”.

Unfortunately, QtmhCvtDb contains a bug that causes corruption of the data entered in the last form element. If the last form element has a size of one, the data entered is lost entirely; if the form element has a size other than one, the value of the address is returned as a string containing the data entered followed by garbage. Therefore, in this example, address is returned as “Anywhere” plus 32 indecipherable characters that do not look very nice on a mailing label!

Fortunately, there is a simple way to overcome this obstacle. Simply add the following line of code as the last element of the HTML table:

This code causes the corrupted data to be parsed into the hidden field, where it no longer poses a problem. Until a PTF is announced to correct the situation, using this method provides a simple fix.

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

Head ’em Up, Move ’em Out!

I created a command called Change Column Heading (CHGCOLHDG), which allows you to easily change the column heading or text description for a previously created file. The example shown in Figure 3 is the equivalent to the following DDS keywords and parameters:

COLHDG(‘THIS’ ‘IS’ ‘FIELDA’)
TEXT(‘THIS IS FIELDA’)

The CHGCOLHDG command accomplishes this task by using Query Manager queries and SQL to execute a LABEL ON SQL statement. Every machine since Version 2 Release 1 of OS/400 has Query Manager, so everyone should be able to take advantage of this command.

The CHGCOLHDG utility consists of three objects: command CHGCOLHDG, CL program PL0001C, and RPG IV program PL000R1. You can download source code for these objects at www.midrangecomputing.com/99/03.

You must have authority to use LABEL ON in QM. To ensure that you have the required authority, type in the command Start Query Manager (STRQM) on a command line and press Enter. This will start the DB2 Query Manager for AS/400 menu. Now, select option 10, Work with Query Manager Profiles. Find your user profile on the next panel and enter a 2 beside it to change it. Next, use the roll keys to scroll forward three screens, and you’ll see a panel like the one shown in Figure 4. Enter a Y at Select allowed SQL statements. Press the Enter key, and you will see a panel like the one shown in Figure 5. On this panel, enter a 1 on the LABEL ON entry line and press the Enter key.

This command is easier to use than Change Physical File (CHGPF) because you can embed this command in a CL program or execute it from a command line. Also, you do not need to hunt down the original DDS that created the file. This command provides an

easy method to change file text and column headings, and, best of all, you don’t need to know SQL!

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

Editor’s note: Be aware that failure to change the DDS from which a file was built may cause problems later. If someone rebuilds the file from the DDS, the changes you’ve made with CHGCOLHDG will be lost.

I’m Sorta Partial to My Key

The code fragment in Figure 6 is an RPG IV example of a DOW loop that executes while part of a field is equal to a “key” or predetermined literal. I use it to load to a subfile part numbers or customer numbers that begin with a specific character sequence. The comparison can be made to a variable that a user enters.

— Jeff Kinzer Porter Cable Corp. This email address is being protected from spambots. You need JavaScript enabled to view it.

ODBC Has Your Number

One of the hardest things about client/server programming on the AS/400 is finding your ODBC job. The Work with Active Jobs (WRKACTJOB) command will list all of the jobs running in the QSERVER subsystem, which is where all ODBC prestart jobs run. If your shop is like mine, you have many ODBC users cluttering up the screen, and the user is always displayed as QUSER! To find the logged in user profile, you have to display the job log of each QSERVER job until you see the user profile you want to debug. This is a time-wasting pain in the posterior, to say the least.

Enter the most useful stored procedure in the world! Stored procedure RETJOBI eliminates the need to search for a particular ODBC job! As you can see in Figure 7, the code for this procedure is only four lines long. It begins with the declaration of a CL variable to hold the job number, and then it executes a call to the Retrieve Job Attributes (RTVJOBA) command to return the number of the job currently running. Once you wrap this command by issuing a CREATE PROCEDURE statement in your ODBC program, you will be able to call it as a stored procedure and see your job number.

I have found this technique so useful that this procedure is called from every program in my shop, and the job number is then posted on each screen in the application. This way, my operators can tell me their job number when they have a problem, and I can use the Display Job Log (DSPJOBLOG) or the Work with Jobs (WRKJOB) command to see why they are having problems.

Please note that ODBC job names are QZDASOINIT for Windows 95/NT and QZDAINIT for Windows 3.x. jobs. To display the job log of a Windows 95/NT ODBC job, you would type DSPJOBLOG xxxxxx/ QUSER/QZDASOINIT, where xxxxxx is the job number returned by the stored procedure.

To prepare the RETJOBI command for execution, use the Create Bound CL Program (CRTBNDCL) command to create an executable version of the RETJOBI program in your QSYS library. Be aware, however, that, when you upgrade to the next release of OS/400, you may lose what you had in QSYS. Perhaps a better approach might be to put the object in QGPL. Next, execute the following statement from an interactive SQL session:

CREATE PROCEDURE QSYS/RETJOBI (INOUT :job CHAR(6)) EXTERNAL NAME QSYS/RETJOBI
SIMPLE CALL;

Once the create procedure statement has been executed, DB2 knows what arguments the procedure will accept and their data type. You are now ready to execute code like that shown in Figure 8 to find your job number.

This code was written using VB 5.0. For the code to work, create a VB form inside the program with a command button labeled Command_1. When the user clicks Command_1, the VB code executes and displays the user’s AS/400 job number. When you enter this code into VB, be sure to do the following:

1. Activate the following VB Project References in the program: the Microsoft ActiveX Data Objects 2.0 library and the Microsoft ActiveX Data Objects Recordset 2.0 library. Project references are activated in VB 5.0 by clicking Project from the VB dropdown menu and then clicking References. Find these entries and place a check mark next to them. If they are missing from your VB references, download and install the Microsoft Data Access Software Development Kit (SDK) and the Microsoft Data Access Components Version 2.0 from the Microsoft Universal Data Access Web site at www.microsoft.com/data/download.htm. This download fixes problems with the earlier releases, adds connection pooling, and provides better parameter object support. I don’t recommend running this code without the new components.

2. Replace the “AS/400” literal in the CON1.OPEN line with the name of your ODBC data source name. Also in that line, replace the “HOWARD” literal with a valid AS/400 user name for your system, and replace the “PASSWORD” literal with the password for that user.

Once these changes are in place, you can retrieve your AS/400 job number at will. — Howard Arner
This email address is being protected from spambots. You need JavaScript enabled to view it.

Identify That Trigger-happy Program

Q: Is it possible for a trigger program to determine what program caused it to fire? — Don Johnson
Lebanon, PA
This email address is being protected from spambots. You need JavaScript enabled to view it.

A: The ILE procedure RtvTgrCaller shown in Figure 9 will do the trick. This module can be bound into your trigger program or, much better, added to a service program, which must be compiled with ACTGRP(*CALLER).

Procedure RtvPgmCaller, which can be found on the MC Web site (www.midrange computing.com/mc/99/03), returns a 277-byte character variable (Figure
10) containing four pieces of information: the name of the program that fired the trigger, the type of program, the name of the module, and the name of the procedure. Look at the code fragment in Figure 9 for an example of how to call this procedure.

This procedure relies on some convenient OS/400 and DB2 behavior, which makes it vulnerable to any changes IBM makes in DB2/400. However, short of IBM supplying an API or adding the name of the trigger program to the trigger buffer, in my opinion, this is about as good as it’s going to get.

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

C d1 adddur 1:*m tempd

C extrct tempd:*days days

C tempd subdur days:*days tempd

Figure 1: Here’s a handy method to determine the date of the last day of the month.

QtmhCvtDb API Fix

QtmhCvtDb API Fix


Name
Address



Figure 2: Use this HTML form to allow entry of a name and an address.

CHGCOLHDG FILE1(TEST1) FIELD(fieldA) +

TEXT(THIS IS FIELDA) HDG1(THIS) +

HDG2(IS) HDG3(FIELDA)

Figure 3: CHGCOLHDG allows you to change column headings and text descriptions.


Figure 4: Enter a Y in the STRQM Select allowed SQL statements field.





Tech_Talk507-00.png 900x458




Figure 5: Enter a 1 next to the LABELS ON field to use the CHGCOLHDG command.


C 'RBC ' SetLL FILE
C Read FILE
C DoW Not %EOF(FILE) And
C %subst(FIELD:1:4) =
C 'RBC '
C eval sc1rrn = sc1rrn + 1
C Write scrn01sf
C Read FILE
C EndDo

Figure 6: Use this technique to perform a Read Equal on a partial key value.

/*===================================================================*/

/* TO COMPILE: */
/* */

/* CRTBNDCL PGM(xxx/RETJOBI) SRCFILE(xxx/QCLSRC) */
/* */

/*===================================================================*/

PGM PARM(&NBR)
DCL VAR(&NBR) TYPE(*CHAR) LEN(6)
RTVJOBA NBR(&NBR)

ENDPGM

Figure 7: This CL code for the RETJOBI procedure retrieves your ODBC job attributes.

Dim Con1 As New Connection
Dim Cmd1 As New Command
Dim Prm1 As Parameter
'Activate the connection with the AS/400
Con1.Open "AS400", "HOWARD", "HOWARD"
'Associate the connection with the command object
Cmd1.ActiveConnection = Con1
'set the command into commandtext property
Cmd1.CommandText = "CALL QSYS.RETJOBI(?)"
'Create a parameter object to hold job number
Set Prm1 = Cmd1.CreateParameter("job", adChar, adParamInputOutput, 6, "")
'append parameter object into command object



Tech_Talk508-00.png 899x464

Cmd1.Parameters.Append Prm1
'execute the command
Cmd1.Execute
'show user the job number
MsgBox "Your job number is: " & Cmd1.Parameters("job").Value
'Release the command and the connection
Set Cmd1 = Nothing
Set Con1 = Nothing

Figure 8: This VB code connects to an AS/400 and executes the RETJOBI procedure.

/COPY QRPGLESRC,PROTOTYPES

D PgmName S 10A

D dsTrgCaller DS

D dsPgmName 10A

D dsPgmType 1A

D dsModName 10A

D dsPrcName 256A

......

* To just get program name...

C EVAL PgmName = RtvTrgCaller

C

* OR, to get all the information...

C EVAL dsTrgCaller = RtvTrgCaller

Figure 9: This program example uses RtvTrgCaller to find the name of a trigger program.

Positions Length Description

1-10 10 Program name 11-11 1 Program type 12-21 10 Module name 22-277 256 Procedure name

Figure 10: The RtvPgmCaller procedure returns information about the caller in a 277-byte data structure.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

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: