Skip to content

Debugging Provider

Your RPG code can be debugged the same as it would for any batch job. The challenge is… how do you know the job number in order to start a service job?

One potential solution is to use the MDR_sendJobInfo() subprocedure shown earlier. When you use a tool like Postman or SoapUI to run your API, you’ll be able to look at the response headers to see the job info.

Adding cgi service job header to API response
dcl-pi *n;
  handle    like(MDR_Handle_t);
  method    char(32) const;
  body      varchar(500000); // MaxSize: 16000000
end-pi;

 ADD THIS 
MDR_sendJobInfo(handle: *ON);

Header from POSTMAN response Header from POSTMAN

Then you can use STRSRVJOB from any 5250 screen and then STRDBG

Warning

But there’s a problem!

You can’t see this until after the API has ended.

If you are the only one using the server, you could do STRSRVJOB and run it a second time, the job number won’t change.

If others are using the server, however, the job number might be different.

So alternatively use the Service Entry Point approach.

Debugging Using Service Entry Point

When you can’t predict the job name, we recommend using a Service Entry Point. Here’s are articles by Susan Gantner in IT Jungle describing the process of using a S.E.P.:

RDi: https://www.itjungle.com/2018/08/29/guru-three-little-words-that-simplify-debugging/

5250: https://www.itjungle.com/2012/10/03/fhg100312-story01/

Using these techniques, you can debug your REST API the same way you would debug any RPG program.