Hi,
Is there a way that I can create a Genie textfield of label with an SQL statment. Something like a combo box but in a simple label.
The main goal is that I have a field in a 5250 screen an I'd like to get related data to show in Genie without having to touch code in RPG or the screen it self.
Thanks,
João Mendes
Creating a textfield or label with sql
-
- New User
- Posts: 18
- Joined: Thu Mar 17, 2011 7:38 am
- First Name: Joao
- Last Name: Mendes
- Company Name: Banco Credibom, SA
- Country: Portugal
- Contact:
Creating a textfield or label with sql
Thanks,
João Mendes
João Mendes
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Creating a textfield or label with sql
SQL can be used with only certain widget types -- a drop down, text box (auto complete), chart, or a grid.
There is not currently the capability to fetch a record for display in a label.
There is not currently the capability to fetch a record for display in a label.
-
- New User
- Posts: 18
- Joined: Thu Mar 17, 2011 7:38 am
- First Name: Joao
- Last Name: Mendes
- Company Name: Banco Credibom, SA
- Country: Portugal
- Contact:
Re: Creating a textfield or label with sql
Thank you David.
I'll put the field in the screen :(
Thanks
João Mendes
I'll put the field in the screen :(
Thanks
João Mendes
Thanks,
João Mendes
João Mendes
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Creating a textfield or label with sql
If you can't modify the screen, something like this could be done with a CGI program, right?
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Creating a textfield or label with sql
For example, you could write an RPG program as follows. I called mine LABELDATA and put it in a library named SKTEST:
So the 'Content-type:' line tells the Apache HTTP server that the data is plain text. The line ends with CRLF (hex 0d25). Then I insert an empty line by sendign another CRLF, this tells Apache that I'm ready to begin the actual data. Then, I send a line of text that simply says "This data goes in the iframe". You can write whatever data you want here... it could be an SQL statement to read a database, or it could just be data calculated somehow in your RPG program. The point is... you can calculate any data you like, and it's not that much more difficult than it would be to run an SQL statement.
You'll need to tell Apache that it's okay to call programs in this library by adding the following to your Apache config file:
My library is named SKTEST. You can name yours whatever you wish by making the appropriate changes to the config, above.
That can be added to a PROFOUNDUI config file if you like. Just add it to the end -- and remember that each time you reinstall ProfoundUI you'll need to go into the advanced options and tell it not to replace your httpd.conf with the one from the installation.
Once you've added those Apache config statements, you need to restart your Apache instance for the changes to take place.
Now in Genie, you can go into the "Containers" widgets in Genie and drag an iframe widget to wherever you want to show the extra label. You can also set the size of the widget, color, font, etc at this time.
The most important property, however, is the "iframe Url" property. This is how you tell it which program to call on the server. In my case, my ScriptAlias starts with /sktest, so the URL to call my program must also start with /sktest. The program's name is "labeldata" so using IFS syntax, the program name should be "labeldata.pgm". So my URL would look like this.
As always with Genie, you have to make sure you set a screen identifier, and save your changes to the server. Once it's all been done, the label will show up on your screen with the data from your program.
I stuck mine on the IBM-supplied command entry screen That may seem like a lot of steps -- but once you've done one program, they're really easy (because you only need to update the Apache config once.) It's a really easy way to add data to a screen without having to change the underlying program -- which is especially useful if you don't want, or can't, change the existing display file.
Code: Select all
* To compile:
*> CRTRPGMOD LABELDATA SRCFILE(QRPGLESRC) DBGVIEW(*LIST)
*> CRTPGM LABELDATA MODULE(LABELDATA) BNDSRVPGM(QHTTPSVR/QZHBCGI)
D QtmhWrStout PR extproc('QtmhWrStout')
D DtaVar 32767A options(*varsize) const
D DtaVarLen 10I 0 const
D ErrorCode 32767a options(*varsize)
D Err ds
D 10i 0 inz(0)
D 10i 0 inz(0)
D CRLF C x'0d25'
D data s 32767a varying
/free
data = 'Content-type: text/plain' + CRLF
+ CRLF;
QtmhWrStout(data: %len(data): Err );
data = 'This data goes in the iframe.';
QtmhWrStout(data: %len(data): Err );
*inlr = *on;
/end-free
You'll need to tell Apache that it's okay to call programs in this library by adding the following to your Apache config file:
Code: Select all
ScriptAlias /sktest /QSYS.LIB/SKTEST.LIB
<Directory /QSYS.LIB/SKTEST.LIB>
Order allow,deny
Allow from all
</Directory>
That can be added to a PROFOUNDUI config file if you like. Just add it to the end -- and remember that each time you reinstall ProfoundUI you'll need to go into the advanced options and tell it not to replace your httpd.conf with the one from the installation.
Once you've added those Apache config statements, you need to restart your Apache instance for the changes to take place.
Now in Genie, you can go into the "Containers" widgets in Genie and drag an iframe widget to wherever you want to show the extra label. You can also set the size of the widget, color, font, etc at this time.
The most important property, however, is the "iframe Url" property. This is how you tell it which program to call on the server. In my case, my ScriptAlias starts with /sktest, so the URL to call my program must also start with /sktest. The program's name is "labeldata" so using IFS syntax, the program name should be "labeldata.pgm". So my URL would look like this.
As always with Genie, you have to make sure you set a screen identifier, and save your changes to the server. Once it's all been done, the label will show up on your screen with the data from your program.
I stuck mine on the IBM-supplied command entry screen That may seem like a lot of steps -- but once you've done one program, they're really easy (because you only need to update the Apache config once.) It's a really easy way to add data to a screen without having to change the underlying program -- which is especially useful if you don't want, or can't, change the existing display file.
Who is online
Users browsing this forum: No registered users and 4 guests