• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • When There’s No Room for Special Values

    September 21, 2005 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
    


    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    ARCAD Software

    Embrace VS Code for IBM i Development

    The IBM i development landscape is evolving with modern tools that enhance efficiency and collaboration. Ready to make the move to VS Code for IBM i?

    Join us for this webinar where we’ll showcase how VS Code can serve as a powerful editor for native IBM i code and explore the essential extensions that make it possible.

    In this session, you’ll discover:

    • How ARCAD’s integration with VS Code provides deep metadata insights, allowing developers to assess the impact of their changes upfront.
    • The role of Git in enabling seamless collaboration between developers using tools like SEU, RDi, and VS Code.
    • Powerful extensions for code quality, security, impact analysis, smart build, and automated RPG conversion to Free Form.
    • How non-IBM i developers can now contribute to IBM i projects without prior knowledge of its specifics, while ensuring full control over their changes.

    The future of IBM i development is here. Let ARCAD be your guide!

    Watch Now

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Red Oak Rides Eclipse to Application Integration Party Quadrant Unveils IntelliChief for Paperless Process Management

    Leave a Reply Cancel reply

Volume 5, Number 35 -- September 21, 2005
THIS ISSUE
SPONSORED BY:

WorksRight Software
iTera
Twin Data

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

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25
  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle