PowerBuilder – The new kid on Developer Center’s block
I’m going to be totally honest…the last time I used PowerBuilder was about 8 years or more…and I didn’t think I was going to use it again…until I read this document from my team mate Uwe Kylau called PowerBuilder Developer Center and I knew this was the time.
This days, everything is about SAP HANA and I can’t of course, stay away from it, so I decided to swept away the dust from my PowerBuilder skills and try to make an application involving SAP HANA.
PowerBuilder 12.5 offers to different IDE environments, or better explained, the classic and the enhanced ones. Being an old time developer (more than 14 years now) I decided to go with the classic one.
First thing I did, was to open my PowerBuilder environment and prepared it to support SAP HANA via JDBC.
Easy as it sounds, I just need to go to Tools –> System Options –> Java and choose the folder where then ngdbc.jar is located.
After that, I established the connection with my Amazon Web Services SAP HANA Server. For this I went to Tools –> Database Painter and in the JDB JDBC choose New Profile… –> fill the parameters and I was ready to rock…
With that ready, the time for application creation was just around the corner.
On the menu File –> New. I create a new Workspace and a .NET Windows Forms Application and after that a Grid DataWindow.
When we create a DataWindow we need to specify from where it’s going to take the information. For this one, choose SQL Select, and then choose the table VOTES_DETAIL which we create on the blog Quick SAP HANA and R usecase and as the field choose COUNTRY and then Design –> Distinct. As we don’t want duplicated values. Save it and call it dg_country.
Repeat the same steps but this time for the field Age. Call this one dg_age.
When you have finished with this, create a new DataWindow but this time of type Freeform and choose External as the Data Source in the next window. This will show us a new window asking for a Result Set, use the following.
In the editor window, choose the Country field and the go to the Properties Window and choose Edit. Change the Style type to DropDownDW and fill the following values.
DataWindow is the the value from where we are going to get the data for our DropDown control. Save as call it ff_params.
Create a new DataWindow of type Grid and choose SQL Select as the Data Source. Select all fields and choose Design –> Retrieval Arguments (This is very important as it will allows us to pass the values of the Drop Down control to our report).
Specify the arguments as follows…
In the Where tab fill in the parameters and the arguments. Call this one dg_report.
Now, we have to create a new DataWindow (Don’t worry…it’s the last one) of type Graph and define the following Expressions.
For the graph style, choose what you want…I like pies…
Save it and call it dg_graph.
And now for something completely different…let’s create a PB Object of type Window. From the menu Insert we can put two buttons and simply drag and drop the DataWindows ff_params and dg_report.
Your layout should end like this one…save it and call it w_window.
One important thing before we go into the coding part of this blog, is that we need to go back to the Database Painter, choose our connection and go to the Preview tab, using the Copy button will help us to get the value we need, which is the connection details.
Now…source code! (Screaming please)
Double click the application and write the following code.
Going back and double click the Show Report button and paste this code.
Do the same in the Show Graphic button.
Finally, press right click and choose Script on w_window and add this code.
Let’s run the application and see how it works…
There you go…a quick and nice application using PowerBuilder and SAP HANA…