Now we want to test the transaction we created in the previous steps. To do so, we'll have GeneXus build the application, create the database, and do everything necessary to get the programs ready to be run and tested. This test cycle that developers undertake before the application is ready is called prototyping.
The full version of GeneXus allows prototyping an application locally (that is to say, the programs and the database will be hosted on our network servers) and in a cloud that is available to GeneXus users. Also, we can prototype in any of the programming languages supported.
However, in the specialized version for SAP Systems, the database will be SAP HANA, the language will be Java, and the prototyping tasks will be done on the Tomcat server that is available to us. In our demo, it will be a local one.
To set the necessary information in the HANA database and the web server, we must select the Preferences tab or press F5. We will use this function key very frequently because it allows us to generate all the objects required, as well as compile and run the main object.
Because it is the first time we press F5, this window is opened to ask us for the server and database details:
A way to build applications that use SAP HANA database is to do it through the Cloud platform available from SAP, called SAP Cloud Platform.
For trial purposes, a free account may be created at hcp.sap.com.
Here we register with our email account:
If we already have an account, we log into it.
From there, going to the option “Databases & Schemas” in the SAP Cloud Platform Cockpit, it is possible to create a new schema within a shared instance of the SAP HANA database offered to free accounts.
We create a new schema for what will be the database of our TravelAgency application:
Here we must place the name of the DB that we want to create (Database ID), select Database System: HANA MDC (<trial>), choose a password for the DB (must be 15 characters or greater), select Configure a User for SHINE = ON, which enables us more options to create a Shine User and a Password).
Once this is done and Save is selected, the creation of the DB begins, which we will then use in our GeneXus KB.
To connect this schema through JDBC, we must open a “tunnel”.
Keep in mind that the process takes a while, and can not be used (open the tunnel) until this process ends, from SCP Cockpit we will receive messages to control when this process ends.
At this moment we will have the DB created and we will proceed to open the tunnel using the neo command of SAPHCPSDK.
To do so, having installed the Hana Cloud Platform SDK (check requirements) corresponding to the version of Java Web Tomcat that we're using:
We need to open a command prompt console over the tools folder:
And there use the command:
neo open-db-tunnel -a <account> -h <host> -u <user> -p <password> -i <schema>
Where the “account” and “user” details are taken from the account we created in the Cockpit:
So, we replace those values in the command:
In this case, in which we're using the trial version, the host is: hanatrial.ondemand.com
The password is that of our account (that we used to log in).
The schema is the one we've just created: TravelAgencyDB.
Note that the tunnel has been opened as a result of the command execution. It will remain open for 24 hours unless we explicitly close it before that.
If we execute the command and the DB has not yet finished creating, we will receive the message:
(!) ERROR: Failed to connect to the backend: bad request
A database tunnel can only be opened for HANA databases in state 'CREATED',
but 'testlem' is currently in state 'CREATING'.
If you need help, provide the output of the command and attach the log
In case everything is done successfully we will receive the following message:
Use these properties to connect to your schema:
Host name : localhost
Database type : HANAMDC
JDBC Url : jdbc:sap://localhost:30015/
Instance number : 00
Use any valid database user for the tunnel.
This tunnel will close automatically in 24 hours on 17/11/2017 at 01:29 PM or when you close the shell.
Press ENTER to close the tunnel now.
In the HANA Data Store properties in the GeneXus KB, you must place the following data:
Server name: localhost
User id: the SHINE User name chosen when the DB was created
Password: the SHINE User password chosen when the DB was created (indeed the new value that will be set, as indicated in the note below)
Database schema: the SHINE User name chosen when the DB was created
NOTE: Before creating the DB from GX, you must enter the HANA Manager web, in order to change the SHINE User password that was placed when the DB was created, because the first time, you are forced to change it, and if run the creation from GX without doing this step, we will receive the error message:
========== Reorganization started ==========
Reorganization com\tstnewtrialscp\ options: -O
GeneXus Java Make v1.0
"C:\Program Files\Java\jdk1.8.0_131\bin\java.exe" com.tstnewtrialscp.Reorganization -nogui -noverifydatabaseschema
com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: : user is forced to change password: alter
password required for user <USERNAME>
You can do that from the SAP CP Cockpit, selecting the SAP HANA Web-Base Development Workbench option.
When entering, the first thing you will be asked to do is change the password.
Once this is done, you are enabled to continue the work from GeneXus.
GeneXus will build the application from the main object known as Launchpad, which we will see later, but for now, we can say that it will contain all the Fiori List Reports of our objects. We don't have any yet, so this object is not useful to us. Therefore, we need GeneXus to run a developer menu to try all the objects that are being created, even if they don't have that Fiori pattern incorporated, without worrying about programming the invocation.
Let's click on Cancel. In the Preferences tab, we see that the information we've just entered has already been configured in the corresponding properties. So, if we open the Data Stores information, we see that we have the Default option (SAP Hana) and if we enable the properties window (by pressing F4, or here on the right):
Here they are!
Now, let's press F5.
The Output window informs us that the Developer Menu execution has started and will end with a report called “Impact Analysis.”
In this report, GeneXus examines the impact caused by the new definitions made in the knowledge base. Also, it indicates which additions or structural changes need to be made to the database.
If we examine the report, we can see that a new table called Customer will be created:
Also, that this table structure will have the following attributes:
As we can see, GeneXus will also create an index by CustomerId automatically. We will explain this concept later on.
Since we agree to have this table created with this definition in the database, we click on the Create button
So, GeneXus starts to create the necessary programs to create the Customer table in the database, with this structure.
Next, GeneXus executes those programs.
Why did it fail? Why does it show a reorganization error?
In the Output window, we're informed that the driver to connect to the database hasn't been found within the folder containing all the necessary files to run this application:
We solve it by copying it to the directory of this Java Environment... within the Drivers folder.
Where do we take it from? It can be downloaded from SAP's website, as shown here.
We have downloaded it to the folder where everything related to HANA is saved:
Now we press F5 again and click on Create.
And the Customer table is created in the database. Next, GeneXus generates other programs (that is to say, all the necessary lines of code in the selected programming language, so that our application does what we want, which in this case is to enter customer details)... Also, we are informed if the result was successful, or if there were any errors or warnings.
We're asked which browser we want to use to open the Developer Menu. We choose anyone we want.
Here we can see the application running:
We have one objects: the Customer transaction that we created.
We right-click on the link and choose to open it in another tab.
Here we have a page that allows us to add, change and delete customers. We enter the details of our first customer.
This customer will be identified with number 1;
His name is John:
His last name is Smith:
He lives on Fifth Avenue.
His phone number is: 1111
And his email address is email@example.com
We click on Confirm and a message is displayed to inform us that the data has been successfully added; meanwhile, the form is cleared and ready for us to enter another customer:
Let’s add the second customer... we identify her with number 2:
Her name is Susan:
Her last name is “Brown”:
Her address is on Seventh Avenue
Her phone number is 2222
And her email address is firstname.lastname@example.org
We click on Confirm. Once again, a message is displayed to inform us that the data has been successfully added.
To look for John’s details, we enter his customer number (one) and press the Tab key.
We see that John's full details are displayed and that from here we could change some information, such as his phone number.
Also, we could even delete customer John from the customer records using the Delete button.
We can also use the upper section buttons to browse customers by going to the next or the previous one, the first or the last one:
Also, we can look for a specific customer using this window:
This window was automatically created by GeneXus, and it corresponds to this object:
Note that if we change the screen size, the controls are adjusted to the space available.
What does it mean? GeneXus generates responsive web applications, or sensitive applications, which offer optimum viewing, good navigation and excellent use of screen space.
This is achieved with design features that allow viewing all the information on the screen, using the functions provided by GeneXus to this end. They allow us to show different layouts depending on the screen size of the device.
Now that we’ve seen everything that was automatically generated by GeneXus using the Customer transaction that we've created... let’s go back to the development environment.