Re: SQLRPGLE CGI Program with Minimal Stack

Martijn van Breden <m.vanbreden-FA3Mb2GlndWL1xShJLHXDbmx5lbCioqB8/[email protected]> Tue, 16 Jun 2026 06:39:35 +0000
Newsgroups gmane.comp.lang.as400.rpg
Message-ID <AM7P194MB080476C8B5B5ECB42DF88D7DC6E52@AM7P194MB0804.EURP194.PROD.OUTLOOK.COM>
Hi Richard,

You have to look at the CGI conversion mode (CGI_MODE) of the Apache HTTP s=
erver with values like %%BINARY%% or %%MIXED%%. That determines the convers=
ion of data from the outside world to your CGI program. It works in harmony=
 with the DefaultNetCCSID and CGIJobCCSID keyword.

We've struggled with that in the past and then decided to send unicode data=
 to our home grown browser front end as hexadecimal data and convert it bac=
k to unicode in te browser. That workaround won't be an option for you.

This mode has an effect on the ap=EF's you can use in you CGI program to re=
ad StdIn (for method POST)  or QUERY_STRING EnvVar (for GET)



Kind regards,

Martijn van Breden

lead software architect






Hi All,

I=92m working on doing a sample minimalist CGI Web API program that uses no=
 external API stack other than what the OS provides along with SQL in an RP=
GLE program.

I essentially want to see what a lightweight RPG CGI REST architecture migh=
t be in today=92s arena.

I know there are frameworks like IWS, HTTPAPI, YAJL and NOXDB, CGIDEV2 etc =
that can be used as helpers.

I also know I can use Python, PHP, Node, Java etc. I want this ONLY to be S=
QLRPGLE.

This is a POC to see if I can do a minimalist approach to CGI. And even AI =
keeps screwing things up as far as appropriate API definitions and data con=
version :-)

The biggest issue is handling the UTF-8 data conversion.

Also for context it=92s been a few years since I=92ve worked much with RPGL=
E and CGI. And I=92m going all in on SQLRPGLE and JSON_TABLE/JSON_OBJECT wi=
th this sample.

Basically I want to:
-Take in a posted JSON packet. (Works)
-Read the request data QtmhRdStdIn. (Works but it appears to be raw UTF-8 d=
ata. I think)
-Convert and review the URL data and JSON and convert it to something reada=
ble in RPGLE as it appears to be coming in as UTF-8.
-Run an SQL using JSON values extracted from the JSON request using JSON_TA=
BLE.
-Run the SQL query.
-Turn around and output the results as JSON

My only real stumbling block is converting the incoming and outgoing data c=
orrectly from and back to UTF-8. And that may also be an Apache configurati=
on issue as far as character conversion.  ICONV may be part of the answer b=
ut even AI comes up with long answers that didn=92t seem to work as I had t=
o use the 80/20 where it gave me 80% and I had to punt on the 20%.

Anyway, any insights relevant to the constraints I laid out are appreciated=
 in case anyone else has already been there when playing with SQLRPGLE, CGI=
 and JSON.

Regards,
Richard Schoen
Web: http://www.richardschoen.net
Email: richard-DiTrGpQEJGItADg8e/3/[email protected]

--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org for any subscription related qu=
estions.

-- =

This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org for any subscription related qu=
estions.