getting started with genexus -...

47
Getting Started with GeneXus 8.0 November, 2003 MONTEVIDEO – URUGUAY Av. 18 de Julio 1645 P.4 - (5982) 402 2082 CHICAGO – USA 400 N. Michigan Ave. Suite 1600 - (312) 836 9152 MEXICO CITY – MEXICO Mariano Escobedo 353 A Of. 701 - (5255) 5255 4733 SAO PAULO – BRAZIL Rua Samuel Morse 120 Conj. 141 - (5511) 5502 6722

Upload: lehanh

Post on 17-May-2018

226 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus 8.0

November, 2003

MONTEVIDEO – URUGUAY Av. 18 de Julio 1645 P.4 - (5982) 402 2082CHICAGO – USA 400 N. Michigan Ave. Suite 1600 - (312) 836 9152MEXICO CITY – MEXICO Mariano Escobedo 353 A Of. 701 - (5255) 5255 4733SAO PAULO – BRAZIL Rua Samuel Morse 120 Conj. 141 - (5511) 5502 6722

Page 2: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Copyright © ARTech Consultores S. R. L. 1988-2003. All rights reserved. This document may not be reproduced in any form without the express permission of ARTech Consultores S.R.L. The information contained herein is intended for personal use only. TRADEMARKS ARTech GeneXus are trademarks or registered trademarks of ARTech Consultores S.R.L. All other trademarks mentioned herein are property of their respective owners.

Page 2 of 47

Page 3: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Content Introduction .................................................................................................................... 4

Objectives .................................................................................................................... 4 System Requirements....................................................................................................... 4

Generator Requirements ................................................................................................ 5 Trial Version Limitations.................................................................................................... 6 Installation and Setup....................................................................................................... 7

Setup Wizard ................................................................................................................ 7 Trial Version Authorization................................................................................................. 9 Getting Started Step by Step ............................................................................................10

Step 1: Creating a Knowledge Base................................................................................10 Step 2: Creating an Object in GeneXus...........................................................................10 Step 3: Defining Attributes for the Object Transaction Invoice............................................11 Step 4: Viewing the Completed Objects Form ..................................................................12 Step 5: Defining Formulas in GeneXus............................................................................13 Step 6: Inserting a Business Rule ..................................................................................15 Step 7: Reviewing the Database after Creating the Invoice Object......................................16 Step 8: Creating a Customer Object...............................................................................18 Step 9: Viewing Table Structure Changes........................................................................19 Step 10: Prototyping your Application in Visual Basic with Microsoft Access..........................20 Step 11: Viewing the Database Creation Report ...............................................................22 Step 12: Creating the Tables with the Database Manager..................................................23 Step 13: Specifying and Generating your Code ................................................................24 Step 14: Running your Application .................................................................................26 Step 15: Adding New Objects to your Project: Item Transaction.........................................27 Step 16: Viewing Table Structure Changes......................................................................29 Step 17: Impacting the Database ..................................................................................29 Step 18: Refactoring the Data and Generating the Programs .............................................30 Step 19: Running your Application .................................................................................32 Step 20: Creating a Report & Making a Call to It ..............................................................32 Step 21: Specifying and Running your Application............................................................36 How to Move your Application to .NET and JAVA ...............................................................38 Step 1: Deploying your Application to .NET with Microsoft SQL Server.................................38 Step 2: Viewing the .NET Application Running .................................................................42 Step 3: Deploying your Application to Java with Microsoft SQL Server .................................42 Step 4: Viewing the JAVA Application Running .................................................................46

Online Resources ............................................................................................................47 GeneXus Community ....................................................................................................47 Support ......................................................................................................................47 How to Buy .................................................................................................................47

Page 3 of 47

Page 4: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Introduction

Objectives The objectives of this document are that you:

• Discover the power of knowledge-based development • Experience the key features of GeneXus:

o Knowledge-based design o Automatic code generation o Automatic database and code maintenance o Multi-platform deployment

System Requirements GeneXus Trial includes the following products: • Development Environment

It is an Integrated Development Environment (IDE) for designing and prototyping your applications, regardless of the production platform.

• Generators GeneXus generates native code for the leading platforms. The generators available are the following:

• .NET • Java • Visual Basic

Below is a list of the hardware and software you will need in order to run GeneXus and the applications generated by it.

Processor: 500 MHz Intel Pentium class

Memory: at least 64 MB of RAM (256 MB recommended)

Hard disk: at least 50 MB of free disk space to install the Development Environment, plus an average of 10 MB for each generator. To create GeneXus applications you will need additional space or a shared disk to create the Knowledge Bases.

Hardware Requirements

Video: 800 x 600 resolution or higher, with 256 colors

Microsoft Windows 98 or higher. If you are using Windows NT, you must install service pack 6.0 or higher

Microsoft .NET Framework 1.1 Redistributable Package 1

Software Requirements

Microsoft Internet Explorer 6.0 SP1 or higher

1 The .NET Framework 1.1 Redistributable Package can be downloaded from Microsoft’s website: http://msdn.microsoft.com/library/default.asp?url=/downloads/list/netdevframework.asp. It can also be downloaded from the Download Center at GXTechnical website: http://www.gxtechnical.com/main/hdcenter.aspx?2,5,36,1035

Page 4 of 47

Page 5: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Generator Requirements This section contains the requirements to generate and execute applications with the different GeneXus generators:

Generator Requirements .NET

• Microsoft .NET Framework 1.1 Redistributable Package 2 • For generating Web interface applications you will need IIS 5.0 or higher

(available on Windows 2000 or XP) • For generating Windows interface applications or printing PDF reports,

you will need Visual J# Distribution Package 1.1 3 • ODBC Driver for the DBMS used

Java • Sun and/or Microsoft JDK (we recommend having both) • For generating Web interface applications:

o Web Server o Servlet Engine o JavaServer Web Development Kit

• For generating 3-tier Windows interface applications: o HTTP: you will need a Web server and a servlet engine o CORBA: you will need Visibroker

• JDBC Driver for the DBMS used Visual Basic • Microsoft Visual Studio 6.0, with Service Pack 5 or higher

• MDAC 2.6 or higher • If you use Sheridan Data Widgets, you will need version 3.0 or higher

installed • ODBC Driver for the DBMS used (except if you are working with Microsoft

Access) In addition, to create the database and execute the generated applications, you must have some of the following DBMSs installed:

Generator DBMS .NET Java

• DB2 Universal Database • DB2 UDB for iSeries • Informix • Oracle • PostgreSQL • SQL Server

Visual Basic • Access • DB2 Universal Database • DB2 UDB for iSeries • Informix • Oracle • PostgreSQL • SQL Server

2 The .NET Framework 1.1 Redistributable Package can be downloaded from Microsoft’s website: http://msdn.microsoft.com/library/default.asp?url=/downloads/list/netdevframework.asp. It can also be downloaded from the Download Center at GXTechnical website: http://www.gxtechnical.com/main/hdcenter.aspx?2,5,36,1035 3 You can obtain Visual J# Distribution Package 1.1 from Microsoft’s website: http://msdn.microsoft.com/vjsharp/downloads/howtoget/default.aspx

Page 5 of 47

Page 6: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Trial Version Limitations Although the license is Unlimited, and all the generators installed remain authorized with a unique Site Key, some restrictions apply to the number of objects: Transactions: 30; Work Panels (included the GeneXus selection prompts): 50; Web Panels (included the GeneXus selection prompts): 50; Procedures: 20; Reports: 20. It is not possible to open a knowledge base developed with GeneXus standard version from GeneXus Trial or vice versa. GeneXus Trial installation is local and single-user (there is no network installation). It does not include the Knowledge Manager's "Distribution" options. Xpz GeneXus standard versions can be consolidated (provided they do not exceed the previously mentioned limits) but they cannot be distributed. Support for GeneXus Trial is limited. If you have any doubts or problems –about version installation and activation only–, please send an e-mail to [email protected]. For any additional information, we recommend contacting your local distributor (www.genexus.com/distributors).

Page 6 of 47

Page 7: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Installation and Setup This section explains how to use the Setup program to install GeneXus Trial on a computer. The Setup program includes a wizard to help you make the correct choices. To start the GeneXus Setup program: 1. Start Windows. 2. Run GeneXus Trial Setup. 3. Follow the Setup Wizard instructions to install the selected products (Development

Environment and Generators).

Setup Wizard The first screen you will come across is the setup wizard welcome screen: click Next if you wish to continue with the installation. The following screen is a License agreement that you should read carefully before continuing to the next one. After selecting the I accept the License Agreement option and clicking Next, the following dialog asks you to register your name and company name. Once you have entered that information, click Next to display the following dialog box:

Figure 1 Setup wizard for GeneXus Trial

In this dialog you select the destination folder where GeneXus will be installed (a directory called gxw80Trial is suggested). By clicking the Browse button you will be able to change the default one. Click Next to go to this dialog:

Page 7 of 47

Page 8: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Figure 2 Product selection dialog box

Once you have selected the destination folder, you will be asked for the products you want to install (i.e. Development Environment and the different Generators). Then, click Next to begin the installation. After all the files you need have been copied to your system, the Setup program places GeneXus icons in a GeneXus group that will be automatically incorporated to your Program Manager's window.

Page 8 of 47

Page 9: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Trial Version Authorization This is a detailed description of the steps to authorize GeneXus: 1. Execute GeneXus 8.0 Trial Version from the desktop shortcut for GeneXus 8.0 or from the

programs menu. 2. Copy the Site Code:

Figure 3 Registration dialog box

3. In order to activate the GeneXus Trial version, go to www.genexus.com/trial/authorize and

enter the Site Code obtained in step 2. Then, click Submit to have the activation key generated and sent to your e-mail address.

4. After receiving the activation key, proceed with the product activation. Then you will be able to

start using GeneXus Trial.

Page 9 of 47

Page 10: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Getting Started Step by Step The objective of this Getting Started guide is to help you easily evaluate GeneXus and test its functionality. We have created a step-by-step process for you to create a small project that is a simplification of a company’s reality. In this example you will create an Invoicing System and have the possibility to prototype in three different platforms: Visual Basic, .NET and JAVA. Although it covers the whole cycle of a standard process, this process is a simplified version that shows you the power of GeneXus and how easy it is to create applications and migrate them to new platforms. Step 1: Creating a Knowledge Base 1. On the File menu, click New

Knowledge Base. 2. Name the Knowledge Base “Demo”

and click OK to continue.

Figure 4 New Knowledge Base creation

Step 2: Creating an Object in GeneXus 1. On the Object

menu, click New Object.

2. Select the type of

object that you want to create: Transaction.

3. Name the Object:

“Invoice”.

Figure 5 Object creation dialog box

Page 10 of 47

Page 11: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Step 3: Defining Attributes for the Object Transaction Invoice

1. Type the attribute characteristics (name, type and description) on the Invoice Structure tab based on the following table.

2. Use the TAB button to move between the attribute name, type and description. Use the ENTER button to add a new attribute.

ATTRIBUTE TYPE DESCRIPTION InvoiceId Numeric(3,0) Invoice InvoiceDate Date Invoice Date CustomerId Numeric(5,0) Customer CustomerNm Character(30) Customer Name Now Press CTRL + “L” ItemId Numeric(5,0) Item ItemDsc Character(15) Item Description ItemPrice Numeric(7,2) Item Price ItemQty Numeric(3,0) Item Quantity ItemLnTot Numeric(7,2) Line Total Now Press ENTER, and then CTRL + LEFT InvoiceSubTot Numeric(7,2) Invoice Sub Total InvoiceTax Numeric(5,2) Invoice Tax InvoiceTotal Numeric(7,2) Invoice Total

3. After entering the attributes, click Save . Now you have created the structure of an Invoice transaction composed by two levels; the Invoice Header where we specified all the information necessary for the Header of the Invoice, and the Invoice Detail where we specify the information that will be repeated for every invoice line. The brackets indicate that for each Invoice Header there are many Lines or Invoice Detail. Every group of attributes between brackets belongs to a transaction LEVEL. Transactions can have many levels, and these levels may be nested or parallel.

Figure 6 Invoice structure

Invoice Detail

Invoice Header

Page 11 of 47

Page 12: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Step 4: Viewing the Completed Objects Form Once all the attributes have been defined and saved, your object form will look as follows: 1. Select the Form tab of the transaction.

Figure 7 Transaction form tab

