[tutorial] silverdev designer - rpg development studio

24
Graphical RPG Framework for IBM i SilverDev Tutorial Build a Grid and its Popup Menu with the RPG Designer

Upload: silverdev-by-experia

Post on 29-Jun-2015

366 views

Category:

Technology


1 download

DESCRIPTION

Learn how to build a graphical application in RPG to display a grid and its popup menu with the RPG Designer SilverDev

TRANSCRIPT

Page 1: [Tutorial] SilverDev Designer - RPG Development Studio

Graphical RPG Framework for IBM i

SilverDev Tutorial Build a Grid and its Popup Menu with the RPG Designer

Page 2: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 2 / 24

Steps:

1. Build a new program ............................................................................................................................. 3 2. FormCreation ........................................................................................................................................ 6 3. Database Wizard ................................................................................................................................... 8 4. Add a Pop-Up menu ............................................................................................................................ 10 5. Saving and compiling the screen ......................................................................................................... 12 6. RPG source: Build OnClick Events ....................................................................................................... 13 7. Additional Tools .................................................................................................................................. 16 8. Whole source ...................................................................................................................................... 17 9. Compiling the RPG source ................................................................................................................... 19 10. Create a CLP program.......................................................................................................................... 20 11. 1st deployment ................................................................................................................................... 22 12. Result ................................................................................................................................................... 23

Page 3: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 3 / 24

- To follow the steps of this tutorial, you have to install SilverDev on your server. - You can download a free 60-day trial on: http://www.silverdev.com/silverdev-free-trial.php

1. Build a new program

Launch SilverDev Designer and select a context from the menu Tools> Context.

Page 4: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 4 / 24

If you have selected the silverdemo option when installing SilverDev, the silverdemo context is diplayed in the list.

Select it and click the OK button.

Use the « + » icon to create your new program, in the Context tab :

Page 5: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 5 / 24

The program appears on the Context tab. Double-click the line to access it

Source and screen will be displayed on the screen. The source file is already filled in.

Page 6: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 6 / 24

2. Form Creation

Use the “Components” tool window to add a CSFL type component. Select the component from the palette and click the form under construction to place it.

Page 7: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 7 / 24

Use the “Inspector” tool window to modify the properties of the CSFL component.

The component must be selected (surrounded by black squares). Modify the Align property. Select the alClient value. This means that the component takes up the whole of its parent’s space (here, the form).

Tip: To obtain help regarding the CSFL component, select the component and press F1 to display the on-line help

Page 8: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 8 / 24

3. Database Wizard

To add columns to the CSFL component, you can double-click the component, but here, we will use a tool to import columns from a database file. Use this icon indicated to display the “Database wizard” tab.

In the “Database wizard” tab, use the search tab. Search for the SDDMBKS file (press Enter to start the search). The list of corresponding files on the server is displayed. Double-click the name of a file to display its characteristics.

A new window opens: select the IDBOOK, TITLE and PRICE fields (use CTRL to select multiple lines), and drag to the form under construction.

Page 9: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 9 / 24

Another window opens, asking what you want to do. Leave the default selection “Add to grid” and click OK.

Three columns have been created in the CSFL component. The properties of these columns have been modified according to the file’s

fields. You can change the properties of these columns if you want.

Page 10: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 10 / 24

4. Add a Pop-Up menu

In the “Components” tab, select the CPopupMenu component and place it on the form.

CpopupMenu is represented by a square. Double-click the square to add elements to the

popup menu. Window “Menu Designer” appears.

Right click and use the “New” option to create a new menu elements.

Page 11: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 11 / 24

Use the Property Inspector to change the menu element properties: - Call it itemRefresh, with the Name property, - Set the Caption property to “Refresh"

Select the CSFL component again and change its PopupMenu property. Select the PopupMenu1 value. This means that when a right click is made on the CSFL component, PopupMenu1 will be displayed.

Page 12: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 12 / 24

5. Saving and compiling the screen

On the Form menu, Save and compile the form:

As you can see below, the screen is a *USRSPC type object:

Page 13: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 13 / 24

6. RPG source: Build OnClick Events

First, we declare SDDMBKS books’ table:

In the RPGSPCIF block reserved for file declarations, declare the SDDMBKS file.

You can also drag the file name from the Database Wizard tab

To display the ruler, press F8.

Page 14: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 14 / 24

Now we add the OnClick event to the menu element, itemRefresh. Tip: Press F10 to display the screen.

Double-click the CPopupMenu component and tick the OnClick event of the itemRefresh element.

Double click the OnClick line: the cursor is now in the source in the itemRefresh_Onclick event.

Page 15: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 15 / 24

In the itemRefresh_OnClick event, we will read the sddmbks file

