• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Prompt and Submit CL Commands

    May 19, 2010 Ted Holt

    I am a blessed man. Among the niceties of life that I enjoy are hot and cold running water, central heat and air conditioning, abundant food, and the CL command prompter. Many people are not so fortunate.

    The CL command prompter provides a functional way to pass properly formatted data to a program so the program can do what it was made to do. Developers who work on other systems can only dream of such a facility.

    To prompt a command from a CL command line is simple: type the command name and press F4. I doubt this is news to readers of this august publication. (An alternate method is to type a question mark before the command and press Enter. I never use it.)

    You can also prompt a CL command from a menu or from a program that is running interactively. Just put a question mark before the command name. Here the Display Object Description (DSPOBJD) command is prompted.

    ?DSPOBJD
    

    You can restrict the permissible data entry by prefixing parameter keywords with certain two-character codes. In the following example, Display Object Description is again prompted, but this time, the OUTPUT parameter is loaded with a value of *PRINT and the user cannot change this value.

    ? DSPOBJD ?*OUTPUT(*PRINT)
    

    To see a table of the prefixes and their meanings, visit the IBM i 7.1 Infocenter.

    If you use CL prompting in a program, be sure to monitor for message CPF6801–Command prompting ended when user pressed &1. The system sends this message to the program if the operation presses F3 or F12 to cancel the command prompt. The &1 substitution parameter tells you which of the two function keys the user pressed.

    If the user presses Enter or F16, the command begins to run–interactively. If the command runs quickly to completion, running interactively is no big deal. But if the prompt must run for an extended time, it really should be submitted to a job queue so that it will run in batch mode. Fortunately, it is not difficult to submit a prompted CL command to batch. Use the Process Commands API, QCAPCMD, to prompt and create a command string, and the Submit Job (SBMJOB) command to run the command string in batch.

    pgm
    
     dcl  &Cmd          *char  1024
     dcl  &CmdLen       *int      4   value(1024)
     dcl  &Options      *char    20
     dcl  &OptionsLen   *int      4   value(20)
     dcl  &Options      *char    20
     dcl  &NewCmd       *char  1024
     dcl  &NewCmdLenA   *int      4   value(1024)
     dcl  &NewCmdLenC   *int      4   value(1024)
    
     chgvar  %sst(&Options  1 4) value(x'00000001')
     chgvar  %sst(&Options  5 1) value('0')
     chgvar  %sst(&Options  6 1) value('1')
     chgvar  %sst(&Options  7 1) value('0')
     chgvar  %sst(&Options 12 4) value(x'00000000')
     chgvar  %sst(&Options 16 5) value(x'0000000000')
     chgvar  &Cmd     value('DSPOBJD')
    
     call    qcapcmd   parm(&Cmd &CmdLen &Options &OptionsLen +
                       'CPOP0100' &NewCmd &NewCmdLenA &NewCmdLenC +
                       x'00000000')
     monmsg  cpf6801  exec(return)
     sbmjob  job(ted) rqsdta(&NewCmd) jobq(nomax)
    
    endpgm
    

    In this example, the command to be prompted, DSPOBJD, is loaded into &Cmd. QCAPCMD prompts the command, the user fills in the blanks, and the revised command comes back in &NewCmd, which is then sent to batch through the Request Data (RQSDTA) parameter.

    One nice thing about this technique is that it eliminates the need to write display files solely for the purpose of collecting data before submitting to batch. Also, while I’ve used one of IBM’s commands as an example, I have found this technique much more useful with commands of my own, especially commands that run application programs.

    RELATED RESOURCES

    QCAPCMD API

    Using selective prompting for CL commands

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Maxava

    Migrate IBM i with Confidence

    Tired of costly and risky migrations? Maxava Migrate Live minimizes disruption with seamless transitions. Upgrading to Power10 or cloud hosted system, Maxava has you covered!

    Learn More

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    PowerTech:  Download your free copy of the updated 2010 The State of IBM i Security today! inFORM Decisions:  Paperless saves $$$. Learn more and get FREE white papers. looksoftware:  re:new Webinar - June 8 at 10 a.m. (GMT) & June 9 at 2 p.m. (EDT)

    IT Jungle Store Top Book Picks

    Easy Steps to Internet Programming for AS/400, iSeries, and System i: List Price, $49.95
    The iSeries Express Web Implementer's Guide: List Price, $49.95
    The System i RPG & RPG IV Tutorial and Lab Exercises: List Price, $59.95
    The System i Pocket RPG & RPG IV Guide: List Price, $69.95
    The iSeries Pocket Database Guide: List Price, $59.00
    The iSeries Pocket SQL Guide: List Price, $59.00
    The iSeries Pocket Query Guide: List Price, $49.00
    The iSeries Pocket WebFacing Primer: List Price, $39.00
    Migrating to WebSphere Express for iSeries: List Price, $49.00
    Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
    Getting Started with WebSphere Express for iSeries: List Price, $49.00
    Can the AS/400 Survive IBM?: List Price, $49.00
    Chip Wars: List Price, $29.95

    IBS Fights ‘iSeries Perception,’ Steps Closer to Microsoft Power7 Blades Plus i Versus X64 Blades Plus Windows

    Leave a Reply Cancel reply

Volume 10, Number 16 -- May 19, 2010
THIS ISSUE SPONSORED BY:

WorksRight Software
Profound Logic Software
Botz & Associates, Inc.

Table of Contents

  • Low Risk Authority Changes
  • Prompt and Submit CL Commands
  • Admin Alert: CBU Product License Keys Can and Will Suddenly Expire

Content archive

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

Recent Posts

  • Public Preview For Watson Code Assistant for i Available Soon
  • COMMON Youth Movement Continues at POWERUp 2025
  • IBM Preserves Memory Investments Across Power10 And Power11
  • Eradani Uses AI For New EDI And API Service
  • Picking Apart IBM’s $150 Billion In US Manufacturing And R&D
  • FAX/400 And CICS For i Are Dead. What Will IBM Kill Next?
  • Fresche Overhauls X-Analysis With Web UI, AI Smarts
  • Is It Time To Add The Rust Programming Language To IBM i?
  • Is IBM Going To Raise Prices On Power10 Expert Care?
  • IBM i PTF Guide, Volume 27, Number 20

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