When defining a Transaction, a default Form is automatically created by GeneXus to specify the way the end user will access data in Windows applications. This form can be changed by the developer.

Page 12 of 47

Page 13: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

2. Select the Web Form tab of the transaction.

Figure 8 Transaction web form tab

When defining a Transaction, a default Web Form is automatically created by GeneXus to specify the way the end user will access data in Web applications. This Web Form is based on a default Theme object, which is a new object introduced in the latest GeneXus version. The Theme object improves the development and maintenance of Web applications by separating the developer’s work from the designer’s.

Step 5: Defining Formulas in GeneXus Now let’s define some calculated fields. You do this by defining formulas. • In this example we will make the following formulas:

o ItemLnTot = ItemPrice * ItemQty o InvoiceSubTot = SUM(ItemLnTot) o InvoiceTax = InvoiceSubTot * .085 4 o InvoiceTotal = InvoiceSubTot + InvoiceTax

4 Note: Most likely you will want to read the tax % from a table, but in this example we will just hardcode the tax % for simplicity.

Page 13 of 47

Page 14: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

1. Choose the Line Total attribute (ItemLnTot) and double-click the Formula field. 2. Write the following expression: “ItemPrice * ItemQty”.

Figure 9 Transaction formula

3. Repeat Steps 1 and 2 for the other three formulas.

Figure 10 More Transaction formulas

Page 14 of 47

Page 15: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Step 6: Inserting a Business Rule In this case we want to have the Invoice Date defaulted to Today’s date. 1. Select the

Rules tab.

Figure 11 Rules tab

2. On the Insert menu, click Rule. 3. Select the Default rule that assigns

a default value to an attribute or variable.

4. Write down the following:

”Default(InvoiceDate, today());” which indicates that the default value for the invoice Date will be today’s date.

5. Click Save.

Figure 12 Transaction rule

Page 15 of 47

Page 16: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Step 7: Reviewing the Database after Creating the Invoice Object 1. On the Tools menu, click List Database.

2. Clear the Modified check box. 3. In the Select Object dialog box, click Select All and then click OK.

Figure 13 Select Object dialog box

Page 16 of 47

Page 17: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Figure 14 Impact Analysis Report

You can see that GeneXus automatically normalizes the tables, and creates two tables to support the Invoice object, Header & Detail: Table Invoice and Table Invoice1 (marked in the image above), with the following structure:

<Invoice> InvoiceId InvoiceDate CustomerId CustomerNm

<Invoice1> InvoiceId ItemId ItemDsc ItemPrice ItemQty

In addition, you will see that GeneXus automatically removes from the tables those attributes that we made as formulas, and makes them global formulas so you can access them automatically anywhere. Note: From the Menu: Advanced \ Table you can change a table name, add new indexes, or define redundancies.

Page 17 of 47

Page 18: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Step 8: Creating a Customer Object To create the Customer Transaction follow Steps 2 and 3. The following attributes will be inserted in the Customer Transaction Structure:

ATTRIBUTE TYPE DESCRIPTION CustomerId --------- -------------------- CustomerNm --------- -------------------- CustomerAddress Character(30) Customer Address CustomerEmail Character(50) Customer Email

Note that when you press the “Save” button GeneXus will ask the attribute definition for the CustomerAddress and the CustomerEmail. That is because the CustomerName and CustomerId were defined before.

After you have added a new Customer object and inserted the attributes into the structure, the Customer object will be created and its Structure and Forms will look as follows:

Figure 15 Customer transaction structure

Page 18 of 47

Page 19: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Figure 16 Customer transaction Win form

Figure 17 Customer transaction Web form

Step 9: Viewing Table Structure Changes By reviewing the Database (Step 7) after the Customer Object was created you can see that GeneXus has automatically normalized the tables for you. You will see that GeneXus automatically moved the CustomerNm and CustomerAddress attributes from the Invoice table to the Customer Table.

Figure 18 Customer table structure

Page 19 of 47

Page 20: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Figure 19 Invoice table structure

The database structure is now the following:

<Invoice> InvoiceId InvoiceDate CustomerId

<Invoice1> InvoiceId ItemId ItemDsc ItemPrice ItemQty

