Page 1 of 1

[RPG] retreive the value of textbox which is bind to SQL statement

Posted: Thu Oct 27, 2016 7:07 pm
by MegumiSawada
Hi,

On the formview for uploading local database table to server, there is a textbox and its value is retrieved from local database table by SQL. Uploading program is just like EXAM0302.

I would like to use that value of textbox in RPG after BUTTON1(Upload button) is tapped.

Code: Select all

A                                  3 10HTML('<<TEXT1>>              
A                                      TYPE: TEXTBOX                
A                                      LAYOUT.COLS : -1             
A*                                     NAME: TEXT1                  
A                                      VALUE.&.SQL: "SELECT         
A                                      SURNAME FROM CONTACT         
A                                      WHERE ROWID = 1"             
A                                      ')                           
A                                  4 10'<<BUTTON1>>'                
A                                  4 10HTML('                       
A                                       TYPE: BUTTON +              
A                                       VALUE: "Upload" +   
A                                       ONCLICK: UPLOAD +           
A                                      ')                           
I have tried to get the value of TEXT1 in several ways,such as LRNG_GetProperty, but am not able to succeeded in it.

Is it possible to retreive the value of textbox which is bind to SQL statement?

I appreciate your kind advice.

Best Regards,
Megumi Sawada

Re: [RPG] retreive the value of textbox which is bind to SQL statement

Posted: Thu Oct 27, 2016 8:42 pm
by tsupartono
Value of bound properties can't be read directly in the RPG program using LRNG_GetProperty (or its variants), they are accessible only through the underlying data (that is, what the property is bound to, such as a field on a database table).

If the value that you want is part of the uploaded data, then it's already accessible from your RPG program.

If it's not part of the uploaded data, you can use form variable to explicitly send the value that you want to the server.
In your example, you want to send the result of query "SELECT SURNAME FROM CONTACT WHERE ROWID=1".
You can explicitly execute the query, and then send the result to a form variable.
When the form is submitted (provided you set Form.SubmitVars to Y), you can access this from your RPG program (using Form.Vars)

Example of ECL:

Code: Select all

lrexec
(
	function() 
	{ 
		this.q_sql("SELECT SURNAME FROM CONTACT WHERE ROWID=1", "scalar"); 
	} , 
	function(surname) 
	{ 
		this.TheSurname = surname;
		this.q_sendVars("TheSurname");
	}
);
You can access the value from your RPG code like so:

Code: Select all

SURNAME = LRNG_GetPropAsStr('/Form.Vars.TheSurname');

Re: [RPG] retreive the value of textbox which is bind to SQL statement

Posted: Fri Oct 28, 2016 12:51 pm
by MegumiSawada
Hi Tony,

Thank you!!
I have confirmed that I can get the value as expected with this way!

Best Regards,
Megumi Sawada