PP Delphi400 Developersguide PDF
PP Delphi400 Developersguide PDF
PP Delphi400 Developersguide PDF
Developer's
Guide
Delphi/400 V2007
Version: 2
Date: january 8th 2008
Disclaimers
SystemObjects Corporation may have patents and/or pending patent applications covering subject matter in this
document. The furnishing of this document does not give you any license to these patents.
Copyright 1999-2008 SystemObjects Corporation. All rights reserved. All SystemObjects products are trademarks or
registered trademarks of SystemObjects Europe. Borland products are trademarks or registered trademarks of Borland
Corporation.
Other brand or product names are trademarks or registered trademarks of their respective holders
TABLE OF CONTENTS
INSTALLATION ........................................................................................ 31
MINIMUM SYSTEM REQUIREMENTS: .............................................................. 33
ISERIES: DELPHI/400 INSTALLATION PROCESS ............................................. 34
SECURITY KEY: ........................................................................................ 35
INSTALLED COMPONENTS:........................................................................... 35
ISERIES: DELPHI/400 UNINSTALL PROCESS ................................................. 38
TRANSFERRING CLIENTOBJECT/400 LICENSES:.............................................. 38
ISERIES SETUP NOTES:.............................................................................. 39
ADDITIONAL TCP/IP INFORMATION: ........................................................... 40
PC: DELPHI INSTALLATION PROCESS ............................................................ 41
DELPHI/400 CONFIGURATION PROGRAM .................................................... 45
EXAMPLE OF A NEW ISERIES TCP/IP CONNECTION: ......................................... 47
DELPHI/400 INSTALLED COMPONENTS: ...................................................... 52
In Delphi:........................................................................................................................94
USING PREPARED SQL .............................................................................. 98
USING TSPOOL400 COMPONENT................................................................ 104
TTRANSACTION400....................................................................... 124
SQLBUILD400.............................................................................. 125
TCMD400.................................................................................... 128
COLIFS....................................................................................... 129
Properties......................................................................................................................132
Methods: .......................................................................................................................134
Commit..................................................................................................................................................... 135
Connect.................................................................................................................................................... 136
Disconnect............................................................................................................................................... 136
RemoteCmd............................................................................................................................................. 137
RollBack................................................................................................................................................... 138
Events............................................................................................................................139
Tips ................................................................................................................................140
Properties......................................................................................................................145
ObjLib....................................................................................................................................................... 145
ObjType.................................................................................................................................................... 146
Properties......................................................................................................................149
Commit..................................................................................................................................................... 151
EOF........................................................................................................................................................... 152
FfilterComparison................................................................................................................................... 152
Fields........................................................................................................................................................ 154
FileDescription........................................................................................................................................ 155
LockOnRead............................................................................................................................................ 158
UserRights............................................................................................................................................... 159
Methods.........................................................................................................................159
ClearCalcFields....................................................................................................................................... 160
GetByKeyFirst......................................................................................................................................... 161
GetByKeyLastInCacheValues................................................................................................................ 164
GetByKeyNext......................................................................................................................................... 165
GetByKeyPreviousInCacheValues........................................................................................................ 167
GetFieldName.......................................................................................................................................... 176
GetLast..................................................................................................................................................... 179
GetLastInCacheValues........................................................................................................................... 180
GetNumberFields.................................................................................................................................... 182
GetPrevious............................................................................................................................................. 183
GetRecordNumber.................................................................................................................................. 186
InsertWithCacheValues.......................................................................................................................... 190
InsertWithScreenValues......................................................................................................................... 191
Open......................................................................................................................................................... 192
PutCacheFieldPValue............................................................................................................................. 193
RemoveCalcField.................................................................................................................................... 194
SetCalcFieldValue................................................................................................................................... 195
UpdateComponents................................................................................................................................ 195
BeforeDelete............................................................................................................................................ 200
BeforeInsert............................................................................................................................................. 201
Call : The code added to this event is executed just after reading a record. ........... 201
OnUpdateComponents........................................................................................................................... 202
Properties: ......................................................................................................................210
DataBaseName........................................................................................................................................ 210
SQL........................................................................................................................................................... 210
Methods: .........................................................................................................................211
GetFieldDescription................................................................................................................................ 211
GetFieldName.......................................................................................................................................... 211
GettNumberFields................................................................................................................................... 211
Properties .......................................................................................................................213
Glyph........................................................................................................................................................ 213
Properties......................................................................................................................214
Methods.........................................................................................................................215
GetIndice.................................................................................................................................................. 215
DoExit....................................................................................................................................................... 215
Properties......................................................................................................................216
Methods.........................................................................................................................217
GetIndice.................................................................................................................................................. 217
Properties......................................................................................................................218
Methods.........................................................................................................................219
GetIndice.................................................................................................................................................. 219
Properties......................................................................................................................221
FilterValue................................................................................................................................................ 223
FilterWithField400................................................................................................................................... 223
Methods.........................................................................................................................225
GetIndex................................................................................................................................................... 225
ReDraw..................................................................................................................................................... 225
DoExit....................................................................................................................................................... 225
KeyDown.................................................................................................................................................. 226
Tip ..................................................................................................................................226
Properties......................................................................................................................227
LookUpFilter............................................................................................................................................ 230
LookUpFont............................................................................................................................................. 230
Caption..................................................................................................................................................... 230
Methods.........................................................................................................................231
GetFieldName.......................................................................................................................................... 231
UpdateControls....................................................................................................................................... 232
Modified method..........................................................................................................234
Properties .......................................................................................................................236
FunctionsAlpha....................................................................................................................................... 236
GroupFunctions...................................................................................................................................... 239
SQL........................................................................................................................................................... 240
Table_HorizSpace................................................................................................................................... 240
Table_VertSpace..................................................................................................................................... 240
Tables....................................................................................................................................................... 240
Methods.........................................................................................................................241
AddTable.................................................................................................................................................. 241
DeleteParamsTab.................................................................................................................................... 241
Properties......................................................................................................................243
ParamDigits............................................................................................................................................. 244
Methods.........................................................................................................................246
ClearParams............................................................................................................................................ 247
SetBuffer.................................................................................................................................................. 248
Events............................................................................................................................249
BeforeExecute......................................................................................................................................... 249
Tip ..................................................................................................................................249
Properties......................................................................................................................250
ParamDigits............................................................................................................................................. 251
Methods.........................................................................................................................252
ClearParams............................................................................................................................................ 253
Events............................................................................................................................253
BeforeExecute......................................................................................................................................... 253
Properties......................................................................................................................254
DataAreaType.......................................................................................................................................... 255
Tip ..................................................................................................................................257
Properties......................................................................................................................258
ForceIndicators....................................................................................................................................... 259
JobName.................................................................................................................................................. 260
JobUser.................................................................................................................................................... 260
MessageListCount.................................................................................................................................. 262
MessageMaxLength................................................................................................................................ 262
SenderWanted......................................................................................................................................... 263
Methods.........................................................................................................................264
ClearDataQueue...................................................................................................................................... 264
GetMessageJobNameInList................................................................................................................... 264
GetMessageJobUserInList..................................................................................................................... 265
GetMessages........................................................................................................................................... 267
GetMessageUserProfileInList................................................................................................................ 270
SendWithKey........................................................................................................................................... 274
SetValue................................................................................................................................................... 275
Tip ..................................................................................................................................276
Properties......................................................................................................................277
Identifier................................................................................................................................................... 277
MessageQueueName.............................................................................................................................. 277
Msg........................................................................................................................................................... 278
MsgLength............................................................................................................................................... 278
SendingJobNumber................................................................................................................................ 279
Methods.........................................................................................................................280
GetMsg..................................................................................................................................................... 280
RemoveMessages................................................................................................................................... 281
Properties......................................................................................................................285
CanSetupColors...................................................................................................................................... 287
Lib............................................................................................................................................................. 287
Menu......................................................................................................................................................... 287
Prog.......................................................................................................................................................... 288
Screen5250.............................................................................................................................................. 288
Event .............................................................................................................................288
Methods.........................................................................................................................290
PrintSelZone............................................................................................................................................ 290
PrintScreen.............................................................................................................................................. 291
Properties......................................................................................................................293
Asynchronous......................................................................................................................................... 293
CurThread................................................................................................................................................ 293
Stream...................................................................................................................................................... 294
Methods.........................................................................................................................294
ListDirectory............................................................................................................................................ 294
ListDirectoryNext.................................................................................................................................... 294
Connect.................................................................................................................................................... 294
CopyFileFromAS..................................................................................................................................... 295
CreateDir.................................................................................................................................................. 296
Properties .......................................................................................................................297
Files.......................................................................................................................................................... 297
Properties .......................................................................................................................298
Count........................................................................................................................................................ 298
Size........................................................................................................................................................... 298
Properties......................................................................................................................301
Methods.........................................................................................................................301
DisplaySubDirByName........................................................................................................................... 301
Events............................................................................................................................301
Properties .......................................................................................................................303
InitialDir.................................................................................................................................................... 303
Methods.........................................................................................................................304
DisplayParentDir..................................................................................................................................... 304
Properties......................................................................................................................306
Buffercount.............................................................................................................................................. 306
SelectedFields......................................................................................................................................... 307
DELPHI/400 FUNCTIONS.......................................................................308
ASCII2EBCDIC ....................................................................................... 308
B22CHR ............................................................................................... 308
B42CHR ............................................................................................... 308
CHR2B2 ............................................................................................... 308
CHR2B4 ............................................................................................... 309
© SystemObjects 1997-2008 www.systemobjects.com 25
Delphi/400™
CHR2F4................................................................................................ 309
CHR2F8................................................................................................ 309
F82CHR................................................................................................ 310
COBUTTONKINDL.................................................................................... 313
DELPHI/400 DEPLOYMENT..................................................................318
SILENT MODE ........................................................................................ 318
ISS FILES GENERALITIES.......................................................................... 319
Visual Component
SCD/400 Delphi Standard Components
CO400
SNA TCP/IP
SNA TCP/IP
CO400
Figure 1.1
Note that a new dbExpress driver is available with Delphi 2007. Unlike the BDE,
dbExpress returns only unidirectional cursors and therefore does no caching. The
MIDAS ClientDataset can be used for caching, and scrolling, indexing, and filtering
on the result set.
Figure 1.2 lists the Native Components and IDAPI Driver compatibilities and
characteristics.
Figure 1.2
Figure 2.1 shows the installation step in which you specify the components you
wish to install.
NB. Install the first component AS/400 Middleware Server Component only one
time. This component is the CO411 library in the iSeries.
iSeries:
PC:
NB. The above is the minimum requirements even if now the iSeries and the PC
are more modern and more powerful.
The installation process may vary depending on the connection type you use to
connect to the iSeries. Figure 2.2 shows you the information required during the
installation process if you use a TCP/IP connection.
Figure 2.2
Before installing the product, verify that the TCP/IP and FTP protocols are active
in the target iSeries. You'll need a user profile with "*SECADMIN" user rights (we
recommend QSECOFR). If your are running a multiple partition iSeries then the
TCP/IP address is the one of the selected partition in which the middleware will be
installed.
You can modify the communication port values if necessary, but keep in mind
that there is no verification of conflicts with other TCP/IP protocols.
During the installation process, a temporary security key is generated for your
iSeries. After one month, the trial period is expired and you need to enter a
permanent key to continue to work with Delphi/400. To enter a permanent
security key, enter the following commands on the iSeries terminal:
• ADDLIBLE CO411
• CALL CO400INS
An online screen will appear that allows you to enter the permanent key that you
receive from SystemObjects. To get this permanent key, you must advise
SystemObjects or its representative the serial number and the partition number
of your iSeries. You can get the serial number and the partition number of the
iSeries by executing CALL CO411/ABOUT.
Installed components:
After completing the installation process, you should have the following new
objects in your iSeries:
If you are using a mirroring system between two iSeries, all objects in the library
CO411 of the two machines are the same execpt the data-area CO400VAL that
contains the security license key .
Be sure that the subsystem CO411TCP is active. In this subsystem, the program
CO411SVR must be running. The subsystem can be started by the command
“STRSBS” CO411/CO411TCP. Be sure that TCP/IP is active when the command is
run.
This procedure describes the technical steps that allows you to transfer
ClientObjects/400 license from one iSeries to another:
CALL CO411/CO400UNS
This program executes the following operations:
• Invalidates the ClientObjects/400 on the first iSeries.
• Genarate a transfer reference which allows you to get a new
ClientObjects/400 validation key for the new iSeries.
3. Restore the CO411 library into the new iSeries with the command:
CALL CO411/CO400INS.
To install the iSeries middleware on your iSeries server, your router (APPC) or
your FTP server (TCP/IP) must have already been started and your iSeries user
profile must have QSECOFR privileges. Before installing the iSeries part, be sure
that the system value QALWOBJRST of your iSeries is set to *ALL. To manage this
value, run the iSeries command:
• WRKSYSVAL SYSVAL(QALWOBJRST).
For TCP/IP support you will need the TCP/IP protocol installed on both PC and
iSeries.
You must start the iSeries FTP service on the iSeries (this is only for the
installation process).
If you wish to install an updated version on the iSeries, you must stop the
CO411TCP sub-system on the iSeries.
You will also need to know the TCP/IP address of the target iSeries, and also
allocate an empty TCP/IP port for Delphi/400 use. The setup proposes the
number 27003 .
© SystemObjects 1997-2008 www.systemobjects.com 39
Once you have successfully installed TCP/IP support, you will then need to
configure the TCP/IP usage from the PC using CO400CFG.EXE. You can start this
Configuration Tool with Start/programs/Delphi400 V2007/Configuration .
TCP and UDP protocols use ports to identify unique origins and destination of
communications between applications.
A TCP/IP port is similar to an APPC device when you use a SNA router to connect
to the iSeries.
Ports 0 - 1023 are reserved port numbers, assigned for universal applications,
e.g. port 21 is used for FTP and port 23 is used for Telnet.
The iSeries also reserves ports for use by the operating system, e.g. port number
397 is used for APPC over TCP/IP (Anynet), while port 8472 is used for data
queues.
Delphi/400 also uses TCP/IP port for communication. Each PC must connect to
the Delphi/400 TCP/IP server on the iSeries. The server will automatically assign
one port to each PC. Since the version 6, Delphi/400 has needed a unique port
number for the server and use the same port number for all client PCs.
The setup program will use 27003 for default port value (recommended):
After the process finishes, the Delphi_400 V2007 menu should be inserted in the
Windows Start Menu under Programs.
In the CO411\DDS directory, no file is yet installed but it is on this site that will
be created by ClientObjects/400 the description of the iSeries files.
This DDS directory contains a cached version of the iSeries description file
databases. Caching up this description information considerably enhances
performance.
In this case, the complete DDS of the concerned files will be downloaded from the
iSeries.
2° Case: (The DDS of the concerned files exists in the DDS Directory)
© SystemObjects 1997-2008 www.systemobjects.com 43
a) The VERIFY FILES parameter (see page 28) = TRUE
Data Description Files are completely updated each time you
open a file.
b) The VERIFY FILES parameter (see page 28) = FALSE
Data Description Files will be updated only if there was a
modification between the one stored in the PC and the original
DDS stored in the iSeries. If you are sure that the DDS will not
change set this parameter to FALSE.
File opening will be faster if this parameter is set to FALSE.
The first thing to do is to configure the AS/400 connection from the host PC to the
target PC. This must be done in the configuration program located in the
Delphi_400 V2007 directory found in the Start Menu (see figure 2.4), or in the
default directory: C:\CO411\CO400CFG.EXE
Figure 2.4
• Define one or several target iSeries that you want to access from a host PC.
• Test the connection to a target iSeries.
• Retrieve DLL information required by the SystemObjects technical support
department.
• Update your PC or iSeries with the latest patches from SystemObjects
"Update from the Web" service via the Internet.
Figure 2.5 shows you the "Access to iSeries Configuration" main window
1°) Select the TCP/IP radio button under the Connection type option as shown
in Figure 2.5.
2°) Click the "Add" button situated in the TCP/IP configuration page of figure 2.5.
3°) Fill in the following attributes
Name Name of the iSeries.
Address TCP/IP address of the iSeries.
Server Port The same port number specified in the iSeries installation,
the installation program proposes 27003.
Code page Depending on the code page of your iSeries and the
keyboard of your PC.
Library CO411.
Figure 2.6
The other options of the configuration program are shown in figures 2.9 and 2.10.
The first one shows you the general information about the DLL's installed on the
PC side; once again this information is important for our support department.
The second one shows you the Update From the Web option. This allows you to
automatically download the latest patches for Delphi/400 from our FTP site. The
update process allows you to automatically update the CO/400 engine in the
iSeries.
Figure 2.10
Figure 2.11 shows you the progress window before starting the update process.
After clicking the Start button, the transfer will take place and, at the end, you
will be able to decide about what components you wish to update.
When finished, click close. Run the executable (or appropriate) file found in
Destination directory as shown in the above figure 2.11 (
C:\DOCUME~1\SCH\LOCALS~1\Temp\PN00110\).
After the installation process ends, you should have the iSeries components in
Delphi's/400 VCL.
Figure 2.12 shows you the different elements installed:
Figure 2.12
Figure 2.13
These packages are located (if the default installation was used) in the directory:
C:\CO411\Delphi11\VCL
Note that the ClientObjects/400 DB Components (TQuery400, TTable400, …) are
only provided in this version to support backward compatibility with Delphi 1, 2
since a 16bit IDAPI driver isn't currently available.
SCD400 Data:
Figure 3.1
The most important component of this folder is the TAS400 component. It allows
you to select via the PLUAlias property which iSeries you want to access. The
iSeries list is retrieved from the iSeries configuration program list.
Figure 3.2
Figure 3.3
SCD400 DB:
Note that the ClientObjects/400 DB Components (TQuery400, TTable400, …) are
only provided in this version to support backward compatibility with Delphi 1, 2
since a 16bit IDAPI driver isn't currently available.
SCD IFS:
Figure 3.5
Screen5250:
Figure 3.6
BDE:
Figure 3.7
Figure 3.8
Each BDE-enabled dataset component on the data access page has a published
DatabaseName property that specifies the database which contains the table or
tables that hold the information in that dataset.
When setting up your application, you must use this property to specify the
database before you can bind the dataset to specific information contained in that
database.
In order to create a BDE alias; launch the SQL explorer by running the program
“dbexplor.exe” from the directory:
“C:\Program Files\CodeGear\RAD Studio\5.0\bin”
© SystemObjects 1997-2008 www.systemobjects.com 61
Then select the Object | New menu bar item (see figure 4.4)
Figure 4.4
Figure 4.4
The "New database Alias" window appears. Select the IDCO400 option from the
combo-box in order to create a new iSeries BDE Alias entry. IDCO400 is the
native iSeries IDAPI driver installed by Delphi/400
Figure 4.5
Figure 4.6
In the following section you will find a description for each of the IDCO400's
parameters.
IDAPI Support:
- OLDFILTER: If TRUE: The filter method is the same as in Delphi/400 versions V3.0
- V4.0 - V4.1.
I.E. Only the Key field is filtered. (Backward compatibility purposes)
If FALSE (Default value) The new filter method is used, all fields can
be filtered.
This property is available only for Delphi/400 V4.2 and superiors.
- VERIFY FILES: If TRUE, DDS (Data Description) Files are checked each time that you
open a file. If you are sure that the DDS will not change set to FALSE.
File opening will be faster if this parameter is set to FALSE.
- TRAN_ISOLATION: Transaction control settings, accepted values are:
*NONE or Blank : no transaction control
*CHG: Each record needing to be updated is locked.
All added, modified or deleted records remain locked
until the next commit or rollback of the transaction.
Records accessed for update that are not modified are
unlocked.
*CS: Each record accessed in a file that has transaction
control enabled will be locked. Each record read but not
modified or deleted is unlocked when another record is
read. All records added, modified or deleted are locked
until commit or rollback of the transaction.
*ALL: All records read from file that has transaction control
enabled are locked until commit or rollback of the
transaction.
Figure 4.7
If you plan to use the transaction mechanism of DB2/400, then you need to:
• Journalize the iSeries target database files
• Set the TRAN_ISOLATION parameter to either *CHG, *CS, *ALL
depending of the transaction level you want to use.
This new driver will allow you to access your iSeries without using the BDE
It’s mainly a dll named dbco400.dll.
To use this driver like other dbexpress driver you need a SQLConnection
component located in the dbExpress tab of the component palette
First, you have to choose CO400 as a DriverName, then you have to choose or
create a “ConnectionName” based on this driver.
Figure 6.1
1°) Start a new project by selecting File | New Application from the Delphi/400
Menu bar.
Figure 6.2
Figure 6.3
Figure 6.4
7°) Name the TdataBase component by filling out the Name field
8°) In the Alias Name ComboBox, select the BDE Alias you created in the first
chapters.
9°) Click the Defaults button. All IDCO400 parameters should be listed in the
Parameter overrides section. You can manually modify any of the parameters from
this section.
You can even skip the login procedure if you provide a correct UserName,
Password and uncheck the Login prompt check box in the options section.
The object inspector for the database component should look similar to the one of
Figure 6.6
10°) Add a Ttable component into the DataModule, and modify the following
properties in the object inspector:
DatabaseName ➜ TEST_AS400
TableName ➜ CUSTOMER
Name ➜ T_Customers
Active ➜ True
The Object Inspector for the Ttable component should be as in the following
figure.
11°) Right click in the T_Customer object and select the Fields Editor... option.
An empty window called DataModule.T_Customer should appear. Right click inside
that window and select the "Add all Fields" (or Ctrl+F short key) option. Figure 6.8
shows the result after adding all table's fields in the project.
Notice that in the code editor, all fields were inserted with their corresponding
types (figure 6.9).
12°) Insert a TsetProp component from the Setprop400 tab in Delphi's VCL.
Modify the "Name" and "DataSet" properties according to figure 6.10.
Figure 6.10
13°) Right Click in the SP_Customers components and select the "Update Field
description" option. This will retrieve the long description for each of the selected
fields from the iSeries data description file.
Now, all "master's" database components are included in the DataModule. We can
now start creating the Detail database components.
15°) Drop a Ttable component into the Datamodule, modify the following
properties
DatabaseName ➜ TEST_AS400
Table ➜ ORDERS
Name ➜ T_Orders
Active ➜ True
MasterSource ➜ DS_Customers
MasterFields ➜ Follow the instructions listed in step 16°
Figure 6.13 represents the ObjectInspector of the new Ttable object.
16°) To determinate the "MasterFields's" field, click in the dotted box that
appears when you choose the MasterFields property in the Object Inspector. The
"Field Link Designer" windows should appear. Select the "Detail Field" and the
"Master Field" which will create the relationship between both databases and then
click the "Add" button. Then the selected relationship should appear in the
"Joined Fields" section like in figure 6.14.
17°) Add the fields to the Table by right clicking in the T_Orders component and
selecting the "Fields Editor" option. Then in the new "DataModule2.T_Orders"
window, right click and select the "Add all fields..." option.
Note: You can select the fields you want to transfer by using the "Add fields"
option and choosing the fields you want to display or modify. This is useful for
optimizing network traffic, specially when you use low speed communication
lines.
18°) Drop a TsetProp component into the DataModule and modify the "Name" and
"DataSet" properties according to figure 6.16.
Figure 6.16
19°) Right Click in the SP_Orders components and select the "Update Field
description" option. This will retrieve the long description for each of the selected
fields from the iSeries data description file.
20°) Drop a TdataSource component from the "DataAccess" tab in Delphi's VCL.
Modify the "Name" and "DataSet" properties according to figure 6.17.
At this point the DataModule should look like the one in figure 6.19
Figure 6.19
All the database access components are now included in the Datamodule. All the
project's forms can access these tables via the DS_Customers, and the DS_Orders
components.
Let's create the database's data control components in the form. Right click in the
T_Customers object and select the "Fields editor" option. Select the following
fields:
CUSTNO, COMPANY, ADDR1, CITY, COUNTRY.
Figure 6.20
22°) Drop a TDBNavigator object into the form and modify the following
properties:
DataSource: ➜ DataModule->DS_Customers
Visible Buttons:
nbFirst ➜ TRUE
nbPrior ➜ TRUE
nbNext ➜ TRUE
nbLast ➜ TRUE
nbInsert ➜ FALSE
nbDelete ➜ FALSE
nbEdit ➜ FALSE
nbPost ➜ FALSE
nbCancel ➜ FALSE
nbRefresh ➜ FALSE
Figure 6.22
23°) Drop a TDBGrid component into the form and modify the following
properties:
Align ➜ alBottom
DataSource ➜ DataModule2.DS_Orders
If the "Active" property of the T_Orders object is set to true, then at design time
you should automatically have access to the first customer records in the
database. The ObjectInspector of the TDBGrid component should be similar to the
one of figure 6.23.
As all fields from T_Orders table were selected, then the grid should have one
column for each of the table's fields. In order to delete some irrelevant columns,
right click in he TDBGrid component and select the "Columns Editor" option. Then a
blank "Editing DBGrid1.Columns" windows should appear. Right click in that window
and select the Add all fields option, then the window of figure 6.24 should appear.
Select the fields you want to delete from the grid and press the Del key or right
click in the column editor window and select the Delete option.
At this time, the form should look like the one in figure 6.25.
Figure 6.25
You can now save all the files by selecting the "File | Save all files" menu option,
and execute the application by selecting the "Run | Run" menu option or by
pressing the function key F9.
Figure 6.26
This example will show how to use Delphi/400's Stored Procedure component
(TstoredProc) with the iSeries.
The final result window should be like the one in figure 6.29
In the iSeries:
NB. Because the CO411 library is ceated with the “CRTLIB” command, and not the
“CREATE COLLECTION”, you will get the following message: the procedure is created
but not saved .
In Delphi IDE:
5° Add two TEdit Objects and Name the parm1 and parm2 respectively.
6° Add a TButton and fill the "Caption" property with "Execute AS/400 program"
9° Select the Tbutton object and select in the Object Inspector, the Events Tab
Double Click on the OnClick event and fil in the following lines of code:
If you insert all the components, the form you created shouldlook like the form in
figure 6.30.
This next example will show you how to call an iSeries program from Delphi using
Delphi/400's components.
The final result of this example should look like figure 6.31
Figure 6.31
In the iSeries:
In Delphi:
Library Name : iSeries library name where you created the RPG
program in the preceeding step
7° Add the Memo and the other Label Objects if you wish.
8° Double click on the "Run program" button and fil in the following lines of
code:
var
myds:Tds; // Define a var for the Data structure
temp: string; // Temporary String variable
begin
// fill the data structure for PARM1 with the Edit values from the form
move(pchar(edit1.text)^,myds.name,length(edit1.text) );
move(pchar(edit2.text)^,myds.address,length(edit2.text) );
move(pchar(edit3.text)^,myds.zipcod,length(edit3.text) );
move(pchar(edit4.text)^,myds.city,length(edit4.text) );
// prepare one single string with all the parameters collected in the Data Structure
SetLength(temp, SizeOf(myds));
move(myds,pchar(temp)^,SizeOf(myds));
Figure 6.32
Example:
While Condition do
Begin
if not Query1.Prepared then
begin
Query1.Close;
Query1.Prepare;
....
Query1.ParamByName('Value').ASString := 'Customer_Name';
....
Query1.Open;
end;
end;
The following example will show you how to use prepared SQL statements.
The purpose of this application is to earn time by coding your SQL string with
parameters by runnig PREPARE before opening or executing your query. This
sample shows how to run a SELECT and an INSERT statements with the
CO411/Customer file.
3° Insert two TQuery components in the Form and fill in the properties:
TQuery1
• DatabaseName The name of a BDE Alias where you declared
the iSeries and the library name containing the
programs mentioned in the previous steps.
• Name QuerySelect.
• SQL Click on the ... button to display the editor,
insert : select * from cuatomer where custcode
= :mycode
8° Add a TButton and fill the "Caption" property with "Run Select" and the
"Name" property with "ButtonSelect"
9° Double click on the "Run program" button and fil in the following lines of
code:
10° Add a TButton and fill the "Caption" property with "Insert" and the "Name"
property with "ButtonInsert"
11° Select the Tbutton object and select in the Object Inspector, the Events Tab
Double Click on the OnClick event and fil in the following lines of code:
screen.cursor:=crdefault;
end;
At this point you should have a form that looks like the following:
Now that you have chosen your spool, you will be able to apply some
“formats” on it. Those formats definition are recorderd in a format file with an
“.sfd” extension, to be reused later.
Now, click on the property editor button of the FormatFile property. A window
will appear inviting you to type the name of your new format file (or to choose
an existing one).
Name your format file, for example myfmt1.sfd, click on Open. The graphic
design window of spool formats will appear.
Format/Font menu enables you to use different fonts to display the spool.
Using various fonts will enable you to better distinguish the text used in your
spool.
In order to exclude them in the useful data, the zone «Number of page to
skip at the beginning » will be used.
Column end
Column beginning
Header
Footer
The columns that are found automatically are displayed in the green area.
In the horizontal ruler each column is delimited by 2 buttons (at the
beginning and end of the column). These buttons enable you to change the
position and the size of the columns.
Header and Footer may be managed the same way by clicking the buttons
in the vertical ruler.
Columns tab enables you to modify field attributes such as Name, Type,
Offset, length and date format.
Available types are:
A = Alphanumeric,
N = Numeric,
D=Date,
T=Time
The selected column (by clicking inside the column area or by selecting in
the Name Combo Box) will appear with a bold border
Up to now spool formatting is valid for all the pages. The Format tab will
enable you to create different page formats for different kinds of pages.
Click on the New button. You have to select the part of text that will
identify the new page format.
Automatic update
Selected Text
Now you can create your columns, header and footer for this particular
page format.
In the example above, the created format will be used only if text
« REPORT » appears on line 12 and column 154.
To display a database file content in a DBGrid with dbExpress, you should place 6
following components:
Click on OK button . The panel will disappear . Set the property Connected to
True. You will be invited to enter the password.
DBConnection : SQLConnection1
7° Place a DBGrid from the Data Controls palette, select DataSource1 for
DataSource property, as the following:
On the CodeGear RAD Studio, the form shows the result as follows:
This chapter gives you all the details concerning the use of Delphi/400 with the
presentation of the iSeries components: their properties, methods, events and
tips.
If you have problems using any of these methods or properties, please consult
the Delphi literature before working with the ScreenDesigner/400 components.
Application examples
The program permutes the first three parameters, adds 5000 to the fourth
and 10000 to the fifth.
Creation of a component
The project (SAMPLES)\COMBOBOX\COMBOBOX.DPR is a sample of
creating a visual object ClientObjects/400. It provides the source for the
creation of the visual component TComboBox400. This class permits the
display of a iSeries file field in a ComboBox ; it inherits the Delphi
TComboBox class. You can install this new component in the palette if you
wish; but, above all, you can inspire yourself of this sample to create your
own visual components. Make them known to us!
Consulting a file
The project (SAMPLES)\CONSULT\PCONSULT.DPR is a sample of Delphi
code using the ScreenDesigner/400 methods (and especially those of the
TFile400 class) for consulting the iSeries file of your choice. It is a good
example of definition and usage of a iSeries file by programming.
Note that the components TQuery400 and TTable400 are only provided in
this version to support backwards compatibility with Delphi 1
This class enables you to manage the communication between your P.C.
and your iSeries, in particular the connection and disconnection. This class,
once created, permits to verify the good installationof your router and
ScreenDesigner/400 (while passing the Active property at True).
TAS400 can also either activate or deactivate the transactional control
defined by an object of class TTransaction400 then manage these transactions.
TTransaction400
TFile400
The methods of class TFile400, will help you execute on this file the
following actions:
© SystemObjects 1997-2008 www.systemobjects.com 124
• Opening of the file,
• Closing of the file,
• Sequential reading in the order of opening (First, Next, Preceding,
Last),
• Reading by key for available files (First, Next, Preceding, Last),
• Reading by relative record number (RRN), the current number being
accessible at any time,
• Lock-up of the current record,
• Modification of the current locked record,
• Addition of a record,
• Deletion of the current locked record,
• Reading of the file description.
These requests can evidently be refused by the iSeries which solely allows
or refuses the access, the rights and the actions asked for.
TSQL400
The TSQL400 class permits to display the result of a request in the SQL
format. If no logical path is found, the SQL of the iSeries is then used ;
otherwise ScreenDesigner/400 proceeds to a native-mode access to the
corresponding file.
The display of resulting data is achieved in the same way as with the class
TFile400.
SQLBuild400
The TNavig400 class permits to move in the associated file, to ask for a
creation, a modification or a cancellation on this file. Record locks are
managed automatically.
The navigation buttons, inheriting the TSpeedButtons, don't take the
‘Focus’.
TGrid400
The filling of the Grid400 is dynamic. The class object TGrid400 reads on
the iSeries the maximum of the necessary record number for the display ;
readings are made every time the vertical scroll bar is used. That allows a
fast display (rarely more than 20 readings) of files which may contain a
very important number of records. On the other hand, the vertical scroll bar
has only three different positions: beginning, middle and end of file.
The user has the possibility, if the programmer gave him the right, to
modify the data directly in the Grid400. The modifications done in the
Grid400 are sent automatically to the iSeries at every record change. A
verification of type is done for the newly stored fields .
TField400
The TField400 class allows you to display and to modify a file field . It
inherits the graphic management of Delphi’s TEdit class. The conversions of
the iSeries type onto P.C. are invisible to the programmer (being done by
the MiddleWare). As the component is exited, a verification of type is done
on the recorded text. The data modification is not done automatically with
the change of text; it is, therefore, necessary to use the modification
methods of the file (or the object Navig400 of type Modification).
TLabel400
The TLabel400 class permits only the display of data. It inherits Delphi’s
TLabel and, therefore, has the same graphic management .
This class can be used to display the description fields, for example.
TMemo400
The TMemo400 class provides more possibilities than the class TField400:
• It inherits all the advantages of Delphi’s TMemo class (Line-up of text
which can be on several lines...)
• It also permits to display the iSeries fields of alphanumeric type of more
than 255 characters.
This class can be used for the long fields (> 50 characters, for example)
enabling their display on several lines.
TlookUp400
The look up file can be of any type, the programmer can choose a sub-list
of this file’s fields as well as a filter if allowed by it. A property defines the
font to be used in the Grid400 of the look up window. When exiting, the
TCall400
The TCall400 class allows the Delphi programmer to call in the iSeries
programs , whether written in C, RPG, CL or any other language.
A property editor permits the definition of different parameters of the
program and their initializing. This definition can also be done by
programming in Pascal.
Once the program is called up, parameters can be consulted.
Through this class the Delphi programmer has access to all the API of the
OS/400. This class was in fact used for the construction of the TDataArea
and TDataQueue classes.
TCmd400
The TCmd400 class gives you the possibility to start iSeries commands with
return of parameters.
A property editor permits the definition of different return values of the
command. This definition can also be made by programming in Pascal.
After execution of the command, the returned values can be consulted.
TDataArea
The TDataArea class permits to consult and to modify a Data Area on your
iSeries, whether of alpha-numeric, numeric or logical type.
TDataQueue
TMessageQueue
The class TMessageQueue manages the message queue on your iSeries.
The developer can send, read, or remove messages on an iSeries message
queue. The user can retrieve the sender’s information.
ColIFS
The TCoifs class permits you to manage your AS400 Integrated File System
For more information about IFS refers to IBM documentation : «OS/400
Integrated File System».
This component works associated to TAS400 component.
ColIFSBrowser
ColIFSBrowserFiles
SC5250
SC5250Panel
Ancestor TComponent
Unit SCDCONN
Type Boolean
Properties
Active
This property returns or changes the state of the connection with the AS400.
As the property passes from False to True, a connection with the iSeries is
created. If the connection goes through normally, work is started on the iSeries.
This activity is found in the QCMN pool if you use an APPC connection protocol, if
TCP/IP is used, then connection is managed by the CO411TCP subsystem (that
depends on the configuration of your system). The status of this activity is CPCW
If you start a second connection on the same iSeries (with the help of a second
instance of this class, for example), it will use the first connection and no change
will occur on your iSeries.
As the property passes from True to False, the disconnection is made on the
iSeries (except if, as in the previous case, two connections have been requested ;
then, the disconnection will take place when the two properties are at False) and
the activity disappears.
If the property change does not go through (impossible connection, for example),
the class generates (' raises ') an exception of class ECO400Error that you can
manage ( See the chapter dealing with error management).
If an user turns off his P.C. as a program is in progress , the object destroys itself
abnormally and the disconnection doesn't take place. However, the computer
being turned off, the iSeries lost its controller and the job is stopped.
If the iSeries breaks down, the P.C. will have an APPC error at the next access
but the P.C. doesn't block itself; you can manage the APPC error, for example
(see the chapter dealing with errors) and stop the application.
BufferSize
Type: Integer.
This property corresponds to the size the router allocates itself for the APPC
communication. The MiddleWare also allocates itself this size as communication
buffer. The size can run from 272 to 32767. Response time vary very little with
the the buffer size. The size influences mostly the allocated memory on the P.C..
The value by default is 5000, that you can lower if you wish.
KeySeparator
Type: Char.
See also: FFilterValue (TFile400), GetByKeyFirst (TFile400), GeyByKeyNext
(TFile400), GetByKeyPrevious (TFile400), GetByKeyLast (TFile400), FilterValue
(TGrid400).
This property defines the character used as key delimiter. When defining filters or
having a key access, if this is a composite key then the separator must be used.
by default, it is equal to '; '. If you think a semicolon can appear in one of your
keys, then it is preferable to change this property to a more suitable value.
This property can be changed at any time. However, it is strongly advised to have
the same separator for all TAS400 objects.
Transaction
Type: TTransaction400.
This property, if non void (different of nil), permits to start, to stop and to
manage transactions. The BeginTrans , EndTrans, Committed and RollBacks
methods become accessible. For more information, consult the description of
these functions and of the TTransaction400 class.
At connection time, if this property is non null then the BeginTrans method is
executed automatically. At the same time, the EndTrans method is executed.
Methods:
BeginTrans
Parameters: none.
Return: Integer.
See also: EndTrans, Commit, Rollback, Active.
Example:
{MyAS400: TAS400;}
{MyTransaction: TTransaction400}
try
MyAS400.Active:=True;
except
one E:ECO400Error do
ShowMessage (' Connection error: ' + E.Message);
end;
MyAS400.Transaction:=MyTransaction;
try
MyAS400.BeginTrans;
except
one E:ECO400Error do
begin
ShowMessage (' BeginTrans problem: ' + E.Message);
© SystemObjects 1997-2008 www.systemobjects.com 134
MyAS400.Active:=False;
end;
end;
MyAS400.Active:=False;
This method permits to start a transaction. Files that you wish to manage in a
transactional mode must be opened afterwards, in Controls transactional mode (
See property Commit of TFile400). Remember that this method was executed
automatically if at the time of connection the Transaction property was non null.
Commit
Parameters: Description commit: PChar.
Return: Integer.
See also: Rollback, BeginTrans, EndTrans, Active.
Example:
{MyAS400: TAS400;}
{MyTransaction: TTransaction400;}
MyAS400.Transaction:=MyTransaction;
try
MyAS400.Active:=True; {BeginTrans done}
except
one E:ECO400Error do
ShowMessage('Connection error(' +IntToStr(E.ErrorCode)+ '): ' +E.Message);
end;
... {Delete, Insert, Update}
MyAS400.Commit (' COMMITTED: END SESSION ');
MyAS400.Active:=False; {EndTrans done}
This method permits to confirm the modifications made on the files opened in
Controls transactional mode. The method parameter is a heading that will be
indicated in the notification object ( See class TTransaction400). If the method
fails, it generates an ECO400Error exception.
Disconnect
Parameters: None.
Return: None.
See also: Connect, Active.
Example:
{MyAS400: TAS400;}
try
MyAS400.Connect;
except
one E:ECO400Error do
ShowMessage ('Connection error (' +IntToStr(E.ErrorCode)+ '): '
+E.Message);
end;
MyAS400.Disconnect;
EndTrans
Parameters: None.
Return: Integer.
See also: BeginTrans, Commit, Rollback, Active.
Example:
{MyAS400: TAS400;}
{MyTransaction: TTransaction400}
© SystemObjects 1997-2008 www.systemobjects.com 136
MyAS400.Transaction:=MyTransaction;
try
MyAS400.Active:=True; {BeginTrans done}
except
one E:ECO400Error do
ShowMessage ('Connection error (' +IntToStr(E.ErrorCode)+ '): '
+E.Message);
end;
MyAS400.EndTrans;
MyAS400.Active:=False;
This method permits to finish a transaction. The files that you manage in
transactional mode must be closed before. Remember that this method was
executed automatically if at the time of disconnection the Transaction property
was non null.
If the method fails, it generates an ECO400Error exception.
RemoteCmd
Parameters: Command iSeries: String.
Return: Integer.
See also: class TCmd400.
Example:
{MyAS400: TAS400;}
try
MyAS400.Connect;
except
one E:ECO400Error do
ShowMessage ('Connection error (' +IntToStr(E.ErrorCode)+ '): '
+E.Message);
end;
try
try
MyAS400.RemoteCmd (' ADDLIBLE WORKLIB ');
except
ShowMessage (' Library WORKLIB cannot be added! ');
end;
finally
MyAS400.Disconnect; end;
This method allows you to execute an iSeries command. If this command cannot
be executed, an ECO400Error exception is generated. For more details on the
RollBack
Parameters: None.
Return: Integer.
See also: Commit, BeginTrans, EndTrans, Active.
Example:
{MyAS400: TAS400;}
{MyTransaction: TTransaction400}
MyAS400.Transaction:=MyTransaction;
try
MyAS400.Active:=True; {BeginTrans done}
except
one E:ECO400Error do
ShowMessage ('Connection error (' +IntToStr(E.ErrorCode)+ '): '
+E.Message);
end;
... {Delete, Insert, Update}
MyAS400.RollBack;
MyAS400.Active:=False; {EndTrans done}
This method permits to cancel the modifications made on the files opened in
transactional Control mode. If the method fails, it generates an ECO400Error
exception.
A RollBack at the server's level is done automatically if the P.C. or the iSeries fails
accidentally.
BeforeActivation
Type: TNotifyCancelEvent
Call: the code added to this event is executed right before a connection.
The parameter ' Cancel ' (of Boolean type), if put at True, permits to cancel the
connection.
BeforeDeactivation
Type: TNotifyCancelEvent
Call: the code added to this event is executed right before the disconnection.
The parameter ' Cancel ' (of Boolean type), if put at True, permits to cancel the
disconnection.
OnActivation
Type: TNotifyEvent
Call: the code added to this event is executed right after the connection.
OnDeactivation
Type: TNotifyEvent (Class Delphi).
Call: the code added to this event is executed right after the disconnection.
If you want to know the list of the available iSeries, you have two possibilities:
Example:
{AS400list: TStringList;}
AS400list:=TStringList.create;
try
TcGetAS400(AS400list);
...
finally
AS400list.Free;
end;
2. Use a direct call to the DLL of the MiddleWare. Add the statement:
This function will send back to you as first parameter the number of iSeries, as
second parameter the list of the iSeries with first the iSeries by default and
{TAB}’s (code ASCII 9) to separate all the names of iSeries.
Router Test
If an error occurs then the router is badly installed ; see the section ' Current
Errors ' below.
Library Management
By using the RemoteCmd method, you can add a library on line (remoteCmd ('
ADDLIBLE LIBRARY1 ')). You can then use ' *LIBL ' as library in order to open
files. Thus, your application can turn either into a work library or into a
production library according to which one you have put on line.
Possible causes:
• your trial period has expired.
• or your number of admitted simultaneous stations is exceeded.
Solution:
consult the chapter concerning the installation of the product in order to put
in a new security key.
Possible cause:
the PLUAlias property is not correct, the name of the iSeries can not be
found.
Solution:
Put the name in capital letters,
or verify the name and the state of the iSeries.
Possible causes:
Router installed badly, or bad DLL EHNAPPC.DLL or EHNRTRW.DLL (for
example, that of PCS while the router is NSRouter),
or Router not started.
Solution:
Start your router or verify its installation.
Possible cause:
A programming error caused a GPFault that stopped your application and
the DLL CO400.DLL remained in memory while you started again your
application.
Solution:
Unload CO400.DLL off the memory either by an utility that you may have or
by starting again Windows.
Parent TComponent
Unit SCDCONN
This class is used to define a transactional control mode, but it does not manage
the transactions (it includes only property definitions). The same definition of the
transactional control mode may be used by several iSeriess. It is class TAS400
that actually manages the transactions.
Level Type:
coLevel (see the section “Types used by ScreenDesigner/400”).
This property defines the level of transaction control. On the iSeries, three levels
are available:
• lvCHG : Each record needing to be updated is locked. All added, modified, or
deleted records remain locked until the next validation (Commit) or invalidation
(Rollback) of the transaction. The records accessed for update but not changed
are unlocked.
• lvCS: Each record accessed in files opened under transactional control
mode is locked. Each record read but not modified or deleted is unlocked when
another record is read. All records added, modified, or deleted are locked until
validation (Commit) or invalidation (Rollback) of the transaction.
• lvALL: All records read from files opened under transactional control
mode are locked until validation (Commit) or invalidation (Rollback) of the
transaction.
ObjLib
Type: String.
See also: ObjMbr, ObjType, ObjName.
This property is one of the four properties used to define the commit object (with
ObjType, ObjName, ObjMbr). It indicates the name of the library where the
commit object is located. Its length may be up to 10 characters.
ObjName
Type: String.
See also:ObjMbr, ObjType, ObjLib.
This property is one of the four properties used to define the commit object (with
ObjType, ObjLib, ObjMbr). It indicates the name of the commit object. Its length
may be up to 10 characters.
ObjType
Type: coObjType
See also: ObjMbr, ObjLib, ObjName.
This property is one of the four properties used to define the commit object (with
ObjLib, ObjName, ObjMbr). It indicates the type of the commit object. Four types
are possible:
• otNONE: any object (default value).
• otMSGQ: a message queue.
• otDATAARA: an alphanumeric data area reserved to this job.
• otFILE: a physical file.
If the commit object is of a type different from otNONE, it must exist as defined
by one of the other three type values available for this property. Otherwise, an
error code will be generated when the transaction is initiated (BeginTrans).
Target
Type: coTarget (see the section “Types used by ScreenDesigner/400”).
This property defines the scope of the validation of transactional control mode.
Two scopes of validation are offered:
• tgACTGRP: Validation at the level of an activating group is initiated for the
activating group associated with the program when issuing the command from
CO400.
• tgJOB: Validation at the level of a job is initiated at the start of a job (default
value).
Parent TComponent
Unit SCDesign
This class is used to manage an iSeries file or one of its members: either a
physical, logical, or join logical file. With the properties of the class TFile400, you
can define:
• *LIBL as your library list.
• Your access rights to the file.
• The access rights of other users to the file.
• Access files in transactional mode.
• Order of accessing the iSeries files: the order in which the records were
created (by 'RRN', relative record number) or the order defined by the
default key.
© SystemObjects 1997-2008 www.systemobjects.com 147
• A filter for the records to be displayed, based on the key of the file (if one
exists); the key may include multiple fields.
• A subset of fields to manage, if you want to minimize activity on the
network.
• The Blocking Factor, used to read multiple records at a time on the iSeries;
it can enhance the performance of certain processes by up to eight times.
With the methods of the class TFile400, you can perform the following operations
on a file:
• Open a file.
• Close a file.
• Read the file sequentially, in the access order (First, Next, Previous,
Last).
• Read the file by access key, when applicable (First, Next, Previous, Last).
• Access the file by record number (RRN); the current record is accessible
immediately.
• Lock the current record.
• Modify the currently locked record.
• Add a record.
• Delete the currently locked record.
• Access the file description.
All the requests listed may be performed or disallowed by the iSeries, which will
authorize or disallow access or actions based on its security system.
Data originating at, or heading for, the iSeries always transits through a memory
zone managed by the TFile400 component. Data can be accessed in 2 ways: ·
In memory:
The access methods with a suffix of "InCacheValues" are used to modify the
field’s content. The TField400 or the Tgrid400 display components are not
Directly:
If you have display components, the call to suffix-less access methods (for
example, GetFirst) updates the present components.
Properties
Active
Type: Boolean
This property manages opening and closing a file on the iSeries.
As the property changes from False to True, a request to open the file is initiated.
The properties AS400, LibraryName, FileName (FileMember if called for) and
FileDescription must have been updated prior to setting the status to 'True'. The
connection becomes active if it wasn’t already so (see the property Active of the
class TAS400). If opening the file is successful, then the first record is read. In
'Design/Developer' mode, this property is used to display the first record, or first
few records, if an object of the class TGrid400 is accessing the file.
Inversely, when the property passes from True to False, a request to close the file
is initiated. The connection stays active, and closing the file is done automatically
(passes from Active to False) when a disconnection is initiated by the attached
AS400 object.
If an error occurs the class generates an exception and will 'raise' an error of the
class ECO400Error that you can manage (see the chapter “Managing the error
codes”).
AS400
Type: TAS400.
See also: Class TAS400.
This property indicates on which iSeries the file is located. It is taken into
consideration when the file is opened, and must not be left blank. In the 'Design'
mode, you will see a list of accessible iSeriess in a window.
BOF
Type: Boolean. READONLY.
See also: EOF.
This property indicates whether the cursor is at the beginning of the file.
It takes into consideration applied filters.
BufferCount
Type: Integer.
This property defines the number of records included in the buffer at each I/O
request.
If the property is set to 0 (default value) or 1, then no buffering occurs and at
each access to the iSeries a request and a response are performed. If this
property is equal to at least two then it defines the size of the buffer in terms of
the number of records.
The value of this property is very important and is often used to greatly
enhance response time. In fact, by reading the records in groups of
BufferCount size, the number of I/O requests from the PC to the iSeries is
tremendously reduced.
The size of the buffer is limited to 32 Kbytes. An exception is generated if the size
limit is exceeded. This property can be modified at any time, even if the file is
already open.
CalcFields
Type: TStringList.
See Also: AddCalcField, RemoveCalcField, ClearClalcFields, OnCalcFields,
Example: CALCFLD.
This property is used to define the list of calculated fields associate with the file.
These calculated fields are defined by the event OnCalcFields. In ‘Design’ mode, a
window is used to enter the different calculated fields:
© SystemObjects 1997-2008 www.systemobjects.com 150
To define this property in programs, use the methods AddCalcField,
RemoveCalcField and ClearCalcFields.
Commit
Type: Boolean.
When the file is open and this property is set to True, then the file is added to the
open transactions. For the access to the file in 'Commit' mode to be successful,
you must have started a transaction on the accessed iSeries (see the property
Active and Transaction and the method BeginTrans of the class TAS400) and this
file must be journaled at the iSeries level (refer to your iSeries system manager).
This property is taken into account only when a file is opened.
DoNotUseRecordNumber
Type: Boolean.
EOF
Type: Boolean. READONLY!!!!.
See also: BOF.
This property indicates whether the cursor is at the end of the file.
It takes the applied filter into consideration.
FfilterComparison
Type: coTypeComparison (see the section “Types used by ScreenDesigner/400”).
See also: FFilterValue.
This property is one of two properties used to define a selection filter on the file
level. To define a selection filter, the value of this property must not be tcNone
and the property FFilterValue defined below must not be blank. The filter cannot
be defined unless the file has an access key that matches the filter. The filter
selection applies to the access key.
• tcNone: No filter.
• tcLessThan: Requests records that have a key that is strictly less
than the key or partial key defined by the property FFilterValue.
• tcLessOrEqual: Requests records that have a key that is less than
or equal to the key or partial key defined by the property FFilterValue.
• tcEqual: Requests records that have a key equal to the key
or partial key defined by the property FFilterValue.
• tcGreaterOrEqual: Requests records that have a key greater than or
equal to the key or partial key defined by the property FFilterValue.
• tcGreaterThan: Requests records that have a key that is strictly
greater than the key or the partial key defined by the property FFilterValue.
• tcLike: Requests records in which the beginning of the
access key is identical to the key or the partial key defined by the property
FFilterValue. This comparison is usable only if the last field indicated in the
property FFilterValue corresponds to a field of alphanumeric type.
This property is one of two properties that allow the definition of a selection filter
on the file level. To define a selection filter, the value of property
FFilterComparison defined above must not be tcNone and property Ffilter Value
cannot be blank. The filter cannot be defined unless the file has an access key
that matches the filter. The filter selection applies to the access key.
The filter can contain multiple fields that will be separated by the KeySeparator
(property of the class TAS400 that defines the delimiter). The number of fields
must be less than or equal to the number of fields in the file access key.
The order of fields in the access filter must correspond strictly to the order of
fields in the access key of the iSeries file. However, the filter may drop fields
present in a composite key beginning with the last field. It is important that the
remaining fields preserve the order of the iSeries file access composite key. You
may drop as many of the fields from the filter as you wish in this way.
Example: On a CUSTOMER file having two keys (State, Company name) you can
set up a filter:
• TN;MC (with FFilterComparison=tcLike and KeySeparator=';'): all the
companies that have names starting with MC in the state of TN.
• CA (with FFilterComparison=tcEqual): all the companies in the state of
California.
Example: On an INVOICE file having two keys (customer number and invoice),
you can set up a filter:
• 12 (with FFilterComparison=tcEqual): all invoices for customer number
12.
• 12;01-01-1996 (with FFilterComparison=tcGreaterOrEqual and
KeySeparator=';'): all the invoices for customer number 12 starting January
1, 1996.
The two fields of this filter follow the order of the file access composite key, with
the result that the filtered index accesses all the invoices of all the customers
starting at the beginning of the year 1996. A more practical approach would be
to reduce access time by using a logical file with the invoice date as the first field.
This property defines the list of fields to be used. It allows the middleware to
transfer only the data that is needed, thus reducing activity on the network. For
reducing response time, this feature is of interest only in the case of an ethernet
network that accesses distant locations using RTC. (See the property BufferCount
for a means of affecting response time that applies across platforms.) The key
fields must be in the field list.
The list represents a list of fields that are separated by ';'. If the list is empty
then all the fields were selected.
A note such as '*1', '*2', and more generally '*i' at the end of the name of a field
signifies that the field is part of the file key and indicates its order in this key.
FileDescription
Type: String.
See also: AS400, LibraryName, FileName, FileMember.
This property must return a unique identifier of the iSeries file description (this
description contains the following information: number of fields, name of the
fields, and name of the keys). When the value of this property changes, and if
AS400, LibraryName and FileName are all non-empty, then the description of the
file is read.
Accessing the file description locally on the PC works to improve access time
when the object File400 is being initialized.
If the structure of the file is modified on the iSeries, delete the associated PC file
so that it will be recreated. Uniqueness of the name is necessary so that a file is
not opened with a wrong description, which could create a GPF (General
Protection Fault) or give you completely incoherent data.
Example: You have two files that have the same name and are in two different
libraries, but have two different descriptions. The two objects File400 must then
have two distinct FileDescription properties (so that one of the two objects
File400 will have a description assignment different from the automatic one) .
• If the name is 8 bytes or less, then the name of the file is the value of
the property with an extension '.FFD'.
• Otherwise, the name of the file corresponds to the first 8 letters of the
value of the property, and the rest of the characters will be used as an
extension.
For Example: 'DESC' gives 'DESC.FFD' and 'DESCRIPTIO' gives
'DESCRIPT.IO'
FileMember
Type: String.
See also: AS400, LibraryName, FileName, FileDescription.
This property is used to work with a member of an iSeries file. If the file has one
member only, the property is not used.
When the value of this property changes, if AS400, LibraryName and FileName
are all non-blank then the description of the file is read (see property
FileDescription).
FileName
Type: String.
See also: AS400, LibraryName, FileMember, FileDescription.
This property allows you to define the name of the iSeries file.
When the value of this property changes, if AS400, LibraryName and FileName
are all non-blank then the description of the file is read (see property
FileDescription).
IndexKeys
Type: TList.
See also: GetKeyIndex, GetTotalKeyIndex, GetFieldIndex, GetTotalFieldIndex.
This property allows you to retrieve the list of fields that constitute the file access
key. It is a list of pointer integers that represent the index of the file’s fields (see
GetTotalFieldIndex).
Example:
{ListOfKeys:String;}
{MyFile: TFile400;}
ListOfKeys:=''
For i:=0 to MyFile.IndexKeys.count-1 do
begin
if ListOfKeys='' then
ListOfKeys := IntToStr(Integer(MyFile.IndexKeys[i]^))
else
ListOfKeys := ListOfKeys +
IntToStr(Integer(MyFile.IndexKeys[i]^))
end;
LibraryName
Type: String.
See also: iSeries, FileName, FileMember, FileDescription.
© SystemObjects 1997-2008 www.systemobjects.com 157
This property is used to specify the library where the iSeries file is located.
When the value of this property changes, and if AS400, LibraryName and
FileName are all non-blank, then the description of the file is read (see property
FileDescription).
The generic name can be left blank to view a list of all the libraries. To list all the
libraries starting with a certain prefix, type in the starting string followed with an
'*'.
LockOnRead
Type: Boolean.
See also: LockCurrent.
This property is used to lock or unlock a record. It is used at each read,
regardless of the type of access requested. If it is set to True, the read is
performed with a record lock; otherwise, (default value) the read is performed
without locking the record.
SharingRights
Type: coSharR (see the section “Types used by ScreenDesigner/400”).
See also: UserRights, Active.
This property is used to define the access rights given to the user :
• rgNone: Any rights, open file in exclusive mode.
• rgRead: File accessible in read mode only.
• rgUpdate(default value): File left completely available.
This property is taken into account only when the file is opened.
© SystemObjects 1997-2008 www.systemobjects.com 158
TypeOpen
Type: coTypeOpen (see the section “Types used by ScreenDesigner/400”).
See also:Active.
This property is used to define the access to the file:
• toDefault (default value): The records are ordered based on the standard
order: by key order if the file description has a key, or by record number
(same as toRRN).
• toRRN: The records are ordered by record number, in the order of
creation.
UserRights
Type: coUserR (see the section “Types used by ScreenDesigner/400”).
See also: SharingRights, Active.
This property is used to define the file access rights you give yourself.
• rgRead: File open in read mode only.
• rgUpdate(default value): File open in read/write mode.
Methods
AddCalcField
Parameters: Name of the calculated field: String,
Description of the calculated field: String.
Return: None.
See Also: RemoveCalcField, ClearCalcFields.
Example:
{MyFile400: TFile400;}
MyFile400.ClearCalcFields;
MyFile400.AddCalcField('CUSTCODE','Customer Code');
This method is used to add a calculated field to an accessed file. The programmer
will have to further define the value of the calculated field in the event
OnCalcFields.
Delete
Parameters: none.
Return: Integer.
See also: LockCurrent, LockOnRead.
Example:
{MyFile400: TFile400;}
try
MyFile400.Open;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
MyFile400.LockOnRead:=True; {You have to lock the record before deletion}
try
try
MyFile400.GetByKeyFirstInCacheValues('TCIS','EQ');
MyFile400.Delete;
except
ShowMessage('Problem during deletion');
end;
© SystemObjects 1997-2008 www.systemobjects.com 160
finally
Myfile400.LockOnRead:=False;
MyFile400.Close;
end;
This method is used to delete a record. You must lock the record prior to the
delete action, with the method LockCurrent, for example. If an error occurs, an
exception code ECO400Error is generated.
GetByKeyFirst
Parameters: Key to seek: String,
Key operator: String.
Return: Integer.
See also: KeySeparator (TAS400), GetByKeyNext, GetByKeyPrevious,
GetByKeyLast,GetByKeyFirstInCacheValues.
Example:
{MyFile400: TFile400;}
{Ret: Integer;}
try
MyFile400.Active:=True;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
Ret:=MyFile400.GetByKeyFirst('TCIS','EQ');
While Ret=0 do
begin
{code}
Ret:=MyFile400.GetByKeyNext('TCIS','EQ');
end;
MyFile400.Close;
This method is used to seek the first record meeting a certain defined criterion
and takes into account any filters applied (see the properties FFilterValue and
FFilterComparison). This request is composed of a compare operator (the second
parameter) and the value compared (the first parameter). Once the record is
read, the visual components attached to this file will be updated.
This method can be used only if the iSeries file has an access key.
The first parameter, comparison value, is a particular value of the file key or of
the composite key that is being targeted. The different fields of a composite key
must be separated by the KeySeparator (class TAS400).
The second parameter, comparison operator, may be one of the following values:
• 'EQ' (Equal): to reach the first record in the file, the key or a subset of a
key must match exactly the value specified in the first parameter.
• 'GE' (Greater or Equal): to reach the first record in the file, the key or a
subset of a key must be greater than or equal to the value specified in
the first parameter.
• 'GT' (Greater Than): to reach the first record in the file, the key or a
subset of a key must be greater than the value specified in the first
parameter.
• 'LE' (Less or Equal): to reach the first record in the file, the key or a
subset of a key must be less than or equal to the value specified in the first
parameter.
• 'LT' (Less Than): to reach the first record in the file, the key or a subset
of a key must be less or than the value specified in the first
parameter.
• 'LK' (Like): to reach the first record in the file, the key or a subset of a
key must start with a value equal to that specified in the first parameter.
For example : for Lk 'TC', the method will reach the first record that
has a key starting with 'TC'. It is imperative that this key field be of an
alphanumeric type. This operator may be used on a composite key.
The comparison operator is applied to the portion of the key supplied in the target
value.
If no record matches the criteria selected, the return code is set to 211. Only the
return code identifies the errors that occur; no exception is generated.
Example:
{MyFile400: TFile400;}
try
MyFile400.Active:=True;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
try {Exception raised for End of File}
MyFile400.GetByKeyFirstInCacheValues('TCIS','EQ');
While True do
begin
{code}
MyFile400.GetByKeyNextInCacheValues('TCIS','EQ');
end;
except;
MyFile400.Close;
end;
This method is similar to the method GetByKeyFirst. One difference is that the
exception ECO400Error is generated in case of an error (End of File is considered
an error). Further, this method, after reaching the targeted record, does not
update the visual components associated with the file. It can thus be used to
make accessing the file invisible to the user.
GetByKeyLast
Example:
© SystemObjects 1997-2008 www.systemobjects.com 163
{MyFile400: TFile400;}
{Ret: Integer;}
try
MyFile400.Active:=True;
Except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
Ret:=MyFile400.GetByKeyLast('TCIS','EQ');
While Ret=0 do
begin
{code}
Ret:=MyFile400.GetByKeyPrevious('TCIS','EQ');
end;
MyFile400.Close;
This method is used to reach the last record that corresponds to the request, and
takes into account any filter that has been applied (see the properties
FFilterValue and FFilterComparison). This request has a comparison operator (the
second parameter) and a value to be compared (the first parameter). Once the
record is read the visual components attached to the file are updated.
For more information on the parameters, refer to the method GetByKeyFirst.
GetByKeyLastInCacheValues
Example:
{MyFile400: TFile400;}
try
MyFile400.Active:=True;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
try {Exception raised for Begin of File}
MyFile400.GetByKeyLastInCacheValues('TCIS','EQ');
While True do
begin
© SystemObjects 1997-2008 www.systemobjects.com 164
{code}
MyFile400.GetByKeyPreviousInCacheValues('TCIS','EQ');
end;
except;
MyFile400.Close;
end;
This method is similar to the method GetByKeyLast. One difference is that the
exception ECO400Error is generated in case of an error (End of File is considered
an error). Further, this method, after reaching the targeted record, does not
update the visual components associated with the file. It can thus be used to
make accessing a file invisible to the user.
GetByKeyNext
Example:
{MyFile400: TFile400;}
{Ret: Integer;}
try
MyFile400.Active:=True;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
Ret:=MyFile400.GetByKeyFirst('TCIS','EQ');
While Ret=0 do
begin
{code}
Ret:=MyFile400.GetByKeyNext('TCIS','EQ');
end;
MyFile400.Close;
This method is used to reach the next record that corresponds to the request, and
takes into account any filter that may have been applied (see the properties
GetByKeyNextInCacheValues
Example:
{MyFile400: TFile400;}
try
MyFile400.Active:=True;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
try {Exception raised for End of File}
MyFile400.GetByKeyFirstInCacheValues('TCIS','EQ');
While True do
begin
{code}
MyFile400.GetByKeyNextInCacheValues('TCIS','EQ');
end;
except;
MyFile400.Close;
end;
This method is similar to the method GetByKeyNext. One difference is that the
exception ECO400Error is generated in case of an error (End of File is considered
an error). Further, this method, after reaching the targeted record, does not
update the visual components associated with the file. It can thus be used to
made accessing the file invisible to the user.
Return: Integer.
Example:
{MyFile400: TFile400;}
{Ret: Integer;}
try
MyFile400.Active:=True;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
Ret:=MyFile400.GetByKeyLast('TCIS','EQ');
While Ret=0 do
begin
{code}
Ret:=MyFile400.GetByKeyPrevious('TCIS','EQ');
end;
MyFile400.Close;
This method is used to reach the previous record that corresponds to the request,
and takes into account any filter that may have been applied (see the properties
FFilterValue and FFilterComparison). This request has a comparison operator (the
second parameter) and a value to be compared (the first parameter). Once the
record is read the visual components attached to the file are updated.
GetByKeyPreviousInCacheValues
Example:
{MyFile400: TFile400;}
try
MyFile400.Active:=True;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
try {Exception raised for Begin of File}
MyFile400.GetByKeyLastInCacheValues('TCIS','EQ');
While True do
Begin
{code}
MyFile400.GetByKeyPreviousInCacheValues('TCIS','EQ');
end;
except;
MyFile400.Close;
end;
GetByRecordNumber
Example:
{MyFile400: TFile400;}
{MyRRN: LongInt;}
{Ret: Integer;}
{...code...}
© SystemObjects 1997-2008 www.systemobjects.com 168
MyRRN:=MyFile400.GetRecordNumber;
{...code...}
Ret:=MyFile400.GetByRecordNumber(MyRRN);
If Ret<>0 then ShowMessage('Record not found');
{...code...}
This method is used to reach a record based on its number (RRN). It takes into
account any filter that has been applied (see the properties FFilterValue and
FFilterComparison). The first and only parameter is the record number you are
seeking.
The return code is set to 0 if everything went well; otherwise, the code indicates
that a problem has surfaced (for example, a record could just have been deleted
by another user). After reading the record, the visual components attached to the
file will be updated.
GetByRecordNumberInCacheValues
Example:
{MyFile400: TFile400;}
{MyRRN: LongInt;}
{...code...}
MyRRN:=MyFile400.GetRecordNumber;
{...code...}
try
MyFile400.GetByRecordNumberInCacheValues(MyRRN);
except
ShowMessage('Record not found');
end;
{...code...}
Example:
{MyFile400: TFile400;}
{FieldDescription:String;}
{i: Integer;}
For i:=1 to MyFile400.GetNumberCalcFields do
FieldDescription:=MyFile400.GetCalcFieldDescription(i);
This method is used to get the description of a calculated field based on its index
number.
GetCalcFieldName
Example:
{MyFile400: TFile400;}
{FieldName:String;}
{i: Integer;}
For i:=1 to MyFile400.GetNumberCalcFields do
FieldName:=MyFile400.GetCalcFieldName(i);
This method is used to get the name of a calculated field from the field index
number.
Example:
{MyFile400: TFile400;}
{FieldValue:String;}
{FieldSeq: Integer;}
FieldSeq := MyFile400.GetCalcFieldSeq('CUSTCODE');
FieldValue := MyFile400.GetCalcFieldValue(FieldSeq);
This method is used to get the index of a calculated field from the field name.
GetCalcFieldValue
Example:
{MyFile400: TFile400;}
{FieldValue:String;}
{i: Integer;}
For i:=1 to MyFile400.GetNumberCalcFields do
FieldValue:=MyFile400.GetCalcFieldValue(i);
This method is used to get the value of a calculated field from the index of the
field.
GetCurrent
Parameters: None.
Return: Integer.
© SystemObjects 1997-2008 www.systemobjects.com 171
See also: GetCurrentInCacheValues, LockCurrent.
Example:
{MyFile400: TFile400;}
{Ret: Integer;}
{...code...}
MyFile400.GetByKeyFirst('TCIS','EQ');
{...screen modification...}
Ret:=MyFile400.GetCurrent;
{ -> Cancel modifications: Refresh screen with iSeries data }
If Ret<>0 Then
ShowMessage('Record has been deleted by another user!');
This method will access the current record on the iSeries file and read it. After
reading the record, it updates the visual components attached to the file. This
method is used to cancel modifications made by the user, and/or update the
display screen with the latest revision of the data, as the fields may have been
modified by another user.
GetCurrentInCacheValues
Parameters: None.
Return: Integer.
See also: GetCurrent, LockCurrent.
Example:
{MyFile400: TFile400;}
{...code...}
MyFile400.GetByKeyFirst('TCIS','EQ');
{...screen modification...}
try
MyFile400.GetCurrentInCacheValues;
{Cancel modifications:Refresh TFile400 data with iSeries data}
except
ShowMessage('Record has been deleted by another user!');
end;
This method is similar to the method Getcurrent. One difference is that the
exception ECO400Error is generated in case of an error. Further, this method,
after reaching the record targeted, does not update the visual components
© SystemObjects 1997-2008 www.systemobjects.com 172
associated with the file. It can thus be used to make accessing the file invisible to
the user.
GetDateFmt
Example:
{MyFile400: TFile400;}
{MyIndex: Integer;}
{InvoiceDateFormat: Integer;}
MyIndex:=MyFile400.GetFieldIndex('INVDATE');
InvoiceDateFormat:=MyFile400.GetDateFmt(MyIndex);
This method is used to get the format of the date field. The first parameter is the
index number (in the list of selected fields: see the property Fields) of the
selected field. The return value is an integer that represents the format of the
date field. Nine different values may be returned:
• -1: an error occurred: field number invalid, or the field is not a date field
(type L on the iSeries).
• 1: Format 'ISO': 21 March 1971 = '1971-03-21'
• 2: Format 'DMY': 21 March 1971 = '21/03/71'
• 3: Format 'MDY': 21 March 1971 = '03/21/71'
• 4: Format 'YMD': 21 March 1971 = '71/03/21'
• 5: Format 'JUL': 21 March 1971 = '71/080' (Day 80 in the year 71)
• 6: Format 'USA': 21 March 1971 = '03/21/1971'
• 7: Format 'EUR': 21 March 1971 = '21.03.1971'
• 8: Format 'JIS': 21 March 1971 = '1971-03-21'
GetDateSep
Example:
{MyFile400: TFile400;}
{MyIndex: Integer;}
{InvoiceDateSeparator: Char;}
MyIndex:=MyFile400.GetFieldIndex('INVDATE');
InvoiceDateSeparator:=MyFile400.GetDateSep(MyIndex);
This method is used to retrieve the separator character used in the date field. The
first parameter is the index number of the selected field (in the list of selected
fields: see the property Fields).
The returned character is the separator character used in the date field.
If the returned character is blank, the default separator is being used. The default
separators are based on the date format being used (see the method
GetDateFmt):
• '/' for the formats 'DMY', 'MDY', 'TMD', 'JUL' and 'USA'.
GetDescription
Example:
{MyFile400: TFile400;}
{MyIndex: Integer;}
{MyDescription: String;}
MyIndex:=MyFile400.GetFieldIndex('INVDATE');
MyDescription:=MyFile400.GetDescription(MyIndex);
GetFieldIndex
Example:
{MyFile400: TFile400;}
{MyIndex: Integer;}
{MyDescription: String;}
MyIndex:=MyFile400.GetFieldIndex('INVDATE');
MyDescription:=MyFile400.GetDescription(MyIndex);
This method is used to find the field sequence number of a field selected from a
file. The first and only parameter is the name of the selected field from the
iSeries file (see the property Fields). The returned integer is the index number of
the corresponding field. If it is null an error has occurred. Either the field does not
exist, or it was not selected.
GetFieldLen
Example:
{MyFile400: TFile400;}
{MyIndex: Integer;}
{MyLength: Integer;}
MyIndex:=MyFile400.GetFieldIndex('INVDATE');
MyLength:=MyFile400.GetFieldLen(MyIndex);
This method is used to get the length of a selected field. The first parameter is
the field index number (in the list of selected fields: see the property Fields). The
returned integer is the field length.
© SystemObjects 1997-2008 www.systemobjects.com 175
The length is calculated as follows:
• For an alphanumeric field or a date field it is the number of characters +
1 (delimiter character).
• For a field of type integer, it is the number of significant digits + 2 (sign
and delimiter character).
• For a field of numeric type with decimals it is the number of significant
digits + 3 (sign, a decimal separater and a delimiter character).
In a more general terms, it is the maximum length possible for the field.
GetFieldName
Example:
{MyFile: TFile400;}
{MyFirstFieldName: String;}
{MyLastFieldName: String;}
MyFirstFieldName:=MyFile.GetFieldName(1);
MyLastFieldName:=MyFile.GetFieldName(MyFile.GetNumberFields);
This method is used to retrieve the name of a selected field of a file. The first
parameter is the field index number (in the list of fields selected: see the property
Fields). The returned string of characters is the name of the field.
GetFieldType
Example:
{MyFile400: TFile400;}
{MyIndex: Integer;}
© SystemObjects 1997-2008 www.systemobjects.com 176
{MyFieldType: String;}
MyIndex:=MyFile400.GetFieldIndex('INVDATE');
MyFieldType:=MyFile400.GetFieldType(MyIndex);
This method is used to get the field type. The first parameter is the index of the
field under consideration (in the list of selected fields: see the property Fields).
The string returned is the description of the field type. Five possible strings can
be returned:
• 'HRE': type Hour: the format for this type of field is '23:59:59',
• 'DTH': type Date/Hour: the format for this type of field is '1999-12-
31-23:59:59.999999'.
GetFirst
Parameters: None.
Return: Integer.
See also: GetNext, GetPrevious, GetLast, GetFirstInCacheValues.
Example:
{MyFile400: TFile400;}
try
MyFile400.Active:=True;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
MyFile400.GetFirst;
While not MyFile400.EOF do
begin
{code}
MyFile400.GetNext;
end;
© SystemObjects 1997-2008 www.systemobjects.com 177
MyFile400.Close;
This method is used to reach the first record of the file that meets the conditions
specified in the filter (see the properties FFilterValue and FFilterComparison).
Once the record is read, the visual components attached to the file will be
updated.
If no record is read, the return will be other than 0, and no exception is
generated. The return code alone will identify any eventual errors.
GetFirstInCacheValues
Parameters: None.
Return: Integer.
See also: GetFirst, GetNextInCacheValues, GetPreviousInCacheValues,
GetLastInCacheValues.
Example:
{MyFile400: TFile400;}
try
MyFile400.Active:=True;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
try {Exception raised for End of File}
MyFile400.GetFirstInCacheValues;
While True do
begin
{code}
MyFile400.GetNextInCacheValues;
end;
except;
MyFile400.Close;
end;
This method is similar to the method GetFirst. One difference is that an exception
ECO400Error is generated in case of an error (End of File is considered an error).
© SystemObjects 1997-2008 www.systemobjects.com 178
Further, this method, after reaching the targeted record, does not update the
visual components associated with the file. It can thus be used to make
accessing the file invisible to the user.
GetKeyIndex
Example:
{MyFile400: TFile400;}
{MyIndex: Integer;}
{MyKeyIndex: Integer;}
MyIndex:=MyFile400.GetFieldIndex('INVDATE');
MyKeyIndex:=MyFile400.GetKeyIndex(MyIndex);
This method is used to determine whether a selected field is part of the file key,
and its rank in the key fields. The first and only parameter is the index number of
the selected field of the file (see the property Fields). The returned value is the
rank of the field in the file key fields. If the returned value is 0, then the key is
not part of the file key.
GetLast
Parameters: None.
Return: Integer.
See also: GetFirst, GetNext, GetPrevious, GetLastInCacheValues.
Example:
{MyFile400: TFile400;}
{Ret: Integer;}
try
MyFile400.Active:=True;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
Ret:=MyFile400.GetLast;
While Ret=0 do
begin
{code}
Ret:=MyFile400.GetPrevious;
end;
MyFile400.Close;
GetLastInCacheValues
Parameters: None.
Return: Integer.
See also: GetLast, GetFirstInCacheValues, GetNextInCacheValues,
GetPreviousInCacheValues.
Example:
{MyFile400: TFile400;}
try
MyFile400.Active:=True;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
try {Exception raised for Begin of File}
MyFile400.GetLastInCacheValues;
While True do
begin
{code}
MyFile400.GetPreviousInCacheValues;
end;
except;
MyFile400.Close;
end;
This method is similar to the method GetLast. One difference is that an exception
ECO400Error is generated in case of an error (End of File is considered an error).
Further, this method, after reaching the targeted record, does not update the
visual components associated with the file. It can thus be used to make
accessing the file invisible to the user.
Parameters: None.
Return: Integer.
See also: GetFirst, GetLast, GetPrevious, GetNextInCacheValues.
Example:
{MyFile400: TFile400;}
{Ret: Integer;}
try
MyFile400.Active:=True;
except
on E:ECO400Error do ShowMessage('Can''t open file: '+E.Message);
end;
Ret:=MyFile400.GetFirst;
While Ret=0 do
begin
{code}
Ret:=MyFile400.GetNext;
end; MyFile400.Close;
This method is used to reach the next record. Any applied filter is taken into
account (see the properties FFilterValue and FFilterComparison). Once the record
is read, the visual components attached to the file will be updated.
GetNextInCacheValues
Parameters: None.
Return: Integer.
See also: GetNext, GetFirstInCacheValues, GetLastInCacheValues,
GetPreviousInCacheValues.
Example:
{MyFile400: TFile400;}
try
MyFile400.Active:=True;
except
© SystemObjects 1997-2008 www.systemobjects.com 181
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
try {Exception raised for End of File}
MyFile400.GetFirstInCacheValues;
While True do
begin
{code}
MyFile400.GetNextInCacheValues;
end;
except;
MyFile400.Close;
end;
This method is similar to the method GetNext. One difference is that an exception
ECO400Error is generated in case of an error (End of File is considered an error).
Further, this method, after reaching the targeted record, does not update the
visual components associated with the file. It can thus be used to make accessing
the file invisible to the user.
GetNumberCalcFields
Parameters: None.
Return: Integer.
See also: GetCalcFieldIndex, GetCalcFieldName, GetCalcFieldValue,
GetCalcFieldDescription.
Example:
{MyFile400: TFile400;}
{FieldDescription:String;}
{i: Integer;}
For i:=1 to MyFile400.GetNumberCalcFields do
FieldDescription:=MyFile400.GetCalcFieldDescription(i);
This method is used to know the number of calculated fields associated with a
file.
GetNumberFields
Parameters: None.
© SystemObjects 1997-2008 www.systemobjects.com 182
Return: Integer.
See also: GetTotalNumberFields.
Example:
{MyFile400: TFile400;}
If MyFile400.GetNumberFields<MyFile400.GetTotalNumberFields Then
ShowMessage('You have not selected all the fields.');
Parameters: None.
Return: Integer.
See also: GetFirst, GetNext, GetLast, GetPreviousInCacheValues.
Example:
{MyFile400: TFile400;}
{Ret: Integer;}
try
MyFile400.Active:=True;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
Ret:=MyFile400.GetLast;
While Ret=0 do
begin
{code}
Ret:=MyFile400.GetPrevious;
end;
MyFile400.Close;
This method is used to reach the previous record in the file. Any applied filter is
taken in account. (See the properties FFilterValue and FFilterComparison). Once
the record is read, the visual components attached to this file are updated.
GetPreviousInCacheValues
Parameters: None.
Return: Integer.
© SystemObjects 1997-2008 www.systemobjects.com 183
See also: GetPrevious,GetFirstInCacheValues,
GetNextInCacheValues, GetLastInCacheValues.
Example:
{MyFile400: TFile400;}
try
MyFile400.Active:=True;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
try {Exception raised for Begin of File}
MyFile400.GetLastInCacheValues;
While True do
begin
{code}
MyFile400.GetPreviousInCacheValues;
end;
except;
MyFile400.Close;
end;
GetPValue
Example:
{MyFile400: TFile400;}
{MyIndex: Integer;}
{MyValue: PChar;}
MyIndex:=MyFile400.GetFieldIndex('INVDATE');
GetMem(MyValue,MyFile400.GetFieldLen(MyIndex));
MyFile400.GetPValue(MyIndex,MyValue);
{...code...}
FreeMem(MyValue,MyFile400.GetFieldLen(MyIndex));
Parameters: None.
Return: LongInt.
See also: GetByRecordNumber, GetByRecordNumberInCacheValues.
Example:
{MyFile400: TFile400;}
{MyRRN: LongInt;}
{Ret: Integer;}
{...code...}
MyRRN:=MyFile400.GetRecordNumber;
{...code...}
Ret:=MyFile400.GetByRecordNumber(MyRRN);
If ret<>0 then ShowMessage('Record not found');
{...code...}
This method returns the current record number (RRN). The file must already be
open.
GetTotalDescription
Example:
{MyFile400: TFile400;}
{MyIndex: Integer;}
{MyDescription: String;}
MyIndex:=MyFile400.GetTotalFieldIndex('INVDATE');
MyDescription:=MyFile400.GetTotalDescription(MyIndex);
This method is used to get the description of a field even when the field is not
selected. The first parameter is the sequence number of the field concerned; the
returned string is the field description.
Example:
{MyFile400: TFile400;}
{MyIndex: Integer;}
{MyDescription: String;}
MyIndex:=MyFile400.GetTotalFieldIndex('INVDATE');
MyDescription:=MyFile400.GetTotalDescription(MyIndex);
This method is used to get the sequence number of a field (even if the field is not
selected). The first and only parameter is the name of the field. The returned
integer is the sequence number of the field. If it is null, then an error occurred;
the name of the field does not exist.
GetTotalFieldName
Example:
{MyFile: TFile400;}
{MyFirstFieldName: String;}
{MyLastFieldName: String;}
MyFirstFieldName:=MyFile.GetTotalFieldName(1);
MyLastFieldName:=
MyFile.GetTotalFieldName(MyFile.GetTotalNumberFields);
This method is used to get the name of a field (even if it is not selected). The first
parameter is the field sequence number of the field concerned. The returned
string is the name of the field.
Example:
{MyFile400: TFile400;}
{MyIndex: Integer;}
{MyKeyIndex: Integer;}
MyIndex:=MyFile400.GetTotalFieldIndex('INVDATE');
MyKeyIndex:=MyFile400.GetTotalKeyIndex(MyIndex);
This method is used to determine whether a selected field is part of the file key,
and its rank in the key fields. The first and only parameter is the sequence
number of the selected field of the file (see the property Fields). The returned
value is the rank of the field in the file key fields. If the returned value is 0, then
the key is not part of the file key.
GetTotalNumberFields
Parameters: None.
Return: Integer.
See also: GetNumberFields.
Example:
{MyFile400: TFile400;}
If MyFile400.GetNumberFields<MyFile400.GetTotalNumberFields Then
ShowMessage('You do not have selected all the fields.');
Example:
{MyFile400: TFile400;}
{MyIndex: Integer;}
{MyValue: String;}
MyIndex:=MyFile400.GetFieldIndex('INVDATE');
MyFile400.MyValue:=GetValue(MyIndex);
This method returns the value of a field of the current record. The file must
already be open. If this field is longer than 255 characters, it will be truncated.
Use the method GetPValue instead.
InsertBlank
Parameters: None.
Return: Integer.
See also: InsertWithScreenValues, InsertWithCacheValues.
Example:
{MyFile400: TFile400;}
try
MyFile400.Open;
Except
on E:ECO400Error do
ShowMessage('Can''t open file (' +
IntToStr(E.ErrorCode) + ')' + E.Message);
end;
Ret:=File400.InsertBlank;
If Ret<>0 Then ShowMessage('Can''t create the new record');
MyFile400.Close;
The return code will be 0 if the operation was successful; otherwise an error code
is returned but no exception is generated.
InsertWithCacheValues
Parameters: None.
Return: Integer.
See also: InsertBlank, InsertWithScreenValues.
Example:
{MyFile400: TFile400;}
{MyUniqueKeyIndex: Integer;}
{MyNewValue: String;}
try
MyFile400.Open;
except
on E:ECO400Error do
ShowMessage('Can''t open file (' +
IntToStr(E.ErrorCode) + ')' + E.Message);
end;
MyUniqueKeyIndex:= Integer(MyFile400.IndexKeys[0]^);
{...code...}
try
MyFile400.GetLastInCacheValues;
MyNewValue := IntToStr( StrToInt( MyFile400.GetValue(
MyUniqueKeyIndex)) + 1);
except
MyNewValue:='1';
end;
MyFile400.UpdateCacheValuesWithBlank;
MyFile400.PutCacheFieldValue(MyUniqueKeyIndex,MyNewValue);
try
File400.InsertWithCacheValues;
except
ShowMessage('Can''t create the new record');
end;
MyFile400.Close;
This method is used to create a record on the iSeries using the data from the
object File400.
© SystemObjects 1997-2008 www.systemobjects.com 190
An exception ECO400Error is generated in case of error.
InsertWithScreenValues
Parameters: None.
Return: Integer.
See also: InsertBlank, InsertWithCacheValues.
Example:
{MyFile400: TFile400;}
{Ret: Integer;}
try
MyFile400.Open;
except
on E:ECO400Error do
ShowMessage('Can''t open file (' +
IntToStr(E.ErrorCode) + ') ' + E.Message);
end;
{...user defines the record in the form...}
Ret:=File400.InsertWithScreenValue;
If Ret<>0 Then ShowMessage('Can''t create the new record');
MyFile400.Close;
This method is used to create an iSeries record using the data entered by the
user on the screen. If fields are not displayed on the screen they will be set to
blanks. If you would like to check certain fields or add information to other fields,
you must to use the following methods: UpdateCacheValuesWithBlank, followed
by UpdateCacheValuesWithScreen, then add or change the data, and finally use
the method InsertWithCacheValues.
LockCurrent
Parameters: None.
Return: Integer.
See also: LockOnRead.
This method is used to lock the current record. An exception ECO400Error will be
generated in case of error.
Open
Parameters: None.
Return: None.
See also: Active, Close.
Example:
{MyFile400: TFile400;}
try
MyFile400.Open;
except
on E:ECO400Error do
ShowMessage('Can''t open file (' +
IntToStr(E.ErrorCode) + ')' + E.Message);
end;
MyFile400.Close;
This method is used to open an iSeries file. It is equivalent to setting the property
Active to True (see that property for more details). In case of an error, an
exception is generated.
Example:
{MyFile400: TFile400;}
{MyIndex,Long1,Long2,MyLong: Integer;}
{MyLongStringField: PChar;}
{MyMemo: TMemo;}
MyIndex:= MyFile400.GetFieldIndex('COMMENT');
Long1:= MyFile400.GetFieldLen(VIndex);
Long2:=MyMemo.GetTextLen+1;
If Long1<Long2 Then MyLong:=Long1 Else MyLong:=Long2;
GetMem(MyLongStringField,MyLong);
MyMemo.GetTextBuf(MyLongStringField,MyLong);
MyFile400.PutCacheFieldPValue(MyIndex, MyLongStringField);
FreeMem(MyLongStringField,MyLong);
This method is used to assign the value of the current field to the working storage
area. The file must already be open.
This method is only useful when you wish to assign the value of an alphanumeric
field of more than 255 characters ( otherwise use the method
PutCacheFieldValue). The present method avoids Pascal string length limitations.
PutCacheFieldValue
Example:
{MyFile400: TFile400;}
{MyUniqueKeyIndex: Integer;}
{MyNewValue: String;}
try
© SystemObjects 1997-2008 www.systemobjects.com 193
MyFile400.Open;
except
on E:ECO400Error do
ShowMessage('Can''t open file (' +
IntToStr(E.ErrorCode) + ')' + E.Message);
end;
MyUniqueKeyIndex:= Integer(IndexKeys[0]^);
{...code...}
try
MyFile400.GetLastInCacheValues;
MyNewValue := IntToStr( StrToInt( MyFile400.GetValue(
MyUniqueKeyIndex)) + 1);
except
MyNewValue:='1';
end;
MyFile400.UpdateCacheValuesWithBlank;
MyFile400.PutCacheFieldValue(MyUniqueKeyIndex,MyNewValue);
try
MyFile400.InsertWithCacheValues;
except
ShowMessage('Can''t create the new record');
end;
MyFile400.Close;
This method returns the value of a field of the current record. The file must
already be open. If this field is longer than 255 characters, it will be truncated.
Use the method PutCacheFieldPValue instead.
RemoveCalcField
Example:
{MyFile400: TFile400;}
{FieldSeq:Integer;}
FieldSeq:=MyFile400.GetCalcFieldSeq('CUSTDESC');
MyFile400.RemoveCalcField(FieldSeq);
This method is used to delete a calculated field using the index of the field.
Example:
{MyFile400: TFile400;}
{FieldSeq: Integer;}
{NewValue: String;}
FieldSeq:=MyFile400.GetCalcFieldSeq('CUSTNAME');
MyFile400.SetCalcFieldValue(FieldSeq,NewValue);
This method is used to assign a value of a Calculated field. This method will often
be used in the OnCalcFields event.
UpdateComponents
Parameters: None.
Return: None.
See also: GetCurrent.
Example:
{MyFile400: TFile400;}
{...code...}
MyFile400.GetByKeyFirst('TCIS','EQ');
{...screen modification...}
MyFile400.UpdateComponents;
{ -> Cancel modifications: Refresh screen with TFile400 data }
This method updates all the visual components with the data in the object
File400. It can also be used to cancel the modifications on the screen. No access
to the iSeries is performed by this method. The file should be already open.
Parameters: None.
Return: None.
See also: UpdateCacheValuesWithScreen, PutCacheFieldValue,
InsertWithCacheValues, UpdateWithCacheValues, GetFirstInCacheValues,
GetByKeyFirstInCacheValues, GetByRecordNumberInCacheValues.
Example:
{MyFile400: TFile400;}
{MyUniqueKeyIndex: Integer;}
{MyNewValue: String;}
try
MyFile400.Open;
except
on E:ECO400Error do
ShowMessage('Can''t open file (' +
IntToStr(E.ErrorCode) + ')' + E.Message);
end;
MyUniqueKeyIndex:= Integer(MyFile400.IndexKeys[0]^);
{...code...}
try
MyFile400.GetLastInCacheValues;
MyNewValue := IntToStr( StrToInt( MyFile400.GetValue(
MyUniqueKeyIndex)) + 1);
except
MyNewValue:='1';
end;
MyFile400.UpdateCacheValuesWithBlank;
MyFile400.PutCacheFieldValue(MyUniqueKeyIndex,MyNewValue);
try
MyFile400.InsertWithCacheValues;
except
ShowMessage('Can''t create the new record');
end;
MyFile400.Close;
This method is used to set to blanks all the fields of a record for an object
File400. It could be useful for customizing the insertion of an empty record, as in
the previous example.
Parameters: None.
Return: None.
See also: UpdateCacheValuesWithBlank, PutCacheFieldValue,
InsertWithCacheValues, UpdateWithCacheValues, GetFirstInCacheValues,
GetByKeyFirstInCacheValues, GetByRecordNumberInCacheValues.
Example:
{MyFile400: TFile400;}
{MyUniqueKeyIndex: Integer;}
{MyNewValue: String;}
try
MyFile400.Open;
except
on E:ECO400Error do
ShowMessage('Can''t open file (' +
IntToStr(E.ErrorCode) + ')' + E.Message);
end;
MyUniqueKeyIndex:= Integer(MyFile400.IndexKeys[0]^);
{...code...}
try
MyFile400.GetLastInCacheValues;
MyNewValue := IntToStr( StrToInt( MyFile400.GetValue(
MyUniqueKeyIndex)) + 1);
except
MyNewValue:='1';
end;
MyFile400.UpdateCacheValuesWithScreen;
MyFile400.PutCacheFieldValue(MyUniqueKeyIndex,MyNewValue);
try
MyFile400.InsertWithCacheValues;
except
ShowMessage('Can''t create the new record');
end;
MyFile400.Close;
This method is used to modify all the fields in a file for the object File400 using
the data entered into the visual components on the screen. This could be useful
for customizing the insertion of a record, as in the previous example.
Parameters: None.
Return: Integer.
See also: UpdateWithScreenValues.
Example:
{MyFile400: TFile400;}
{MyNumModifIndex: Integer;}
{MyNewValue: String;}
try
MyFile400.Open;
except
on E:ECO400Error do
ShowMessage('Can''t open file (' +
IntToStr(E.ErrorCode) + ')' + E.Message);
end;
MyNumModifIndex:= MyFile400.GetFieldIndex('NUMMODIF');
{...code and screen modifications...}
MyNewValue := IntToStr( StrToInt( MyFile400.GetValue(
MyNumModifIndex)) + 1);
MyFile400.UpdateCacheValuesWithScreen;
MyFile400.PutCacheFieldValue(MyNumModifIndex,MyNewValue);
try
MyFile400.UpdateWithCacheValues;
except
ShowMessage('Can''t modify the record');
end;
MyFile400.Close;
This method is used to modify the iSeries record based on the data from the
object File400.
An exception ECO400Error is generated in case of an error.
Parameters: None.
Return: Integer.
See also: UpdateWithCacheValues.
Example:
{MyFile400: TFile400;}
{Ret: Integer;}
try
MyFile400.Open;
except
on E:ECO400Error do
ShowMessage('Can''t open file (' +
IntToStr(E.ErrorCode) + ') ' + E.Message);
end;
{...user redefines the record in the form...}
Ret:=MyFile400.UpdateWithScreenValue;
If Ret<>0 Then ShowMessage('Can''t modify the record');
MyFile400.Close;
This method is used to modify a record on the iSeries with the data entered on
the screen by the user. If fields do not appear on the data entry screen, they will
be left unchanged. If fields are not displayed on the screen they will by set to
blanks. If you would like to check certain fields or add information to other fields,
you will need to use the following methods: UpdateCacheValuesWithScreen
followed by UpdateWithCacheValues, then add or change the data, and use the
method.
BeforeActivation
Type: TNotifyCancelEvent (See Types used by ScreenDesigner/400).
Call : The code added to this event is executed just before opening the file.
The parameter 'Cancel' (of Boolean type) if set to True allows you to cancel
opening the file.
BeforeDeactivation
Type: TNotifyCancelEvent (See Types used by ScreenDesigner/400).
Call : The code added to this event is executed just before closing the file.
The parameter 'Cancel' (of Boolean type) is used to cancel closing the file when it
is set to True.
BeforeDelete
Type: TNotifyCancelEvent (See Types used by ScreenDesigner/400).
Call : The code added to this event is executed just before deleting a record.
The parameter 'Cancel' (of Boolean type) is used to cancel deleting the record
when it is set to True.
BeforeModify
Type: TNotifyCancelEvent (See Types used by ScreenDesigner/400).
Call : The code added to this event is executed just before modifying a record.
The parameter 'Cancel' (of Boolean type) is used to cancel modifying a record
when it is set to True.
OnActivation
Type: TNotifyEvent (Delphi Class).
Call : The code added to this event is executed just after opening the file.
OnCalcFields
Type: TNotifyEvent (Delphi class).
Call: The code added to this event gets executed to define the list of calculated
fields. The sample CALCFLD is a good example of how to use this event. If you
do not add any code to this event, then the calculated fields will remain empty
and they will not get initialized.
OnDelete
Type: TNotifyEvent (Delphi Class).
Call : The code added to this event is executed just after deleting a record.
OnDeactivation
Type: TNotifyEvent (Delphi Class).
Call : The code added to this event is executed just after closing the file.
OnInsert
Type: TNotifyEvent (Delphi Class).
Call : The code added to this event is executed just after inserting a record.
OnModify
Type: TNotifyEvent (Delphi Class).
Call : The code added to this event is executed just after modifying a record.
OnRead
Type: TNotifyEvent (Delphi Class).
Call : The code added to this event is executed just after reading a record.
© SystemObjects 1997-2008 www.systemobjects.com 201
OnUpdateComponents
Type: TNotifyEvent (Delphi Class).
Call : The code added to this event is executed just after updating the visual
components in the window.
Likewise, if you define one of the Tfile400 properties for the object File400 in a
program, you optimize your response time by setting the property Active of the
object AS400 to True before defining the properties.
Property BufferCount
This property is used to set a buffer to access data files (see the definition of the
property). The best value to be used depends on the type of application deployed.
Here are some specific examples:
If the file is used to access the records one record at a time, for example for the
purpose of displaying a few objects Field400 in a navigator window, then
BufferCount could be left at 0.
If the file is used to access multiple records at a time, for example with an object
Grid400, then the optimal BufferCount should be the number of lines of Grid400
visible +1. This will allow Grid400 to be painted rapidly when using the side bar.
If the file is used to read all the records, for example to import data, then it is
suggested that you refer to the graphs supplied in the appendix to evaluate the
optimal value (often it is close to 20 in terms of allocated memory) in your case;
it depends on the number of fields, the size of the record, and the type of iSeries
Router.
Property Fields
If you need to minimize your network activity, this property could be useful. You
have to remember, however, that the number of fields to be selected from the
complete list cannot exceed a maximum of 60. Additionally, selecting a large list
of fields (more than 30 often) could slightly deteriorate the response time of your
application. On the one hand, a little processing time is gained because fewer
fields will transition on the network, and less data will be converted to PC format.
But, on the other hand, more processing time is lost because of the time needed
by the iSeries to divide the records into substrings.
The first choice must be a wisely selected one (based on its access key). The
most important criterion of selection is often useful to be the first field in the
access key. For example, to search a list of customers by state sorted by
customer name, a file having the first two key fields as State and Customer Name
is well suited for the request; the code would be:
{MyFile400: TFile400;}
MyFile400.Open;
try
MyFile400.GetByKeyFirstInCACHEValues('TN','EQ');
While Not MyFile400.EOF Do
Begin
{...code...}
MyFile400.GetByKeyNextInCACHEValues('TN','EQ');
End;
except
MyFile400.Close;
end;
{MyFile400: TFile400;}
{Activity: String;}
{ActivityIndex: Integer;}
MyFile400.Open;
ActivityIndex:=GetFieldIndex('ACTIVITY');
try
MyFile400.GetByKeyFirstInCACHEValues('CA','EQ');
While Not MyFile400.EOF Do
Begin
If MyFile400.GetValue(ActivityIndex)='BANK' Then
MyFile400.GetByKeyFirstInCACHEValues('CA;BANK','GT')
{To Jump all the 'BANK' records}
Else
Begin
{...code...}
MyFile400.GetByKeyNextInCACHEValues('CA','EQ');
End;
End;
except
MyFile400.Close;
end;
1. You can use join files created on the iSeries to access data. A join file is
viewed by ClientObjects/400 just like any other file. Refer to the
documentation on your iSeries on how to create a join file on the iSeries.
For example, you can create a join file CustomerNbr/Invoices,
(CustomerNbr being the join field), by defining the access key on the
master file as State, Activity Sector (two limitations are present: the access
key must be unique on the master file and the file can be opened in read
mode only). With the following code, you can access all the invoices for the
companies in the state of CA in the banking sector:
{FileJoinCustInv: TFile400;}
FileJoinCustInv.Open;
try
FileJoinCustInv.GetByKeyFirstInCACHEValues('CA;BANK','EQ');
While Not FileJoinCustInv.EOF Do
Begin
{...code...}
FileJoinCustInv.GetByKeyNextInCACHEValues('CA;BANK','EQ');
End;
except
FileJoinCustInv.Close;
end;
Adding a join file slows down the creation and modification of records in the
files concerned with the join operation.
2. You used the files separately and you perform the join yourself. You are
going to use the properties FFilterComparison and FFilterValue of the Class
TFile400.
Search all the customers in the state of CA sorted by Customer Name who
received an invoice in 1996. The CUSTOMER file used has a key on State,
Company Name; the INVOICE file has a key on Customer Number, Date of
Invoice. The code is as follows:
The class TFile400 contains a list of all the visual objects attached to it. When
creating your class, add or remove future objects to that list with the methods
AddDataObject and RemoveDataObject.
Procedure RemoveDataObject(YourObject:TComponent);
This procedure removes the object YourObject from the list.
Once your object is attached to the list, it is able to receive messages Invalidate.
If your objrct receives the method Invalidate, you need to check the property
InvalidateFlag (of type TypeIfFlag) of File400. These are the possible values :
Parent: Tcomponent
Unit: SCDsql
Properties:
Active
Type: Boolean.
See also: Class TFile400, Class TAS400.
This property is used to open or close the SQL statement, much like the class
TFile400.
DataBaseName
This is the same as PLUAlias in TAS400.
SQL
Type: String.
This property will analyze the syntax of your command, check on whether a
logical access path exists to your data, then if a logical path is found access the
data in native mode. Otherwise, start the execution of this SQL command on the
iSeries using an open query logic, and obtain the result to pass on to the
Windows application.
GetFirst
GetFirstInCacheValue
GetNext
GetNextInCacheValues
GetFieldIndex
GetFieldDescription
GetFieldName
GettNumberFields
GetValue
All of these new methods have the same definitions as the ones listed in TFile400.
Please refer to the previous chapters.
Parent TspeedButton
Unit: SCDesign
The class TNavig400 is used to navigate the associated iSeries file, create
records, modify records, and delete records. Locking the records is performed
automatically.
The navigation buttons inherit the TSpeedButton, but they do not get its 'Focus'.
AttachedFile
Type: TFile400.
See also: Class TFile400.
This property is used to define the file that the navigation buttons will operate on.
ButtonKind
Type: coButtonKind.
This property is used to define the type of navigation button to be used. When
the button is clicked, the associated action will be performed. Eight types of
buttons are possible:
Glyph
Type: TBitmap.
This property is used to define the Bitmap image displayed on the button. it is
assigned automatically by ScreenDesigner/400 based on the property ButtonKind
(see this property). The images are as follows:
(bkUpdate);
Ancestor TEdit
Unit SCDFIELD
Properties
AttachedField
Type: String.
This property permits to define the field to be displayed. It is necessary to
indicate the name of the field in question. In ‘Design’ mode, a window permits a
convivial field choice with, in addition, the possibility to create an object class
TLabel indicating the field name or description:
Class object TLabel created
automatically above the object
Field400
Methods
GetIndice
Parameters: None.
Return: Integer.
See also: AttachedField.
Example:
{MyField: TField400;}
{MyFieldIndex: Integer;}
{MyDescription: String;}
MyFieldIndex:=MyField.GetIndice;
MyDescription:=MyField.AttachedFile.GetDescription(MyFieldIndex);
This method permits to know the index of the field associated to this object.
DoExit
Parameters: None.
Return: None.
This method inherits the TEdit class one. A data control has been added which
gives out a Beep if the typed in value doesn't correspond to the expected type.
Ancestor TLabel
Unit SCDFIELD
Properties
AttachedField
Type: String.
This property permits to define the field to be displayed. It is necessary to
indicate the name of the field in question. In Design mode, a window permits a
convivial field choice:
The field choice is made by a Double-Click on the wanted line or by a Click on this
field and a Click on the OK button. The Cancel button cancels the choice in
progress.
Methods
GetIndice
Parameters: None.
Return: Integer.
See also: AttachedField.
Example:
{MyLabel: Tlabel400;}
{MyFieldIndex: Integer;}
{MyDescription: String;}
MyFieldIndex:=MyLabel.GetIndice;
MyDescription:=MyLabel.AttachedFile.GetDescription(MyFieldIndex);
This method allows to know the index of the field associated to this object.
Ancestor TMemo
Unit SCDESIGN
Properties
AttachedField
Type: String.
This property permits to define the field to be displayed. It is necessary to
indicate the name of the field in question. In ‘Design’ mode, a window permits a
convivial field choice with, in addition, the possibility to create an object of Tlabel
class indicating the field name or description:
AttachedFile
Type: TFile400.
See also: Class TFile400.
This property permits to define the file containing the field to be displayed.
Methods
GetIndice
Parameters: None.
Return: Integer.
See also: AttachedField.
Example:
{MyMemo: TMemo400;}
{MyFieldIndex: Integer;}
{MyDescription: String;}
MyFieldIndex:=MyMemo.GetIndice;
MyDescription:=MyMemo.AttachedFile.GetDescription(MyFieldIndex);
This method permits to know the index of the field associated to this object.
Ancestor TStringGrid
Unit SCDGRID
The field choice is made by a selection of wanted lines in the list on the left by a
Click on the button ' > '.
The button '>> ' permits to choose all the fields.
The button ' <<' permits to choose no field.
The button ' < ' permits to no longer choose the lines selected in the list on the
right.
The OK button confirms the choice in progress.
The Cancel button cancels the choice in progress.
If you wish to define this property by programming use the Clear and Add
methods of the TStringList class to add fields to Grid400 (do not forget to do the
same operations for the TStringList: Header).
AttachedFile
Type: TFile400.
See also: Class TFile400.
This property permits to define the file containing fields to be displayed.
FilterComparison
Type: coTypeComparison ( See section Types used by ScreenDesigner/400).
See also: FilterValue, FilterWithField400.
You are advised to use the filter with the file!
This property is one of the three permitting to define a filter for the Grid400. To
define a filter, it is necessary to have this property different from tcNone and the
FilterValue property or the FilterWithField400 property defined bellow, non null. A
filter can be defined only if the file has an access key. The filter applies to this
access key.
• tcNone: : No filter,
• tcLessThan:demand of records of which the access key is strictly less than the
key (or the sub-key) defined by the FFilterValue property,
• tcLessOrEqual: demand of records of which the access key is less than or
equal to the key (or the sub-key) defined by the FFilterValue property,
• tcEqual : demand of records of which the access key is equal to the key (or the
sub-key) defined by the FFilterValue property,
• tcGreaterOrEqual : demand of records of which the access key is greater than
or equal to the key (or the sub-key) defined by the FFilterValue property,
• tcGreaterThan: demand of records of which the access key is strictly greater
than the key (or the sub-key) defined by the FFilterValue property,
• tcLike : demand of records of which the beginning of the access key is identical
to the key (or the sub-key) defined by the FFilterValue property. This
FilterValue
Type: String.
See also: FilterComparison, FilterWithField400, KeySeparator (TAS400).
You are advised to use the filter with the file!
This property is one of the three permitting to define a filter for the Grid400. To
define a filter, it is necessary to have the FilterComparison property defined
above different from tcNone and this property or the FilterWithField400 property
defined bellow, non null. A filter can be defined only if the file has an access key.
The filter applies to this access key.
The filter can contain several fields ; these will be separated by the KeySeparator
(property of the class TAS400). The number of fields must remain less than or
equal to the number of key-fields of the file.
The first key-field of the filter necessarily corresponds to the first key-field of the
file iSeries key; just as the following fields. Only the last key-fields of the file
iSeries key can be left out of the filter.
FilterWithField400
Type: TField400.
See also: FilterComparison, FilterValue, KeySeparator (TAS400).
You are advised to use the filter with the file and to use the
OnUpdateComponents event!
This property is one of the three permitting to define a filter for the Grid400. To
define a filter, it is necessary to have the FilterComparison property defined
above different from tcNone and this property or the FilterValue property defined
above, non null.
This property permits to create a dynamic filter since it is tied to the value of a
Field400 object which varies according to the records of the file to which it is
attached. It is forbiden to define a filter on a Field400 object which is attached to
the same file as the one of the Grid400.
A filter can be defined only if the file has an access key. The filter applies to this
access key.
If you want to define this property by programming then use the Clear, Add
methods and the Strings property of the TStringList class in order to add, erase
or modify the Grid400 column headings(do not forget to always have the same
number of elements of the two TStringList Header and AttachedFields).
GetIndex
Parameters: Name of the field: String.
Return: Integer.
See also: AttachedFields.
Example:
{MyGrid: TGrid400;}
{MyFirstColumnIndex: Integer;}
{MyDescription: String;}
MyFirstColumnIndex :=
MyGrid.GetIndice(MyGrid.AttachedFields.Strings[0]);
MyDescription :=
MyGrid.AttachedFile.GetDescription(MyFirstColumnIndex);
This method permits to know a Grid400 field index . The first and only parameter
is the field name of the Grid400 in question.
ReDraw
Parameters: None.
Return: None.
See also: UpdateComponents(TFile400).
This method permits to repaint the Grid400 while canceling the modifications in
progress. This method is equivalent to the UpdateComponents one (of the object
File400) applied only to this Grid400.
Click
Parameters: None.
Return: None.
This method inherits the TStringGrid class one. A positioning in the file on the
corresponding record was added to it at the line where the Click took place.
Moreover, if the Click of the mouse engendered a line exit then a verification of
the data type is done; and if the record has been modified then the modification
is done automatically on the iSeries.
DoExit
Parameters: None.
Return: None.
This method inherits the TStringGrid class one. A data control was added to it
which gives out a Beep if the value typed in doesn't correspond to the expected
type.
Tip
If the file is used for a multi-record display, for example with an object Grid400,
then in order to make BufferCount optimal it must be affected to the number of
visible lines of the Grid400 + 1. This allows Grid400 to repaint itself faster when
the scroll bar is used. Indeed, going down a page of the Grid400 demands only a
request and a response.
Ancestor SpeedButton
Unit SCDLOOK
Properties
LookUpCaption
Type: String.
Type: TStringList.
This property permits to define the fields to be displayed in the look up window
and controls receiving the selected data. In Design mode, a window permits a
convivial choice of fields and controls:
Buttons of field
selection and Description of the selected Two buttons to create or cancel an
disselection field of the list association between a field and a
control.
• The choice of fields is made then by a selection of wanted lines in the list at
left by a Click on the button ' > '.
• The button ' < ' permits to no longer choose the lines selected in the central
list.
• The ‘handshake’ button permits to associate the field selected in the central list
to the control selected in the list at the right. The controls associated to the
fields appear in quotes at the end of the name in the central list.
• The ‘crossed handshake’ button permits to dissociate the control from the field
selected in the central list.
If you want to define this property by programming then do as follows: use the
Clear and Add methods of the TStringList class to add the fields to display in the
look up window (it is the names of fields that must be found in the list); next, use
the PutControlName method to associate a control to a selected field; finally, call
the UpdateControls method.
LookUpFile400
Type: TFile400.
This property permits to define which file the user is going to see show up in the
window. It is the fields of this file that you choose in the LookUpFields property.
To read the data, the TLookUp400 class opens the file for reading only.
If the property is left blank then no filter is applied and the file appears in its
totality.
Otherwise, you can choose one of the controls associated to your fields ( See
LookUpFields property) as the filter. For example, you create a look up window on
a client file of which the access key is composed of only one key-field: the
Customer Name. You associate the Customer Name field to an edition field so
that the name of the customer chosen in the look up window by the user appears
in this edition field. You can then define this edition field as a filter; thus, the
person can type in ' TC ' in the edition field then press the LookUp button: he/she
will be able, by this operation, to consult all clients whose company name begins
by ' TC ' and then choose among this list.
This property is a character string. It is the name of the control (taken as filter)
that must be indicated. In Design mode, the available control list is indicated.
LookUpFont
Type: TFont.
In a look up window, the data will appear in a class object TGrid400 ( See this
class). This property permits to define the font of this Grid400. The TFont class is
a Delphi class ; refer to your Delphi literature to learn more about the ways to
define this property by programming or in Design mode.
Modified properties
Caption
Type: String.
This property is initialized at '... '.
This method permits to know the name of the control associated to a field. The
first and only parameter is the index of the field selected (the first field has 0 for
index). The return is the name of the associated control. If no control is
associated, a blank string is returned.
GetFieldName
Parameters: Index of the field selected: Integer.
Return: String.
See also: GetControlName, PutControlName, UpdateControls.
Example:
{MyLookUp: TLookUp400;}
{MyIndex: Integer;}
{MyFieldName: String;}
For MyIndex:=0 to MyLookUp.LookUpFields.Count-1 Do
Begin
MyFieldName:=MyLookUp.GetFieldName(MyIndex);
End;
This method permits to know the name of a selected field. The first and only
parameter is the index of the field selected (the first field has 0 for index). The
return is the name of this field.
This method permits to associate a control to a field. The first parameter is the
index of the selected field (the first field has 0 for index), the second is the name
of the control that you wish to associate to this field. After this method, use the
UpdateControls method to attach this control dynamically to the specified field
(so, thereafter, you will be able to change the name of the control while keeping
the association active). To cancel a link, use this function with the blank string as
name of control.
UpdateControls
Parameters: None.
Return: None.
See also: GetFieldName, PutControlName, GetControlName.
Example:
{MyLookUp: TLookUp400;}
{MyIndex: Integer;}
{MyControlName: String;}
For MyIndex:=0 to MyLookUp.LookUpFields.Count-1 Do
Begin
MyLookUp.GetFieldName(MyIndex yew) = ' CUSTNAME ' Then
Begin
MyLookUp.PutControlName(MyIndex, ' MyEditBox ');
MyLookUp.UpdateControls;
End;
End;
This method attaches dynamically controls to fields. Thus, thereafter, you will be
able to change the name of controls without modifying the associations.
Click
Parameters: None.
Return: None.
This method is inherited from the Click method of the TSpeedButton class (the
object LookUp400 doesn't take the Focus, therefore). Moreover, the look up
window is created then activated in a modal way until the window closing by the
user with a Click on the OK button or the Cancel button. It is not created,
however, if no field has been selected.
If you wish to attach a code to this event, insert it in the OnClick procedure of the
object ; it will be executed when exiting the window after the possible updating of
the associated controls.
Unit: SCDBUILD
Properties
AS400
Type: TAS400
This property indicates on which iSeries the object is located (the command, the
program, etc.).
FunctionsAlpha
Type: TStringList
This property defines the list of functions using alphanumeric values:
• Concatenation with|CONCAT
• Length of the string|LENGTH
• Remove blanks|STRIP
• Extract a sub-string|SUBSTR
• Minimum of strings|MIN
• Maximum of strings|MAX
• **|**
AddTable
Parameters: AS400 TAS400; LibraryName:String; FileName:String
Return: None
This method can be used to add a table in the first tab.
Example:
{MyBuilder: TSQLBuild400;}
MyBuilder.AddTable(MyBuilder.AS400,’CO400’,’CUSTOMER’);
Clear
Parameters: nONE
Return: None
This method clears the current query definition.
Example :
{MyBuilder: TSQLBuild400;}
MyBuilder.Clear;
DeleteParamsTab
Parameters: None
Return: None
This method deletes the tab where the user can define parameters for the query.
Example :
{MyBuilder: TSQLBuild400;}
MyBuilder.DeleteParamsTab;
JoinTables
Parameters: Table1:TListBoxFields;Table2:TListBoxFields
;FieldTable1:String;FieldTable2:String
Return: None
With this method, you can join two tables.
Example :
{MyBuilder: TSQLBuild400;}
MyBuilder.JoinTables(MyBuilder.Tables0,MyBuilder.Tables1, CUSTCODE’,’CUSTCODE’);
SaveToFile
Parameters: FileName : String
Return: None
This method saves a query definition to a file. Use method LoadFromFile to reload
the definition of the query.
Example :
{MyBuilder: TSQLBuild400;}
MyBuilder.SaveToFile(‘C :\TEMP\MYQUERY.TXT’); {. . . . . .
MyBuilder.LoadFromFile(‘C :\TEMP\MYQUERY.TXT’);
SQLAsPChar
Parameters: AskParams : Boolean ;pMySQL : Pchar
Return: None
This method gives the SQL statement corresponding to the current query
definition as a PChar. It returns the length of the SQL statement. If you want to
use a String, see property SQL. The first parameter defines if the values of the
parameters are asked or not.
Example :
{MyBuilder: TSQLBuild400;}
GetMem(MySQL,500) ;
MyBuilder.SQLAsPChar(True,MySQL);
{.....
FreeMem(MySQL,500) ;
Ancestor TComponent
Unit SCDCALL
Properties
AS400
Type: TAS400.
See also: Class TAS400
This property permits to define on which iSeries is found the program to call.
LibraryName
Type: string
This property permits to define the library where the program iSeries is found.
A window permits to search for your library name on your iSeries:
ParamDecimals
Type: Array of Integer
See also: Params, ParamDigits, ParamType.
This property permits to define and to know the number of decimals defined for a
parameter. ParamDecimals(0) identifies the number of decimals of the first
parameter.
ParamDigits
Type: Array of Integer.
See also: Params, ParamDecimals, ParamType.
This property permits to define and to know the maximal length defined for a
parameter. ParamDigits(0) identifies the length of the first parameter.
Params
Type: TStringList.
See also: Values.
This property permits to define the iSeries program parameters. In conception
mode, a window permits to define the parameters visually:
You must define a type for every parameter. The conversion type will be done
automatically by the object except for the type ‘H ' (Buffer). For the type ‘H ', the
parameter is converted neither before nor after the call of the program; this can
be useful if the parameter is a structure (which is often the case for the API of the
OS/400). You have access to the conversion functions, which are found in the
SCDTOOLS unit:
⇒ function ebcdic2ascii (ascii, ebcdic: pchar; lg: integer): integer;
⇒ function ascii2ebcdic (ebcdic, ascii: pchar; lg: integer): integer;
Each parameter can be modified with the help of the ‘Modify' button or deleted
with the ‘Delete ' button.
ParamType
Type: Array of char
See also: Params, ParamDigits, ParamDecimals.
This property permits to define and to know a parameter type. ParamType(0)
identifies the type of the first parameter.
ProgramName
Type: string
This property permits to define your iSeries program name. In conception mode,
a window permits to search for your iSeries programs:
Value
Type: Array of String
See also: RetrieveBuffer, SetBuffer.
This property permits to define and to know a parameter value. Value[0] is the
value of the first parameter. You can use this property for all parameters other
than of type ‘H '. The conversions are done automatically and you only work with
character strings.
For parameters of type ‘H ', you can affect this buffer with the help of the
SetBuffer method and consult it with the RetrieveBuffer method. This property
will have the value ‘See Buffer '
Methods
AddParam
Parameters: Parameter type: Char (‘A ', 'S ', 'P ', 'B ', 'F ', 'L ', 'T ', 'Z ' or ‘H ');
Maximal parameter length: Integer;
Number of parameter decimals: Integer
Return: None
See also: Params, ClearParams.
Example:
{MyProg: TCall400;}
MyProg.ClearParams;
MyProg.AddParam(‘P’,5,2);
MyProg.Value(0):=’12’;
MyProg.Execute;
ShowMessage(‘The been worth is: ’+MyProg.Value(0));
This method permits to add a parameter while passing by parameter its type, its
length and its number of decimals. For the types ‘L ', ‘T ' and ‘Z ', you can put the
last two parameters at 0. For the types ‘A ', ‘H ' and ‘B ', you can put the last
parameter at 0.
ClearParams
Parameters: None.
Return: None.
See also: Params, AddParam.
Example:
{MyProg: TCall400;}
MyProg.ClearParams;
MyProg.AddParam(‘P’,5,2);
MyProg.Value(0 (:= ‘12 'S;
MyProg.Execute;
ShowMessage(‘The been worth is: ’+MyProg.Value(0 ();
This method permits to cancel all the parameters.
Execute
Parameters: None.
Return: None.
Example:
{MyProg: TCall400;}
MyProg.ClearParams;
MyProg.AddParam(‘P’,5,2);
MyProg.Value(0 (:= ‘12 'S;
MyProg.Execute;
ShowMessage(‘The been worth is: ’+MyProg.Value(0 ();
RetrieveBuffer
Parameters: Parameter index: Integer;
Buffer to fill in: Pchar
Return: None
See also: Value, ParamType, Params, AddParam, SetBuffer.
Example:
{MyProg: TCall400;}
{MyBuff: PChar}
MyProg.ClearParams;
MyProg.AddParam(‘H’,128,0);
SetBuffer
Parameters: Parameter index: Integer;
Buffer to affect: Pchar;
Return: None
See also: Value, ParamType, Params, AddParam, RetrieveBuffer.
Example:
{MyProg: TCall400;}
{MyBuff: PChar}
MyProg.ClearParams;
MyProg.AddParam(‘H’,14,0);
GetMem(MyBuff,15);
StrPCopy(MyBuff+4, 'test TCall ');
ascii2ebcdic(MyBuff+4,MyBuff+4,10)
MyProg.SetBuffer(0,MyBuff);
Freemem(MyBuff,15);
MyProg.Execute;
BeforeExecute
Type: TNotifyCancelEvent ( See Types used by ScreenDesigner/400).
Call: the code added to this event is executed right before the start of the
program.
The parameter ' Cancel ' (of Boolean type), if put at True, permits to cancel the
start of the program.
OnExecute
Type: TNotifyEvent (Class Delphi).
Call: the code added to this event is executed right after the start of the
program.
Tip
Ancestor TComponent
Unit SCDCMD
Properties
AS400
Type: TAS400.
See also: Class TAS400
This property permits to define on which iSeries must the command be executed.
CommandLine
Type: TStringList
This property represents the command line to execute. The return variables
included in the command must be named in the following way:
• P.1 for the first
• P.2 for the second
• …
• P.n for the n th
• and they must appear in the command line order.
• For example:
• RTVSYSVAL SYSVAL(QDATE) RTNVAR(&P.1)
• RTVJOBA JOB(&P.1) USER(&P.2) NBR(&P.3)
You must define all parameters with the help of the Params property.
ParamDecimals
Type: Array of Integer.
See also: Params, ParamDigits, ParamType.
This property permits to define and to know the number of decimals defined for a
parameter. ParamDecimals[0] identifies the number of decimals of the first
parameter.
© SystemObjects 1997-2008 www.systemobjects.com 250
ParamDigits
Type: Array of Integer.
See also: Params, ParamDecimals, ParamType.
This property permits to define and to know the maximal length defined for a
parameter. ParamDigits(0) identifies the length of the first parameter.
Params
Type: TStringList.
This property permits to define parameters of the iSeries command.
In conception mode, a window permits to define the parameters visually:
Define each parameter in the group ‘ New Parameter ' then press the button ‘Add
' to insert it in the list.
You must define a type for each parameter. The type conversions will be made
automatically by the object.
Each parameter can be modified with the help of the ‘Modify' button or deleted
with the ‘Delete' button.
Value
Type: array of string.
This property permits to read the value of a parameter. Value(0) is the value of
the first parameter. The conversions are made automatically and you only work
with character strings.
Methods
AddParam
Parameters: Type of the parameter: Char (‘A ', 'N ' or ‘L ');
Maximal parameter length: Integer;
Number of parameter decimals: Integer;
Return: None
See also: Params, ClearParams.
Example:
{MyCmd: TCmd400;}
MyCmd.ClearParams;
MyCmd.AddParam(‘A’,10,0);
MyCmd.Execute;
ShowMessage(‘The been worth is: ’+MyCmd.Value(0 ();
This method permits to add a variable while passing by parameter its type, its
length and its number of decimals. For the type ‘L ', you can put the last two
parameters at 0. For the type ‘A ', you can put the last parameter at 0.
The three types of variables are the following:
Execute
Parameters: None.
Return: None.
Example:
{MyCmd: TCmd400;}
MyCmd.ClearParams;
MyCmd.AddParam(‘A’,10,0);
MyCmd.Execute;
ShowMessage(‘The been worth is: ’+MyCmd.Value(0));
This method executes the iSeries command.
This method generates an ECO400Error exception in case of error.
Events
BeforeExecute
Type: TNotifyCancelEvent ( See Types used by ScreenDesigner/400).
Call: the code added to this event is executed right before the start of the
command.
The parameter ' Cancel ' (of Boolean type), if put at True, permits to cancel the
start of the command.
OnExecute
Type: TNotifyEvent (Class Delphi).
Call: the code added to this event is executed right after the start of the
command.
Ancestor TComponent
Unit SCDCALL
Properties
AS400
Type: TAS400.
See also: Class TAS400
This property permits to define on which iSeries is fond the Data Area.
DADecimals
Type: Integer
See also: DataAreaType, DAType, DALength,
This property permits to define your Data Area’s number of decimals. This
property is useful only for the type ‘N ' (Numeric).
DALength
Type: Integer
See also: DataAreaType, DAType, DADecimals,
This property permits to define your Data Area length. This property is useful only
for the types ‘N ' (Numeric) and ‘A ' (Alpha-numeric).
DataAreaName
Type: string
This property permits to define your Data Area name.
In conception mode, a window permits to search for your Data Areas:
LibraryName
Type: string
This property permits to define the library where the Data Area is found.
A window permits to search for your library name on your iSeries:
You can leave the generic name blank if you wish to display all the libraries.
Otherwise, indicate the beginning of the library name followed by the character '
* ' ; you will get the corresponding library list.
Value
Type: String.
This property permits to define and to know the Data Area value. The conversion
is made automatically and you only work with character strings.
Editor of component
By a Double Click on the component, in conception mode, you can read the Data
Area value (This Data Area must be defined previously):
Ancestor TComponent
Unit SCDDTAQ
Properties
AS400
Type: TAS400.
See also: Class TAS400
This property permits to define on which iSeries is found the Data Queue.
BufferSizeAvailable
Type: LongInt READONLY
See also: MessageListCount, MessageAvailableCount, MessageListError,
GetMessages, GetMessagesWithKey, GetMessageValueInList,
GetMessageJobNameInList, GetMessageJobUserInList,
GetMessageJobNumberInList, GetMessageUserProfileInList, GetMessageKeyInList.
This property can be used after the call of the GetMessageses and the
GetMessagesWithKey methods. It permits to know the optimal buffer size to be
used in order to recover all messages requested by the GetMessages.
DataQueueName
Type: String.
This property permits to define the Data Queue name.
In conception mode, a window permits to search for the Data Queues:
Description
Type: String READONLY
This property permits to know the defined Data Queue description.
ForceIndicators
Type: Boolean READONLY
This property permits to know if the Data Queue has been created with the
option: Force on the auxiliary memory (FORCE).(*yes)
JobNumber
Type: String READONLY
See also: JobName, JobUser, SenderProfile,
This property permits to know the number of the job sending the message
received by the Receive or the ReceiveByKey method. This property can be used
only if the Data Queue has been created with the option: Sender ID (*yes)
(SenderWanted=True).
JobUser
Type: String READONLY
See also: JobName, JobNumber, SenderProfile,
This property permits to know the user owning the job sending the message
received by the Receive or the ReceiveByKey method. This property can be used
only if the Data Queue has been created with the option: Sender ID (*yes)
(SenderWanted=True).
KeyLength
Type: Integer READONLY
See also: SendWithKey, ReceiveByKey,
This property permits to know the defined key length at the time of the Data
Queue creation.
You can leave the generic name blank if you wish to display all the libraries.
Otherwise, indicate the beginnin of the library name followed by the character ' *
' ; you will get the corresponding library list.
The research is Key Sensitive, think of capitals.
MessageAvailableCount
Type: LongInt READONLY
See also: MessageListCount, BufferSizeAvailable, MessageListError,
GetMessages, GetMessagesWithKey, GetMessageValueInList,
GetMessageJobNameInList, GetMessageJobUserInList,
GetMessageJobNumberInList, GetMessageUserProfileInList,
GetMessageKeyInList,,,
This property can be used after the call of the GetMessageses and
GetMessagesWithKey methods. It permits to know the total number of messages
requested by the GetMessages (WithKey).
This property can be used after the call of the GetMessageses and
GetMessagesWithKey methods. It permits to know the number of the messages
truly read by the GetMessages (WithKey). This property can be less than
MessageAvailableCount if the defined buffer is not big enough.
MessageListError
Type: LongInt READONLY
See also: MessageListCount, BufferSizeAvailable, MessageAvailableCount,
GetMessages, GetMessagesWithKey, GetMessageValueInList,
GetMessageJobNameInList, GetMessageJobUserInList,
GetMessageJobNumberInList, GetMessageUserProfileInList,
GetMessageKeyInList,,,
This property can be used after the call of the GetMessageses and the
GetMessagesWithKey methods. It permits to know the iSeries error code if an
error occured at the time of the GetMessages (WithKey). ‘CPF0000 ' means that
no error occured.
MessageMaxLength
Type: LongInt READONLY
See also: NumberOfMessages, KeyLength,
This property permits to know the maximum message size of this Data Queue.
NumberOfMessages
Type: LongInt READONLY
See also: MessageMaxLength, KeyLength,
This property permits to know the number of messages contained in the Data
Queue.
ReceivingWait
Type: Integer.
See also: Receive, ReceiveByKey, ReceivingKeyOrder;
This property permits to define the response time for a message in the Data
Queue. It is used by the ReceiveByKeys and the Receive methods. The value by
default is 0: the Receive method unstacks a message if the Data Queue is non
void ; otherwise it gives you back immediately the control.
SenderProfile
Type: String READONLY
See also: JobUser, JobNumber, JobName,
This property permits to know the user profile of the message received by the
Receive or the ReceiveByKey method. This property can be used only if the Data
Queue has been created with the option: Sender ID (*yes)
(SenderWanted=True).
SenderWanted
Type: Boolean READONLY
See also: SenderProfile, Jobuser, JobName, JobNumber.
This property permits to know if the sender's ID is includeded in the Data Queue
messages. It’s a Data Queue creation option on the iSeries: Sender ID (*yes)
(Option SENDERID).
Sequence
Type: coDtaqSequence ( See section Types used by ScreenDesigner/400).
This property permits to define the Data Queue type: First In First Out, Last In
First Out, by key. It is a Data Queue creation option on the iSeries (Option SEQ).
ClearDataQueue
Parameters: None
Return: None
See also: NumberOfMessages, Send, Receive,
Example:
{MyDtaq: TDataQueue;}
yew MyDtaq.NumberOfMessages>0 then
MyDtaq.ClearDataQueue;
This method permits to cancel all the Data Queue messages.
GetMessageJobNameInList
Parameters: Message index: Integer;
Job name: String;
Return: None
See also: MessageListError, MessageListCount, BufferSizeAvailable,
MessageAvailableCount, GetMessages, GetMessagesWithKey,
GetMessageValueInList, GetMessageJobUserInList, GetMessageJobNumberInList,
GetMessageUserProfileInList, GetMessageKeyInList,,,
Example:
{MyDtaq: TDataQueue;}
{MyJobName: String;}
Yew MyDtaq.GetMessages(stAll,100,1000)>0 then
begin
ShowMessage(IntToStr(MyDtaq.MessageListCount)+
‘messages ' retrieved);
MyDtaq.GetMessageJobNameInList(1,MyJobName);
ShowMessage(‘First message is coming from job name: '+
MyJobName);
end;
This method permits to know (second parameter) the name of the job having
sent one of the messages recovered by the GetMessageses and the
GetMessagesWithKey methods. This method can be used only if the Data Queue
has been created with the option: Sender ID (*yes) (SenderWanted=True).
This method permits to know (second parameter) the job number having sent
one of messages recovered by the GetMessageses and the GetMessagesWithKey
methods. This method can be used only if the Data Queue has been created with
the option: Sender ID (*yes) (SenderWanted=True).
GetMessageJobUserInList
Parameters: Message index: Integer;
Work user: String;
Return: None
See also: MessageListError, MessageListCount, BufferSizeAvailable,
MessageAvailableCount, GetMessages, GetMessagesWithKey,
GetMessageValueInList, GetMessageJobNumberInList, GetMessageJobNameInList,
GetMessageUserProfileInList, GetMessageKeyInList
Example:
{MyDtaq: TDataQueue;}
{MyJobUser: String;}
Yew MyDtaq.GetMessages(stAll,100,1000)>0 then
begin
ShowMessage(IntToStr(MyDtaq.MessageListCount)+
‘messages ' retrieved);
This method permits to know (second parameter) the user corresponding to the
job having sent one of the messages recovered by the GetMessages and the
GetMessagesWithKey methods. This method can be used only if the Data Queue
has been created with the option: Sender ID (*yes) (SenderWanted=True).
GetMessageKeyInList
Parameters: Message index: Integer;
Message key: PChar;
Key length: LongInt
Return: None
See also: MessageListError, MessageListCount, BufferSizeAvailable,
MessageAvailableCount, GetMessages, GetMessagesWithKey,
GetMessageValueInList, GetMessageJobNumberInList, GetMessageJobNameInList,
GetMessageUserProfileInList, GetMessageJobUserInList
Example:
{MyDtaq: TDataQueue;}
{MyKey: PChar;}
{Lg: LongInt;}
Yew MyDtaq.GetMessages(stAll,100,1000)>0 then
begin
ShowMessage(IntToStr(MyDtaq.MessageListCount)+
‘messages ' retrieved);
GetMem(MyKey,MyDtaq.KeyLength+1);
MyDtaq.GetMessageKeyInList(1,MyKey,Lg);
MyKey(Lg(:=Char(0);
Ebcdic2ascii(MyKey,MyKey,Lg); {Key is year EBCDIC string in this sampe}
ShowMessage(‘Key of the first message is: '+
StrPas(MyKey));
end;
This method permits to know the key of one of the messages recovered by the
GetMessages and the GetMessagesWithKey methods. This method can be used
only if the Data Queue has been created as a KEYED type.
The second parameter is the buffer representing the read key and the third
parameter is the key returned length.
This method permits to consult messages in a Data Queue. The first parameter
permits to define the extent of the consultation:
• stAll: All the messages;
• stFirst: The first message;
• stLast: The last message.
The second parameter defines the length of the message to return. The
MessageMaxLength property can be used. If your Data Queue has been created
with the option: Sender ID (SenderWanted=True) then add 36 to the length of
the message wanted (SenderProfile:10; JobName:10; JobNumber:6; JobUser:10)
in order to have the message in its totality.
The third parameter defines a buffer size used to memorize the read messages. If
this size is insufficient, the first messages only will be bufferized. After using this
method, MessageListCount is the number of messages memorized and available;
MessageAvailableCount is the number of messages that could have been
memorized, had the buffeur been bigger.
• GetMessageValueInList,
• GetMessageJobNumberInList,
• GetMessageJobNameInList,
• GetMessageUserProfileInList,
• GetMessageJobUserInList.
GetMessagesWithKey
Parameters: Key comparison: coDtaqKeyOrder ( See section Types used by
ScreenDesigner/400).;
Key value: Pchar;
Key value length: Word;
Length of the messages to bring back: Word;
Length of the keys to bring back: Word;
Return buffer size to use: Integer
Return: Number of messages returned: LongInt;
See also: MessageListError, MessageListCount, BufferSizeAvailable,
MessageAvailableCount, GetMessages, GetMessageValueInList,
GetMessageJobNumberInList, GetMessageJobNameInList,
GetMessageUserProfileInList, GetMessageJobUserInList;
Example:
{MyDtaq: TDataQueue;}
{MyKey: PChar;}
{Lg: LongInt;}
MyDtaq.GetMessagesWithKey yew (
dkGreaterThan, ’TCIS’,4,100,0,1000)>0 then,
begin
ShowMessage(IntToStr(MyDtaq.MessageListCount)+
‘messages ' retrieved);
GetMem(MyKey,MyDtaq.KeyLength+1);
MyDtaq.GetMessageKeyInList(1,MyKey,Lg);
MyKey(Lg(:=Char(0);
ShowMessage(‘Key of the first message is: '+
StrPas(MyKey));
end;
To use this method, your Data Queue must have been created as a KEYED type
(Option SEQ). If the case, the KeyLength property is different from 0.
The fourth parameter defines the message length to be returned and the fifth, the
key length to bring back. The MessageMaxLength and the KeyLength properties
can be used. If your Data Queue has been created with the option: Sender ID
(SenderWanted=True) then add 36 to the length of the message wanted
(SenderProfile:10; JobName:10; JobNumber:6; JobUser:10) to have the message
in its totality.
The last parameter defines a buffer size used to memorize the read messages. If
this size is insufficient, the first messages only will be bufferized. After using this
method, MessageListCount is the number of messages memorized and available;
MessageAvailableCount is the number of messages that could have been
memorized, had the buffer been bigger.
• GetMessageValueInList,
• GetMessageJobNumberInList,
• GetMessageJobNameInList,
• GetMessageUserProfileInList,
• GetMessageKeyInList,
• GetMessageJobUserInList.
This method permits to know (second parameter) the user profile of one of the
messages recovered by the GetMessageses and the GetMessagesWithKey
methods. This method can be used only if the Data Queue has been created with
the option: Sender ID (SenderWanted=True).
GetMessageValueInList
Parameters: Message index: Integer;
Message: PChar;
Message lenght: LongInt
Return: None
See also: MessageListError, MessageListCount, BufferSizeAvailable,
MessageAvailableCount, GetMessages, GetMessagesWithKey,
GetMessageKeyInList, GetMessageJobNumberInList, GetMessageJobNameInList,
GetMessageUserProfileInList, GetMessageJobUserInList
Example:
{MyDtaq: TDataQueue;}
{MyMessage: PChar;}
{Lg: LongInt;}
Yew MyDtaq.GetMessages(stAll,100,1000)>0 then
begin
ShowMessage(IntToStr(MyDtaq.MessageListCount)+
‘messages ' retrieved);
This method permits to know the value of one of the messages recovered by the
GetMessageses and the GetMessagesWithKey methods.
The second parameter is the buffer representing the read message and the third,
the returned length of this message.
GetValue
Parameters: Message: PChar;
Message length: LongInt
Return: None
See also: SetValue, Receive, Send, ReceiveByKey, SendWithKey.
Example:
{MyDtaq: TDataQueue;}
{MyMessage: PChar;}
{Lg: LongInt;}
yew MyDtaq.Receive then
begin
GetMem(MyMessage,MyDtaq.MessageMaxLength+1);
MyDtaq.GetValue(MyMessage,Lg);
MyMessage(Lg(:=Char(0);
Ebcdic2ascii(MyMessage,MyMessage,Lg); {message is year EBCDIC string in this
sample}
ShowMessage(‘Message received: '+StrPas(MyMessage));
end;
This method permits to know the message received by the Receive or the
ReceiveByKey method. The first parameter is the buffer containing the message,
the second is the buffer size.
This method permits to unstack a Data Queue message with access by key. The
return permits to know if a message has been read (True) or if no message
corresponds to the request on the key (False). Use the GetValue method to have
the message. The method parameter is modified to indicate the real key of the
unstacked message.
The ReceivingWait property is used by this method to define the response time of
a Data Queue message.
The access by key is defined by the ReceivingKeyOrder property for the
comparison key and by the method parameter for the reference key.
This method can be used only if the Data Queue has been created as a KEYED
type.
This method permits to stack a message in the Data Queue. Use the SetValue
method to define the message.
This method can be used only if the Data Queue has been created as a type other
than KEYED.
SendWithKey
Parameters: Message key
Return: None
See also: Send, Receive, ReceiveByKey, Getvalue, SetValue
Example:
{MyDtaq: TDataQueue;}
{MyMessage: PChar;}
GetMem(MyMessage,MyDtaq.MessageMaxLength+1);
StrPCopy(MyMessage, 'My new message to ' send);
ascii2ebcdic(MyMessage,MyMessage,22);
{Message is year EBCDIC string in this sample}
MyDtaq.SetValue(MyMessage,22);
MyDtaq.SendWithKey(‘TCIS ');
This method permits to stack a message in a Data Queue of KEYED type. Use the
SetValue method to define the message.
The parameter of this method represents the key associated to the message that
will be stacked in the Data Queue.
This method can be used only if the Data Queue has been created as a KEYED
type.
This method permits to define the message to send by the Send or by the
SendWithKey method. The first parameter is the buffer defining the message, the
second is the buffer size.
Component editor
By a Double Click on the component, in conception mode, you can read the Data
Queue description (This Data Area must be defined previously):
This window indicates from top to bottom, the library name, the Data Queue
name, the Data Queue description, the Data Queue type (First-In-First-Out, By
key or Last-In-First-Out), whether the sender identification is managed, whether
the Data Queue has been created with the option ‘Force on auxiliary memory ',
the key length , the maximal size of a message.
Ancestor TComponent
Unit: SCDMSGQ
Properties
AS400
Type: AS400
This property indicates on which iSeries the object is located (the command, the
program, etc.).
Identifier
Type: String
This property gives the identifying code of the message received. If an immediate
message is received, this field is blank.
LibraryName
Type: String
This property is used to specify the library where the iSeries object(file, program,
data area, etc.) is located.
MessageQueueName
Type: String
This property is used to define the name of the message queue.
In Design mode, a popup window is used to search for the message queues in a
library.The generic name can be left blank to view a list of all the data queues in
a library.
© SystemObjects 1997-2008 www.systemobjects.com 277
To list all the message queues starting with a certain prefix, type in the starting
string followed with an '*' (wildcard).
Msg
Type: String
This property gives the last message received, or prepares the next message to
send. If you need a Pchar, use methods GetMsg and SetMsg.
MsgBookmark
Type: TMsg400Bookmark (ReadOnly)
This property gives the bookmark of the message received. You can use this
bookmark to delete the message later, using method
RemoveMessageWithBookmark.
MsgCount
Type: LongInt (ReadOnly)
This property gives the number of messages in the message queue.
MsgLength
Type: LongInt (ReadOnly)
This property gives the length of the last message received.
MsgType
Type: String
This property gives the message type of the message received. The possible
values and their meanings are:
• 01: Completion
• 02: Diagnostic
• 04: Informational
• 05: Inquiry
• 06: Sender’s copy
• 08: Request
• 10: Request with prompting
• 14: Notify
• 15: Escape
• 21: Reply, not validity checked
• 22: Reply, validity checked
• 23: Reply, message default used
• 24: Reply, system default used
© SystemObjects 1997-2008 www.systemobjects.com 278
• 25: Reply, from system reply list
ReceivingWait
Type: Integer
This property defines the response time for a message in the data queue. It is
used by the ReceiveFirst, ReceiveNext, ReceivePrior and ReceiveLast methods.
The default value is 0.
SendingJob
Type: String (ReadOnly)
This property gives the name of the job in which the message being received was
sent.
SendingJobNumber
Type: String (ReadOnly)
This property gives the name of the job number of the job in which the message
being received was sent.
SendingProgramName
Type: String (ReadOnly)
This property gives the program name, or ILE program name, that contains the
procedure sending the message.
SendingUserProfile
Type: String (ReadOnly)
This property gives the name of the user profile that sent the message being
received.
Severity
Type: Longint (ReadOnly)
This property gives the severity of the message received. Possible values are 0
through 99.
ReceiveFirst
Parameters: action:TmsgAction
Return: Boolean
This method is used to receive the first message in the message queue.
Example:
{MyMsgq: TMessageQueue;}
if MyMsgq.ReceiveFirst(maSame) then
ShowMessage(‘Message is: ‘+MyMsgq.Msg);
ReceiveLast
Parameters: action:TmsgAction
Return: Boolean
This method is used to receive the last message in the message queue.
Example:
{MyMsgq: TMessageQueue;}
if MyMsgq.ReceiveLast(maSame) then
ShowMessage(‘Message is: ‘+MyMsgq.Msg);
ReceivePrior
Parameters: action:TmsgAction
Return: Boolean
This method is used to receive the prior message in the message queue.
Example:
{MyMsgq: TMessageQueue;}
if MyMsgq.ReceivePrior(maSame) then
ShowMessage(‘Message is: ‘+MyMsgq.Msg);
RemoveMessages
Parameters: Type_of_removal:TRemoveType400
Return: Boolean
This method is used to delete a set of messages in a message queue. You can
delete:
• all the messages
• all messages except unanswered inquiry messages and unanswered
senders’ copies
• all new messages
• all old messages
Example:
{MyMsgq: TMessageQueue;}
if MyMsgq.RemoveMessages(rtAll) then
ShowMessage(‘Message queue is empty’);
Send
Parameters Message_type : TMsg400Type; Reply_Message_Queue :
TMessageQueue
Return: Boolean
This method is used to send a message to the data queue, use the property msg
or the method SetMsg to prepare the message. You have to choose the type of
your message:
• Completion
• Diagnostic
• Informational
• Inquiry.
Note: When you send an inquiry message, a copy of the message is placed in the
reply message queue.
Example:
{MyMsgq: TMessageQueue;}
MyMsgq.Msg:=’Do not delete programs!’;
if MyMsgq.Send(mtInfo,nil) then
ShowMessage(‘Message sent.’);
Ancestor Tcomponent
Unit SC5250
The TSC5250 class enables to manage the communication between your P.C. and
your iSeries, in particular connection and disconnection in order to open or to
close 5250 sessions. This corresponds to iSeries’s PASSTHRU function.
This component wors associated to Tsc5250Panel component.
Properties
Active
Type: boolean
This property gives or changes the state of the connection to the AS400.
When the property passes from False to True, a connection to the iSeries is
established. If you have a normal connection, a job is initiated on the iSeries. This
job will be (in the majority of cases) in the pool QCMN (depending on the
configuration of your system). The status of the job is CPCW. If you initiate a
© SystemObjects 1997-2008 www.systemobjects.com 285
second connection to the iSeries (with a second instance of this class, for
example), it will use the first connection, and there will be no change on your
iSeries.
When the property passes from True to False, the program will disconnect from
the iSeries unless, as in the previous case, two connections are established. In
this situation where two connections where established, disconnection from the
iSeries will occur only when both properties are set to False, and the job will
disappear from the iSeries subsystem.
If changing this property from one state to the other generates an abnormal
termination (impossible connection for example), the class will generate an
exception and raise an exception of the class ECO400Error that you can manage
(see the Help topics concerning managing errors).
Disconnection occurs automatically when the object is destroyed, so there is no
need to change the property to false at the end of a program.
If a user turns off his or her PC while in the middle of a program, the object will
be abnormally destroyed. Disconnection from the iSeries will not occur, but the
iSeries will have lost its controller and the job will stop on the iSeries.
If the iSeries breaks down for any reason, the PC will receive an APPC error the
next time it tries to access the iSeries. The PC will not freeze, and you can
manage the APPC error (see the chapter concerning errors) to stop the
application.
AdaptFormTitle
Type: boolean
This property sets the caption value of the parent form to the current 5250 screen
title.
The 5250 screen’s title has to locate on the middle of the first line of the screen.
Allow132
Type: boolean
This property has to be set to «true» to enables the Screen5250panel component
to display 132 columns screens.
The Screen5250panel component automatically aligns itself to the form and
manages its height and width properties.
This is not available for Chinese and Korean CHARSETS (DBCS).
Note: This setting needs that the screen/5250 components are alone on a form.
© SystemObjects 1997-2008 www.systemobjects.com 286
AS400
Type: String
This property must be set to the name of the iSeries to connect.
Note: if connections are active a list of available iSeries is displayed.
CanSetupColors
Type: boolean
To allow the program user to customize the displaying settings and to save it as
default through a PopupMenu.
This property is taken into consideration at connection time.
Its also Allow Zooming options.At design time clicking on the ellipse button allows
to set visual properties such as the font name, size and colors .
Colored, Normal, Highlight, blink and reverse are the different attributes of a
5250 screen.Changing the Font Name and Size properties can as well ameliorate
or deteriorate displaying.
If CanSetupColors property is set to «true» all these settings can be modified at
RunTime using the right button of the mouse.
Lib
Type: String
To define the current library of the 5250 session.
Setting this property is useless if the user and Password properties are invalid or
left to blank.
Menu
Type: String
To define the menu of the 5250 session. Setting this property is useless if the
user and Password properties are invalid or left to blank.
Password
Type: String
To connect the iSeries under a defined profile (see also : User Property)
Screen5250
Type: String
This property sets the name of the TSc5250Panel associated to this component.
The graphical options will be apply.
User
Type: String
To connect the AS\400 with the define profile .
If the User and the Password properties are set, the QDSIGNON screen is by-
passed.
Event
OnError
Type : TNotifyErrEvent
call : the code added to this event is executed right after connecting the iSeries
has failed.
Text: this read-only parameter (of String type) permits to get the message sent.
Code: this parameter (of Integer type) permits to get the error code returned by
the CO40032.dll
Cancel: this parameter (of Boolean type) permits, if put at true to cancel the
Message Box following the connection error.
Ancestor TComponent
Unit SC5250Panel
This class defines the graphic component, inheritates the TCustomPanel object’s
properties, and corresponds to the iSeries 5250 session.
This object must be linked to a TSC5250 component which connects the P.C. to
the iSeries and defines its graphical options.
CopySelZone
Parameters: None
Return: None
This method extract the block of text selected with the mouse and sends it to the
clipboard.
GetSelZone
Parameters: None
Return: None
This method extracts a selected block of text and returns a String.
To select a block drag on the screen with the mouse.
GetTextBuff
Parameters: ColS,ColE,LignS,LignE :integer
Return: String
This function extracts from the selected area the text and returns a String .
The area is defined by four parameters :
• ColS : the start column,
• ColE : the end column,
• LignS : the start line,
• LignE : the end line.
For a 80 columns screen, the columns are numbered from 0 to 79 and the lines
from 0 to 24. For a 132 columns screen, the columns are numbered from 0 to
131 and the lines from 0 to 24.
PasteFrClip
Parameters: None
Return: None
This method paste the clipboard text in the Windows active control.
Note : you cannot call this method from a button that catch the focus. It’s better
to use a menu.
To send text to a Screen\5250 edit zone please use the SendTextTo method.
PrintSelZone
Parameters: None
Return: None
PrintScreen
Parameters: None
Return: None
This method permits to send to the printer the entire screen.
Sendfunction
Parameters: Newfunct :Tfonction ; ReadOnly :Boolean
Return: String
This function sends a function to the iSeries (if ReadOnly is set to false)
The available values of NewFunct are :
ENTER
F01,F02......,F24
SYST
ATT
SAME(*)
It also intercepts the last function which was sent to the iSeries (when ReadOnly
is set to true).
(*) SAME is required when the ReadOnly parameter is set to true.
SendTextTo
Parameters: Ftext :WideString ; Num_Field :Integer
Return: Boolean
This function send a String to a Screen5250 edit zone. Num_Field is the number
of the edit zone. They are numbered from Top/Left to Right/Down. If the value of
Num_Field is greater than the number of edit zone of the current screen it returns
false.
Ancestor: TComponent
Unit: scdifs
The TCoifs class permits you to manage your iSeries Integrated File System
For more information about IFS refers to IBM documentation : “OS/400
Integrated File System”.
Properties
Tcoifs
This property must be set to the name of the TAS400 component to connect.
Asynchronous
Type: Boolean
This property works with ListDirectory and ListDirectroryNext methods. It
allows you to access Directory objects repetitively.
Connected
Type: Boolean
This property Indicates whether the connection to the IFS is established.
CurThread
Type: TDirThread
This property points to a TdirThread class which contains information about
objects in the current Directory.
© SystemObjects 1997-2008 www.systemobjects.com 293
TransferComplete
Type: Boolean
This property Indicates whether the current Directory information transfer is
completed.
Stream
This property is the stream object that receives the memory image of a bitmap
after a call to CopyFileASToStream method.
Methods
ListDirectory
Parameters: RootDir:string; nbentry:smallint
Return: None
This method retrieves objects of RootDir Directory and populates Curthread
object. If Asynchronous property is set to False, all objects are returned.
If Asynchronous property is set to True, only nbentry obejcts are retrieved. To
retrieve following objects use ListdirectoryNext method
Property TransferComplete will be set to True when all objects are retrieved.
If an error occurs, an exception is raised.
ListDirectoryNext
Parameters: nbentry:smallint
Return: None
This method retrieves objects of the current Directory and populates Curthread
object. It should be use only after a successful call to ListDirectory when:
Asynchronous property is set to True.
Property TransferComplete will be set to True when all objects are retrieved.
If an error occurs, an exception is raised.
Connect
Parameters: None
Return: None
The Connect method establishes the connection to the IFS. Connected property
will be set to True. If an error occurs, an exception is raised.
CopyFileASToStream
Parameters: ASFile:string
Return: None
CopyFileToAS
Parameters
PCFile:string;ASFile:string;overwrite:boolean;Showprogress:boolean
Return: None
The CopyFileToAS method copies PCFile into ASFile. If overwrite is set to True and
ASFile exists, ASFile will be overwritten. If Showprogress is set to True, a
progress bar will be displayed on screen. If an error occurs, an exception is
raised.
CopyFileFromAS
Parameters:
ASFile:string;PCFile:string;overwrite:boolean;Showprogress:boolean;
convert:boolean
Return: None
The CopyFileFromAS method copies ASFile into PCFile.
If overwrite is set to True and PCFile exists, PCFile will be overwritten.
If Showprogress is set to True, a progress bar will be displayed on screen.
If convert is set to True, ASFile contents will be converted from ebcdic to Ansi
character set. This parameter should be used only when transferring source files
located in QSYS.LIB. If an error occurs, an exception is raised. See TCoifs
exception classeshlp_errcoifs
CopyStreamToFileAS
Parameters: ASFile:string;overwrite:boolean
Return: None
The CopyStreamtoFileAS method copies Stream object contents into ASFile.
If overwrite is set to True, ASFile will be overwritten.
See DBBitmap sample for more information. (On this path: Instdir\Delphi
4.1\samples\DBBitmap )
If an error occurs, an exception is raised.
DisConnect
Parameters: None
Return: None
The DisConnect method terminates the connection to the IFS.
Connected property will be set to False.
DeleteDirectory
Parameters: path:string
Return: None
The DeleteDirectory method deletes the directory specified by path.
If an error occurs, an exception is raised.
DelFile
Parameters: path:string
Return: None
The DelFile method deletes the file specified by path.
If an error occurs, an exception is raised.
Ancestor: TComponent
Unit: scdifs
The TDirThread class allows you to access information about objects located in
the current Directory.
Properties
Dirs
Type: TIFSObject
The Dirs property refers to a TIFSObject which contains information about
children Directory located in the current directory.
Files
Type: TIFSObject
The Files property refers to a TIFSObject which contains information about
children Files located in the current directory.
Path
Type: TIFSObject
The Path property contains the path of the current directory.
The TIFSObject class allows you to access information about Files or Directories.
Properties
Count
Type:Integer
The Count property returns the number of object in the TIFSObject.
Names
Type: String
The Names property returns the name of the object (File or Directory) referred by
index.
Modified
Type: Boolean
The Modified property returns the last modified date of the object (File or
Directory) referred by index.
Size
Type: LongInt
The Size property returns the Size in Bytes of the object (File or Directory)
referred by index.
Units: ifstools
Description:
When using TCoifs component, if an error occurs, one of these exceptions is
raised:
Ancestor: TComponent
Unit: CoIFSBrowseDirs
A sample on how to use it is available under your install directory at this path:
COIFS
Tyoe: TCOIFS
This property must be set to the name of the TCoifs component to connect.
CODIR
Type: String
InitialDir determines the default directory displayed in the List when it is
displayed. For example, to point the list at the /QDLS/ directory, set the value of
InitialDir to /QDLS/
If no value is assigned to InitialDir, the list is displayed with the root Directory.
SelectedDir
Type: String
This property contains the current selected directory path.
Methods
DisplayCurrentDir
Parameters: None
Return: None
Use DisplayCurrentDir to display all objects located in the current directory.
DisplaySubDir
Parameters: AnItem : TTreeNode
Return: None
Use DisplaySubDir to display all objects bellow AnItem node.
DisplaySubDirByName
Parameters: DirName : String
Return: None
Use DisplaySubDirByname to display all objects bellow DirName Directory.
Events
OnSelected
Type: TNotifyEvent
Write an OnSelected event handler to respond when a Directory in the
CoIFSBrowseDirs view is selected.
© SystemObjects 1997-2008 www.systemobjects.com 301
Class TCoIFSBrowseFiles
Ancestor: Component
Unit: CoIFSBrowseFiles
Use TCoIFSBrowseFiles to manage and display a list of files in a form. The objects
can be displayed in columns with column headers and sub-items, or vertically or
horizontally.
This control can be seen as the right pane of the Database Explorer.
A sample on how to use it is available under your install directory at this path:
Instdir \ CO411\Delphi 11\samples\IFSexplorer
COIFS
Type: TCOIFS
This property must be set to the name of the TCoifshlp_Tcoifs>Main component
to connect.
CODIR
Type: String
This property must be set to the name of the
TCoIFSBrowseDirshlp_TcoifsDir>Main component to connect.
InitialDir
Type: String
InitialDir determines the default directory displayed in the List when it is
displayed. For example, to point the list at the /QDLS/ directory, set the value of
InitialDir to /QDLS/
If no value is assigned to InitialDir, the list is displayed with the root Directory.
CopyToClipBoard
Parameters: None
Return: None
Use CopyToClipBoard to copy the selected file to the clipboard. Then you will be
able to paste it in an other application like Windows Explorer.
DeleteSelected
Parameters: None
Return: None
Use DeleteSelected to delete all selected files in the list.
DisplayCurrentDir
Parameters: None
Return: None
Use DisplayCurrentDir to display all objects located in the current directory.
DisplayDir
Parameters: DirName:string
Return: None
Use DisplayDir to display all objects located in the DirName Directory.
PasteFromClipBoard
Parameters: None
Return: None
Use PasteFromClipBoard to paste a previously copied file into the list.
DisplayParentDir
Parameters: None
Return: None
Use DisplayParentDir to display all objects located in the parent Directory.
Unité: Prop400
TSetprop class allows you to define certain number of properties and actions to
execute in TTable and/or TQuery components accessing iSeries files.
During design time (and if the component points to a TTable), one right click on
that component will show you a menu where you can enter the DisplayLabel
property of the fields created in the Field editor.
Buffercount
Type: Integer
This property will allow you to fix the exact number of records to return from an
iSeries access. This will decrease the number of iSeries access in a read
sequence, thus decreasing total access time.
Dataset
Type : Boolean
This property allows you to choose the type of dataset (Ttable or Tquery).
This property allows you to indicate that you only want to transfer through the
network, the selected fields specified in a Ttable component.
Lock Type
This property allows you to choose between the following locking types
CoLckPessimistic: (Default Value) When in edit mode, the Current record is blocked.
CoLckOptimistic: When in edit mode the current record is NOT locked. An exeption will be
raised if the record is changed
All functions presented below can be reused in your applications: the module
indicated for each function must be added to the ' uses '.
ascii2ebcdic
Module: SCDtools.
Declaration: (ebcdic,ascii:pchar;lg:shortint):shortint;
Utility: Conversion of an ASCII string into a EBCDIC one. Lg represents the string
length to be converted.
b22chr
Module: SCDtools.
Declaration: (target,source:pchar;targetlen,decimalpos:shortint):shortint;
Utility: Conversion of a binary value on two iSeries-type bytes into a string
representing this value (‘+012.35 'S). targetlen represents the number of
significant digits of the value represented by the parameter target, decimalpos
the number of digits after the comma.
B42chr
Module: SCDtools.
Declaration: (target,source:pchar;targetlen,decimalpos:shortint):shortint;
Utility: Conversion of a binary value on four iSeries-type bytes in a string
representing this value (‘+012.35 'S). targetlen represents the number of
significant digits of the value represented by the parameter target, decimalpos
the number of digits after the comma.
chr2b2
Module: SCDtools.
Declaration: (target,source:pchar;sourcelen,decimalpos:shortint):shortint;
Utility: Conversion of a string representing a numeric value (‘+012.35 'S) into a
binary value on two iSeries_type bytes. sourcelen represents the number of
significant digits of the value represented by the parameter source, decimalpos
the number of digits after the comma.
chr2f4
Module: SCDtools.
Declaration: (target,source:pchar;sourcelen,decimalpos:shortint):shortint;
Utility: Conversion of a string representing a numeric value (‘+012.35 'S) into a
floating-comma value on four iSeries-type bytes. sourcelen represents the
number of significant digits of the value represented by the parameter source,
decimalpos the number of digits after the comma.
chr2f8
Module: SCDtools.
Declaration: (target,source:pchar;sourcelen,decimalpos:shortint):shortint;
Utility: Conversion of a string representing a numeric value (‘+012.35 'S) into a
floating-comma value on eight iSeries-type bytes. sourcelen represents the
number of significant digits of the value represented by the parameter source,
decimalpos the number of digits after the comma.
chr2pck
Module: SCDtools.
Declaration: (target,source:pchar;targetlen,digits,decimals:shortint):shortint;
Utility: Conversion of a string representing a numeric value (‘+012.35 'S) into a
numeric iSeries-type condensed value. digits represents the number of significant
digits of the value represented by the parameter target, decimalpos the number
of digits after the comma, targetlen the length in bytes.
chr2zon
Module: SCDtools.
Declaration: (target,source:pchar;targetlen,decimalpos:shortint):shortint;
Utility: Conversion of a string representing a numeric value (‘+012.35 'S) into an
extended numeric iSeries-type value. targetlen represents the number of
significant digits of the value represented by the parameter target, decimalpos
the number of digits after the comma.
f42chr
Module: SCDtools.
Declaration: (target,source:pchar;targetlen,decimalpos:shortint):shortint;
Utility: Conversion of a floating-comma value on four iSeries-type bytes into a
string representing a numeric value (‘+012.35 'S). targetlen represents the
number of significant digits of the value represented by the parameter target,
decimalpos the number of digits after the comma.
f82chr
Module: SCDtools.
Declaration: (target,source:pchar;targetlen,decimalpos:shortint):shortint;
Utility: Conversion of a floating-comma value on eight iSeries-type bytes into a
string representing a numeric value (‘+012.35 'S). targetlen represents the
number of significant digits of the value represented by the parameter target,
decimalpos the number of digits after the comma.
pck2chr
Module: SCDtools.
Declaration: (chr,pck:pchar;sourcelen,digits,decimals:shortint):shortint;
Utility: Conversion of a condensed numeric iSeries-type value into a string
representing a numeric value (‘+012.35 'S). sourcelen represents the length in
bytes of the value represented by the parameter source, digits the number of
significant digits and decimalpos the number of digits after the comma.
cGetListDataArea
Module: SCDtools.
Declaration: (hnd:shortint; SearchString:string; Libraryname:string;
listDtaara:tstrings; listdesc:tstrings; size:word): shortint;
Utility: Recuperation of a Data Area library list. The first parameter is the
connection ‘ handle’ (class TAS400, Gethandle method permits to know this
value); the second is the research string (‘D * ': Data Areas the name of which
starts with a D); the third, the research library name; the fourth, the return
parameter of the Data Queue name list (TListBox class, Items property, for
example); the fifth, the return parameter of the Data Area description list; the
TcGetListDataQueue
Module: SCDtools.
Declaration: (hnd:shortint; SearchString:string; Libraryname:string;
listDtaq:tstrings; listdesc:tstrings; size:word): shortint;
Utility: Recuperation of a Data Queue library list. The first parameter is the
connection ‘handle’ ( TAS400 class, Gethandle method permits to know this
value); the second is the research string (‘D * ': Data Queues the name of which
starts with a D); the third, the research library name; the fourth, the return
parameter of the Data Queue name list (TListBox class, Items property, for
example); the fifth, the return parameter of the Data Queue description list; the
sixth, the buffer size used to recover the lists described above (32000, for
example).
TcGetListFile
Module: SCDtools.
Declaration: (hnd:shortint; SearchString:string; Libraryname:string;
listFile:tstrings; listdesc:tstrings; size:word): shortint;
Utility: Recuperation of a library file list. The first parameter is the connection
‘handle’ ( TAS400 class, Gethandle method permits to know this value); the
second is the research string (‘D * ': files the name of which starts with a D); the
third, the research library name; the fourth, the return parameter of the file
name list (TListBox class, Items property, for example); the fifth, the return
parameter of the file description list; the sixth, the buffer size used to recover the
lists described above (32000, for example).
TcGetListLib
Module: SCDtools.
Declaration: (hnd:shortint; SearchString:string; listLib:tstrings;
listdesc:tstrings; size:word): shortint;
Utility: Recuperation of a library list. The first parameter is the connection
‘handle’ ( TAS400 class, Gethandle method permits to know this value); the
second is the research string (‘D * ': libraries the name of which starts with a D);
the third, the return parameter of the library name list (TListBox class, Items
property, for example); the fourth, the return parameter of the library description
list; the fifth, the buffer size used to recover the lists described above (32000, for
example).
TcGetListProg
Module: SCDtools.
Declaration: (hnd:shortint; SearchString:string; Libraryname:string;
listProg:tstrings; listdesc:tstrings; size:word): shortint;
Utility: Recuperation of a library program list. The first parameter is the
connection ‘handle’ ( TAS400 class, Gethandle method permits to know this
value); the second is the research string (‘D * ': programs the name of which
starts with a D); the third, the research library name; the fourth, the return
parameter of the program name list (TListBox class, Items property, for
example); the fifth, the return parameter of the program description list; the
sixth, the buffer size used to recover the lists described above (32000, for
example).
zon2chr
Module: SCDtools.
Declaration: (target,source:pchar;targetlen,decimalpos:shortint):shortint;
Utility: Conversion of an extended numeric iSeries-type value into a string
representing a numeric value (‘+012.35 'S). targetlen represents the numberof
significant digits of the value represented by the parameter target, decimalpos
the number of digits after the comma.
All the types presented below can be reused in your applications: the module
indicated for each type must be added to the ' uses '.
coAccessMode
Module: SCDtools.
The coAccessMode type is the list of access modes to solve a SQL request:
• amSQL
• amNative
coActions
Module: SCDtools.
The coActions type is the list of reading/ writing actions on the iSeries files:
• atFirst
• atPrevious
• atNext
• atLast
• atKeyFirst
• atKeyPrevious
• atKeyNext
• atKeyLast
• atRRN
• atCurrent
• atModify
• atInsert
• atDelete
coButtonKindl
Module: SCDtools.
The coButtonKind type is the list of the following constants:
• bkFirst
• bkPrior
• bkNext
• bkLast
• bkUpdate
• bkCancel
• bkInsert
• bkDelete
coDtaqSelectionType
Module: SCDtools.
The coDtaqSelectionType type is the selection type list used to consult the Data
Queue messages:
• stAll
• stFirst
• stLast
coDtaqSequence
Module: SCDtools.
The coDtaqSequence type is the list of the Data Queue stacking/ unstacking
sequences:
• dsFIFO
• dsKeyed
• dsLIFO
coGridOption
Module: SCDtools.
The coGridOption type is the Grid400 option list:
• goWithoutRRN
coGridOptions
Module: SCDtools.
The coGridOptions type is a group of coGridOption type elements.
CoGridOptions = set of coGridOption
CoLevel
Module: SCDtools.
The coLevel type is the list of the following constants:
• lvCHG
• lvCS
© SystemObjects 1997-2008 www.systemobjects.com 314
• lvALL
coObjType
Module: SCDtools.
The coObjType type is the list of the following constants:
• otMSGQ
• otDATAARA
• otFILE
• otNONE
coOption
Module: SCDdbutl.
The coOption type is the Table400 option list:
• doWithBufferCount
co-opted
Module: SCDdbutl.
The coOptions type is a group of coOption type elements.
CoOptions = set of coOption
coSens
Module: SCDtools.
The coSens type is the key reading direction list:
• ssAscending
• ssDescending
coSharR
Module: SCDtools.
The coSharR type is the list of the following constants:
• rgRead
• rgUpdate
• rgNone
coTarget
Module: SCDtools.
The coTarget type is the list of the following constants:
• tgACTGRP
• tgJOB
coTypeOpen
Module: SCDtools.
The coTypeOpen type is the list of the following constants:
• toDefault
• toRRN
coUserR
Module: SCDtools.
The coUserR type is the list of the following constants:
• rgRead
• rgUpdate
TnotifyCancelEvent
Module: SCDtools.
The TNotifyCancelEvent type is a procedure with a cancellation parameter
(Cancel) passed evidently by address. It permits, besides the fact of being able to
attach a code to an event, to also cancel this event (by indicating in the code
Cancel:=True;).
Silent Mode
Delphi/400 2007 Deployment version Setup program can be run in two different
modes:
2° Launch Delphi/400's Setup program with the -S (Silent) and -F1 (File)
parameters: SETUP -S -F1C:\INSTALL\SETUPPC.ISS
An ISS file is build like an INI file: It has sections, and each section answers to a
dialog box.
You will have to modify some of the default answers to install Delphi/400 2007
Deployment.
[CPAGEDIALOG-0]
EBCDICFILE=FR1.EBC
ASCIIFILE=FR1.ASC
Result=1
EBCDICFILE and ASCIIFILE define the code pages you want to use to convert
characters to and from iSeries.
See TABLE.LST file in “Instdir \ CO411” directory for a list of valid values.
[ROUTERDIALOG-0]
svRouter=RALLY
Result=1
svRouter defines the type of router you are using for the installation.
Valid types are: SNASERVER, TCPIP ,RALLY, RUMBA, OTHER.
AS400NAME=TCISFR
Result=1
[TCPDIALOG-0]
PROFILE= // type your PROFILE (*SECOFR class)
PASSWORD= // type your password here
TCPADDRESS= // type your iSeries TCP/IP address here
PORTSRV=27003 // Default value
FPORTPC=27500 // These ports are not anymore used but required
NBPORTPC=500 // This number is not anymore used but required
Result=1
When set up is finished, a SETUP.LOG file is generated in the target PC, if the
section [ResponseResult] contains ResultCode=0, and the installation is
successful.
© SystemObjects 1997-2008 www.systemobjects.com 319
9 Error Management
EXCEPTION
ECO400ERROR TCISERROR
ECO400APPCERROR ECO400KEYERROR
These four classes inherit the Exception class (for more information, see the
Delphi literature on the exceptions).
A ErrorCode property of Integer type has been added for the three ECO400
classes. You can treat the errors with the help of this error code ( See the list of
error codes further on in this chapter).
In the ECO400AppcError, class are found all the APPC communication errors, all
the error codes between 1 and 100.
In the ECO400KeyError class are found all the errors concerning the access keys,
the error codes: 264, 303, 304, 306, 321, 322 and 324.
SystemObjects Corporation
432 Park Avenue South
New York, NY 10016
USA
«(212) 295-2124
¬ (212) 295-2125
| [email protected]
SystemObjects Europe
7 rue Traversière
B.P. 30407
94573 Rungis Cedex
Paris - France
« + 33 (0)1 41 80 09 09
¬+ 33 (0)1 41 80 09 08
| [email protected]
Partners:
www.systemobjects.com/partners.htm