<Customer> CustomerId CustomerNm CustomerAddress CustomerEmail

Step 10: Prototyping your Application in Visual Basic with Microsoft Access Note: Refer to the chapter: System Requirement / Generator Requirements / Visual Basic, to make sure that you have all the software required to execute the application. You won’t need an ODBC driver or a DBMS. 1. Select Prototype. 2. Choose Visual Basic to Prototype the two objects created

so far: Invoice and Customer.

Figure 20 Toolbar menu

Figure 21 Model creation dialog box

3. Click OK.

Page 20 of 47

Page 21: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

4. In the GeneXus Create

Model Wizard that is displayed, type a name for the model: “Prototype Visual Basic”.

5. From the combination of

Languages, User Interfaces, and different DBMSs, select “Visual Basic” with a “Win” interface (the default one) and “Access” as DBMS. Open each drop-down menu to see the different possibilities.

6. Click Next.

Figure 22 Model creation wizard, Step 1

7. In Step 2, select “Microsoft DataGrid 6.0 (OLEDB)” in the Grid version drop down.

8. Click Next. 9. In Step 3, select the Visual

Basic 6.0 path. 10. Click Next.

Figure 23 Model creation wizard, Step 2

Page 21 of 47

Page 22: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

11. In Step 4, Click Finish.

12. In the dialog box that is displayed, click OK.

Figure 24 Database Creation Analysis dialog box

Step 11: Viewing the Database Creation Report GeneXus displays a Database Creation Report to show you exactly what it is creating in the DB you specified in this case (Access) after viewing it. To do so, click Reorganize in the Database Creation Report dialog box. After you click this button, GeneXus will generate all the code to create the database. Then it will compile the code so that you can execute the reorganization program.

Figure 25 Database Creation Report

Page 22 of 47

Page 23: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Step 12: Creating the Tables with the Database Manager At this stage GeneXus launches its Database Manager, a GeneXus-generated program, to create the database, perform a data transfer (refactor the database when reorganizations are performed), rename tables, create indexes and update models. 1. In the GeneXus Database Reorganization dialog box, click Execute.

The reorganization program is generated depending on your language selection in the GeneXus Create Model Wizard (Step 10). In this case the Database Manager is running a Visual Basic program to perform the tasks. 2. Click Exit.

Figure 26 Completed Database Reorganization

Page 23 of 47

Page 24: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Step 13: Specifying and Generating your Code After the Database has been created, you can have GeneXus specify your objects and generate the programs in the language you selected (Visual Basic Code in this example). 1. On the Build menu, click Build All. You can also click Build All in the GeneXus toolbar.

Figure 27 GeneXus toolbar

2. Select the Type: Check

specification and Other Options: Specify & Generate.

Figure 28 Build All dialog box

GeneXus presents you with a specification report for each program it will generate.

The specification report’s objective is to show you in a high level how the program will execute, which tables it will access and which operations it will perform. In this case you are viewing the specification report of the transactions; notice that transactions are programs that will enable the user to Insert, Update, and Delete functions on the database. It also ensures that referential integrity and record locking are handled. All this without you writing one line of code!

Page 24 of 47

Page 25: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Figure 29 Navigation Report

You will also notice that GeneXus adds new objects, called “Selection List … ”

Figure 30 Selection list

GeneXus automatically takes charge of referential integrity. That is, transactions have the necessary knowledge to avoid data inconsistency due to updates (for example, a parent with children has been deleted, or a child without a parent has been entered). However, an integrity check alone would not be enough because a check failure and a "Client does not exist" message would not be useful for the user. It is necessary to help the user find the valid values! For this reason, GeneXus not only provides integrity controls, but also creates Prompt type objects that give the user a set of valid values to choose from. Although the Prompts are initially created by GeneXus, they can be modified by the user.

Referential Integrity: It means that when you delete a customer from the Customer Transaction, the program will check that there aren’t any invoices with that customer.

Page 25 of 47

Page 26: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Step 14: Running your Application After the Database has been created and all your objects have been specified and generated, you can now launch VB and run your application to test it. 1. Press F5, and click Execute

in the Execution dialog box.

Figure 31 Execution dialog box

2. In the Developer Menu

dialog box, click Transactions.

3. Next, click Customer to enter new data.

