• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • 10 Facts You Should Know about Special Values

    October 26, 2011 Ted Holt

    Imagine not being allowed to code *FIRST in the MBR parameter of the Override with Database File (OVRDBF) command. Horrible thought, isn’t it? Special values make commands more sensible and easy to use. Here are 10 facts every IBM i developer should know in order to effectively use special values in his own commands.

    1. Special values are character strings that are incompatible with validity checking rules. In this example, BATCH requires a three-digit number, and *ALL does not fit that description.

    PARM  KWD(BATCH) +
          TYPE(*DEC) LEN(3 0) +
          DFT(*ALL) +
          REL(*GT 0) +
          SPCVAL((*ALL -1)) +
          PROMPT('Batch number')</all>
    

    2. Special values make it easier for humans to communicate with computers. Here’s a logical parameter that accepts *YES and *NO. These values make more sense to humans than 1 and 0.

    PARM  KWD(BLANKRECS) TYPE(*LGL) +
           RSTD(*YES) +
           DFT(*YES) +
           SPCVAL((*YES '1') (*NO '0')) +
           PROMPT('Write blank records?' 5)
    

    3. IBM‘s standard is that special values begin with an asterisk, but this is not a system requirement. Here ALL is a special value.

    PARM  KWD(BATCH) +
           TYPE(*DEC) LEN(3 0) +
           DFT(ALL) +
           REL(*GT 0) +
           SPCVAL((ALL -1)) +
           PROMPT('Batch number')
    
    

    4. The data type and length of a data element match the underlying values, not the special values. BATCH is defined here as a three-digit decimal number with no decimal places, not as a four-byte character variable.

    PARM  KWD(BATCH) +
          TYPE(*DEC) LEN(3 0) +
          DFT(*ALL) +
          REL(*GT 0) +
          SPCVAL((*ALL -1)) +
          PROMPT('Batch number') </all>
    

    5. A special value may be passed as is, or replaced by a replacement value, when passed to the command-processing program (CPP). Here *MBR is passed to the CPP.

    PARM  KWD(WORKMBR) TYPE(*NAME) DFT(*MBR) +
            SPCVAL((*MBR)) EXPR(*YES) PMTCTL(CHANGE) +
            PROMPT('Member')
    

    But here a blank and an asterisk replace *BLANK and *AST respectively.

    PARM   KWD(CURRENCY) TYPE(*CHAR) LEN(1) DFT(*BLANK) +
            RANGE(X'41' X'FE') +
            SPCVAL((*BLANK ' ') (*AST '*')) +
            EXPR(*YES) PROMPT('Currency fill character')
    

    6. If the replacement value of special value *CURLIB is the unquoted string *CURLIB, the name of the current library is passed to the command-processing program. Otherwise, the string *CURLIB is passed to the CPP. In this example, there is no replacement value, so the string *CURLIB will be passed to the CPP.

    QUAL  TYPE(*NAME) LEN(10) DFT(*LIBL) +
           SPCVAL((*LIBL) (*CURLIB)) +
           EXPR(*YES) +
           PROMPT('Library')
    

    But here *CURLIB is replaced with the name of the current library.

    QUAL  TYPE(*NAME) LEN(10) DFT(*LIBL) +
           SPCVAL((*LIBL) (*CURLIB *CURLIB)) +
           EXPR(*YES) +      
           PROMPT('Library')
    

    If the job has no defined current library, QGPL is passed to the CPP.

    7. You can ignore errors of severity 20 and below in the compiler listing, provided that the command processing program can properly handle the invalid substitution values. The following parameter definition generates three CPF0257 errors, because the three replacement values are not valid dates. However, because the CPP must define date fields as seven-byte character variables, the replacement values are appropriate ones.

    PARM  KWD(DATE) TYPE(*DATE) +
           DFT(TODAY) +
           SPCVAL((TODAY 2222222) (YESTERDAY 3333333) (TOMORROW 4444444)) +
           EXPR(*YES) +
           PROMPT('Cutoff date')
    

    8. You may list up to 300 special values in the SPCVAL parameter. This PARM defines three special values.

    PARM  KWD(SPLNBR) TYPE(*INT4) +
           DFT(*ONLY) +
           RANGE(1 999999) +
           SPCVAL((*ONLY 0) (*LAST -1) (*ANY -2)) +
           EXPR(*YES) +
           PROMPT('Spooled file number' 4)
    

    9. Special values may be used in PARM, ELEM and QUAL statements. I’ve already shown several PARM examples, so here is an example of a qualified parameter that accepts special values.

                PARM  KWD(TEMPLATE) TYPE(FILE1) MIN(1) +
                       PROMPT('Template' 1)
    
    FILE1:      ELEM  TYPE(QUALFILE1) MIN(1) PROMPT('File')
                ELEM  TYPE(*NAME) LEN(10) DFT(*FIRST) +
                       SPCVAL((*FIRST)) EXPR(*YES) PROMPT('Member')
    
    QUALFILE1:  QUAL  TYPE(*NAME) LEN(10) MIN(1) EXPR(*YES)
                QUAL  TYPE(*NAME) LEN(10) DFT(*LIBL) + 
                      SPCVAL((*LIBL) (*CURLIB)) EXPR(*YES) +
                      PROMPT'Library')
    

    10. Special values are not allowed when a parameter returns a value to the caller. (That is, the RTNVAL keyword has the value *YES.) This restriction is not a hardship, because it is hard to imagine a reason why a person would want to define input values for an output parameter.



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Krengeltech

    When it comes to consuming web APIs on your IBM i, your options often boil down to one of two things:

    First, you end up having to rely on a variety of open source and non-RPG solutions. This adds developer complexity, taking away time that could have been better spent invested in other projects. Of course, open source software is free, but generally comes at the cost of no professional support, which adds an element of risk in your production environment. RXS is completely professionally supported, and is complemented by a staff of trained IBM i developers who can address your nuanced development challenges, head on.

    Second, if you choose not to pursue an open-source solution, you’re often left having to shake up your current program architecture with proprietary software, external dependencies, and partial RPG implementations – many of which are sub-par compared to RPG-XML Suite’s wide range of features. RXS aims to simplify the efforts of developers with tools like code generators, useful commands, and subprocedures written in 100% RPG – no Java. Because they are entirely RPG, the RXS subprocedures are easy to add to new or existing ILE programs and architecture, helping to cut your development time. RPG-XML Suite offers powerful capabilities in an accessible, easy-to-implement format.

    With RPG-XML Suite, you can accomplish a variety of complex tasks, such as:

    • Calling REST and SOAP web services from your IBM i
    • Offering APIs from your IBM i
    • Creating JSON & XML
    • Parsing JSON & XML
    • Text manipulation, Base64 encoding/decoding, CCSID handling, hashing and encryption functions, and more.

    To try RXS for yourself, we recommend a free proof of concept, which not only gives you access to all of RPG-XML Suite’s subprocedures and utilities but also includes a tailor-made software demonstration that can be used as a starting point for your future API implementations.

    For a free proof of concept, contact us at sales@krengeltech.com, or visit our website for more information.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    New Generation Software:  FREE Business Intelligence Webinar. November 9
    Dan Riehl Presents:  Fall Training Sale – Discounts up to 40%! RPG IV COBOL CL Admin Security
    Connectria Hosting:  What's your IBM System i strategy? Download our FREE report

    IT Jungle Store Top Book Picks

    BACK IN STOCK: Easy Steps to Internet Programming for System i: List Price, $49.95

    The iSeries Express Web Implementer's Guide: List Price, $49.95
    The iSeries Pocket Database Guide: List Price, $59
    The iSeries Pocket SQL Guide: List Price, $59
    The iSeries Pocket WebFacing Primer: List Price, $39
    Migrating to WebSphere Express for iSeries: List Price, $49
    Getting Started with WebSphere Express for iSeries: List Price, $49
    The All-Everything Operating System: List Price, $35
    The Best Joomla! Tutorial Ever!: List Price, $19.95

    On ‘GTFM’ and a Place for Experts Bang For The Buck on Power7 Gen 2 Servers

    Leave a Reply Cancel reply

Volume 11, Number 32 -- October 26, 2011
THIS ISSUE SPONSORED BY:

ProData Computer Services
WorksRight Software
The 400 School

Table of Contents

  • 10 Facts You Should Know about Special Values
  • VALUES: A Truly Useless DDS Keyword
  • Limiting How Much Memory a Storage Pool Can Allocate

Content archive

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

Recent Posts

  • The Cloud’s Future Is So Bright, So Why Are You So Glum?
  • Most App Modernization Projects a Struggle, Survey Finds
  • COMMON Launches IBM i Security Conference
  • Four Hundred Monitor, August 17
  • A Slew Of Add-On Services For Power10 Systems
  • Power10 Midrange Machine: The Power E1050
  • IBM Puts The Finishing Touches On PowerHA For IBM i 7.5
  • Guru: Regular Expressions, Part 2
  • Get Your Security Education, And Not From The School Of Hard Knocks
  • IBM i PTF Guide, Volume 24, Number 33

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 © 2022 IT Jungle

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.