(RPG) Transferring parms between offline programs

Please do not use to report errors- use your regional help desk.
Please mark posts as being for RPG or RDMLX (LANSA) developer.
To subscribe by email, display this forum, scroll to the end and select ‘Subscribe Forum’.
Post Reply
DavidS
Posts: 15
Joined: Wed Jan 22, 2014 7:41 pm

(RPG) Transferring parms between offline programs

Post by DavidS »

Hello, me again with another awkward question.

In brief I'm trying to pass the user selection in program 1 to program 2 to populate a screen field.

The selection I want to pass is when the user touches a row on a table to pass the value of that row, I assume my code would need to look something like this:
OnRowClicked.Operation
(
Type : PerformAction
Pgm : PROG2
Action : CALLED_FROM_PROG1
Param%1 : ValuefromTable
) +
I can't figure out how to put the value from the table into the parameter though. A couple of methods I've tried (for reference the value is column 2, called stock, linked to field stockcode on a local table.)
Param%1 : col%2
Param%1 : STOCK
Param%1 : ( FLD:STOCKCODE )

In the first two cases it has taken my input to be a character constant, in the third it returned a blank. I assume there is some combination of syntax I'm missing here so hopefully someone can point out :)

The second problem I've got is populating the field in program 2, I think the problem is that I've linked the field to a global variable:
LRNG_SetProperty( '/Form.Fields.S1BARC.Value.&.GVAR': 'LASTSTOCKCODE' );
So when I try to set property on it this doesn't take, I've tested by transferring to a different field on screen:
LRNG_GetProperty( 'CurrentOp.Param%1' : S1STCK : %size(S1STCK) );
This then shows the value (although due to above problem not the right value.)

I'm wondering if what I need to do is to invoke a javascript call in program1 to populate the global variable and so it'll be available in program2?
tsupartono
Posts: 289
Joined: Wed Apr 18, 2012 10:21 am

Re: (RPG) Transferring parms between offline programs

Post by tsupartono »

Hi David,
There is currently no way to specify (declaratively) that we want the Param values to come from the row.

The best way would be to write a small ECL script that retrieves the selected stock value, and then programmatically invoke the 'PerformAction' operation, passing the stock value.

I have provided below an example of the script as a starting point.

Code: Select all

lrexec(
	function()
	{
		// Retrieve the stock code from the row that triggered this script              
		this.q_sql("SELECT &(FLD:STOCKCODE)", "scalar");
	},
	function(stockCode)
	{
		this.console("Selected stock code = " + stockCode);
		
		// Now launch the second form
		var op =
		{
			type: "performaction",
			pgm: "VIEWSTOCK",
			param: [ stockCode ]
		};
		this.q_setProperties({ runoperation: op });
	}	
);

With this script, instead of directly setting up the OnRowClick with PerformAction operation, you'd set it up with ExecScript operation.
E.g.

Code: Select all

OnRowClick.Operation 
(
   Type : ExecScript
   Script: "the script goes here"
}
or, you can place the script in a resource file (which is the better approach, but make sure you declare the resource file in the schema properties so it will get downloaded).

Code: Select all

OnRowClick.Operation 
(
   Type : PerformAction 
   Resource: myscript.js
}
DavidS
Posts: 15
Joined: Wed Jan 22, 2014 7:41 pm

Re: (RPG) Transferring parms between offline programs

Post by DavidS »

Thanks for the reply tsupartono. As mentioned I was starting to lean towards some sort javascript and it's useful to hear someone confirm it and point the way forward.
Post Reply