Figure 32 Developer menu options

Page 26 of 47

Page 27: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

4. Next, enter some data into the Invoice. You will notice a couple of things here: o The date automatically defaults once you tab over it. o If you tab over CustomerId you will get a system message: “No matching Customer. BROWSE

DATA?” which was automatically created by GeneXus. If you click Yes, the corresponding prompt will appear. Also, if you press F4 on the Customer Id it will display a prompt list.

o Formulas are automatically calculated when the values are entered. Step 15: Adding New Objects to your Project: Item Transaction Adding a new object called “Item” and reorganizing the Database is simple in GeneXus. 1. Select Design in the drop-down menu of the GeneXus toolbar.

2. Create the Item Transaction by following Steps 2 to 4. The following attributes will be inserted in the Item Transaction Structure:

ATTRIBUTE TYPE DESCRIPTION ItemId --------- -------------------- ItemDsc --------- -------------------- ItemPrice --------- --------------------

Note that when you press the Save button, GeneXus won’t ask for the attribute definition of any of them.

Figure 33 Item transaction structure

Page 27 of 47

Page 28: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

3. Now click the Form and Web Form tabs to see the transaction’s windows and Web forms,

respectively.

Figure 34 Item transaction win form

Figure 35 Item transaction web form

Page 28 of 47

Page 29: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Step 16: Viewing Table Structure Changes After the Item object is saved, GeneXus will reorganize the tables again. The new database structure will be:

<Invoice> InvoiceId InvoiceDate CustomerId

<Invoice1> InvoiceId ItemId ItemQty

<Customer> CustomerId CustomerNm CustomerAddress CustomerEmail

<Item> ItemId ItemDsc ItemPrice

Reviewing the Database after the Item Object has been created allows you to see that GeneXus automatically normalizes the tables for you. You will see that GeneXus has automatically moved the ItemDsc and ItemPrice attributes from the Invoice1 (Invoice Detail) table to the Item Table.

Figure 36 Impact Analysis Report

Step 17: Impacting the Database Now we will go back to Prototype as we did in Step 10, and GeneXus will perform an Impact to the application. 1. Select Prototype in the drop-down menu of the GeneXus toolbar. You will see that GeneXus automatically moves the attributes from the InvoiceHeader to the Item. 2. In the dialog box that is displayed, click OK.

Page 29 of 47

Page 30: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

3. In the Impact Analysis Report

dialog box, click Reorganize.

Figure 37 Impact Analysis Report

Step 18: Refactoring the Data and Generating the Programs

GeneXus will automatically transfer the data that was stored in the Invoice (Item data) to the Item Table.

Figure 38 Database reorganization dialog box

Page 30 of 47

Page 31: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

1. On the Build menu, click

Build\Specify or press SHIFT + F8 to display the Select Object dialog box. Note that only the Item object will appear (if the Edited Only checkbox is selected). Click OK.

Figure 39 Object selection dialog box

2. In the Specify Objects dialog

box, select the Check specification option and click OK.

Figure 40 Object specification dialog box

3. In the Specification Report

dialog box, click Generate to generate the program associated to the Item transaction.

Figure 41 Specification Report dialog box

Page 31 of 47

Page 32: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Step 19: Running your Application Now let’s run the application again, to see how GeneXus moved the data from the InvoiceDetail file to the Item file. 1. Press F5, and then click Execute.

2. Click the Item file in the Developer Menu dialog box and click the Select button to see the data you entered in the Invoice.

This means that the reorganization programs not only change the database structure, but also maintain the information stored in the database.

Figure 42 Developer Menu dialog box

Step 20: Creating a Report & Making a Call to It Now let’s go back to GeneXus and create a quick report to print an invoice. We will create a report in Prototype as no Database changes will be done; we will also call the report by adding a print button to the existing Invoice object. 1. Follow Step 2 to

create the new Report object, but this time click on Report and type Invoice in the Name field.

Figure 43 Object definition dialog box

Page 32 of 47

Page 33: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

2. Next, click Insert

from Trn in the report wizard that appears.

Figure 44 Invoice Report Wizard, Step 1

3. Choose Invoice, and

click OK.

Figure 45 Object selection dialog box

Page 33 of 47

Page 34: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

