SIMPLESRV - A simple SQL RPGLE Service Program
This is an IBM i RPG program - which will be compiled as an SQL RPGLE MODULE
The code is very simple and contains one procedure getsystemname.
This procedure will use SQL to retrieve the IBM i system name and put the 8 character value into the variable 'systemname'.
**free
ctl-opt nomain;
// procedure called 'getsystemname'
dcl-proc getsystemname export;
dcl-pi getsystemname;
systemname char(8);
end-pi;
exec sql
VALUES CURRENT SERVER INTO :systemname ;
return;
end-proc;
ctl-opt nomain;
// procedure called 'getsystemname'
dcl-proc getsystemname export;
dcl-pi getsystemname;
systemname char(8);
end-pi;
exec sql
VALUES CURRENT SERVER INTO :systemname ;
return;
end-proc;
You might evoke this service program from your code like this:
my_system_name = getsystemname();