If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
1 - Create a physical file, with a 1000 long one-field record.
2 - Put a trigger on the file (ADDPFTRG), for Trigger Time *AFTER Trigger Event *INSERT.
3 - In your trigger program interrogate the 1000 long string for commands and parameters and call whatever programs you want, then delete the record.
4 - In C#, insert the command into the file using ODBC.
I like this method, because it saves C# coding; It limits the functions that can be executed; It doesn't need a password as long as ODBC is running. Also I really hate Visual Studio.
I think the easiest way to call an RPG-program from whatever environment is to register the RPG program as external stored procedure and call it through the SQL-Command CALL.
That depends. What kinds of interface does the program have? what are it's parms? Are you expecting anything in return from the program? All of these effect the solution you should use.
"Time passes, but sometimes it beats the <crap> out of you as it goes."
Hi,
here you have the C# Source(1) and the RGP Source(2)
Best regrads Axel Arnold Bangert - Herzogenrath 2011
__________________________________________________ _____________ (1)
using System;
using System.Collections.Generic;
using System.Text;
using cwbx;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string result = string.Empty;
StringConverter stringConverter = new StringConverter();
AS400System system = new AS400System();
system.Define("AS400");
system.UserID = "XXXXXX";
system.Password = "yyyyyyyyyyy";
system.IPAddress = "62.176.136.104";
system.Connect(cwbcoServiceEnum.cwbcoServiceRemote Cmd);
if (system.IsConnected(cwbcoServiceEnum.cwbcoServiceR emoteCmd) == 1)
{
cwbx.Program program = new cwbx.Program();
program.LibraryName = "XXXXXXX";
program.ProgramName = "BA2_TE_RPG";
program.system = system;
string param = "Beispiel";
int paramLength = 15;
ProgramParameters parameters = new ProgramParameters();
parameters.Append("in", cwbrcParameterTypeEnum.cwbrcInout, paramLength);
parameters.Append("out", cwbrcParameterTypeEnum.cwbrcInout, paramLength);
parameters["in"].Value = stringConverter.ToBytes(param.PadRight(paramLength , ' '));
try
{
program.Call(parameters);
}
catch (Exception ex)
{
if (system.Errors.Count > 0)
{
foreach (cwbx.Error error in system.Errors)
{
Console.WriteLine("System= " + error.Text);
Console.WriteLine(ex);
}
}
if (program.Errors.Count > 0)
{
foreach (cwbx.Error error in program.Errors)
{
Console.WriteLine("Program= " + error.Text);
}
}
}
result = stringConverter.FromBytes(parameters["in"].Value) + " = " + stringConverter.FromBytes(parameters["out"].Value);
}
system.Disconnect(cwbcoServiceEnum.cwbcoServiceAll );
Console.WriteLine(result);
Console.ReadKey();
}
}
}
__________________________________________________ ___________________ (2)
Comment