4. Click Finish and the

report Layout will appear.

Figure 46 Invoice Report Wizard, Step 1

The Layout tab contains the output to be printed later, and each one of them can have a set of controls such as attributes, variables, labels, etc.

Figure 47 Invoice report

Page 34 of 47

Page 35: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

The navigation structure (which data is going to be listed, and in what order) is defined in the Source tab. To this end, a very simple procedural language is used.

Figure 48 For each command

In order to make the communication between the two objects we will make a call from the Invoice Transaction to the Invoice Report.

5. Select the Rules tab. 6. Write

“parm(InvoiceId);” 7. Click Save.

Figure 49 Invoice report rule

The FOR EACH command indicates that all the reports of a certain table will be queried, showing the information indicated in the printing block(s). The FOR EACH command is used to define the information to read in the database, but this is done by naming the corresponding attributes, and you will NEVER have to specify from which tables this data will be obtained, or with what indexes.

Page 35 of 47

Page 36: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

8. On the Object menu,

click Open and select the Invoice Transaction.

9. Next, click the Rules Tab.

10. Type in “call(RInvoice,

InvoiceId) if after(TRN);”

Figure 50 More invoice report rules

Note: After(TRN) is a GeneXus function; to read about it press CTRL + “U”, scroll to the bottom, highlight “After(TRN)” and hit the Help button.

Step 21: Specifying and Running your Application 1. To Specify your Invoice, follow Step 13, to run your application follow Step 19. 2. Click Invoice and

enter some data, then click Confirm. After this your rule will be triggered and your report will appear; your report can either be displayed on the screen or sent to a printer.

Figure 51 Destination selection

Page 36 of 47

Page 37: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Figure 52 Invoice Report Viewer

CONGRATULATIONS…, you have successfully created an Invoice application in GeneXus; our next step is to show you how to move your application to another platform, .NET and/or JAVA.

Page 37 of 47

Page 38: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

How to Move your Application to .NET and JAVA

Step 1: Deploying your Application to .NET with Microsoft SQL Server Note: Refer to the chapter: System Requirement / Generator Requirements / .NET, and make sure that you have all the software required to execute the application Next we will deploy the application to .NET with a SQL DB. 1. Select Design in the drop-down menu of the GeneXus toolbar. 2. On the File Menu, click New

Model to display the GeneXus Create Model Wizard.

3. Name the model: “Prototype

.NET”. 4. Select “.NET” with a “Web”

interface and “SQLServer” as the DBMS.

5. Click Next.

Figure 53 Create Model Wizard, Step 1

6. In Step 2, select “Driver” and “SQL Server” 7. Write the name of the Database and the Server. In the example, the Database name is

“demo” 5 and the Server name is “(local)” 8. Click Next.

5 The creation of the database is not performed by GeneXus when the creation process is carried out, so the database must be created manually before GeneXus actually creates the database tables. Please refer to your SQL Server manual for information on how to create the database.

Page 38 of 47

Page 39: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

9. In Step 3, select “No” on

Use trusted connection. 10. Enter the user id and

password for the DBMS login. In the example the User Id is “user_name” 6

11. Select the SQL Server

version. 12. Click Next.

Figure 54 Create Model Wizard, Step 3

13. In Step 4, enter the Compiler and Virtual Directory paths and click Next.

14. In Step 5, click Finish.

Figure 55 Create Model Wizard, Step 4

6 The user needs CREATION rights to the database tables. For simplicity, we recommend assigning OWNER rights.

Page 39 of 47

Page 40: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

15. In the dialog box that is

displayed, click OK.

Figure 56 Model creation dialog box

16. Follow Steps 11 and 12 to create the database. 17. Open the Invoice Report. Select the Properties icon.

Figure 57 Invoice report toolbar

18. Select “Only To Screen” for

the Report output property under Options.

19. Save the Report Invoice

Object with the Save button or by pressing: CTRL + S.

Figure 58 Report Properties dialog box

Page 40 of 47

Page 41: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

20. Follow Steps 13 and 14 to specify and generate the code.

21. Before executing it, compile

the code with the Compile button.

Figure 59 Application execution dialog box

22. After compiling the

application, Execute it by clicking the Execute button.

23. Execute the Invoice

Transaction. Note that the application’s menu will look like Fig. 60.

Figure 60 Application menu

Page 41 of 47

Page 42: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Step 2: Viewing the .NET Application Running

Figure 61 Invoice

Step 3: Deploying your Application to Java with Microsoft SQL Server Note: Refer to the chapter: System Requirement / Software Requirements / JAVA Generator, and make sure that you have all the software required to execute the application. Next we will deploy the application to Java with a SQL DB. 1. In the GeneXus toolbar, select Design.

Page 42 of 47

Page 43: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

2. On the File menu, click

New Model to display the GeneXus Create Model Wizard.

3. Name the model: “Prototype

JAVA” 4. Select “JAVA” with a “Web”

interface and “SQLServer” as the DBMS.

5. Click Next.

Figure 62 Create Model Wizard, Step 1

6. In Step 2, enter the Database and Server name. In the example, the Database name is “demo” 7 and the Server name is “server-name”.

7. Click Next.

Figure 63 Create Model Wizard, Step 2

7 The database is not created by GeneXus when the creation process is performed, so you must create the database manually before GeneXus actually creates the database tables. Please refer to your SQL Server manual for information on how to create the database.

Page 43 of 47

Page 44: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

8. In Step 3, enter the user id and password for the DBMS login. In the example the User Id is

“user_name” 8 9. Select the SQL Server version. 10. Click Next.

11. Enter the Servlet directory (the Servlet directory allows to specify the directory where the servlets generated will be transferred). In the example we use Resin and the Servlet directory is: “C:\resin-2.1.7\doc\WEB-INF\classes”.

12. Enter the Static content

base URL (indicates the directory where the servlet will search for the static content -javascripts and images- used in the web objects corresponding to it).

13. Finally enter the Static

content directory seen from client, which indicates the directory to which we will transfer the javascripts -*.js files- generated.

14. Click Next.

Figure 64 Create Model Wizard, Step 4

8 The user needs CREATION rights to the database tables. For simplicity we recommend assigning OWNER rights.

Page 44 of 47

Page 45: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

15. In Step 5, enter the

Compiler Path, the Make Path, the Interpreter Path, the Classpath and the Web Application Base URL9

16. Click Next, and then click

Finish. 17. Click OK.

Figure 65 Create Model Wizard, Step 5

18. Follow Steps 11 and 12 to create the database. 19. Follow Steps 13 and 14 to specify and generate the code. Remember that before executing you must compile the code, with the Compile button Also remember to start the Servlet Server. 20. Execute the JAVA application, and then the Invoice Transaction. More information about the JAVA Development Kits at: http://www.gxtechnical.com/main/hPSAmpInf.aspx?2,8,219,E,774,JAVA

9 In the example: • Compiler Path = C:\Program Files\Microsoft SDK for Java 4.0\bin\jvc.exe • Make Path = C:\Program Files\Microsoft SDK for Java 4.0\bin\nmake.exe • Interpreter Path = C:\WINDOWS\system32\jview.exe • Classpath = gxclassr.zip;.;C:\resin-2.1.7\lib\jsdk23.jar;C:\jdbc\sqlserver\Una2000.jar • Web Application Base URL = http://localhost:8080/servlet/

Page 45 of 47

Page 46: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Step 4: Viewing the JAVA Application Running

Figure 66 Invoice

Page 46 of 47

Page 47: Getting Started with GeneXus - Republica.comempresayeconomia.republica.com/files/2011/02/introduccion_genexus.pdfGetting Started with GeneXus Introduction Objectives The objectives

Getting Started with GeneXus

Online Resources

GeneXus Community The GeneXus Community provides a variety of ways to get answers to your questions, solutions to your problems, and to share your own expertise. Find the list of community resources available to you at: www.genexus.com/community

Support ARTech offers a wide range of support services and resources: • Self-Service Online Support

These resources are available to anyone online. However, the information that you access depends on your GXTechnical Access Level.

• Interactive Support Services Interact with other members of the Community and with our Support Team.

www.genexus.com/support

How to Buy The GeneXus Technologies are sold through a network of distributors worldwide. Find a distributor near you at: www.genexus.com/distributors Otherwise, please contact [email protected]

Page 47 of 47