bvstone

Debugging an RPG CGI Program

Posted:

Debugging an RPG CGI Program

Debugging a normal interactive program is pretty straightforward.  But, what if we want to debug a web program running our on IBM i (AS/400)?   These programs normally run under "Batch" jobs are are initiated from a web browser, not from us just calling the program from a command line.

The only real difference in debugging a web application is using the Start Service Program (STRSRVPGM) command to identify the job that we want to start debugging on.  But sometimes finding that job can be tricky

Method 1 - Start the HTTP Server with a Maximum of 1 Processing Job
If you have the option (for example, if you have a testing/development environment) you should be able to start the HTTP server so that only one job will be started that will be used to process the CGI Program requests.  This is done by adding a couple of keywords to the STRTCPSVR command as such:

STRTCPSVR SERVER(*HTTP) HTTPSVR(MYSERVER '-minat 1 -maxat 1')

These parameters tell the HTTP server to start a MINimum of 1 job and a MAXimum of 1 job.  This way we can find the single job, normally with a status of PGM-QZSRCGI, that we can use the STRSRVJOB command on.

Now, depending on our OS level, this may not always work.  If you're wondering why, ask IBM, not me.  I'm just the messenger.  But, if you do have issues you could try using the uiMin and uiMax paramters instead to see if that works.  While I've found these work fine when you have a very busy server and need to make sure you have enough jobs running to handle requests, specifying a min and max of 1 has mixed results.

Method 2 - Get Lucky
The second method, and one that I use when I need to, is the "Get Lucky" method by guessing which job to start a service on.  This can be by running a CGI program and watching the CPU for the jobs using WRKACTJOB to see which one is being used, or just guessing that it's most likely the 1st or 2nd job in the PGM-QZSRCGI status.  

Once you've determined which job you want to start a servicing in order to debug a CGI program, we can enter the appropriate job identifying data into the STRSRVJOB command.

One trick that I used, since it's never fun to try and remember all of those variables, is using the STRSRVJOB command from the command line while viewing the job properties.  So it goes something like this:

  1. User WRKACTJOB JOB(servername)
  2. Determine which job you want to service/debug
  3. Use option 5 next to that particular job.  You should see something like the following:
  4. Now, at the top of this display we we see the Job Name, User Name and Job Number.  If we just remember to enter these in reverse order, we can use the STRSRVJOB command quite easily from the command line provided.
     
    STRSRVJOB JOB(166814/QTMHTTP/PDOCWTEST)

     

Once this is complete it's as simple as issuing the Start Debug (STRDBG) command for the program in question and initiating the program from the browser.  When we get to the appropriate break points the job that we issued the STRSRVJOB command on should go into debug mode.


Last edited 01/18/2016 at 14:34:32



Latest Posts:

QuickBooks Online - Subtotals and Discounts Frustration QuickBooks Online - Subtotals and Discounts Frustration
Posted by March 16, 2023
QuickBooks >> QuickBooks Online
Making the Switch From QuickBooks Desktop to QuickBooks Online - No Picnic Making the Switch From QuickBooks Desktop to QuickBooks Online - No Picnic
Posted by March 16, 2023
QuickBooks >> QuickBooks Online
BVSTools Software Verified on V7R5 and Power10 BVSTools Software Verified on V7R5 and Power10
Posted by December 9, 2022
BVSTools >> BVSTools Announcements
Microsoft Office 365 Servers and Random Errors Issue Microsoft Office 365 Servers and Random Errors Issue
Posted by November 14, 2022
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
Sending/Resending Emails Using a MIME File with MAILTOOL Sending/Resending Emails Using a MIME File with MAILTOOL
Posted by November 8, 2022
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
Sending an HTML Email on Your IBM i Using MAILTOOL Sending an HTML Email on Your IBM i Using MAILTOOL
Posted by November 1, 2022
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
Transferring License Keys from One System to Another Transferring License Keys from One System to Another
Posted by October 31, 2022
BVSTools >> BVSTools Software Discussion
Calculating the Size of a File Before Base64 Encoding Calculating the Size of a File Before Base64 Encoding
Posted by August 13, 2022
Programming >> RPG Programming
GreenTools for Microsoft Apps (G4MS) v9.12 Now Includes Function to Send Emails using MIME File GreenTools for Microsoft Apps (G4MS) v9.12 Now Includes Function to Send Emails using MIME File
Posted by August 11, 2022
BVSTools >> BVSTools Announcements >> GreenTools for Microsoft Apps (G4MS) Specific Announcements
GreenTools for Google Apps (G4G) v15.20 Now Supports Shortcuts GreenTools for Google Apps (G4G) v15.20 Now Supports Shortcuts
Posted by August 6, 2022
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
GreenTools for Microsoft Apps (G4MS) Groups Admin Authority Instructions GreenTools for Microsoft Apps (G4MS) Groups Admin Authority Instructions
Posted by July 26, 2022
BVSTools >> BVSTools Software Discussion >> GreenTools for Microsoft Apps (G4MS) Specific Discussion
GreenTools for Microsoft Apps (G4MS) v9.10 Now Includes OneDrive Functions that Work With Groups/Shared Drives GreenTools for Microsoft Apps (G4MS) v9.10 Now Includes OneDrive Functions that Work With Groups/Shared Drives
Posted by July 19, 2022
BVSTools >> BVSTools Announcements >> GreenTools for Microsoft Apps (G4MS) Specific Announcements
GreenTools for Google Apps (G4G) v15.10 Now Includes Drive Functions that Work With Shared Drives GreenTools for Google Apps (G4G) v15.10 Now Includes Drive Functions that Work With Shared Drives
Posted by July 15, 2022
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
GreenTools for Microsoft Apps (G4MS) v9.00 Now Offers Functions to Bypass Registration Command and BVSTools Landing Page GreenTools for Microsoft Apps (G4MS) v9.00 Now Offers Functions to Bypass Registration Command and BVSTools Landing Page
Posted by July 4, 2022
BVSTools >> BVSTools Announcements >> GreenTools for Microsoft Apps (G4MS) Specific Announcements
What Objects Should I Omit from Replication to Ensure My License Keys Work on my HA/DR System? What Objects Should I Omit from Replication to Ensure My License Keys Work on my HA/DR System?
Posted by June 27, 2022
BVSTools >> BVSTools Software Discussion

Reply




© Copyright 1983-2020 BVSTools
GreenBoard(v3) Powered by the eRPG SDK, MAILTOOL Plus!, GreenTools for Google Apps, jQuery, jQuery UI, BlockUI, CKEditor and running on the IBM i (AKA AS/400, iSeries, System i).