• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Optional Parameters and CL Procedures

    August 11, 2004 Hey, Ted

    In “Adding New Parameters to RPG Programs,” you stated that CL programs require that the exact number of expected parameters be passed to them. That’s not entirely true.

    If you use ILE CL (source type CLLE), you do not have to pass in the same number of parameters as expected. You can use the same technique you described in the RPG example. You would assign the parameter to the work field with CHGVAR, but monitor the assignment for message MCH3601 (“pointer not set for location referenced”). If that message is sent, you assign the default value to the work field.

    PGM        PARM(&OPTION_P &COPIES_P)
    
    DCL        VAR(&OPTION_P) TYPE(*CHAR) LEN(1)
    DCL        VAR(&COPIES_P) TYPE(*DEC) LEN(1)
    
    DCL        VAR(&OPTION) TYPE(*CHAR) LEN(1)
    DCL        VAR(&COPIES) TYPE(*DEC) LEN(1)
    
    CHGVAR     VAR(&OPTION) VALUE(&OPTION_P)
    MONMSG     MSGID(MCH3601) +
                 EXEC(CHGVAR VAR(&OPTION) VALUE(A))
    CHGVAR     VAR(&COPIES) VALUE(&COPIES_P)
    MONMSG     MSGID(MCH3601) +
                 EXEC(CHGVAR VAR(&COPIES) VALUE(1))
    

    Thanks for listening.

    –Doug

    Thanks for writing, Doug. And thanks to the other readers who corrected me as well. My comment applied only to OPM CL, which I am currently using. I haven’t done a formal study, but it seems that many iSeries shops use RPG IV along with OPM CL. One comment I’ve heard several times is that OPM supports the Retrieve CL Source (RTVCLSRC) command but ILE CL doesn’t. All I can say is that I have probably retrieved CL source code from a program object less than half a dozen times since 1988, when I first touched a System/38. Given a choice between being able to retrieve source code from the program object and being able to pass fewer than the number of defined parameters, I’d much rather have the latter ability. This seems to me an excellent reason to dump OPM CL, as many have dumped RPG III (A.K.A. RPG/400).

    Monitoring for MCH3601 has another purpose. You will need to monitor for MCH3601 if you write your own RTV-type commands. IBM‘s RTV commands, such as Retrieve Job Attributes (RTVJOBA) and Retrieve User Profile (RTVUSRPRF), can return a lot of different data, but require you to code only the parameters that interest you. If you write a CL program that processes an RTV-type command, you’ll need to monitor for MCH3601 for optional parameters.

     PGM        PARM(&OPTION &TEXT)
    
     DCL        VAR(&OPTION) TYPE(*CHAR) LEN(1)
     DCL        VAR(&TEXT) TYPE(*CHAR) LEN(50)
    
     CHGVAR     VAR(&OPTION) VALUE(whatever...)
     MONMSG     MSGID(MCH3601)
    
     CHGVAR     VAR(&TEXT) VALUE(whatever...)
     MONMSG     MSGID(MCH3601)
    

    –Ted

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Midrange Dynamics North America

    Want to deliver DevOps on IBM i?

    DevOps enables your IBM i development teams to shorten the software development lifecycle while delivering features, fixes, and frequent updates that are closely aligned with business objectives. Flexible configuration options within MDChange make it easy to adapt to new workflow strategies and policies as you adopt DevOps practices across your organization.

    Learn More.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Califon Systems Ships New Release of OS/400 Security Module Fast400 Founder Sues Big Blue

    One thought on “Optional Parameters and CL Procedures”

    • pankratz2013 says:
      August 13, 2022 at 10:19 am

      18 years later, this post shows up first in my search results. So congratulations on that.
      Looking into the CLLE documentation, the solution for optional CLLE parameters is the %parms() function.
      See https://www.ibm.com/docs/en/i/7.4?topic=procedure-parms-built-in-function

      Reply

    Leave a Reply Cancel reply

Volume 4, Number 27 -- August 11, 2004
THIS ISSUE
SPONSORED BY:

T.L. Ashford
WorksRight Software
Damon Technologies

Table of Contents

  • Listing Spool Files
  • Optional Parameters and CL Procedures
  • Control Break Programs, Version 3

Content archive

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

Recent Posts

  • The Power11 Transistor Count Discrepancies Explained – Sort Of
  • Is Your IBM i HA/DR Actually Tested – Or Just Installed?
  • Big Blue Delivers IBM i Customer Requests In ACS Update
  • New DbToo SDK Hooks RPG And Db2 For i To External Services
  • IBM i PTF Guide, Volume 27, Number 33
  • Tool Aims To Streamline Git Integration For Old School IBM i Devs
  • IBM To Add Full System Replication And FlashCopy To PowerHA
  • Guru: Decoding Base64 ASCII
  • The Price Tweaking Continues For Power Systems
  • IBM i PTF Guide, Volume 27, Numbers 31 And 32

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