Turning RPG Display file program into an json API

Use this board for starting discussions, asking questions, and giving advice on Web programming for the IBM i platform (and predecessors.)
hcantor
New User
Posts: 1
Joined: Fri Aug 07, 2020 8:30 pm
First Name: Hugo
Last Name: Cantor
Company Name: Vitamin Shoppe
Contact:

Turning RPG Display file program into an json API

Post by hcantor »

Hi,
I'm trying out ProfoundUI and I'm experimenting on turning a Display file program into a json API. I noticed that an anonymous program will do an ajax call to http://xx.xx.xx.xx:8080/profoundui/PUI0001200.pgm. This program returns JSON with info on the record format, which is what I want. My question is... Is it advisable to send a request directly to PUI0001200? Is this program going to be deprecated in the near future or will it stick around for a good while?

-thanks
Hugo
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Turning RPG Display file program into an json API

Post by Scott Klement »

PUI0001200 (and also PUI0002110) will be around for the forseeable future. (Definitely not deprecated.)

But using them as a way to create REST APIs... hmm.. honestly, I'm struggling to even put my thoughts into words.

Most RPG programs were designed in a stateful, top-down, sort of paradigm. That's not to say that all were, but it is the norm. And you've stated that you want to read the displays, so you're basically asking for a program that thinks its stateful and interacting with a display to work nicely as a stateless program that doesn't have a display. In my opinion, this is simply not a good idea... but, again, that's based on an assumption that this is a traditional stateful program.

I guess my main question is: Why do you want to do this?

Why wouldn't you just take the relevant code, remove it from your old RPG interactive program, and put it into a new program that's designed to be called as an API? That would be 100 times more robust, and 1000 times easier to maintain in the future. And its super easy to do! Why would you want, instead, to create this mangled mess of scraping a display and converting the output into an API?

I guess if you have a crucial application that you don't have the source code for, maybe it'd make sense.
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests