AS400 Debug Batch Programs

, ,

To debug batch programs through command-line entry, use the following steps:

To debug batch programs through command-line entry

  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. At the IBM i command line, type
      CALL LAWENV
    2. Type the name of an Environment and press Enter.
  1. 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 .

  1. 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).
  2. Start a service job for the program.
    1. Get the job information by typing at the IBM i command line,
      WRKJOBQ QueueName
      where QueueName is the job queue to which you submitted the batch program.Select option 5 (Work with) for the job queue and then write down the job, user, and job number information for the appropriate job.Note: You can also use the WRKUSRJOB command to find the job information, but this may yield a much longer list of jobs to view in order to find the one you need.
    2. At the IBM i command line, type:
      STRSRVJOB JobNumber/UserName/JobName
  1. Start debug. At the command line, type STRDBGand prompt it (F4). Make sure the library is the one where you compiled the source and that UPDPROD(*YES) is set. If the information is correct, press Enter.
  2. When source listing appears, press F12to resume.
  3. Start the batch program by changing the job to run in an active queue. On the “Work with Job Queue” screen, enter 2(Change) to change the job queue for the job. After typing in the job queue name, press Enter.The ILE debugger will display the “Start Serviced Job” screen with 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.”
  4. Press F10and then at the IBM i command line, type:DSPMODSRC
  1. Set break points (F6), then press F12, and then press F3 to return to the “Start Serviced Job” screen.
  2. Press Enterto run the program.
  3. After finished with debugging, end debug and the service job. At the IBM i command line, type:
    ENDDBG
    thenENDSRVJOB