• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Value An Expression? *YES!

    July 24, 2013 Ted Holt

    I find it ironic that the most commonly used CL command suffers from an annoying (if not aggravating) limitation that does not afflict many less-used commands. Fortunately, the commands you and I write do not have to have this limitation.

    The command to which I refer is CALL. The limitation is that the parameters must be literals or variables, never expressions. To see what I mean, look at this CALL command.

    call   somepgm   parm(%sst(&Data 5 4))
    

    Doesn’t that make sense to you? The first parameter consists of bytes 5 through 8 of a variable named &DATA. The compiler complains, expressing its displeasure by means of diagnostic message CPD0105 (Built-in function not allowed for parameter PARM).

    To make this code work, you must declare another variable, copy the required four bytes into it, and use that variable in the parameter list.

    dcl      &SomeVar    *char    4
                           
    chgvar   &SomeVar     %sst(&Data 5 4)
    
    call     somepgm parm(&SomeVar)
    

    I’m sure there is a good reason for this limitation. I just don’t know what that good reason is.

    Consider two commands, DOTHIS and DOTHAT.

    CMD        PROMPT('Do this')
    PARM       KWD(RATE) TYPE(*CHAR) LEN(4) RSTD(*YES) +
                 VALUES(SLOW FAST) MIN(1) EXPR(*YES) +
                 PROMPT('How fast?')
    PARM       KWD(TIMES) TYPE(*INT2) MIN(1) EXPR(*YES) +
                 PROMPT('How many times?')
    
    
    CMD        PROMPT('Do that')
    PARM       KWD(INTERVAL) TYPE(*DEC) LEN(7 0) MIN(1) +
                 PROMPT('How frequently?')
    PARM       KWD(UNIT) TYPE(*CHAR) LEN(9) RSTD(*YES) +
                 VALUES(HOURS MINUTES SECONDS DAYS MONTHS +
                 YEARS DECADES CENTURIES MILLENNIA EONS) +
                 PROMPT('Unit of time')
    

    They are similar in that both of them accept two parameters: a character parameter and a numeric parameter. But they differ in that the parameters of DOTHIS include the keyword EXPR(*YES). A parameter that is defined to allow expressions may include concatenation operators, as well as built-in functions %SUBSTRING (%SST), %BIN, %TRIM, %TRIML, %TRIMR, %SCAN, and %CHECK.

    Now look at a program that calls these commands.

       dcl   &Settings    *char    48
       dcl   &Interval    *char     3
       dcl   &Units       *char     9
    
       RtvDtaAra   dtaara(DoDahData (1 48)) rtnvar(&Settings)
    
       DoThis      rate(%sst(&Settings 1 4)) times(%sst(&Settings 5 3))
    
       ChgVar      &Units     %sst(&Settings 11 9)
       ChgVar      &Interval  %sst(&Settings 20 3)
    
       DoThat      interval(&Interval) unit(&Units)
    

    Since DOTHAT does not allow expressions, the programmer had to declare and load two variables, &INTERVAL and &UNITS. DOTHIS requires no such variables.

    For this reason, I make it a habit to include EXPR(*YES) when defining command parameters.



                         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
    VISUAL LANSA 16 WEBINAR

    Trying to balance stability and agility in your IBM i environment?

    Join this webinar and explore Visual LANSA 16 – our enhanced professional low-code platform designed to help organizations running on IBM i evolve seamlessly for what’s next.

    🎙️VISUAL LANSA 16 WEBINAR

    Break Monolithic IBM i Applications and Unlock New Value

    Explore modernization without rewriting. Decouple monolithic applications and extend their value through integration with modern services, web frameworks, and cloud technologies.

    🗓️ July 10, 2025

    ⏰ 9 AM – 10 AM CDT (4 PM to 5 PM CEST)

    See the webinar schedule in your time zone

    Register to join the webinar now

    What to Expect

    • Get to know Visual LANSA 16, its core features, latest enhancements, and use cases
    • Understand how you can transition to a MACH-aligned architecture to enable faster innovation
    • Discover native REST APIs, WebView2 support, cloud-ready Azure licensing, and more to help transform and scale your IBM i applications

    Read more about V16 here.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    Profound Logic Software:  Now On-Demand: Take IBM i EVERYWHERE With Mobile Apps!
    System i Developer:  Upgrade your skills at the RPG & DB2 Summit in Minneapolis, Oct 15-17.
    Abacus Solutions:  Qualified IBM i users eligible for free pair of running shoes

    More IT Jungle Resources:

    System i PTF Guide: Weekly PTF Updates
    IBM i Events Calendar: National Conferences, Local Events, and Webinars
    Breaking News: News Hot Off The Press
    TPM @ The Reg: More News From ITJ EIC Timothy Prickett Morgan

    Working Vacations On The Rise For Americans BlueFountain Delivers a Modern Looking WMS for IBM i

    Leave a Reply Cancel reply

Volume 13, Number 14 -- July 24, 2013
THIS ISSUE SPONSORED BY:

WorksRight Software
SEQUEL Software
ASNA

Table of Contents

  • Control The Flow Of Stored Procedure Result Sets
  • Value An Expression? *YES!
  • Automatically Answering IBM i Unable To Allocate Record Messages

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