As was already posted, you can use the QUSRJOBI API.
Check the QUSRJOBI copybook in QSYSINC/QCBLLESRC.

-----------------------------------------------------------------------
       identification division.
       program-id.    PC001R.
       author.        T. Winchester.
       date-written.  04/19/01.

     *---------------------------------------------------------------*
     * This program is an example of retrieving IP addresses in the  *
     * "dot" notation and launching a remote job (command) at a      *
     * workstation running Client Access on a TCP/IP network.        *
     *                                                               *
     * This could be used, for example, to launch WordPad, Excel,    *
     * or any other PC based Windoze applications.  In order to do   *
     * this, you must have the Client Access remote command daemon   *
     * running on the workstation.                                   *
     *                                                               *
     * In the NT/Win2000 world this runs as a service. In the Win95  *
     * and Win98 environments you must add CWBRXD to the STARTUP     *
     * group.  This is easily configured using the Client Access     *
     * Properties icon (see the Incomming Remote Command tab).       *
     *                                                               *
     * If everything is successful, then the desptop user will see   *
     * the WRITE program startup and there will be a QSYSPRT spool   *
     * created on the AS/400 indicating the PC command completed,    *
     * as follows:                                                   *
     *                                                               *
     *          "The remote command has produced no output."         *
     *                                                               *
     *---------------------------------------------------------------*
     *                                                               *
     * Guidelines to set up the remote command daemon on the PC can  *
     * be found at the Support Line Knowledge Base for Client Access *
     * at the following location.  Look under Client Access, Data    *
     * Access, Miscellaneous Functions (RUNRMTCMD) under the title   *
     *                                                               *
     *   "Initiating Data Transfers From an OS/400 Command Line      *
     *    Using Client Access Incoming Remote Command Service"       *
     *                                                               *
     * http://as400service.rochester.ibm.com/supporthome.nsf/        *
     * Document/10000051                                             *
     *                                                               *
     * Unwrap this direct link to take you right to it:              *
     *                                                               *
     * http://as400service.rochester.ibm.com/s_dir/slkbase.NSF       *
     * /515a7ef1f8deef8c8625680b00020380/26e8d8b78808bc4686256       *
     * 6ba00595402?OpenDocument                                      *
     *                                                               *
     *---------------------------------------------------------------*
       environment division.
       configuration section.
       input-output section.
       file-control.
     *----                                                     Printer
                   select ptofile    assign to printer-QPRINT.
       data division.
       file section.

       fd  ptofile.
       01  ptorecd.
           05  ptoline              pic  x(132).


       working-storage section.
     *---------------------------------------------------------------*
     *   Variables for the QUSRJOBI and QDCRDEVD system API's that   *
     *   retrieve the Internal Job-Id number and the IP address of   *
     *   the client currently signed onto the AS/400.                *
     *---------------------------------------------------------------*

       01  Qualified-Job-Name.
           05  Qual-JobName         pic  x(10)      value "*         ".
           05  Qual-UserId          pic  x(10)      value spaces.
           05  Qual-JobNbr          pic  x(06)      value spaces.
       01  Internal-Job-Identifier  pic  x(16)      value spaces.
       01  Format-Name              pic  x(08)      value spaces.
       01  Length-of-Receiver       pic s9(09)      value +0    binary.

     *---------------------------------------------------------------*
     *   Variables to hold the RUNRMTCMD and its length for QCMDEXC  *
     *   Note that the command string can be up to 1000 bytes long   *
     *   to compensate for those *long* directory paths :)           *
     *---------------------------------------------------------------*

       01  RunRmtCmd-Command        pic  x(256)     value spaces.
       01  RunRmtCmd-Length         pic s9(10)v9(5) value +0    comp-3.

     *---------------------------------------------------------------*
     * Note:  The following fields should be enclosed using single   *
     *        quotes in order for WinNT/Win2K to recognize them.     *
     *        Unfortunately, this only allows 8 character user-id's  *
     *        and passwords to be used on the PC side of the house   *
     *        since the RUNRMTCMD only permits 10 characters <sigh>. *
     *---------------------------------------------------------------*

       01  PC-User-Id               pic  x(10)      value "'userid  '".
       01  PC-Password              pic  x(10)      value "'password'".

     *---------------------------------------------------------------*
     * The following is an error code return data structure for APIs *
     *---------------------------------------------------------------*

                     copy qusec    of qsysinc-qcbllesrc.
           05  Exception-Data                      pic  x(00100).

     *---------------------------------------------------------------*
     *    Protoype for calling Retrieve Device Desc API QDCRDEVD     *
     *---------------------------------------------------------------*

                     copy qdcrdevd of qsysinc-qcbllesrc.

     *---------------------------------------------------------------*
     *   Protoype for calling Retrieve Job Information API QUSRJOBI  *
     *---------------------------------------------------------------*

                     copy qusrjobi of qsysinc-qcbllesrc.


       procedure division.
       000-main section.
       000-begin.

           open output ptofile.
     *----                                                Set-Up Parms
     *----                                                for QUSRJOBI
           move "JOBI0100"               to Format-Name.
           move length of QWC-JOBI0100   to Length-of-Receiver.
     *----                                            Get the Internal
     *----                                              Job-Id Number
           call "QUSRJOBI" using QWC-JOBI0100
                                 Length-of-Receiver
                                 Format-Name
                                 Qualified-Job-Name
                                 Internal-Job-Identifier
                                 QUS-EC.
     *----                                                      Error?
           if EXCEPTION-ID not = spaces
               move spaces               to ptoline
               move "02 QUSRJOBI error=" to ptoline (1:20)
               move EXCEPTION-ID         to ptoline (21:)
               write ptorecd after advancing 1 line
               go to 990goback
           end-if.
     *----                                                Set-up Parms
     *----                                                for QDCRDEVD
           move length of QDC-DEVD0600   to Length-of-Receiver.
           move "DEVD0600"               to Format-Name.
     *----                                             Get Device Info
     *----                                            (TCP/IP address)
           call "QDCRDEVD" using QDC-DEVD0600
                                 Length-of-Receiver
                                 Format-Name
                                 JOB-NAME of QWC-JOBI0100
                                 QUS-EC.
     *----                                                      Error?
           if EXCEPTION-ID not = spaces
               move spaces               to ptoline
               move "02 QDCRDEVD error=" to ptoline (1:20)
               move EXCEPTION-ID         to ptoline (21:)
               write ptorecd after advancing 1 line
               go to 990goback
           end-if.

     *---------------------------------------------------------------*
     * Build the RUNRMTCMD string in a character string. The TCP/IP  *
     * dotted address must NOT contain embedded spaces. To check the *
     * CCSID of the PC, open a DOS window and type CHCP. This will   *
     * provide the correct code-page number.                         *
     *---------------------------------------------------------------*

           string "RUNRMTCMD CMD('C:\WINNT\system32\write.exe')"
                                     delimited by size
                  " RMTLOCNAME('"    delimited by size
                  NETWORK-IP-ADDRESS-DOTTED-FMT of QDC-DEVD0600
                                     delimited by spaces
                  "' *IP) RMTUSER("  delimited by size
                  PC-User-Id         delimited by spaces
                  ") RMTPWD("        delimited by size
                  PC-Password        delimited by spaces
                  ") CCSID(437)"     delimited by size
                                     into RunRmtCmd-Command
           end-string.
     *----                                               Set-up length
     *----                                                for QCMDEXC
           move length of RunRmtCmd-Command to RunRmtCmd-Length.
     *----                                                    Execute
     *----                                                   RUNRMTCMD
           call "QCMDEXC" using RunRmtCmd-Command
                                RunRmtCmd-Length.

           close ptofile.

       990goback.

           goback.

       end program PC001R.
--------------------------------------------------------------------------

Terry


> -----Original Message-----
> From: Cesar Altamirano [mailto:cesaralt@viabcp.com]
> Sent: Wednesday, November 20, 2002 10:10 PM
> To: COBOL AS/400
> Subject: Job Parameters
>
>
> Hi,
> Is there any way or structure inside a COBOL program,
> to obtain the Job Name, User Name, Job Number, etc.
> like the SDS structure of an RPG program?
> I need to invoke a CL program from COBOL
> passing this parameters.
>
> Thanks for any Help.
> Regards,
> Caesar A.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.