and fill in the CSFL component:

In the example, the words shown in purple are functions provided with SilverDev. They enable the components to be manipulated via the RPG program. To see the list of Silverdev functions, press Ctrl+Space to display the list of functions corresponding to the first letters of the word you are typing in.

Page 16: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 16 / 24

7. Additional Tools

Press F2: to display the list of the window’s components and properties in a tree structure Press Enter: to insert a component or property name

Press F4: to see a format prompt window

Page 17: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 17 / 24

8. Whole source

// *===============================================================*

// * Title . . . : *

// * Author . .ADUVAL *

// * Date . . .2014-10-21 *

// * Project . . : *

// * Description : *

// * *

// * *

// * -Technical data-----------------------------------------------*

// * *

// * Main SDF .*LIBL/TUTO1 *

// * *

// *===============================================================*

*/BLOCK RPGSPCIH

// -------------- RPGSPCIH : H specifications (Heading)

*/BLOCK RPGSPCIF

// -------------- RPGSPCIF : Files declarations (F Spec.)

FSDDMBKS if e k disk

*/BLOCK RPGSPCID

// -------------- RPGSPCID : Data descriptions (D Spec.)

*/BLOCK RPGSPCII

// -------------- RPGSPCII : Input descriptions (I Spec.)

*/BLOCK RPGPARM

// -------------- RPGPARM : Program parameters and declarations (KLIST, DEFINE, ...)

*/BLOCK RPGPGMSTART

// -------------- RPGPGMSTART :Begining of Initializations procedure

*/BLOCK RPGBEFORECREATE

// -------------- RPGBEFORECREATE : just before form creation

*/BLOCK RPGAFTERCREATE

// -------------- RPGAFTERCREATE : After form creation

*/BLOCK RPGBEFORESHOW

// -------------- RPGBEFORESHOW: Before show(F1)

*/BLOCK RPGAFTERSHOW

// -------------- RPGAFTERSHOW : After show(F1)

*/BLOCK RPGPROCDEF

Page 18: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 18 / 24

// -------------- RPGPROCDEF : User procedures

*/BLOCK RPGSR

// -------------- RPGSR : Sub Routine

*/BLOCK RPGTABLE

// -------------- RPGTABLE : Compile time array data (**)

*/EVENT itemRefresh_OnClick

‚* --------------------------------------------------------------*

‚* Description :

‚* --------------------------------------------------------------*

D Parameters ds based(pevtinf)

D Win 5u 0

D Evt 48a

‚*

D row s 10u 0

ccallpsdClear(F1:'SFL1')

C *lovalsetllsddmbks

c read sddmbks

cdow not %eof(sddmbks)

ceval row = row + 1

ccallpsdSetCell(F1:'SFL1':'Title':Row:Title)

ccallpsdSetCellNum(F1:'SFL1':'Price':Row:price)

ccallpsdSetCellNum(F1:'SFL1':'idbook':Row:idbook)

c read sddmbks

cenddo

Page 19: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 19 / 24

9. Compiling the RPG source

Save the modifications made to the source via the “Members/Save member” menu.

Compile the program using the “Compilation/Generate

program” menu.

If an error occurs during compilation, a dialog box will be displayed. Click OK. The compilation results will be displayed in a new window. Compilation errors are shown in bold. Double click a line to access the location in the source. When there are no more errors, the program will be created in SILVERDEMO.

Page 20: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 20 / 24

10. Create a CLP program

Now, we are going to create a CL program which will add SILVERDEMO to the library list and run our TUTO1EN program. Write it as usual:

Or in SilverDev editor:

Open a New Member in the menu Members And write your program:

Save it in the menu Members/Save Member Don’t forget to change the source type in CLP

Page 21: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 21 / 24

And compile in the menu Compiling / Create a program:

Page 22: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 22 / 24

11. 1st deployment

To make the application available, you must have administrator rights. Check that your profile is in the SILVERDEV/PSVDADM file. Launch MyDesk and right click where you want to make your application available. Then, choose « New application » Fill the dialog box with the application title, the file name and the call command. On next screen, select the app authorizations.

Page 23: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 23 / 24

12. Result

An icon is now shown in MyDesk: The application is available. Double click the icon to start the application that we have just created. Once the application is running, right click on the form and click “Refresh”.

The grid appears. You can sort it by clicking on the column

headers

Page 24: [Tutorial] SilverDev Designer - RPG Development Studio

SilverDev Tutorial – Build a Grid and its Popup Menu with the RPG Designer

Experia -- Reproduction Rights Reserved -- 24 / 24

More info on www.silverdev.com

EXPERIA Europe 4, rue L.Beridot

Les jardins d'Epione 38500 VOIRON - FRANCE

www.experia.com [email protected]