Running Multiple AS/400 commands in one statement - IBM AS400

This is a discussion on Running Multiple AS/400 commands in one statement - IBM AS400 ; I am trying to add a query to the job scheduler and it needs to run two queries. I setup the job using the following command: RUNQRY QRY(LIB/QUERY1) how do I change it to RUNQRY QRY(LIB/QUERY1) and RUNQRY QRY(LIB/QUERY2) is ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Running Multiple AS/400 commands in one statement

  1. Running Multiple AS/400 commands in one statement

    I am trying to add a query to the job scheduler and it needs to run
    two queries. I setup the job using the following command:

    RUNQRY QRY(LIB/QUERY1)

    how do I change it to

    RUNQRY QRY(LIB/QUERY1) and RUNQRY QRY(LIB/QUERY2)

    is there a way to seperate them i tried commas, semi colon, etc but
    nothing seems to work. is there not a way to run multiple commands in
    one statement?

  2. Re: Running Multiple AS/400 commands in one statement

    On Aug 20, 9:44*am, lcollin...@hotmail.com wrote:
    > I am trying to add a query to the job scheduler and it needs to run
    > two queries. *I setup the job using the following command:
    >
    > RUNQRY QRY(LIB/QUERY1)
    >
    > how do I change it to
    >
    > RUNQRY QRY(LIB/QUERY1) and RUNQRY QRY(LIB/QUERY2)
    >
    > is there a way to seperate them i tried commas, semi colon, etc but
    > nothing seems to work. *is there not a way to run multiple commands in
    > one statement?


    You would have to create a seperate job entry or have 1 job entry to
    call a program which will hold the 2 runqry statements.


  3. Re: Running Multiple AS/400 commands in one statement

    Nope. The CMD parameter of the ADDJOBSCDE only takes a single item.
    But, the name "CMD" is a little misleading. It will accept either an
    actual IBM command, like RUNQRY, or it will take a call to a program,
    like CALL PGM(RUNTWOQRYS) So all you need to do is create and compile
    a CL program with the two RUNQRY commands from your original posting.
    Then use that program in your job schedule entry and you will be good
    to go.


    On Aug 20, 9:44 am, lcollin...@hotmail.com wrote:
    > I am trying to add a query to the job scheduler and it needs to run
    > two queries. I setup the job using the following command:
    >
    > RUNQRY QRY(LIB/QUERY1)
    >
    > how do I change it to
    >
    > RUNQRY QRY(LIB/QUERY1) and RUNQRY QRY(LIB/QUERY2)
    >
    > is there a way to seperate them i tried commas, semi colon, etc but
    > nothing seems to work. is there not a way to run multiple commands in
    > one statement?



  4. Re: Running Multiple AS/400 commands in one statement

    MrDolomite.wiki@gmail.com wrote:
    > Nope. The CMD parameter of the ADDJOBSCDE only takes a single item.
    > But, the name "CMD" is a little misleading. It will accept either an
    > actual IBM command, like RUNQRY, or it will take a call to a program,
    > like CALL PGM(RUNTWOQRYS) So all you need to do is create and compile
    > a CL program with the two RUNQRY commands from your original posting.
    > Then use that program in your job schedule entry and you will be good
    > to go.
    >
    >
    > On Aug 20, 9:44 am, lcollin...@hotmail.com wrote:
    >> I am trying to add a query to the job scheduler and it needs to run
    >> two queries. I setup the job using the following command:
    >>
    >> RUNQRY QRY(LIB/QUERY1)
    >>
    >> how do I change it to
    >>
    >> RUNQRY QRY(LIB/QUERY1) and RUNQRY QRY(LIB/QUERY2)
    >>
    >> is there a way to seperate them i tried commas, semi colon, etc but
    >> nothing seems to work. is there not a way to run multiple commands in
    >> one statement?

    >


    Note that CALL is also "an actual IBM command"
    ===> DSPOBJD OBJ(QSYS/CALL) OBJTYPE(*CMD) DETAIL(*SERVICE)
    Licensed program . . . . . . . . . . : 5761SS1 V6R1M0

    Another option for grouping commands is SBMDBJOB, but that would run the
    commands in a different (batch) job. A CL program also provides
    capabilities like better error handling, etc.

    --
    Karl Hanson


  5. Re: Running Multiple AS/400 commands in one statement

    lcollinsfl@hotmail.com wrote:
    > I am trying to add a query to the job scheduler and it needs to run
    > two queries. I setup the job using the following command:
    >
    > RUNQRY QRY(LIB/QUERY1)
    >
    > how do I change it to
    >
    > RUNQRY QRY(LIB/QUERY1) and RUNQRY QRY(LIB/QUERY2)
    >
    > is there a way to seperate them i tried commas, semi colon, etc but
    > nothing seems to work. is there not a way to run multiple commands
    > in one statement?


    I believe that QSHell may be the easiest way to issue the two
    separate requests via just one request to the QSH command requested as
    the one CMD() for the scheduled task on ADDJOBSCDE. Refer to the
    utility named 'system' which enables a "Run CL command" function.
    http://publib.boulder.ibm.com/infoce...zahz/rzahz.pdf

    Something like the following for example may suffice; not tested, nor
    syntax verified:

    QSH CMD('system -nqvsK "RUNQRY LIB/QRY1"; system -nqvsK "RUNQRY
    LIB/QRY2";')

    Command list activity can be more sophisticated than what the
    semicolon provides, but the ';' character provides serial and
    synchronous requests.

    If that were not an option, e.g. if the option giving that feature is
    not available, then:

    I am not aware of any system-supplied CL command processor that takes
    a string of delimited commands as input from a parameter. The easiest
    program to write that could do so, would probably be a REXX program that
    assumes non-escaped semicolons as command delimiter. Then the STRREXPRC
    can be the command invocation used for the scheduled request, with the
    first parameter being parsed as the delimited command requests. The
    biggest issue is how to handle errors; typical for scheduled requests,
    ensuring dependencies are met across multiple requests.

    Neither of the following rexx sources are verified to be correct for
    syntax nor even functional. Nor have the sample STRREXPRC invocations
    [that follow each code sample] been tested. They should give an idea of
    how easy it can be; at least given command strings without apostrophes.


    /* rexx source: DoCmds */
    parse arg CmdLst

    address "*COMMAND"
    signal on error
    CmdNbr=0 /* CmdNbr assignments & .CmdNbr stems are optional */
    Do while CmdLst^=""
    CmdNbr=CmdNbr+1
    parse var CmdLst CmdStr.CmdNbr";"CmdLst
    CmdStr.CmdNbr /* pass request to *COMMAND */
    End
    exit
    error: say CmdStr.CmdNbr" failed."; exit 99


    strrexprc DoCmds parm('RUNQRY QRY(LIB/QUERY1); RUNQRY QRY(LIB/QUERY2)')


    /* rexx source: DoCmdsI */
    parse arg CmdLst /* valid REXX and/or CL requests */

    address "*COMMAND"
    signal on error
    interpret CmdLst /* interpret delimited requests */
    error: exit 99


    strrexprc DoCmdsI parm('"RUNQRY QRY(LIB/QUERY1)";"RUNQRY
    QRY(LIB/QUERY2)";')

    strrexprc DoCmdsI parm('Q1="QUERY1"; Q2="QUERY2"; "RUNQRY
    QRY(LIB/"Q1")";"RUNQRY QRY(LIB/"Q2")";')

    Regards, Chuck

  6. Re: Running Multiple AS/400 commands in one statement

    On Aug 20, 9:44*am, lcollin...@hotmail.com wrote:
    > I am trying to add a query to the job scheduler and it needs to run
    > two queries. *I setup the job using the following command:
    >
    > RUNQRY QRY(LIB/QUERY1)
    >
    > how do I change it to
    >
    > RUNQRY QRY(LIB/QUERY1) and RUNQRY QRY(LIB/QUERY2)
    >
    > is there a way to seperate them i tried commas, semi colon, etc but
    > nothing seems to work. *is there not a way to run multiple commands in
    > one statement?


    I would handle this with a single CL program
    basically, with 2 commands in the program
    SBMJOB CMD(RUNQRY.........)......

    Schedule the CL program, it will then spawn off the 2 queries to the
    jobq of your choice or the default queue. This accomplishes what you
    want, having the 2 queries run with a single job.

    Want more, email me

+ Reply to Thread