Using the OpenAPI with Dynamic Prodatasets

Posted by Admin on 31-Jan-2007 16:47

Hello,

I have a C# procedure that calls a ABL procedure on the Appserver. The ABL procedure builds a dynamic dataset based upon the INPUT parameters it is provided. The parameters of the ABL procedure (named CI_PASS3) are as follows:

DEFINE INPUT-OUTPUT PARAMETER DATASET-HANDLE DataSet_1.

DEFINE INPUT PARAMETER src AS CHARACTER NO-UNDO.

DEFINE INPUT PARAMETER fld AS CHARACTER NO-UNDO.

DEFINE INPUT PARAMETER cond AS CHARACTER NO-UNDO.

In C#, if I declare a TempTableMetaData object and ProDataSetMetaData object, such as below, then it works fine:

ProDataSetMetaData pro_meta = new ProDataSetMetaData(ds1.DataSetName, "WindowsApplication6.ds_CompInfo");

TempTableMetaData tt_meta = new TempTableMetaData(dt.TableName, "WindowsApplication6ds_CompInfo.dt_CompInfo", 4, true, 1, "1, Mine-id:Num-i", System.String.Empty , System.String.Empty );

tt_meta.SetFieldMetaData(1, "Mine-ID", 0, Progress.Open4GL.Parameter.PRO_CHARACTER, 0, 0);

tt_meta.SetFieldMetaData(2, "MSHA-Control-ID", 0, Progress.Open4GL.Parameter.PRO_CHARACTER, 1, 0);

tt_meta.SetFieldMetaData(3, "MSHA-Operating-ID", 0, Progress.Open4GL.Parameter.PRO_CHARACTER, 2, 0);

tt_meta.SetFieldMetaData(4, "MKT-Mine-Name", 0, Progress.Open4GL.Parameter.PRO_CHARACTER, 3, 0);

pro_meta.AddDataTable(tt_meta);

ParamArray params_1 = new ParamArray(3);

ParamArray params_2 = new ParamArray(0);

params_1.AddDatasetHandle(0, ds1, ParamArrayMode.INPUT_OUTPUT, pro_meta);

params_1.AddCharacter(1, str_Action , ParamArrayMode.INPUT);

params_1.AddCharacter(2, str_Query, ParamArrayMode.INPUT);

Connection conn = new Connection(@"AppServerDC://mssbm06:2725/Broker_for_SMART10","", "", "");

conn.SessionModel = 1;

OpenAppObject OpenApp = new OpenAppObject(conn, "Broker_for_SMART10");

OpenApp.RunProc(@"
mssbm06\e\smartapp\Source\Progress\CI_PASS3.r", params_1);

In the code above, notice that I had to know the structure of my schema, before accessing the ABL procedure named CI_PASS3. (ie. The AddDatasetHandle method of the params_1 ParamArray object requires a ProDataSetMetaData object as a parameter. The ProDataSetMetaData object in turn requires that a TempTableMetaData be added to it and the TempTableMetaData requires a schema definition).

However, I was wondering if there is a way, WITHOUT using ProxyGen, to pass an untyped Dataset object to a ABL procedure and have a dynamic dataset return based upon the strQuery (Query string) that I passed to the ABL procedure.

I hope that this was somewhat clear.

Any help with this would be GREATLY appreciated!!

All Replies

Posted by Tim Kuehn on 31-Jan-2007 22:00

You may also want to post this question over on www.peg.com - doubtless someone over there's tried to do something similar to this.

Posted by Admin on 14-Feb-2007 19:13

Try something like this:

ProDataSetMetaData pro_meta = new ProDataSetMetaData("", null);

ParamArray params_1 = new ParamArray(3);

params_1.AddDatasetHandle(0, null, ParamArrayMode.INPUT_OUTPUT, pro_meta);

params_1.AddCharacter(1, str_Action , ParamArrayMode.INPUT);

params_1.AddCharacter(2, str_Query, ParamArrayMode.INPUT);

OpenApp.RunProc(@"
mssbm06\e\smartapp\Source\Progress\CI_PASS3.r", params_1);

ds1 = (DataSet)params_1.GetOutputParameter(0);

This thread is closed