• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Submit a Prompted Command to Batch

    August 31, 2005 Hey, Ted

    If I put a question mark before a command name in a CL program and run the program interactively, the system prompts the command, allows me to fill in the blanks, and then executes the command. Is there a way to prompt the command, then send it to batch for execution?

    –Mark

    Yes, there’s an API for this sort of thing. First, here’s the type of code you’re running interactively.

    ? SAVOBJ
    MONMSG     MSGID(CPF6801) EXEC(RETURN)
    

    The system prompts the Save Object (SAVOBJ) command. If the user presses Enter, the system runs the command. However, if the user presses F3 or F12 to cancel the prompt, the Monitor Message command takes over.

    If you want the command to run in batch, you need the QCMDCHK API. It is like the QCMDEXC API most of us are very familiar with in that it accepts the same parameters.

    Here’s an example that prompts a Save Object command and submits it to batch.

    DCL        VAR(&CMD) TYPE(*CHAR) LEN(1024)
    DCL        VAR(&CMDLEN) TYPE(*DEC) LEN(15 5) VALUE(1024)
    
    CHGVAR     VAR(&CMD) VALUE('?SAVOBJ')
    CALL       PGM(QCMDCHK) PARM(&CMD &CMDLEN)
    MONMSG     MSGID(CPF6801) EXEC(RETURN)
    
    SBMJOB     RQSDTA(&CMD)
    SNDPGMMSG  MSG('Your command was submitted to batch.') +
               MSGTYPE(*COMP)
    

    The &CMD variable is initialized to a prompted SAVOBJ command. Calling QCMDCHK causes the system to prompt the command and change the value of &CMD as modified by the user from the prompt screen.

    After QCMDCHK runs, use Submit Job (SBMJOB) to start a batch job. Notice that the command is passed through the Request Data (RQSDTA) parameter, not the Command (CMD) parameter.

    –Ted


    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    FalconStor

    Begin Your Journey to the Cloud with Hybrid Cloud Date Protection and Disaster Recovery

    FalconStor StorSafe optimizes and modernizes your IBM i on-premises and in the IBM Power Virtual Server Cloud

    FalconStor powers secure and encrypted IBM i backups on-premise and now, working with IBM, powers migration to the IBM PowerVS cloud and on-going backup to IBM cloud object storage.

    Now you can use the IBM PowerVS Cloud as your secure offsite copy and take advantage of a hybrid cloud architecture or you can migrate workloads – test & development or even production apps – to the Power VS Cloud with secure cloud-native backup, powered by FalconStor and proven IBM partners.

    Learn More

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    DataMystic Provides iSeries Data Transformation Services Valid Tech Delivers Biometric Authentication Solution for OS/400

    Leave a Reply Cancel reply

Volume 5, Number 33 -- August 31, 2005
THIS ISSUE
SPONSORED BY:

T.L. Ashford
Advanced Systems Concepts
COMMON

Table of Contents

  • Let’s See Those Command Parameters
  • Submit a Prompted Command to Batch
  • Admin Alert: Changing Your Mind When Loading Group PTFs

Content archive

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

Recent Posts

  • With Power11, Power Systems “Go To Eleven”
  • With Subscription Price, IBM i P20 And P30 Tiers Get Bigger Bundles
  • Izzi Buys CNX, Eyes Valence Port To System Z
  • IBM i Shops “Attacking” Security Concerns, Study Shows
  • IBM i PTF Guide, Volume 27, Number 26
  • 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

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