I'm working on a business application modernization project where I need to call existing AS400 programs (RPG, CLP ...) from a .NET 8 app.
These RPG programs have I/O parameters with complex Data Structures (DS) and I need to create/parse these DS from/to POCOs.
Our server is AS400 V7.4 on Power 9 but that doesn't really matter here.
Assume the DS empl below and a program EMPLPGM taking this DS as first parameter :
dcl-ds empl qualified;
name char(10) inz('Unknown');
salary packed(9 : 2) inz(0);
end-ds;
The corresponding POCO in .NET for this DS would be:
public class Employee {
public string Name {get; set;}
public decimal Salary {get; set;}
}
Now what I'd like to achieve is the following:
var empl = new Employee() {
Name = "Foo",
Salary = 50000.0M
};
//Calling program in a "dapper way"
//Does this exist or can be achieved ?
someClass.SomeMethodToCallProgram("EMPLPGM", new[] {P1 = empl});
Console.WriteLine(empl.Name); // I/O Parameter, output data is relevant
Is it something achievable or do we need to reconsider the project?
EDIT 1
As suggested I'm investigating direct call through the network. Here is a list of TCP/IP ports for the different services. Do anybody know if the Remote Command service can be used to call a program from a remote client over the network ? Any idea to find a documentation of the underlying protocol ?
EDIT 2
I came across a 3rd party solution called Aumerial nti. It seems to provide remote program call. Has anyone ever tested this ? I cannot see any feedback out there.
This snippet on their website here caught my attention:
//Open connection
var conn = new NTiConnection(connectionString);
conn.Open();
//Create parameter list:
List<NTiProgramParameter> parms = new List<NTiProgramParameter>() {
new NTiProgramParameter("Hello", 10).AsInput(), //CHAR(10) INPUT
new NTiProgramParameter("World", 10).AsInput(), //CHAR(10) INPUT
new NTiProgramParameter(new byte[] {0x00}).AsInput(), //CHAR(10) INPUT
new NTiProgramParameter(128).AsInput(), //INTEGER (BYTE(4)) INPUT
new NTiProgramParameter("", 128).AsOutput(), //CHAR(128) OUTPUT
new NTiProgramParameter("", 50) //CHAR(50) I/O
};
//Program call
conn.CallProgram("MYLIB", "MYPGM", parms);
//Data retrieval from return variable (parameter n°5)
string message1 = parms[4].GetString(0, 64);
string message2 = parms[4].GetString(64, 64);
//Closing the connection
conn.Close();
Looks like I have a good candidate to solve my issue here, waiting for an answer from the editor...
was looking for something more direct...well first you need to find out whether RPG programs on the AS400 can be invoked remotely over the network. Once you find out how that's done (assuming it's actually possible), then you can work out whether .NET can interact with that invocation protocol. So the .NET part of this question is still premature, I think. At a guess, maybe you can do something using SSH or similar. My knowledge of the AS400 is zero unfortunately - I saw this post because of the C# tag.