Official Content

Consider all the defined in GeneXus for SAP Systems - Working with Attributes and Domains and create a Transaction object for countries. Click on File > New > Object in the GeneXus main menu and select "Transaction", call it "Country".

Create a country identifier attribute. As you can see, GeneXus assigned it the Id domain.

Create an attribute to store the name of the country, CountryName, which takes the Name domain. 

image_20221122103953_1_png

Save (Ctr + s).

Note that just as it did with Customer, GeneXus has automatically created the form in the Web Layout to add, edit and delete countries.
 
Go back to the Attraction Transaction created in GeneXus for SAP Systems - Working with Attributes and Domains, so as to assign a country to each attraction. Note that typing the letter C displays the list of attributes existing in the Knowledge Base that begin with this letter.

image_2022112210424_1_png

Select CountryId, and its entire definition is displayed. 

Also, include the CountryName attribute in this Transaction. It's useful to see the country´s name when this Transaction object is executed and a country identifier is selected.

Focus on these two attributes included in more than one Transaction, in order to find out what role they play in Attraction.

image_20221122104318_1_png

Remember that CountryId is the identifier or key in the Country Transaction:

image_20221122104416_1_png

To be more precise, CountryId is the Primary Key of the Country Transaction and when a Primary Key is included in another Transaction, it has the role of a foreign key.

image_2022112210469_1_png

Including an attribute that is a Transaction's Primary Key in another Transaction relates them both. This means that when executing the Attraction Transaction, for this attribute you will have to enter a value that has been previously recorded through the Country Transaction.

image_20221122104916_1_png

See it at runtime.

Remember to open the tunnel to connect the schema to the SAP HANA Database.  

Press the Build All option. 

GeneXus analyzes the impact caused by the new definitions made on the Knowledge Base

image_20221122105430_1_png

and informs you that a new Table called Country will be created in the Database with the CountryId and CountryName fields. 

In addition, a new Table called Attraction will also be created with the fields AttractionId, AttractionName and CountryId.

image_20221122105530_1_png

Note that in the Attraction physical Table that GeneXus will create, the CountryName attribute is not included, even though you had included it in the Attraction Transaction Structure. This happens because the Transaction concept is not the same as the physical Table concept. Remember that Transaction is the GX object created in the Knowledge Base to represent an object or actor of reality. By examining it, GeneXus creates a Physical Table in the Database, to store the data that will be entered when executing the Transaction object.

GeneXusForSAPSystems_DataModelChanges_Image14

Not all the attributes included in a Transaction structure will later be stored in the physical Table created based on this Transaction.

GeneXusForSAPSystems_DataModelChanges_Image15

Storing the country´s name in several physical Tables would mean storing duplicate data.

GeneXusForSAPSystems_DataModelChanges_Image16

Instead, the country name can be retrieved from a single location where it is stored, in this case, from the country Table.

GeneXusForSAPSystems_DataModelChanges_Image17

Go back to the development environment and click on Reorganize. The term Reorganize means to reorganize the Database. It refers to the task of making changes to it.

GeneXus creates the programs to change the Database and executes them, making any necessary changes. Next, it generates all the programs corresponding to the application itself. For example, for each new Transaction object that has been defined, programs in the selected programming language to enter, change and delete countries and tourist attractions were generated.

Go to View > Other Tool Windows > Launchpad 

image_2022112211057_1_png

Now, there are links to work not only with clients but also with attractions and countries.

Add data about some countries. Click on Country and this will open the browser.

Transaction Country SAP Fiori Horizon v 18 u4

Since the CountryId attribute was previously defined as belonging to the Id domain and this domain has the Autonumber property set to True, there's no need to enter a value for the identifier because it will be numbered automatically. Add Brazil, France and China and execute the Attraction Transaction.

Add the tourist attraction "Louvre Museum". Remember that it is not necessary to enter a value for the identifier, so simply type the name "Louvre Museum". Indicate that the Louvre Museum is located in France.

If you remember the identifier number of France, enter it. 

Transaction Attraction SAP Fiori Horizon V 18 u4

Note that the country's name can't be changed from here, because it is displayed only for reading purposes.

If you do not remember the France identifier, you can click on the arrows next to CountryId. This shows you a list of available countries.

The arrow was displayed next to this attribute in particular because, as previously stated, CountryId is a foreign key here. So, here the user will have to enter a value that has been previously registered as primary key value through the Country Transaction. Therefore, GeneXus collaborates by generating and offering a list of countries available.

