Newsletters   Subscriptions  Forums  Store   Career  Media Kit  About Us  Contact  Search   Home 
fhg
Volume 5, Number 35 -- September 21, 2005

When There's No Room for Special Values


by Ted Holt


It's trivia time, esteemed colleagues. The LEN parameter of the PARM command, used to define parameters in CL commands, will accept up to three values. Character data types need one value in the LEN parameter. Decimal values accept one or two. (If only one is specified, the decimal variable is assumed to have zero decimal positions.) What data type allows you to specify three values in the LEN parameter?

You may use three values with the *X data type. This type is supposed to be used with IBM commands, but I don't know of any reason we mortals can't use it, too. The *X type allows the user to key either decimal data or character data into a parameter. If the parameter value consists of digits, an optional decimal point, and an optional leading plus or minus sign, the command processing passes a decimal value to the command-processing program. The size of this decimal value is defined in the second and third values of the LEN parameter. Otherwise, the keyed value is passed as a character value whose length is the first value of the LEN parameter.

Let's consider a situation in which you might need to use the *X data type. Suppose you're writing a command that includes an adjustment quantity, and you'd like the user to be able to use the special character value REVERSE. Normally you would map the special value to an unused numeric value. In the following command definition, REVERSE is converted to -999.

CMD   PROMPT('Do Something')           
PARM  KWD(ADJQTY) TYPE(*DEC) LEN(3 0) +
        SPCVAL((REVERSE -999)) MIN(1) +
        PROMPT('Adjustment quantity')

The command-processing program would normally test for the special value and carry out special processing.

PGM  PARM(&QTY)                   
                                  
DCL  &QTY     *DEC      3         
                                  
IF (&Qty *eq -999) THEN(... do something ...) 
ELSE (... do something else ...) 

But what if there is no unused value that can be substituted for the special value? Suppose all values from -999 to 999 are valid values and none can be used to represent the special value REVERSE? This is a good time to use the *X data type.

In the following command, the ADJQTY parameter may be passed as an eight-character value or a three-digit decimal value with no decimal positions. The command processor will decide which of those formats to use by examining the parameter's value.

CMD   PROMPT('Do Something')                  
PARM  KWD(ADJQTY) TYPE(*X) LEN(8 3 0) MIN(1) +
        PROMPT('Adjustment quantity')

The command-processing program will have to determine which type of value was passed from the command and act accordingly. Since the parameter value may be either decimal or character, it may not make sense to use a CL program to process the command. The following code fragment is from a command-processing program written in RPG.

D AdjStruc        ds             8                  
D   AdjChar               1      3                  
D   AdjQty                1      2p 0               
                                                    
C     *entry        plist                           
C                   parm                    AdjStruc
C                                                   
C                   if        AdjChar = 'REV'       
... REVERSE, do something
C                   else                            
... numeric, do something else using subfield AdjQty
C                   endif

Sponsored By
WORKSRIGHT SOFTWARE

Do you need area code information?
Do you need ZIP Code information?
Do you need ZIP+4 information?
Do you need city name information?
Do you need county information?
Do you need a nearest dealer locator system?

We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

Just call us and we'll arrange for 30 days FREE use of either
ZIP/CITY or PER/ZIP4.

WorksRight Software, Inc.
Phone: 601-856-8337
Fax: 601-856-9432
E-mail: software@worksright.com
Web site: www.worksright.com


Technical Editors: Howard Arner, Joe Hertvik, Ted Holt,
Shannon O'Donnell, Kevin Vandever
Contributing Technical Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Marc Logemann, David Morris
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.


THIS ISSUE
SPONSORED BY:

WorksRight Software
iTera
Twin Data


Four Hundred Guru

BACK ISSUES

TABLE OF
CONTENTS
When There's No Room for Special Values

Odd Ways to Round Numbers

Admin Alert: A Checklist for Creating OS/400 User Profiles, Part II


The Four Hundred
Forget Oracle 10g. Let's Talk About i5/OS V5g

IBM Shifts Its SOA Initiative Up Into High Gear

Big Blue Delivers Industrial-Strength Laser Printer

As I See It: Save Now or Suffer Later

Four Hundred Stuff
Plasmon's New UDO Media Destroys Records, By Design

Cape Clear's Enterprise Service Bus Avoids WebSphere Gridlock

Chick's Digs iSeries as Replacement for Windows Farm

Red Oak Rides Eclipse to Application Integration Party

Four Hundred Monitor


Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc. (formerly Midrange Server), 50 Park Terrace East, Suite 8F, New York, NY 10034
Privacy Statement