Debugging Batch Programs Through the WORK Command

To debug batch programs through the WORK command, use the following steps:

To debug batch programs through the WORK command

  1. If LAWENV is not called as part of your user profile’s sign-on program, you must call the LAWENV program to set the environment variables correctly.
    1. If you installed Lawson Core Technology on an IASP, at the IBM i command prompt, type

      SETASPGRP IASPName

    2. At the IBM i command line, type

      CALL LAWENV

    3. Type the name of an Environment and press Enter.
  2. Compile the program you want to debug. At the Qshell command line, type

    qcompile -D productline systemcode programcode

    Note: If you need to include modules in the compile, use qcompile -Dm productline systemcode programcode .
  3. Submit the program to a job queue that is on hold or is not tied to a subsystem (so that the batch job does not execute).
  4. Access the job for the batch program.
    1. At the IBM i command line, type

      WORK Subsystem

      where Subsystem is the same subsystem under which you compiled the program and under which you will be running the program. After you enter this command, the "Work Subsystem Jobs" screen appears.

    2. On the "Work Subsystem Jobs" screen, locate any job for which you are the user and type O (for Other Jobs) by the job. The "Work My Other Jobs" screen appears.
    3. Locate the job for the batch program you had submitted.
  5. Start debug on the appropriate program.
    1. On the "Work My Other Jobs" screen, type S by the appropriate job.

      The options available on the "Work My Other Jobs" screen include:

      Option Name Description
      4 End Will prompt ENDJOB.
      5 Work with Will work or display job if user has authority.
      S STRSRVJOB Will prompt to start debug on a program (STRSRVJOB, then STRDBG). It will also allow the job to be moved to another job queue. STRDBG is executed with UPDPROD(*YES) and OPMSRC(*YES).
    2. Enter the name of the program to be debugged. Move the batch job to an active job queue (one not on hold or one in a subsystem) by entering the appropriate job queue name.
  6. When the source listing appears, press F12.
  7. When the ILE debugger displays the following message: "The serviced job has been released from the job queue. Press Enter to start the job or F10 to enter debug commands for that job," press F10.
  8. Enter debug commands.
    1. At the IBM i command line, type

      DSPMODSRC

      (If you did not compile with *LIST, you will receive a "Source not available" message. This is normal.)

    2. Set break points. (Position the cursor on the line where you a break point and then press F6 to set the break point.)
  9. Press F12 twice and then press Enter to run the program.
  10. When you are finished debugging the session, be sure to end debug and end the service job. On the "Work Subsystem Jobs" screen, press F15 to execute the ENDDBG and ENDSRVJOB commands. (You may need to reply to a "Job being serviced ended" message.)