Now, you will see at runtime how the Country and Attraction Transactions check that the values entered for the CountryId attribute are consistent. 

Enter a new attraction, such as the “Pyramids of Egypt”. In the country field, enter the value "4", but an error message is displayed because country number 4 doesn’t exist.

Transaction Attraction no muching country - v18u4 Fiori Horizon

Check the registered countries and you will see that only countries 1, 2 and 3 have been entered, but not 4. 

Likewise, if you want to change an attraction that has already been entered and try to replace its country with another one that doesn't exist —4 again— you will get the same error message.

That is to say, when you enter or change data through Transactions, the associated data is automatically checked for consistency. Also, when trying to delete data through Transactions, the necessary controls are made to maintain the consistency of the stored data. 

Now, for instance, when trying to delete the country France:

Transaction Country SAP Fiori Horizon v 18 u4 - delete a country

A message will be displayed, informing that the deletion cannot be performed because related data exists in Attraction (remember the Louvre Museum, which belongs to France).

Something very important to take into consideration is that attributes must be named using exactly the same name when they are related to the same concept.

For example, suppose that you type "CountryIdentifier" instead of "CountryId" in the Attraction Transaction. They will be different attributes for GeneXus.

GeneXusForSAPSystems_DataModelChanges_Image32 

Therefore, GeneXus won't check whether the value entered in the CountryIdentifier attribute of the Attraction Transaction exists in the Table Country.

Hence, it won't offer the country selection list in the Attraction Transaction.  

Also, it won't be possible to retrieve the name of the corresponding country. Because CountryName is referenced in the Attraction Transaction due to the fact that CountryId plays the role of foreign key, retrieving its corresponding CountryName. However, CountryIdentifier is not a foreign key, as it isn’t the primary key of any Transaction, so it isn’t possible to retrieve data associated with this attribute.

Represent more features of the travel agency's reality. Another requirement is that every attraction has an associated category to indicate if it is a monument, museum, park, and so on.

GeneXusForSAPSystems_DataModelChanges_Image36
 
Here, the same situation that was mentioned with countries arises. Create a "Categories" Transaction and assign the attractions’ categories.
Create the Category Transaction with CategoryId and CategoryName.

GeneXusForSAPSystems_DataModelChanges_Image36-5

Now, add the CategoryId and the CategoryName attributes to the Attraction Transaction.

GeneXusForSAPSystems_DataModelChanges_Image37

Before trying this at runtime, allow the category not to be set, as you don't know its value at the time of entering the attraction. 
This is done by changing the value of the Nullable property of the CategoryId attribute. Set it to Yes:

GeneXusForSAPSystems_DataModelChanges_Image38

This only makes sense for foreign keys that reference values from another Table.

Implement another request of the travel agency: For each attraction, they want to enter its photo. So, in the Attraction Transaction, enter an attribute called AttractionPhoto.
It will be of Image type because this type makes it possible to store images. 

GeneXusForSAPSystems_DataModelChanges_Image39

Now, press F5 to apply the changes to the database and programs and run the application.
Note that a new Table will be created in the database to store the categories.

image_20221122131841_1_png

Click on Attraction:

image_20221122132049_1_png

The Attraction Table has to be converted, which means that the CategoryId and AttractionPhoto attributes will be added.

This element is added to store the file and to give the option to only reference a URL to it.

GeneXusForSAPSystems_DataModelChanges_Image42

Press the REORGANIZE button. 

Run the Category Transaction from the Launchpad:

image_20221122132253_1_png

Add the categories Museum and Monument.

Execute the Attraction Transaction, note that it allows you to enter a category and a photo.

Category Id in Pattern Fiori Horizon v18 u4.

Search for the Louvre Museum, and assign the Museum category and a photo to it.

Museo del Louvre photo. v18u4

Confirm.

A special feature of SAP HANA makes it possible to use Table row storage instead of column storage.

To do so, click on View > Tables

Here, GeneXus shows all the Tables of the corresponding Database. 

image_20221122133142_1_png

By clicking on one of the Tables, you will see that among its properties there's one that is related to the type of storage in a SAP Hana Database.  

GeneXusForSAPSystems_DataModelChanges_Image50

If you're trying to create a Table and the percentage of transactional operations (that is to say, INSERT, UPDATE and DELETE operations) is very high, using row storage is recommended because it is the default value. Also, it is how traditional relational DBMSs work.

For SAP Hana, there is an option to use column storage, which is useful when the Table being designed has a very high percentage of reading operations (SELECT). 
If this is the case of ATTRACTION, change that value.

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant