PP Delphi400 Developersguide PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 333

Delphi/400

Developer's
Guide

© SystemObjects 1997-2008 www.systemobjects.com 1


Delphi/400™

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

© SystemObjects 1997-2008 www.systemobjects.com 2


Delphi/400™

TABLE OF CONTENTS

DELPHI/400 GENERAL CONCEPTS..................................................... 28


NATIVE ISERIES COMPONENTS VS. IDAPI COMPONENTS. ................................. 29

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

ISERIES COMPONENTS OVERVIEW.................................................. 55


SCD400 DATA:....................................................................................... 55
SCD400 SYSTEM:.................................................................................... 57
SCD400 DB:.......................................................................................... 57
SCD IFS:............................................................................................... 58
SCREEN5250: ......................................................................................... 58
BDE:..................................................................................................... 59
DATA ACCESS & DATA CONTROLS: ............................................................... 60

© SystemObjects 1997-2008 www.systemobjects.com 3


Delphi/400™

CREATING AN ALIAS IN THE BDE. ..................................................... 61


IDAPI SUPPORT:..................................................................................... 63

USING CLIENTOBJECTS/400 DBEXPRESS DRIVER: ...................... 66


DELPHI/400 TUTORIALS: ................................................................... 68
BUILDING AN ISERIES MASTER-DETAIL DATABASE APPLICATION. ....................... 68
USING STORED PROCEDURES ...................................................................... 87

In the iSeries: ................................................................................................................88

In Delphi IDE: ................................................................................................................89


CALLING AN ISERIES PROGRAM .................................................................... 93

In the iSeries: ................................................................................................................94

In Delphi:........................................................................................................................94
USING PREPARED SQL .............................................................................. 98
USING TSPOOL400 COMPONENT................................................................ 104

Step 1: Choice of the Spool to be used ..................................................................104

Step 2: Creating a Format File .................................................................................106

Step 3: Choice of a Font ............................................................................................108

Step 4: Skip Pages at the Beginning of the Spool................................................109

Step 5: Automatic Columns Definition....................................................................110

Step 6: Type of the Fields.........................................................................................112

Step 7: Creation of New Formats ............................................................................113


USING THE DBEXPRESS DRIVER ................................................................. 115

PROGRAMING WITH DELPHI/400 COMPONENTS. .......................121

© SystemObjects 1997-2008 www.systemobjects.com 4


Delphi/400™

Call of an iSeries program ............................................................................................................. 122

Starting of a iSeries control with parameter return ........................................................... 122

Using a Data Area.............................................................................................................................. 122

Using a Data Queue .......................................................................................................................... 122

Creation of a component ................................................................................................................ 122

Creation of a iSeries file ................................................................................................................. 123

Consulting a file ................................................................................................................................. 123

Using the calculated fields ............................................................................................................ 123

Application with unique data window ...................................................................................... 123

TAS400 ..................................................................................... 124

TTRANSACTION400....................................................................... 124

TFILE400 ................................................................................... 124

TSQL400 ................................................................................... 125

SQLBUILD400.............................................................................. 125

TNAVIG400 ................................................................................ 126

TGRID400 .................................................................................. 126

TFIELD400 ................................................................................. 126

TLABEL400 ................................................................................. 127

© SystemObjects 1997-2008 www.systemobjects.com 5


Delphi/400™

TMEMO400 ................................................................................. 127

TLOOKUP400 ............................................................................. 127

TCALL400 ................................................................................... 128

TCMD400.................................................................................... 128

TDATAAREA ................................................................................. 128

TDATAQUEUE ............................................................................... 128

TMESSAGEQUEUE ........................................................................... 129

COLIFS....................................................................................... 129

COLIFSBROWSER .......................................................................... 129

COLIFSBROWSERFILES ................................................................... 129

SETPROP400 ................................................................................ 131

SC5250 ...................................................................................... 131

SC5250PANEL .............................................................................. 131


CLASS TAS400 ..................................................................................... 132

Properties......................................................................................................................132

Active ....................................................................................................................................................... 132


© SystemObjects 1997-2008 www.systemobjects.com 6
Delphi/400™

BufferSize ................................................................................................................................................ 133

KeySeparator .......................................................................................................................................... 133

PLUAlias .................................................................................................................................................. 134

Transaction ............................................................................................................................................. 134

Methods: .......................................................................................................................134

BeginTrans .............................................................................................................................................. 134

Commit..................................................................................................................................................... 135

Connect.................................................................................................................................................... 136

Disconnect............................................................................................................................................... 136

EndTrans ................................................................................................................................................. 136

RemoteCmd............................................................................................................................................. 137

RollBack................................................................................................................................................... 138

Events............................................................................................................................139

Tips ................................................................................................................................140

Current errors ..............................................................................................................142


CLASS TTRANSACTION ............................................................................. 144

Properties......................................................................................................................145

Description .............................................................................................................................................. 145

Level Type: .............................................................................................................................................. 145

ObjLib....................................................................................................................................................... 145

ObjMbr ..................................................................................................................................................... 146

ObjName .................................................................................................................................................. 146

ObjType.................................................................................................................................................... 146

© SystemObjects 1997-2008 www.systemobjects.com 7


Delphi/400™

Target ....................................................................................................................................................... 146

CLASS TFILE400 ................................................................................... 147

Properties......................................................................................................................149

Active ....................................................................................................................................................... 149

AS400 ....................................................................................................................................................... 149

BOF .......................................................................................................................................................... 150

BufferCount ............................................................................................................................................. 150

CalcFields ................................................................................................................................................ 150

Commit..................................................................................................................................................... 151

DoNotUseRecordNumber ...................................................................................................................... 151

EOF........................................................................................................................................................... 152

FfilterComparison................................................................................................................................... 152

FfilterValue .............................................................................................................................................. 153

Fields........................................................................................................................................................ 154

FileDescription........................................................................................................................................ 155

FileMember .............................................................................................................................................. 156

FileName .................................................................................................................................................. 156

IndexKeys ................................................................................................................................................ 157

LibraryName ............................................................................................................................................ 157

LockOnRead............................................................................................................................................ 158

SharingRights ......................................................................................................................................... 158

TypeOpen ................................................................................................................................................ 159

UserRights............................................................................................................................................... 159

© SystemObjects 1997-2008 www.systemobjects.com 8


Delphi/400™

Methods.........................................................................................................................159

AddCalcField ........................................................................................................................................... 159

ClearCalcFields....................................................................................................................................... 160

Close ........................................................................................................................................................ 160

Delete ....................................................................................................................................................... 160

GetByKeyFirst......................................................................................................................................... 161

GetByKeyFirstInCacheValues ............................................................................................................... 163

GetByKeyLast ......................................................................................................................................... 163

GetByKeyLastInCacheValues................................................................................................................ 164

GetByKeyNext......................................................................................................................................... 165

GetByKeyNextInCacheValues ............................................................................................................... 166

GetByKeyPrevious ................................................................................................................................. 167

GetByKeyPreviousInCacheValues........................................................................................................ 167

GetByRecordNumber ............................................................................................................................. 168

GetByRecordNumberInCacheValues ................................................................................................... 169

GetCalcFieldDescription ........................................................................................................................ 170

GetCalcFieldName .................................................................................................................................. 170

GetCalcFieldIndex .................................................................................................................................. 171

GetCalcFieldValue .................................................................................................................................. 171

GetCurrent ............................................................................................................................................... 171

GetCurrentInCacheValues ..................................................................................................................... 172

GetDateFmt ............................................................................................................................................. 173

GetDateSep ............................................................................................................................................. 173

© SystemObjects 1997-2008 www.systemobjects.com 9


Delphi/400™

GetDescription ........................................................................................................................................ 174

GetFieldIndex .......................................................................................................................................... 175

GetFieldLen ............................................................................................................................................. 175

GetFieldName.......................................................................................................................................... 176

GetFieldType ........................................................................................................................................... 176

GetFirst .................................................................................................................................................... 177

GetFirstInCacheValues .......................................................................................................................... 178

GetKeyIndex ............................................................................................................................................ 179

GetLast..................................................................................................................................................... 179

GetLastInCacheValues........................................................................................................................... 180

GetNext .................................................................................................................................................... 181

GetNextInCacheValues .......................................................................................................................... 181

GetNumberCalcFields ............................................................................................................................ 182

GetNumberFields.................................................................................................................................... 182

GetPrevious............................................................................................................................................. 183

GetPreviousInCacheValues ................................................................................................................... 183

GetPValue ................................................................................................................................................ 184

GetRecordNumber.................................................................................................................................. 186

GetTotalDescription ............................................................................................................................... 186

GetTotalFieldIndex ................................................................................................................................. 187

GetTotalFieldName ................................................................................................................................. 187

GetTotalKeyIndex ................................................................................................................................... 188

GetTotalNumberFields ........................................................................................................................... 188

© SystemObjects 1997-2008 www.systemobjects.com 10


Delphi/400™

GetValue .................................................................................................................................................. 189

InsertBlank .............................................................................................................................................. 189

InsertWithCacheValues.......................................................................................................................... 190

InsertWithScreenValues......................................................................................................................... 191

LockCurrent ............................................................................................................................................ 191

Open......................................................................................................................................................... 192

PutCacheFieldPValue............................................................................................................................. 193

PutCacheFieldValue ............................................................................................................................... 193

RemoveCalcField.................................................................................................................................... 194

SetCalcFieldValue................................................................................................................................... 195

UpdateComponents................................................................................................................................ 195

UpdateCacheValuesWithBlank ............................................................................................................. 196

UpdateCacheValuesWithScreen ........................................................................................................... 197

UpdateWithCacheValues ....................................................................................................................... 198

UpdateWithScreenValues ...................................................................................................................... 199

Tfile400 Events ...............................................................................................................200

BeforeActivation ..................................................................................................................................... 200

BeforeDeactivation ................................................................................................................................. 200

BeforeDelete............................................................................................................................................ 200

BeforeInsert............................................................................................................................................. 201

BeforeModify ........................................................................................................................................... 201

OnActivation ........................................................................................................................................... 201

OnCalcFields ........................................................................................................................................... 201

© SystemObjects 1997-2008 www.systemobjects.com 11


Delphi/400™

OnDelete .................................................................................................................................................. 201

OnDeactivation ....................................................................................................................................... 201

OnInsert ................................................................................................................................................... 201

OnModify ................................................................................................................................................. 201

OnRead .................................................................................................................................................... 201

Call : The code added to this event is executed just after reading a record. ........... 201

OnUpdateComponents........................................................................................................................... 202

Tips and Shortcurts.........................................................................................................202

Key list ..................................................................................................................................................... 202

Avoid connecting and disconnecting repeatedly ............................................................................... 202

Property BufferCount ............................................................................................................................. 202

Property Fields........................................................................................................................................ 203

Optimizing record search ...................................................................................................................... 203

Join Files Access.................................................................................................................................... 205

Creating new components..................................................................................................................... 208

CLASS TSQL400 ................................................................................... 210

Properties: ......................................................................................................................210

Active ....................................................................................................................................................... 210

DataBaseName........................................................................................................................................ 210

SQL........................................................................................................................................................... 210

Type: String. ........................................................................................................................................ 210

Methods: .........................................................................................................................211

GetFirst .................................................................................................................................................... 211

© SystemObjects 1997-2008 www.systemobjects.com 12


Delphi/400™

GetFirstInCacheValue ............................................................................................................................ 211

GetNext .................................................................................................................................................... 211

GetNextInCacheValues .......................................................................................................................... 211

GetFieldIndex .......................................................................................................................................... 211

GetFieldDescription................................................................................................................................ 211

GetFieldName.......................................................................................................................................... 211

GettNumberFields................................................................................................................................... 211

GetValue .................................................................................................................................................. 211

CLASS TNAVIG400 ................................................................................. 212

Properties .......................................................................................................................213

AttachedFile ............................................................................................................................................ 213

ButtonKind .............................................................................................................................................. 213

Glyph........................................................................................................................................................ 213

CLASS TFIELD400.................................................................................. 214

Properties......................................................................................................................214

AttachedField .......................................................................................................................................... 214

AttachedFile ............................................................................................................................................ 215

Methods.........................................................................................................................215

GetIndice.................................................................................................................................................. 215

DoExit....................................................................................................................................................... 215

CLASS TLABEL400 ................................................................................. 216

Properties......................................................................................................................216

AttachedField .......................................................................................................................................... 216

© SystemObjects 1997-2008 www.systemobjects.com 13


Delphi/400™

AttachedFile ............................................................................................................................................ 217

Methods.........................................................................................................................217

GetIndice.................................................................................................................................................. 217

CLASS TMEMO400 ................................................................................. 218

Properties......................................................................................................................218

AttachedField .......................................................................................................................................... 218

AttachedFile ............................................................................................................................................ 219

Methods.........................................................................................................................219

GetIndice.................................................................................................................................................. 219

CLASS TGRID400 .................................................................................. 220

Properties......................................................................................................................221

AttachedFields ........................................................................................................................................ 221

CoOptions ............................................................................................................................................. 222

AttachedFile ............................................................................................................................................ 222

FilterComparison .................................................................................................................................... 222

FilterValue................................................................................................................................................ 223

FilterWithField400................................................................................................................................... 223

Header ................................................................................................................................................... 224

Methods.........................................................................................................................225

GetIndex................................................................................................................................................... 225

ReDraw..................................................................................................................................................... 225

Click ......................................................................................................................................................... 225

DoExit....................................................................................................................................................... 225

© SystemObjects 1997-2008 www.systemobjects.com 14


Delphi/400™

KeyDown.................................................................................................................................................. 226

Tip ..................................................................................................................................226

BufferCount property of the associated file ........................................................................... 226

CLASS TLOOKUP400 .............................................................................. 227

Properties......................................................................................................................227

LookUpCaption ....................................................................................................................................... 227

LookUpFields .......................................................................................................................................... 228

LookUpFile400 ........................................................................................................................................ 229

LookUpFilter............................................................................................................................................ 230

LookUpFont............................................................................................................................................. 230

Modified properties .....................................................................................................230

Caption..................................................................................................................................................... 230

Methods.........................................................................................................................231

GetControlName ..................................................................................................................................... 231

GetFieldName.......................................................................................................................................... 231

PutControlName ..................................................................................................................................... 232

UpdateControls....................................................................................................................................... 232

Modified method..........................................................................................................234

Click ........................................................................................................................................................ 234

CLASS SQLBUILD400............................................................................. 235

Properties .......................................................................................................................236

AS400 ....................................................................................................................................................... 236

FunctionsAlpha....................................................................................................................................... 236

© SystemObjects 1997-2008 www.systemobjects.com 15


Delphi/400™

FunctionsDateTime ................................................................................................................................ 237

FunctionsNumeric .................................................................................................................................. 238

GroupFunctions...................................................................................................................................... 239

Options .................................................................................................................................................... 240

ParamsCount .......................................................................................................................................... 240

SQL........................................................................................................................................................... 240

Table_Height ........................................................................................................................................... 240

Table_HorizSpace................................................................................................................................... 240

Table_VertSpace..................................................................................................................................... 240

Tables....................................................................................................................................................... 240

TableCount .............................................................................................................................................. 240

Methods.........................................................................................................................241

AddTable.................................................................................................................................................. 241

Clear ......................................................................................................................................................... 241

DeleteParamsTab.................................................................................................................................... 241

JoinTables ............................................................................................................................................... 241

LoadFromFile .......................................................................................................................................... 242

SaveToFile ............................................................................................................................................... 242

SQLAsPChar ........................................................................................................................................... 242

CLASS TCALL400................................................................................... 243

Properties......................................................................................................................243

AS400 ....................................................................................................................................................... 243

LibraryName ............................................................................................................................................ 243

© SystemObjects 1997-2008 www.systemobjects.com 16


Delphi/400™

ParamDecimals ....................................................................................................................................... 244

ParamDigits............................................................................................................................................. 244

Params ..................................................................................................................................................... 244

ParamType .............................................................................................................................................. 245

ProgramName ......................................................................................................................................... 245

Value ........................................................................................................................................................ 246

Methods.........................................................................................................................246

AddParam ................................................................................................................................................ 246

ClearParams............................................................................................................................................ 247

Execute .................................................................................................................................................... 247

RetrieveBuffer ......................................................................................................................................... 247

SetBuffer.................................................................................................................................................. 248

Events............................................................................................................................249

BeforeExecute......................................................................................................................................... 249

OnExecute ............................................................................................................................................... 249

Tip ..................................................................................................................................249

Call of the OS/400’s API ......................................................................................................................... 249

CLASS TCMD400 ................................................................................... 250

Properties......................................................................................................................250

AS400 ....................................................................................................................................................... 250

CommandLine ..................................................................................................................................... 250

ParamDecimals ....................................................................................................................................... 250

ParamDigits............................................................................................................................................. 251

© SystemObjects 1997-2008 www.systemobjects.com 17


Delphi/400™

Params ..................................................................................................................................................... 251

ParamType .............................................................................................................................................. 252

Value ........................................................................................................................................................ 252

Methods.........................................................................................................................252

AddParam ................................................................................................................................................ 252

ClearParams............................................................................................................................................ 253

Execute .................................................................................................................................................... 253

Events............................................................................................................................253

BeforeExecute......................................................................................................................................... 253

OnExecute ............................................................................................................................................... 253

CLASS DATAAREA ................................................................................... 254

Properties......................................................................................................................254

AS400 ....................................................................................................................................................... 254

DADecimals ............................................................................................................................................. 254

DALength .............................................................................................................................................. 254

DataAreaName ........................................................................................................................................ 254

DataAreaType.......................................................................................................................................... 255

DAType .................................................................................................................................................... 256

LibraryName ............................................................................................................................................ 256

Value ........................................................................................................................................................ 256

Tip ..................................................................................................................................257

Editor of component............................................................................................................................... 257

CLASS TDATAQUEUE ............................................................................... 258

© SystemObjects 1997-2008 www.systemobjects.com 18


Delphi/400™

Properties......................................................................................................................258

AS400 ....................................................................................................................................................... 258

BufferSizeAvailable ................................................................................................................................ 258

DataQueueName ..................................................................................................................................... 258

Description .............................................................................................................................................. 259

ForceIndicators....................................................................................................................................... 259

Type: Boolean READONLY.............................................................................................................. 259

JobName.................................................................................................................................................. 260

JobNumber .............................................................................................................................................. 260

JobUser.................................................................................................................................................... 260

KeyLength ............................................................................................................................................... 260

LibraryName ............................................................................................................................................ 261

MessageAvailableCount ........................................................................................................................ 261

MessageListCount.................................................................................................................................. 262

MessageListError ................................................................................................................................... 262

MessageMaxLength................................................................................................................................ 262

NumberOfMessages ............................................................................................................................... 262

ReceivingKeyOrder ................................................................................................................................ 263

ReceivingWait ......................................................................................................................................... 263

SenderProfile .......................................................................................................................................... 263

SenderWanted......................................................................................................................................... 263

Sequence ................................................................................................................................................. 263

Methods.........................................................................................................................264

© SystemObjects 1997-2008 www.systemobjects.com 19


Delphi/400™

ClearDataQueue...................................................................................................................................... 264

GetMessageJobNameInList................................................................................................................... 264

GetMessageJobNumberInlist ................................................................................................................ 265

GetMessageJobUserInList..................................................................................................................... 265

GetMessageKeyInList ............................................................................................................................ 266

GetMessages........................................................................................................................................... 267

GetMessagesWithKey ............................................................................................................................ 268

GetMessageUserProfileInList................................................................................................................ 270

GetMessageValueInList .................................................................................................................. 270

GetValue .................................................................................................................................................. 271

Receive .................................................................................................................................................... 272

ReceiveByKey ......................................................................................................................................... 273

Send ......................................................................................................................................................... 274

SendWithKey........................................................................................................................................... 274

SetValue................................................................................................................................................... 275

Tip ..................................................................................................................................276

Communications between iSeries Users.................................................................................. 276

Communication with an iSeries program ................................................................................ 276

Component editor.............................................................................................................................. 276

CLASS TMESSAGEQUEUE .......................................................................... 277

Properties......................................................................................................................277

AS400 ....................................................................................................................................................... 277

Identifier................................................................................................................................................... 277

© SystemObjects 1997-2008 www.systemobjects.com 20


Delphi/400™

LibraryName ............................................................................................................................................ 277

MessageQueueName.............................................................................................................................. 277

Msg........................................................................................................................................................... 278

MsgBookmark ......................................................................................................................................... 278

MsgCount ................................................................................................................................................ 278

MsgLength............................................................................................................................................... 278

MsgType .................................................................................................................................................. 278

ReceivingWait ......................................................................................................................................... 279

SendingJob ............................................................................................................................................. 279

SendingJobNumber................................................................................................................................ 279

SendingProgramName ........................................................................................................................... 279

SendingUserProfile ................................................................................................................................ 279

Severity .................................................................................................................................................... 279

Methods.........................................................................................................................280

GetMsg..................................................................................................................................................... 280

ReceiveFirst ............................................................................................................................................ 280

ReceiveLast ............................................................................................................................................. 280

ReceiveNext ............................................................................................................................................ 281

ReceivePrior ............................................................................................................................................ 281

RemoveMessages................................................................................................................................... 281

RemoveMessageWithBookMark ........................................................................................................... 283

Send ......................................................................................................................................................... 283

SetMsg ..................................................................................................................................................... 284

© SystemObjects 1997-2008 www.systemobjects.com 21


Delphi/400™

CLASS TSC5250.................................................................................... 285

Properties......................................................................................................................285

Active ....................................................................................................................................................... 285

AdaptFormTitle ....................................................................................................................................... 286

Allow132 .................................................................................................................................................. 286

AS400 ....................................................................................................................................................... 287

CanSetupColors...................................................................................................................................... 287

Lib............................................................................................................................................................. 287

Menu......................................................................................................................................................... 287

Password ................................................................................................................................................. 287

Prog.......................................................................................................................................................... 288

Screen5250.............................................................................................................................................. 288

User .......................................................................................................................................................... 288

Event .............................................................................................................................288

OnError .................................................................................................................................................... 288

CLASS TSC5250PANEL ........................................................................... 289

Methods.........................................................................................................................290

CopySelZone ........................................................................................................................................... 290

GetSelZone .............................................................................................................................................. 290

GetTextBuff ............................................................................................................................................. 290

PasteFrClip .............................................................................................................................................. 290

PrintSelZone............................................................................................................................................ 290

PrintScreen.............................................................................................................................................. 291

© SystemObjects 1997-2008 www.systemobjects.com 22


Delphi/400™

Sendfunction ........................................................................................................................................... 291

SendTextTo ............................................................................................................................................. 291

CLASS TCOIFS ....................................................................................... 293

Properties......................................................................................................................293

Tcoifs ....................................................................................................................................................... 293

Asynchronous......................................................................................................................................... 293

Connected ............................................................................................................................................... 293

CurThread................................................................................................................................................ 293

TransferComplete ................................................................................................................................... 294

Stream...................................................................................................................................................... 294

Methods.........................................................................................................................294

ListDirectory............................................................................................................................................ 294

ListDirectoryNext.................................................................................................................................... 294

Connect.................................................................................................................................................... 294

CopyFileASToStream ............................................................................................................................. 294

CopyFileToAS ......................................................................................................................................... 295

CopyFileFromAS..................................................................................................................................... 295

CopyStreamToFileAS ............................................................................................................................. 295

DisConnect .............................................................................................................................................. 295

CreateDir.................................................................................................................................................. 296

DeleteDirectory ....................................................................................................................................... 296

DelFile ...................................................................................................................................................... 296

TDIRTHREAD ........................................................................................ 297

© SystemObjects 1997-2008 www.systemobjects.com 23


Delphi/400™

Properties .......................................................................................................................297

Dirs ........................................................................................................................................................... 297

Files.......................................................................................................................................................... 297

Path .......................................................................................................................................................... 297

TIFSOBJECT ......................................................................................... 298

Properties .......................................................................................................................298

Count........................................................................................................................................................ 298

Names ...................................................................................................................................................... 298

Modified ................................................................................................................................................... 298

Size........................................................................................................................................................... 298

TCOIFS EXCEPTIONS CLASSES .................................................................... 299


CLASS TCOIFSBROWSEDIRS .................................................................... 300

Properties......................................................................................................................301

COIFS ....................................................................................................................................................... 301

CODIR ...................................................................................................................................................... 301

SelectedDir .............................................................................................................................................. 301

Methods.........................................................................................................................301

DisplayCurrentDir ................................................................................................................................... 301

DisplaySubDir ......................................................................................................................................... 301

DisplaySubDirByName........................................................................................................................... 301

Events............................................................................................................................301

OnSelected .............................................................................................................................................. 301

CLASS TCOIFSBROWSEFILES ................................................................... 302

© SystemObjects 1997-2008 www.systemobjects.com 24


Delphi/400™

Properties .......................................................................................................................303

COIFS ....................................................................................................................................................... 303

Type: TCOIFS ...................................................................................................................................... 303

CODIR ...................................................................................................................................................... 303

InitialDir.................................................................................................................................................... 303

Methods.........................................................................................................................304

CopyToClipBoard ................................................................................................................................... 304

DeleteSelected ........................................................................................................................................ 304

DisplayCurrentDir ................................................................................................................................... 304

DisplayDir ................................................................................................................................................ 304

PasteFromClipBoard .............................................................................................................................. 304

DisplayParentDir..................................................................................................................................... 304

TSETPROP400 ...................................................................................... 305

Properties......................................................................................................................306

Buffercount.............................................................................................................................................. 306

Dataset ..................................................................................................................................................... 306

SelectedFields......................................................................................................................................... 307

Lock Type ................................................................................................................................................ 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

CHR2PCK .............................................................................................. 309

CHR2ZON .............................................................................................. 309

EBCDIC2ASCII ....................................................................................... 310


F42CHR................................................................................................ 310

F82CHR................................................................................................ 310

PCK2CHR .............................................................................................. 310

CGETLISTDATAAREA ............................................................................... 310

TCGETLISTDATAQUEUE ........................................................................... 311


TCGETLISTFILE ..................................................................................... 311
TCGETLISTLIB ....................................................................................... 311
TCGETLISTMBR ..................................................................................... 312
TCGETLISTPROG .................................................................................... 312
ZON2CHR .............................................................................................. 312

TYPES USED BY DELPHI/400.....................................................313


COACCESSMODE ..................................................................................... 313

COACTIONS ........................................................................................... 313

COBUTTONKINDL.................................................................................... 313

CODTAQKEYORDER ................................................................................. 314

CODTAQSELECTIONTYPE .......................................................................... 314


CODTAQSEQUENCE .................................................................................. 314

COGRIDOPTION ..................................................................................... 314


COGRIDOPTIONS .................................................................................... 314

COLEVEL .............................................................................................. 314


COOBJTYPE ........................................................................................... 315

© SystemObjects 1997-2008 www.systemobjects.com 26


Delphi/400™

COOPTION ............................................................................................ 315


CO-OPTED ............................................................................................. 315

COSENS ................................................................................................ 315

COSHARR ............................................................................................. 315


COTARGET ............................................................................................ 315
COTYPECOMPARISON .............................................................................. 316
COTYPEOPEN ......................................................................................... 316

COUSERR ............................................................................................. 316


TNOTIFYCANCELEVENT ............................................................................ 316
TYPEIFFLAG .......................................................................................... 317

DELPHI/400 DEPLOYMENT..................................................................318
SILENT MODE ........................................................................................ 318
ISS FILES GENERALITIES.......................................................................... 319

9 ERROR MANAGEMENT ....................................................................320


EXCEPTION CLASS HIERARCHY ................................................................... 320
EXCEPTION CLASS PRESENTATION ............................................................... 321
USING THE EXCEPTION CLASSES ................................................................. 322
ERROR CODES ........................................................................................ 323

© SystemObjects 1997-2008 www.systemobjects.com 27


Delphi/400™

1 Delphi/400 General Concepts

In 1995, SystemObjects introduced the ClientObjects/400 Middleware package


for the iSeries. This product allows you to connect applications created with
Borland's Delphi or C++Builder to the iSeries. After the success of this product,
Borland decided to merge both products and create Borland's iSeries product line
with Delphi/400 and C++Builder/400.
Figure 1.1 represents the architecture used by both Delphi/400 and
C++Builder/400 to connect Client PC applications to iSeries data and programs.
As the figure shows, you can either:
• Use an Integrated Database Application Programming Interface (IDAPI)
driver from the Borland Database Engine (BDE).
• Use a dbExpress Driver.
• Use ClientObjects/400 middleware package
Those options provide native access to your iSeries across:
• A Local Area Network (LAN) via SNA or TCP/IP
• An Extranet or the Internet via TCP/IP.

© SystemObjects 1997-2008 www.systemobjects.com 28


Delphi/400 Application C++Builder/400 App.

Visual Component
SCD/400 Delphi Standard Components

DbExpress Borland Database Engine


Driver
IDAPI Driver IDCO400

CO400
SNA TCP/IP

SNA TCP/IP
CO400

Figure 1.1

Native iSeries Components vs. IDAPI Components.

Delphi/400 provides the developer with multiple options for developing


sophisticated applications for the iSeries. Included in this product are both iSeries
native components, and an iSeries IDAPI driver.
The native components do not use IDAPI and can access the iSeries natively
providing a level of functionality and integration with the iSeries that IDAPI is
unable to offer.
The IDAPI driver also supports native access to iSeries data, and allows
developers to build applications with cross platform capabilities. The IDAPI driver
works with nearly all of Borland's data aware controls, as well as with 3rd party
components. It can be replaced with another appropriate IDAPI drivers for
various data sources, e.g. InterBase, Oracle, SQL Server, Sybase, Informix etc
(for Client/Server Suite Version only).
As a developer you can use the native components, IDAPI driver or both to build
your applications. Delphi/400 provides the developer with both native control and
cross platform capability.
dbExpress also addresses the following issues we currently have with the BDE:

© SystemObjects 1997-2008 www.systemobjects.com 29


Complexity involved with BDE configuration, BDE deployment and adapting to a
new data source. Run-time resource overheads from caching blobs, metadata and
loading BDE configuration.

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.

Native Components IDAPI Driver


Multi-tier Applications No Yes (via MIDAS)
iSeries System Commands Yes N/A
Call iSeries Programs Yes N/A
Portable Applications No Yes
Other 3rd Party and Borland
Component Integration No Yes

Performance Excellent Excellent


Adjust Record Blocking Easy Easy (Via Tsetprop400
component)
(Buffercount)
Select Specific Columns for Yes Yes (Via Tsetprop400
Transfer component)

Figure 1.2

© SystemObjects 1997-2008 www.systemobjects.com 30


2 Installation

The Delphi/400 development suite consists of 3 main components:


• The iSeries middleware (engine and communication components).
• The PC Middleware (communication components).
• the PC Delphi/400 component (development tools)
The Delphi/400 installation wizard, launched by the SETUP.EXE program, allows
you to select which components you want to install on both the host PC and the
iSeries.
You only need to install the iSeries Middleware Server Component once for each
iSeries. For example, if you have a team of five developers all using the same
iSeries, you install all three components in the first PC installation, then you will
only need to install the Client Middleware Component in the other four developer
PCs.
If you have two or more iSeries then you will have to install the iSeries
Middleware Server Component for each target iSeries. You will also need a
development or deployment Delphi/400 license for each iSeries.
If you are running a multiple LPAR iSeries system then you should have several
partitions on the box. You have to choose in which partition you want to install
Delphi/400. This selection will determine the TCP/IP address that you will be
invited to type in one installation process screen.

Figure 2.1 shows the installation step in which you specify the components you
wish to install.

© SystemObjects 1997-2008 www.systemobjects.com 31


Figure 2.1

NB. Install the first component AS/400 Middleware Server Component only one
time. This component is the CO411 library in the iSeries.

© SystemObjects 1997-2008 www.systemobjects.com 32


Minimum System Requirements:

iSeries:

• OS/400 Version V3R7M0 or higher.


• Main SNA Routers Support (IBM, Microsoft, Netsoft...) as well as TCP/IP.

PC:

• Intel Pentium 90 or higher (P166 recommended).


• Microsoft Windows 95, 98 or NT4.0 with Service Pack 3 or later.
• 32MB RAM (64MB recommended).
• Hard Disk Space:
100 MB for compact installation.
250 MB for full installation.
• CDROM Drive
• VGA or higher resolution Monitor.
• Mouse or other pointing device.

NB. The above is the minimum requirements even if now the iSeries and the PC
are more modern and more powerful.

© SystemObjects 1997-2008 www.systemobjects.com 33


iSeries: Delphi/400 Installation Process
During the iSeries installation process you will be able to select
• The type of connection you use to communicate with the iSeries (SNA Server,
Rumba, Rally, TCP/IP, NS Router)
• The Code Page of your choice in order to convert iSeries data to PC data.

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.

© SystemObjects 1997-2008 www.systemobjects.com 34


Security Key:

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:

• CO411TCP Subsystem (see figure 2.3)


• CO411 Library (see figure 2.4)

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.

© SystemObjects 1997-2008 www.systemobjects.com 35


Figure 2.3

© SystemObjects 1997-2008 www.systemobjects.com 36


Figure 2.4

© SystemObjects 1997-2008 www.systemobjects.com 37


iSeries: Delphi/400 Uninstall Process

To delete ClientObjects/400 from your iSeries, do the following:


• Stop the CO411TCP subsystem (ENDSBS CO411TCP *IMMED)
• Delete the CO411 library from your iSeries (DLTLIB CO411).

Transferring ClientObject/400 Licenses:

This procedure describes the technical steps that allows you to transfer
ClientObjects/400 license from one iSeries to another:

1. On the iSeries, where ClientObjects/400 was first installed, launch the


CO400UNS program as follows:

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.

2. Save the CO411 library with the following command:

SAVLIB LIB (CO411) DEV (devd)


(Devd = Back up unity name).

3. Restore the CO411 library into the new iSeries with the command:

RSTLIB SAVLIB (CO411) DEV (devd)

© SystemObjects 1997-2008 www.systemobjects.com 38


4. Contact SystemObjects to get a new validation key for the new iSeries
providing the following information:

1.The transfer reference obtained in Step 1.


2.The serial number of your new iSeries.
3.The partition number of your new iSeries.

4. Validate ClientObjects/400 on your new iSeries with the command :

CALL CO411/CO400INS.

6. Delete the CO411 library from the old iSeries.

iSeries Setup Notes:

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 .

Then the CO411TCP sub-system (STRSBS CO411/CO411TCP on iSeries) can be


started. All your connected clients will appear in this sub-system.

After each iSeries IPL, be sure to:

• Restart TCP/IP service (STRTCP).


• then Restart CO411TCP sub-system (STRSBS CO411/CO411TCP ).

Additional TCP/IP Information:

TCP and UDP protocols use ports to identify unique origins and destination of
communications between applications.

A Port is a logical value. It is assigned a number from 0 to 65535.

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):

© SystemObjects 1997-2008 www.systemobjects.com 40


This value can be modified; however, the chosen value must not be used by other
applications. This value is set in the CO411/TCPPORTSRV in the iSeries and on
each PC; it is set by the Delphi/400 Configuration Tool.

PC: Delphi Installation Process

The PC installation process will:


• Create the following directories
C:\CO411, C:\CO411\DDS, C:\CO411\Delphi, etc
• Add the following system files:
CO40032.dll, TCRTR32.DLL, E32TCPIP.DLL, etc
• Update the windows registry
HKEY_LOCAL_MACHINE\SOFTWARE\TCIS\Delphi/400/11.0
Even though you can manually select the components you want to install, we
recommend using the standard installation.

After the process finishes, the Delphi_400 V2007 menu should be inserted in the
Windows Start Menu under Programs.

Here is the list of the installed files:

In the Windows\System32 directory:


CO40032.DLL 32 bit middleware for accessing the iSeries data.
CO400LOC.DLL
TCRTR32.DLL E32TCPIP.DLL

E32*.DLL Compatibility between ClientObjects/400 and native protocols.


In the CO411\Delphi11 directory:
D11SCD400.* ClientObjects/400 V11 on-line help.
In the CO411\Delphi11\VCL directory:
*.RES 32 bit resources of images necessary for ClientObjects/400.
*.DCR Delphi Resources
© SystemObjects 1997-2008 www.systemobjects.com 41
SCDABOUT.DCU Compiled unit of ClientObjects/400’s About window.
SCDABOUT.DFM Initial property values for ClientObjects/400’s About window.
SCDCALC.DCU Compiled unit for the calculated fields’ definition window.
SCDCALC.DFM Initial property values for the calculated fields’ definition window.
SCDCALL.DCU Compiled management unit for the iSeries procedure calls with parameter
return.
SCDCALL.DFM Initial property values of the definition parameter window of the iSeries
programs.
SCDCMD.DCU Compiled command management unit for the iSeries system with
parameter return.
SCDCMD.DFM Initial values of definition window properties of return parameters of

commands, system iSeries.


SCDCOLUM.DCU Compiled unit of the window 'Choice of file fields '.
SCDCOLUM.DFM Initial property values of the window 'Choice of several file fields '.
SCDCONN.DCU Compiled management unit of classes TAS400 and TTransaction400.
SCDDBUTL.DCU Compiled unit of tools necessary for the Scddbs and Scddbnavs units.
SCDDTAQ.DCU Compiled management unit for Data Queues.
SCDDTAQ.DFM Initial property values of the definition window of the Data Queues.
SCDDTARA.DCU Compiled management unit for Data Areas.
SCDDTARA.DFM Initial property values of the definition window for the Data Area.
SCDERR32.RES 32-bit error codes resulting from ClientObjects/400.
SCDERRS.DCU Compiled error management unit..
SCDESIGN.DCU Compiled management unit of TFile400 and TNavig400 classes.
SCDESIGN.DFM Initial property values of the definition window for the TFile400 and
TNavig400 classes.
SCDFIELD.DCU Compiled management unit of TField400, TLabel400, TMaskEdit400 and
TMemo400 classes.
SCDFIELD.DFM Initial property values of the window 'Choice of a file field '.
SCDGRID.DCU Compiled management unit for class TGrid400.
SCDGRID.DFM Initial property values of the window 'Choice of fields for the Grid '.

© SystemObjects 1997-2008 www.systemobjects.com 42


SCDHEADE.DCU Compiled management unit for the window 'Definition of the Grid
Header'
SCDHEADE.DFM Initial property values of the window 'Definition of the Grid Header '.
SCDLOOK.DCU Compiled management unit of the class TLookUp400.
SCDLOOK.DFM Initial property values of the window 'Definition of fields to display and
of fields to retrieve '.
SCDLOOK2.DCU Compiled management unit of the window created at the time of the
LookUp.
SCDLOOK2.DFM Initial property values of the window created at the time of the LookUp.
SCDREG32.DCU 32 bit compiled unit of the ClientObjects/400 library.
SCDSEARF.DCU Compiled demand unit for list of library objects.
SCDSEARF.DFM Initial property values of the demand of a list of library objects.
SCDSEARL.DCU Compiled demand unit for library list.
SCDSEARL.DFM Initial property values of the demand of library list.
SCDSEARM.DCU Compiled demand unit for a file member list.
SCDSEARM.DFM Initial property values of the demand of a file’s member list.
SCDSQL.DCU Compiled management unit for class TSql400.
SCDTOOLS.DCU Compiled unit of tools used by the other units.

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.

1° Case: (DDS Directory empty or the concerned files were deleted)

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.

© SystemObjects 1997-2008 www.systemobjects.com 44


Delphi/400 Configuration Program

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

The Configuration program allows you to:

• 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.

See figure 2.5 on the following page.

© SystemObjects 1997-2008 www.systemobjects.com 45


Figure 2.5

Figure 2.5 shows you the "Access to iSeries Configuration" main window

© SystemObjects 1997-2008 www.systemobjects.com 46


Example of a new iSeries TCP/IP connection:

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

4°) Click the OK button


5°) Test the connection by clicking the "Apply and test connection" button in
figure 2.5. The window in Figure 2.7 should appear.

© SystemObjects 1997-2008 www.systemobjects.com 47


Figure 2.7

Figure 2.7 represents the "Test Connection on Applied Configuration"


window. After clicking the Connect button in Figure 2.7, you will get the version
of CO/400 you are running in the iSeries. It is the same information that you
should get if you launch the program "call CO411/about" via a 5250 terminal
emulation.
Our support department requires this information when you issue a problem
report. Figure 2.8 shows you the complete return screen after calling the about
program in a 5250 terminal session.

© SystemObjects 1997-2008 www.systemobjects.com 48


Figure 2.8

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.

© SystemObjects 1997-2008 www.systemobjects.com 49


Figure 2.9

Figure 2.10

© SystemObjects 1997-2008 www.systemobjects.com 50


Figure 2.11

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\).

© SystemObjects 1997-2008 www.systemobjects.com 51


Delphi/400 Installed components:

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

© SystemObjects 1997-2008 www.systemobjects.com 52


If you do not have access to the iSeries components, then you can install them
manually from the VCL.
Go to the Component | Install Packages option menu, and add the
ClientObjects/400 packages of your need.

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.

© SystemObjects 1997-2008 www.systemobjects.com 53


Figure 2.14

© SystemObjects 1997-2008 www.systemobjects.com 54


3 iSeries Components Overview

In the following section we will present you ClientObject/400's native iSeries


components. They are located in the VCL's folders listed bellow:
• SCD400 Data
• SCD400 System
• SCD IFS
• SCD Screen5250

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

© SystemObjects 1997-2008 www.systemobjects.com 55


• TAS400 Connect to a iSeries using CO/400 native access
• TTransaction400 Select iSeries transaction control operations.
• TFile400 Manage physical, logical or joint iSeries files.
• TSQL400 Visualize the result of a SQL query.
• TNavig400 Navigate through and update (when allowed),
iSeries files.
• TLabel400 View iSeries zone descriptions...
• TField400 Edit and modify an iSeries data fields.
• TMaskEdit400 Validate user entries.
• TMemo400 Visualize alphanumerical zones larger than 255
characters.
• TGrid400 Visualize files.
• TLookUp400 Enables F4 functionality via a grid.
• TSQLBuild400 Allows SQL query construction.

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

© SystemObjects 1997-2008 www.systemobjects.com 56


SCD400 System:

Figure 3.3

• TCall400 Call any C, RPG, CL, and COBOL program already


written for your iSeries.
• TCmd400 Allows you to send any CL command with in and
out parameters.
• TDataArea Display and modify any kind of Data Area
(logical, numerical or alpha numerical).
• TDataQueue Manage "Data Queues" and all of their parameters.
• TMessageQueue Manage any iSeries message queue.
• Tsetprop400 Allows you to define a certain number of properties
and actions to execute in TTable and/or TQuery
components accessing iSeries files.
• Tspool400 Allows you to read your iSeries spools.
• Tspool400list Allows you to get a list of spools in an OutQueue.
• TspoolViewer permits to display graphicaly format spool files.

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.

• TTable400 It is used like the standard Delphi TTable component.


The class TTable400 is 'seen' and can be accessed from
the TDataSource class.
© SystemObjects 1997-2008 www.systemobjects.com 57
• TQuery400 Same characteristics as TSQL400 but can be accessed
from a TdataSource component.
• TNavigator400 Navigator component to be used only with this
component family.
• TDBMemo400 Notepad component to be used with this component
family.

SCD IFS:

Figure 3.5

• TCoIFS Allows you to manage the iSeries Integrated


File System (IFS).
• TCoIFSBrowseDir Use this component to display in a tree
structure, an iSeries directory list inside a
content window.
• TCoIFSBrowseFiles Use this component to manage and display a
file list inside a browser window.

Screen5250:

Figure 3.6

• TCS5250 This component handles the communication


between your PC and an iSeries. Particularly
for connecting, disconnecting, opening and
closing sessions.

© SystemObjects 1997-2008 www.systemobjects.com 58


• TSc5250Panel This components inserts a graphical 5250
screen emulator.

The following is a brief description of Delphi's most commonly used database


components.

BDE:

Figure 3.7

• TDatabase TDatabase provides discrete control over a connection to


a single database in a database application.
• TTable TTable is a dataset component that encapsulates a
database.

© SystemObjects 1997-2008 www.systemobjects.com 59


Data Access & Data Controls:

Figure 3.8

• TDataSource TDataSource provides an interface between a dataset


component and data-aware controls on a form.

• TDBGrid TDBGrid displays and manipulates records from a dataset


in a tabular grid.

• TDBNavigator The database navigator is used to move through the data


in a dataset and perform operations on the data, such as
inserting a blank record or posting a record.

© SystemObjects 1997-2008 www.systemobjects.com 60


4 Creating an Alias in the BDE.

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.

The value you specify depends on whether:


• The database has a BDE alias. You can specify a BDE alias as the value of the
DatabaseName property. A BDE alias represents a database plus configuration
information for that database. The configuration information associated with
an alias differs by database type (DB2/400, Oracle, Sybase, InterBase,
Paradox, dBASE, and so on). Use the BDE Administration tool or the SQL
explorer to create and manage BDE aliases.
• You are using explicit database components. Database components
(TDatabase) represent a database in your application. If you don’t add a
database component explicitly, a temporary one is automatically created for
you, based on the value of the DatabaseName property. If you are using
explicit database components. DatabaseName is the value of the
DatabaseName property of the database component.

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

© SystemObjects 1997-2008 www.systemobjects.com 62


Figure 4.6 shows the result for a new Alias entry. The default name created by
the SQL Explorer for a new alias is "ODBC1". Rename this property as you wish.
You can modify the other parameters found in the Definition tab.

Figure 4.6

In the following section you will find a description for each of the IDCO400's
parameters.

IDAPI Support:

ALIAS Properties specific to IDCO400 driver are


- ALLOW SMALLINT:
TRUE: Integer iSeries field where digits < 5 are shown as SmallintFields.
FALSE: All integer iSeries are shown as Tintegerfields.
- B0E0F Only used on DBCS systems.
TRUE: 0E and 0F characters are replaced by blanks (only in read only mode)
FALSE: nothing is done.
- BATCH COUNT: Determines the blocking factor applied to each table of the ALIAS.

© SystemObjects 1997-2008 www.systemobjects.com 63


Default is 0.
- DATABASE NAME: iSeries server name.
- LIBRARY NAME: iSeries library name.
- APPC BUFFSIZE: APPC buffer size used in iSeries connection (Default 5000 bytes)
- DDS PATH: Path to the directory where local files description will be located.
Default path C:\CO4??\DDS.
- LOCAL INDEXES: If TRUE, list of indexes is copied on your PC.
- LONG FIELDNAMES: If TRUE, long field name will be used.
Default : FALSE
- MULTISESSION: If TRUE, A new job is launched on your iSeries each time you connect
a TDatabase component.

- 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.

© SystemObjects 1997-2008 www.systemobjects.com 64


Figure 4.7 shows you an example of a BDE IDCO400 alias.

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.

The entire transactional process is handled by the OS/400.


Delphi/400 does not modify or alter any of the OS/400 logic or security
system.

© SystemObjects 1997-2008 www.systemobjects.com 65


5 Using ClientObjects/400 dbExpress Driver:

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.

Particular things concerning CO400 dbExpress driver parameters in the following


panel that is obtained by double-clicking on the component SQLConnection.
© SystemObjects 1997-2008 www.systemobjects.com 66
- DataBase is the name of the iSeries you want to connect ( as it was
specified in the Delphi/400 configuration tool).
-
- DriverName is CO400.
-
- HostName is same than Database.
-
- RoleName is the default library (if no library is specified this library will be
used by default).

© SystemObjects 1997-2008 www.systemobjects.com 67


6 Delphi/400 Tutorials:

Building an iSeries Master-Detail Database Application.


This tutorial will show you how to begin with Delphi/400.
We will create a simple application using a Master-Detail relationship by using the
BDE standard components. Figure 6.1 shows you the final result after finishing
this section.

Figure 6.1

© SystemObjects 1997-2008 www.systemobjects.com 68


We will start by creating a new application with a DataModule to centralize all data
access components. A DataModule object provides a visual container into which a
developer can place non-visual components, set their properties, and write event
handlers for them.

1°) Start a new project by selecting File | New Application from the Delphi/400
Menu bar.

Figure 6.2

© SystemObjects 1997-2008 www.systemobjects.com 69


2°) Then select File | New to create a DataModule. Figure 6.3 shows you the New
Items window that appears. Select the icon named DataModule from the New tab,
click OK.

Figure 6.3

3°) A new DataModule is created in the desktop


4°) Add the DataModule to the project by:
a) Selecting the New form Project
b) Adding the Unit by selecting the File | Use Unit option from the
Delphi/400 menu bar (or by using the Alt + F11 short cut key
combination).
c) Type the unit name or select it from the list of available units, click
OK.

© SystemObjects 1997-2008 www.systemobjects.com 70


This will include a "Uses" clause in the main project form.
5°) Add a TDataBase component into the DataModule
6°) Double Click the TDataBase component from the DataModule in order to view
the Database editor window shown in Figure 6.4.

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.

© SystemObjects 1997-2008 www.systemobjects.com 71


Figure 6.5

The object inspector for the database component should look similar to the one of
Figure 6.6

© SystemObjects 1997-2008 www.systemobjects.com 72


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.

© SystemObjects 1997-2008 www.systemobjects.com 73


Figure 6.7

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).

© SystemObjects 1997-2008 www.systemobjects.com 74


Figure 6.8 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.

© SystemObjects 1997-2008 www.systemobjects.com 75


14°) Drop a TdataSource component from the DataAccess tab in Delphi's VCL.
Modify the "Name" and "DataSet" properties according to figure 6.11.

All the datamodule components

Figure 6.11 Figure 6.12

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.

© SystemObjects 1997-2008 www.systemobjects.com 76


Figure 6.13

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.

© SystemObjects 1997-2008 www.systemobjects.com 77


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.

© SystemObjects 1997-2008 www.systemobjects.com 78


Figure 6.15

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.

© SystemObjects 1997-2008 www.systemobjects.com 79


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.

© SystemObjects 1997-2008 www.systemobjects.com 80


21°) Drag and drop the selected fields into the form. Ten objects should be
created, five TLabel and five TDBEdit. Arrange them as in the following figure
6.20.

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

© SystemObjects 1997-2008 www.systemobjects.com 81


Figure 6.21

© SystemObjects 1997-2008 www.systemobjects.com 82


The object inspector for the navigator should look similar to figure 5.23, and the
form should look similar to figure 6.22.

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.

© SystemObjects 1997-2008 www.systemobjects.com 83


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.

© SystemObjects 1997-2008 www.systemobjects.com 84


Figure 6.24

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.

© SystemObjects 1997-2008 www.systemobjects.com 85


Figure 6.26 presents the example's form while in execution time.

Figure 6.26

© SystemObjects 1997-2008 www.systemobjects.com 86


Using Stored Procedures

This example will show how to use Delphi/400's Stored Procedure component
(TstoredProc) with the iSeries.

The purpose of this application is to execute a procedure stored in the iSeries


from Delphi. The iSeries stored procedure will:

• Add 1000 to the first parameter


• Return "Hello" in the second parameter.
• Return a result set for "select * from customer".( Customer is
supposed to be included in the library list).

The final result window should be like the one in figure 6.29

© SystemObjects 1997-2008 www.systemobjects.com 87


Figure 6.29

Follow these steps :

In the iSeries:

1° Create the following program

0001.00 * SQLRPG TO CREATE IN CO411 LIBRARY


0002.00 *
0003.00 * CREATE BY CRTSQLRPG WITH CLOSQLCSR(*ENDJOB)
0004.00 *
0005.00 C *ENTRY PLIST
0006.00 C PARM MYPACK 92
0007.00 C PARM MYALPH 10
0008.00 C ADD 1000 MYPACK
0009.00 C MOVEL'HELLO' MYALPH
0010.00 *** EXECUTE SQL STATEMENT ***
0011.00 C/EXEC SQL DECLARE C1 CURSOR FOR SELECT * FROM CUSTOMER
0012.00 C/END-EXEC

© SystemObjects 1997-2008 www.systemobjects.com 88


0013.00 C/EXEC SQL OPEN C1
0014.00 C/END-EXEC
0015.00 C/EXEC SQL SET RESULT SETS CURSOR C1
0016.00 C/END-EXEC
0017.00 C RETRN

2° Compile the program in the CO411 library by CRTSQLRPG command with


CLOSQLCSR(*ENDJOB). We name the program STOREDPGM.

3° Execute the following Create Procedure in the iSeries STRSQL or in the


Borland SQL explorer (dbexplor.exe in the bin directory of your CodeGear
installation)

CREATE PROCEDURE CO411/STOREDPGM


(INOUT MYPACKED DECIMAL(9, 2), INOUT MYALPH CHAR(10) )
RESULT SET 1
EXTERNAL NAME CO411/STOREDPGM
LANGUAGE RPG GENERAL ;

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:

1° Create a "File | New Application"

2° Insert a TstoreProc component in the Form and fill in the properties:

• DatabaseName The name of a BDE Alias where you declared


the iSeries and the library name containing the
programs mentioned in the previous steps.

• StoredProcName The Name of the stored Procedure in the


iSeries, STOREDPGM in our case.
• Params Click the Editing ... button in the Params
property to display the following window:

© SystemObjects 1997-2008 www.systemobjects.com 89


Click on each parameter and verify them as shown in the following figures :

3° Drop a TDataSource Component and link the DataSet property to the


StoreProcedure Object.

4° Add the Memo and Label Objects if you wish.

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"

7° Add a TDBNavigator component an bind the DataSource property to the


Tdatasource object created in step 3.

© SystemObjects 1997-2008 www.systemobjects.com 90


8° Add a TDBGrid component an bind the DataSource property to the
Tdatasource object created in step 3.

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:

procedure TForm1.executeClick(Sender: TObject);


begin
storedproc1.ParamByName('mypacked').Asfloat := strtofloat(parm1.text);
storedproc1.ParamByName('myalph').asstring := parm2.text;
//storedproc1.ExecProc; use it if there is no result set
storedproc1.open; // use it if a result set will be returned
parm1.text :=storedproc1.ParamByName('mypacked').asstring;
parm2.text :=storedproc1.ParamByName('myalph').asstring;
end;

10° Save, build and execute the program.

If you insert all the components, the form you created shouldlook like the form in
figure 6.30.

© SystemObjects 1997-2008 www.systemobjects.com 91


Figure 6.30

© SystemObjects 1997-2008 www.systemobjects.com 92


Calling an iSeries program

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

© SystemObjects 1997-2008 www.systemobjects.com 93


Follow these steps :

In the iSeries:

1° Create the following program

* This program is to create on your iSeries


*
* THIS PROGRAM HAS 3 PARAMETERS :
* 1/ DATA STRUCTURE DS1 CONTAINING :
* NAME 30 CHARACTERS
* ADDRESS 30
* ZIP CODE 20
* AND CITY 20
* 2/ 30 CHARACTERS
* 3/ 20 CHARACTERS
*
* THE PROGRAM RECEIVES INFORMATION IN
* PARAMETER 1 AND RETURNS
* NAME IN PARAMETER 2 AND CITY IN PARAMETER 3
*
*
IDS1 DS
I 1 30 NAME
I 31 60 ADRES
I 61 80 ZIP
I 81 100 CITY
C*
C *ENTRY PLIST
C PARM DS1
C PARM PARM2 30
C PARM PARM3 20
C*
C MOVELNAME PARM2
C MOVELCITY PARM3
C RETRN

In Delphi:

1° Create a "File | New Application"

2° Insert a TAS400 component in the Form and fill in the properties:


© SystemObjects 1997-2008 www.systemobjects.com 94
PluAlias : Target iSeries (Select from the combo box your AS400).

3° Insert a TCall400 component in the Form and fill in the properties:

AS400 : The AS400 object created in step 2.

Library Name : iSeries library name where you created the RPG
program in the preceeding step

ProgramName Name of the iSeries program that you created in the


preceeding step.

Params : Click on the button … in the Params property to


display the following editor:

Define 3 parameters as shown in the above figure. They are 3


parameters of the RPG program created above.

4° Add six TEdit components, align them as in figure 6.31 above.

© SystemObjects 1997-2008 www.systemobjects.com 95


5° Add six Tlabel components fill their caption property and align them as in
figure 6.31.
6° Add a TButton and fill the "Caption" property with "Run program".

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:

procedure TForm1.Button1Click(Sender: TObject);


type

// Define a Data Structure for PARM1


Tds = record
name:array[1..30] of char;
address:array[1..30] of char;
zipcod:array[1..20] of char;
city:array[1..20] of char;
end;

var
myds:Tds; // Define a var for the Data structure
temp: string; // Temporary String variable
begin

fillchar(myds,sizeof(myds),' '); // initialize all the Data structure with blanks

// 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));

as4001.active:=true; // Activate the iSeries connection

call4001.value[0] := temp; // prepare the income parameter for the iSeries


call4001.execute; // execute the AS400+Library+Program
// specified in the Call400 properties

edit5.text:=call4001.value[1]; // Display the returned values


edit6.text:=call4001.value[2];
as4001.active:=false; // Disconnect from the iSeries
end;

10° Save, build and execute the program.

© SystemObjects 1997-2008 www.systemobjects.com 96


If you insert all the components, the form you created should look like the form in
figure 6.32.

Figure 6.32

© SystemObjects 1997-2008 www.systemobjects.com 97


Using Prepared SQL

While a query need not be prepared before execution, execution performance is


considerably enhanced if the query is prepared beforehand, particularly if it is a
parameterized query that is executed more than once using the same parameter
values.

The Prepared property of the TSQL component determines if a query is already


prepared for execution. If Prepared is True, the query is prepared, and if Prepared
is False, the query is not prepared.

Note: An application can change the current setting of Prepared to prepare or


unprepare a query. If Prepared is True, setting it to False calls the Unprepare
method to unprepare the query. If Prepared is False, setting it to True calls the
Prepare method to prepare the query. Generally, however, it is better
programming practice to call Prepare and Unprepare directly. These methods
automatically update the Prepared property.

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.

© SystemObjects 1997-2008 www.systemobjects.com 98


Follow these steps :

1° Create a "File | New Application"

2° Insert a TdataBase component in the Form and fill in the properties:


• DriverName IDCO400.
• DatabaseName The name of a BDE Alias where you declared
the iSeries and the library name containing the
programs mentioned in the previous steps.

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

• Params Click on the ... button to display the editor as


follows. Select mycode and check Param Type
= ptUnkown .

© SystemObjects 1997-2008 www.systemobjects.com 99


Tquery2

• 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 QueryInsert.

• SQL In the Editing ... window, insert one parameter


as follows:

• Params Click on the ... button to display the editor as


follows. Select each parameter and check
Param Type = ptUnkown .

© SystemObjects 1997-2008 www.systemobjects.com 100


4° Drop a TDataSource Component and link the DataSet property to the
QuerySelect Object.

5° Add the Memo and Label Objects if you wish.

6° Add one TEdit Object.

7° Add a TDBGrid component an bind the DataSource property to the


Tdatasource object created in step 4.

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:

procedure TForm1.ButtonselectClick(Sender: TObject);


begin
screen.cursor:=crsqlwait;
if not queryselect.prepared then queryselect.prepare; //this line is important
If queryselect.active then queryselect.Close;
queryselect.parambyname('mycode').asinteger := strtoint(edit1.text);
queryselect.open;
screen.cursor:=crdefault;
end;

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:

procedure TForm1.ButtoninsertClick(Sender: TObject);


© SystemObjects 1997-2008 www.systemobjects.com 101
begin
screen.cursor:=crsqlwait;
if not queryinsert.prepared then queryinsert.prepare; //this line is important
queryinsert.parambyname('p0').asinteger := 100;
queryinsert.parambyname('p1').asstring := 'Custname 100';
queryinsert.parambyname('p2').asstring := 'Address 1 100';
queryinsert.parambyname('p3').asstring := 'Address 2 100';
queryinsert.parambyname('p4').asstring := 'Zp100';
queryinsert.parambyname('p5').asstring := 'City 100';
queryinsert.parambyname('p6').asstring := 'Phonenr 100';
queryinsert.parambyname('p7').asstring := 'Faxnr 100';
queryinsert.parambyname('p8').asstring := 'Activity 100';
queryinsert.ExecSQL;

screen.cursor:=crdefault;
end;
At this point you should have a form that looks like the following:

10° Save, build and execute the program.

The following picture represents the application running.

© SystemObjects 1997-2008 www.systemobjects.com 102


© SystemObjects 1997-2008 www.systemobjects.com 103
Using Tspool400 Component

Step 1: Choice of the Spool to be used


Open the SCD400 System palette and drop a Tspool400 component on the
form. In the Object Inspector:

Select the iSeries in the As400name property,


Click on SpoolName property button to display the Spooled files research
editor:

© SystemObjects 1997-2008 www.systemobjects.com 104


Type the beginning of a library name in the Library combo box. Then pull
down the button. A library list will appear. Here you can choose your library.
Proceed in the same way with the OutQueue combo box to and select an
output queue.
Click on the Browse button. The spooled files list will appear as follows:

Figure 1 Spooled file List of an Output Queue

Choose the spool you want to use then click OK.


The SpoolName, SpoolNumber, JobName, JobNumber and User
properties of the Tspool400 will then be updated .

© SystemObjects 1997-2008 www.systemobjects.com 105


Step 2: Creating a Format File

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).

Figure 2. Creation of a format file

Name your format file, for example myfmt1.sfd, click on Open. The graphic
design window of spool formats will appear.

© SystemObjects 1997-2008 www.systemobjects.com 106


The spooled file content will display as follows.

Figure 3.Graphic design window of spool formats

© SystemObjects 1997-2008 www.systemobjects.com 107


Step 3: Choice of a Font

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.

It’s recommended that you use only non-proportional fonts in order to


preserve the visual alignment of the data.

Figure 4 Change of the font

© SystemObjects 1997-2008 www.systemobjects.com 108


Step 4: Skip Pages at the Beginning of the Spool

Spools often contain pages of presentation that do not contain useful


information.

In order to exclude them in the useful data, the zone «Number of page to
skip at the beginning » will be used.

Figure 5. Number of pages to skip

© SystemObjects 1997-2008 www.systemobjects.com 109


Step 5: Automatic Columns Definition

Click on one button of the set of buttons to display a selected


page . For example the selected page is as the following:

Figure 6 Menu « Find default format «

The menu Format/Find Default format allows you to automatically retrieve


the columns of your spool.

© SystemObjects 1997-2008 www.systemobjects.com 110


Your spool becomes then:

Column end

Column beginning

Header

Footer

Figure 7 Default column design

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.

A right click on one of these buttons will delete the column.

Header and Footer may be managed the same way by clicking the buttons
in the vertical ruler.

© SystemObjects 1997-2008 www.systemobjects.com 111


Step 6: Type of the Fields.

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

Figure 8. Example of definition of the field’s type

© SystemObjects 1997-2008 www.systemobjects.com 112


Step 7: Creation of New Formats

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

Figure 9 Creation of a new format

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.

Obviously, you can create as many page formats as you want.

© SystemObjects 1997-2008 www.systemobjects.com 113


Tspool400 component will use the format file to provide the content of the
defined columns the same way as fields of a table. It is seen as a dataset .

Figure 10. Display of a spool in a DBgrid

The Tspool400 component behaves consequently like a Ttable. Therefore


you will be able to connect it to a Tdatasource, however, key access
methods are not supported.

To remove records, you can use OnFilterRecord event.

© SystemObjects 1997-2008 www.systemobjects.com 114


Using the dbExpress Driver

To display a database file content in a DBGrid with dbExpress, you should place 6
following components:

• SQLConnection (dbExpress palette)


• SQLDataSet (dbExpress palette),
• DataSetProvider (Data Access),
• ClientDataSet (Data Access),
• DataSource (Data Access),
• DBGrid (Data Controls) .

1° Create a "File | New Application"

2° Put a SQLConnection component in the Form and fill in the properties:


DriverName: CO400 (just select from the combo box).

© SystemObjects 1997-2008 www.systemobjects.com 115


3° Double click on the SQLConnection component, a connection Editor will
appear as follows:

Fill in connection parameters :

Database = your iSeries Name


HostName = your iSeries Name
RoleName = Default Library to use (to get File list for example).

Click on OK button . The panel will disappear . Set the property Connected to
True. You will be invited to enter the password.

4° Put a SQLDataset on the form and fill in appropriate properties :

DBConnection : SQLConnection1

CommandType : set to ctTable

© SystemObjects 1997-2008 www.systemobjects.com 116


CommandText : Pull down the list box, you will see a list of files
located in CO411 library. This library is defined in the parameter
ROLENAME of the above SQLConnection component .

Select CUSTOMER file .

Set Active property to True .

© SystemObjects 1997-2008 www.systemobjects.com 117


4° Place a DataSetProvider from the Data Access palette, select SQLDataSet1 for
DataSet property, as the following:

5° Place a ClientDataSet from the Data Access palette, select DataSetProvider1


for ProviderName property, as the following:

© SystemObjects 1997-2008 www.systemobjects.com 118


6° Place a DataSource from the Data Access palette, select ClientDataSet1 for
DataSet property, as the following:

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:

© SystemObjects 1997-2008 www.systemobjects.com 119


© SystemObjects 1997-2008 www.systemobjects.com 120
7 Programing with Delphi/400 Components.

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.

However, properties, methods and events inherited from the


Delphi components will not be presented in this chapter
unless they were redefined.

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 directory \CO411\DELPHI11\SAMPLES contains several application examples


in fifteen different sub-directories.

Using calculated fields


The project (SAMPLES)\CALCFLD\CALCFLD.DPR is an example of
Delphi code using a calculated field. In this example, the calculated
field is a heading, this wording being read in another file. The code
shows you how to use the OnCalcFields event.

© SystemObjects 1997-2008 www.systemobjects.com 121


Call of an iSeries program
The project (SAMPLES)\CALL400\PCALLPGM.DPR is an example of Delphi
code using the class TCall400 to call an iSeries program with input and
output of parameters. The iSeries program used in this example has five
parameters: three alpha-numeric, one packed and one zoned.

The program permutes the first three parameters, adds 5000 to the fourth
and 10000 to the fifth.

Starting of a iSeries control with parameter return


The project (SAMPLES)\CMD400\PCMD400.DPR is a sample of Delphi code
using the TCmd400 class to start an iSeries command and to recover
certain definite parameters in this command. This sample permits to find
the model and the serial number of your iSeries.

Using a Data Area


The project (SAMPLES)\DATAAREA\PDATAARA.DPR is a sample of Delphi
code using the TDataArea. class. In this sample, you read and write in a
Data Area.

Using a Data Queue


The project (SAMPLES)\DTAQUEUE\PDTAQ.DPR is a sample of Delphi code
using the TDataQueue. class. In this sample, you can send, receive and
read all the contents of a Data Queue of the Last-In-First-Out type. You can
try this program with several users present in the network. The program
recovers also the user having sent the message.

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!

© SystemObjects 1997-2008 www.systemobjects.com 122


Creation of a iSeries file
The project (SAMPLES)\NEWFILE\NEWFILE.DPR is a sample of Delphi code
using the ScreenDesigner/400 methods (and especially the Remote
Command) to create a file on the iSeries. If in your applications you wish to
create iSeries files, take a cue from this sample.

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.

Using the calculated fields


The project (SAMPLES)\CALCFLD\CALCFLD.DPR is a sample of Delphi code
using a calculated field. In this sample, the calculated field is a heading, this
heading being read in another file. The code shows you how to use the
OnCalcFields event.

Application with unique data window


The project (SAMPLES)\MULTFORM\MULTFORM.DPR is an example of Delphi
code using the ScreenDesigner/400 methods (and especially those of the
TFile400 class) for consulting iSeries files by creating the TAS400 and
TFile400 objects in one window only. The main window contains objects
AS400 and File400 and the other windows display data with the visual
objects of ScreenDesigner/400. This application is a good example of visual
and data objects being found on different windows. Study this example if
you don't wish to place File400 objects in all your windows.

Note that the components TQuery400 and TTable400 are only provided in
this version to support backwards compatibility with Delphi 1

© SystemObjects 1997-2008 www.systemobjects.com 123


TAS400

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

The TTransaction400 class permits to define a transactional control mode,


in particular the mode of record lock-up, and the definition of the
notification object of the 'Commit’s' already done.
Remember that the transactional control is managed by the iSeries and,
therefore, it must be ready to manage your transactions (Creation of a
journalization and addition of files to control in this journal; see this with
the person in charge of the administration of your iSeries).

TFile400

This class permits to manage an iSeries file (or a member), whether


Physical, Logical or Logical Joint. The class TFile400 properties, can help you
define:
• *LIBL as library,
• your opening rights,
• the rights that you give to the other users of this file,
• an opening in the transactional mode,
• an opening in the order of record creations (called ’ by 'RRN ') or by
default (according to a key defined on this file, for example),
• a filter on the file key (if one exists), this key being multiple if
needed,
• a sub-list of fields to manage, if the goal is minimizing the network
activity,
• a blocking factor allowing you to read several records on the iSeries.
A time improvement in certain cases (up to eight times faster).

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 class TSQLBuild400 is used to build an SQL statement.

When you create an SQLBuild400 object, buttons, listboxes, comboboxes,


and so on, may be created on your form, depending on the object. You can
create and add your own objects to the different Componenet Palette tabs,
but you do not have to delete the standards objects. Instead, set the Visible
property to False.

© SystemObjects 1997-2008 www.systemobjects.com 125


TNavig400

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 TGrid400 class allows you to display a sub-file.


The class properties will help you define:
• The file in question,
• The list of fields to display,
• A filter on this file, which can be static or dynamic (filter connected to
a TField400),
• The headline of the ' Grid400 ', that is the header on the first line.

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).

© SystemObjects 1997-2008 www.systemobjects.com 126


If the same field appears as Field400 and in a Grid400, it is the value in the
Grid400 that is taken into consideration. If the same field appears as
Field400 and Memo400, it is the first created of these components that will
be taken into consideration.

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 TLookUp400 class provides the functions of key F4 of the iSeries. It


allows to consult a file and to bring back the reference fields chosen by the
user.
The look up window contains a Grid400, that allows the user to move freely
within the file, and two buttons: OK and Cancel in order to either accept the
in-progress record (signaled by an arrow in the first column) or to cancel
the request. The double-click on the Grid400 is equivalent to pressing the
OK button.

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

© SystemObjects 1997-2008 www.systemobjects.com 127


possibility is given to bring from none to all the fields of the recording
chosen by the user in the Windows controls of the window.
This class will allow you to gain a lot of programming time, since calls to
reference files are very current in the applications.

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

The TDataQueue class manages the Data Queue on your iSeries.


You can either send, receive or consult messages of your Data Queues. In
function of the type of Data Queue you have created on your iSeries, you
can learn the emitter’s identity , manage the messages by key (emission,

© SystemObjects 1997-2008 www.systemobjects.com 128


reception and consultation), know the number of messages of your Data
Queue, know the number of messages corresponding to a key, consult all
messages, the last or the first…
The management of Data Queues is rich and complete. It will allow, for
example, to the users of your iSeries to communicate between themselves!

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

Use TCoIFSBrowseDirs to manage and display a tree of Directory in a form.


Each Directory can have a list of subdirectories associated with it. By
clicking on a node, the user can expand and collapse the associated list of
subdirectories.
This control can be seen as the left pane of the Database Explorer.

ColIFSBrowserFiles

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.
© SystemObjects 1997-2008 www.systemobjects.com 129
This control can be seen as the right pane of the Database Explorer.

© SystemObjects 1997-2008 www.systemobjects.com 130


SetProp400
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.
DisplayLabel properties of the selected fields will be updated automatically
with the iSeries fields description.

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.

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.

© SystemObjects 1997-2008 www.systemobjects.com 131


Class TAS400

Ancestor TComponent

Unit SCDCONN

Type Boolean

See also: PLUAlias, Transaction, Connect, Disconnect.

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).

© SystemObjects 1997-2008 www.systemobjects.com 132


The disconnection takes place automatically as the object is destroyed ; it is,
therefore, unnecessary to put the property at False at the end of the program, for
example.

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.

This property is taken into consideration at connection time.

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.

© SystemObjects 1997-2008 www.systemobjects.com 133


PLUAlias
Type: String.
This property permits to define a particular iSeries. If it is left blank, it is the
iSeries by default that is concerned. A list of the available iSeries is given in
Delphi’s object inspector.
This property is taken into consideration at the connection time.

Transaction
Type: TTransaction400.

See also: BeginTrans, EndTrans, Committed, Rollback, Active, object


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.

If the method fails, it generates an ECO400Error exception.

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.

© SystemObjects 1997-2008 www.systemobjects.com 135


Connect
Parameters: None.
Return: None.
See also: Disconnect, Active.
Example:
{MyAS400: TAS400;}
try
MyAS400.Connect;
except
one E:ECO400Error do
ShowMessage ('Connection error (' +IntToStr(E.ErrorCode)+ '): '
+E.Message);
end;
MyAS400.Disconnect;

This method permits to connect yourself. It corresponds to: Active:=True.


Consult the presentation of the Active property for more information.

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;

This method permits to connect yourself. It corresponds to: Active:=False.


Consult the presentation of the Active property for more information.

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

© SystemObjects 1997-2008 www.systemobjects.com 137


error, you can consult the Work History on the iSeries. No parameter return is
possible with this method. The return code represents the error code.

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.

© SystemObjects 1997-2008 www.systemobjects.com 138


Events

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.

© SystemObjects 1997-2008 www.systemobjects.com 139


Tips

The iSeries List

If you want to know the list of the available iSeries, you have two possibilities:

1. Use the function (SCDtools module) TcGetAS400(ListAS400:tstrings):integer


that fills the list ' ListAS400 ' ; the return code gives an error code, or 0, if all
happens well.

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:

function GetAS400List(var NbAS400:integer;ListAS:pchar):integer;far;external '


CO400 ';

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

To find out if the router is well installed:

1. Place a class object TAS400 on your Window.


2. Put the Active property at True.

If an error occurs then the router is badly installed ; see the section ' Current
Errors ' below.

© SystemObjects 1997-2008 www.systemobjects.com 140


PLUAlias property

Keeping the PLUAlias property blank (iSeries by default) permits a change of


iSeries (an iSeries of work into an iSeries of production, for example) while
intervening only on the router (change of the iSeries by default) and without
changing the application.

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.

© SystemObjects 1997-2008 www.systemobjects.com 141


Current errors
10: Protection error

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.

28: APPC LU Name Invalid or Not Found

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.

101: Cannot Find A2E Table

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.

313: Bad Connection Handle

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.

© SystemObjects 1997-2008 www.systemobjects.com 142


© SystemObjects 1997-2008 www.systemobjects.com 143
Class TTransaction

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.

The class TTransaction400 is used to enter into a transaction control mode, as


well as to perform commit and rollback processes on any locked transaction.

Note: The transaction control and management is performed by the iSeries, so it


must be configured and ready to manage the transaction (creation of journalizing
files, adding files to be journalized, etc.). Have your iSeries system administrator
perform all the necessary setups.

© SystemObjects 1997-2008 www.systemobjects.com 144


Properties
Description
Type: String.
This property is a text description of the transactional control process, up to 50
characters long.
It is optional and may be left blank. It is taken into account only during a
'BeginTrans'.

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.

© SystemObjects 1997-2008 www.systemobjects.com 145


ObjMbr
Type: String.
See also: ObjLib, ObjType, ObjName.
This property is one of the four properties used to define the commit object (with
ObjType, ObjName, Objlib). It indicates the name of the file member (and so, is
useful when the object is a file). Its length may be up to 10 characters. The
property is optional if the file has only one member.

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).

© SystemObjects 1997-2008 www.systemobjects.com 146


Class TFile400

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

© SystemObjects 1997-2008 www.systemobjects.com 148


updated. If you want to update them, you can use the UpdateComponents
method.·

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.

© SystemObjects 1997-2008 www.systemobjects.com 149


You can define this property in your program. You can also define a link with an
iSeries that is available in another window, so that the number of objects in the
application can be limited and a smaller executable created.

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.

See also: Class TTransaction400, Transaction (TAS400), BeginTrans (TAS400),


EndTrans (TAS400), Commit (TAS400), RollBack (TAS400).

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.

© SystemObjects 1997-2008 www.systemobjects.com 151


When True, the record number is not used for indexing the file. It is used for
joined files.

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.

This property can take seven different values:

• 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.

© SystemObjects 1997-2008 www.systemobjects.com 152


FfilterValue
Type: String.
See also: FFilterComparison, KeySeparator (TAS400).

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.

© SystemObjects 1997-2008 www.systemobjects.com 153


Fields
Type: String.
See also: IndexKeys.

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.

© SystemObjects 1997-2008 www.systemobjects.com 154


In the Design Mode, a window allows a more attractive field selection list.

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.

This identifier (property FileDescription) is associated with a PC file description on


a local disk. If this file does not exist then the description of the fields is accessed
from the iSeries, and the file is saved on the PC file. Otherwise, the description of
the fields is accessed directly from the PC file.

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.

© SystemObjects 1997-2008 www.systemobjects.com 155


This property is assigned automatically by ScreenDesigner/400 to the name of
the file or to the name of the member if indicated. However, if necessary, you can
assign another value to this property.

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) .

The name of the PC file description is constructed in the following way:


• The path is that indicated in the WIN.INI file under the section [CO400]
and the entry PATH_DDS.
• The name of the file depends on the length of the property:

• 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.

© SystemObjects 1997-2008 www.systemobjects.com 156


The generic name can be left blank to view a list of all the files in the specified
library (refer to the property LibraryName). To list all the files starting with a
certain prefix, type in the starting string followed with an '*'.

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.

A lock is automatically removed the next time a read, a modification, or an add is


performed.

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.

This method is taken into account when the file is opened.

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.

This property is taken into account when opening a file.

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.

© SystemObjects 1997-2008 www.systemobjects.com 159


ClearCalcFields
Parameters: None.
Return: None.
See Also: RemoveCalcField, AddCalcField.
Example:
{MyFile400: TFile400;}
MyFile400.ClearCalcFields;
MyFile400.AddCalcField('CUSTCODE','Customer Code');
This method is used to clear all the calculated fields from the associated file.
Close
Parameters: none.
Return: none.
See also: Active, Open.
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 close an iSeries file. It is equivalent to setting property


Active to False. In case of error, an exception is generated.

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).

© SystemObjects 1997-2008 www.systemobjects.com 161


The order of fields in the comparison value must correspond to the order of fields
in the key of the iSeries file; however fields may be dropped in reverse order
from the end of the comparison key.

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.

© SystemObjects 1997-2008 www.systemobjects.com 162


GetByKeyFirstInCacheValues

Parameters: Key to reach: String,


Key operator: String.
Return: Integer.
See also: KeySeparator (Class TAS400), GetBykeyNextInCacheValues,
GetByKeyPreviousInCacheValues, GetByKeyLastInCacheValues, GetByKeyFirst.

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

Parameters: Key to reach: String.


Key operator: String.
Return: Integer.
See also: KeySeparator (Class TAS400), GetByKeyFirst, GetByKeyNext,
GetByKeyPrevious,GetByKeyLastInCacheValues.

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

Parameters: Key to reach : String.


Key operator: String.
Return: Integer.
See also: KeySeparator (Class TAS400), GetByKeyFirstInCacheValues,
GetByKeyNextInCacheValues, GetByKeyPreviousInCacheValues, GetByKeyLast.

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

Parameters: Key to reach: String.


Key operator: String.
Return: Integer.
See also: KeySeparator (Class TAS400), GetByKeyFirst, GetByKeyLast,
GetByKeyPrevious, GetByKeyNextInCacheValues.

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

© SystemObjects 1997-2008 www.systemobjects.com 165


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.

GetByKeyNextInCacheValues

Parameters: Key to reach: String.


Key operator: String.
Return: Integer.
See also: KeySeparator (Class TAS400), GetByKeyFirstInCacheValues,
GetByKeyLastInCacheValues, GetByKeyPreviousInCacheValues, GetByKeyNext.

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.

© SystemObjects 1997-2008 www.systemobjects.com 166


GetByKeyPrevious

Parameters: Key to reach : String.


Key operator: String.

Return: Integer.

See also: KeySeparator (Class TAS400), GetByKeyFirst, GetByKeyNext,


GetByKeyLast,
GetByKeyPreviousInCacheValues.

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.

For more information on the parameters, refer to the method GetByKeyFirst.

GetByKeyPreviousInCacheValues

Parameters: Key to reach: String.


© SystemObjects 1997-2008 www.systemobjects.com 167
Key operator: String.
Return: Integer.
See also: KeySeparator (Class TAS400), GetByKeyFirstInCacheValues,
GetByKeyNextInCacheValues, GetByKeyLastInCacheValues, GetByKeyPrevious.

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;

This method is similar to the method GetByKeyPrevious. One difference is that


the exception ECO400Error is generated in case of errors (Begin 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 access invisible to the user.

GetByRecordNumber

Parameters: Record Number: LongInt.


Return: Integer.
See also: GetRecordNumber, GetByRecordNumberInCacheValues.

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

Parameters: Record number: LongInt.


Return: Integer.
See also: GetRecordNumber, GetByRecordNumber.

Example:
{MyFile400: TFile400;}
{MyRRN: LongInt;}
{...code...}
MyRRN:=MyFile400.GetRecordNumber;
{...code...}
try
MyFile400.GetByRecordNumberInCacheValues(MyRRN);
except
ShowMessage('Record not found');
end;
{...code...}

This method is similar to the method GetByRecordNumber. 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
assiciated with the file. It can thus be used then to make accessing the file
invisible to the user.

© SystemObjects 1997-2008 www.systemobjects.com 169


GetCalcFieldDescription

Parameters: Index of the calculated field: Integer.


Return: String.
See Also: GetCalcFieldSeq, GetCalcFieldName, GetCalcFieldValue,
GetNumberCalcFields.

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

Parameters: Index of the calculated field: Integer.


Return: String.
See also: GetCalcFieldIndex, GetCalcFieldDescription, GetCalcFieldValue,
GetNumberCalcFields.

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.

© SystemObjects 1997-2008 www.systemobjects.com 170


GetCalcFieldIndex

Parameters: Name of the calculated field: String.


Return: Integer.
See also: GetCalcFieldDescription, GetCalcFieldName, GetCalcFieldValue,
GetNumberCalcFields.

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

Parameters: Index of the calculated field: Integer.


Return: String.
See also: GetCalcFieldIndex, GetCalcFieldName, GetCalcFieldDescription,
GetNumberCalcFields.

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

Parameters: Field sequence number: Integer.


Return: Integer.
See also: GetFieldName, GetNumberFields, GetFieldLen, GetFieldType,
GetFieldIndex, GetDateSep, GetDescription, Fields.

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

Parameters: Field sequence number: Integer.


Return: Char.
© SystemObjects 1997-2008 www.systemobjects.com 173
See also: GetFieldName, GetNumberFields, GetFieldLen, GetFieldType,
GetFieldIndex, GetDateFmt, GetDescription.

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'.

• '-' for the formats 'ISO' and 'JIS'.

• '.' for the format 'EUR'.

GetDescription

Parameters: Field sequence number: Integer.


Return: String.
See also: GetFieldName, GetNumberFields, GetFieldLen, GetFieldType,
GetFieldIndex, GetDateFmt, GetDateSep, GetTotalDescription, Fields.

Example:
{MyFile400: TFile400;}
{MyIndex: Integer;}
{MyDescription: String;}
MyIndex:=MyFile400.GetFieldIndex('INVDATE');
MyDescription:=MyFile400.GetDescription(MyIndex);

© SystemObjects 1997-2008 www.systemobjects.com 174


This method is used to retrieve the field description of a selected field. The first
parameter is the field index number of the field in question (in the list of selected
fields: see the property Fields). The returned value is a string that represents the
field description.

GetFieldIndex

Parameters: Name of a field: String.


Return: Integer.

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

Parameters: Field sequence number: Integer.


Return: Integer.
See also: GetFieldName, GetNumberFields, GetDescription, GetFieldType,
GetFieldIndex, GetDateFmt, GetDateSep, GetTotalDescription, Fields.

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

Parameters: Field sequence number: Integer.


Return: String.
See also: GetDescription, GetNumberFields, GetFieldLen, GetFieldType,
GetFieldIndex, GetDateFmt, GetDateSep, GetTotalDescription, Fields.

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

Parameters: Field sequence number: Integer.


Return: String.
See also: GetFieldName, GetNumberFields, GetFieldLen, GetDescription,
GetFieldIndex, GetDateFmt, GetDateSep, GetTotalDescription, Fields.

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:

• 'STR': type Alphanumeric,

• 'ORD': type Numeric,

• 'DTE': type Date,

• '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

Parameters: Field sequence number: Integer.


Return: Integer.
See also: GetTotalKeyIndex, GetFieldIndex, IndexKeys.

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;

© SystemObjects 1997-2008 www.systemobjects.com 179


This method is used to reach the last record of a file. It takes into account any
filter that has been applied. (see the properties FFilterValue and
FFilterComparison). Once the record is read, the visual components attached to
the file will be updated.

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.

© SystemObjects 1997-2008 www.systemobjects.com 180


GetNext

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.');

This method is used to get the number of selected fields.


GetPrevious

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;

This method is similar to the method GetPrevious. One difference is that an


exception ECO400Error is generated in case of an error (Begin 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.

GetPValue

Parameters: Field sequence number: Integer,


Value of the field: PChar.
Return: None.
See also: GetFieldIndex, GetValue.

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));

© SystemObjects 1997-2008 www.systemobjects.com 184


This method returns the value of a field of the current record. The file must
already be open.
The method is useful when seeking the value of an alphanumeric field longer than
255 characters; otherwise, use the method GetValue. The present method avoids
the Pascal string size limitation.

© SystemObjects 1997-2008 www.systemobjects.com 185


GetRecordNumber

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

Parameters: Field sequence number: Integer.


Return: String.
See also: GetDescription, GetTotalFieldIndex.

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.

© SystemObjects 1997-2008 www.systemobjects.com 186


GetTotalFieldIndex

Parameters: Name of the field sequence number: String.


Return: Integer.

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

Parameters: Field sequence number: Integer.


Return: String.
See also: GetFieldName, GetTotalFieldIndex.

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.

© SystemObjects 1997-2008 www.systemobjects.com 187


GetTotalKeyIndex

Parameters: Field sequence number: Integer.


Return: Integer.
See also: GetKeyIndex, GetTotalFieldIndex, IndexKeys.

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.');

This method is used to get the total number of fields in a file.

© SystemObjects 1997-2008 www.systemobjects.com 188


GetValue

Parameters: Field sequence number: Integer.


Return: String.
See also: GetFieldIndex, GetPValue.

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;

© SystemObjects 1997-2008 www.systemobjects.com 189


This method is used to create a blank record on the iSeries. If the file has a
unique key, then this method can’t be used. You must use instead the methods
UpdateCacheValuesWithBlank ,then PutCacheFieldValue, and finally
InsertWithCacheValues.

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.

The return code is set to 0 if the operation is successful; otherwise, it will be


updated. No exception error is generated.

LockCurrent

Parameters: None.
Return: Integer.
See also: LockOnRead.

© SystemObjects 1997-2008 www.systemobjects.com 191


Example:
{MyFile400: TFile400;}
try
MyFile400.Open;
except
on E:ECO400Error do
ShowMessage('Can''t open file: '+E.Message);
end;
try
{...code...}
try
MyFile400.LockCurrent;
MyFile400.Delete;
except
ShowMessage('Problem during deletion');
end;
finally
MyFile400.Close;
end;

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.

© SystemObjects 1997-2008 www.systemobjects.com 192


PutCacheFieldPValue

Parameters: Field index: Integer,


Field value: PChar.
Return: None.
See also: PutCacheFieldValue, GetPValue.

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

Parameters: Field sequence number: Integer,


Value of the field: String.
Return: None.
See also: GetFieldIndex, PutCacheFieldPValue.

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

Parameters: Index of the calculated field: Integer.


Return: None.
See also: AddCalcField, ClearCalcFields.

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.

© SystemObjects 1997-2008 www.systemobjects.com 194


SetCalcFieldValue

Parameters: Index of the calculated field: Integer,


New value: String.
Return: None.
See also: GetCalcFieldValue, OnCalcFields, Example CALCFLD.

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.

© SystemObjects 1997-2008 www.systemobjects.com 195


UpdateCacheValuesWithBlank

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.

© SystemObjects 1997-2008 www.systemobjects.com 196


UpdateCacheValuesWithScreen

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.

© SystemObjects 1997-2008 www.systemobjects.com 197


UpdateWithCacheValues

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.

© SystemObjects 1997-2008 www.systemobjects.com 198


UpdateWithScreenValues

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.

The return code is set to 0 if the operation is successful. Otherwise, it will be


updated. No exception error is generated.

© SystemObjects 1997-2008 www.systemobjects.com 199


Tfile400 Events

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.

© SystemObjects 1997-2008 www.systemobjects.com 200


BeforeInsert
Type: TNotifyCancelEvent (See Types used by ScreenDesigner/400).
Call : The code added to this event is executed just before adding a record.
The parameter 'Cancel' (of Boolean type) is used to cancel adding a 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.

Tips and Shortcurts


Key list
To find the key list of a file rapidly, click on the button labeled '...' of the property
Fields. The key fields are those that have '*1', '*2' or more general '*I' on the
field name line,. The number indicates the order of the field in the key list of the
file (see the property Fields).

Avoid connecting and disconnecting repeatedly


Reading a file description requires an access the iSeries and then establishing a
connection. As an iSeries file is accessed, its description is read as part of the
process of assigning the properties that defines it (AS400, LibraryName,
FileName, MemberName,and FileDescription). If, at the moment of access, no
connection is active, then a connection is established, entailing the sequence
connection, opening the file, closing the file, and disconnection. On the other
hand, if the property Active of the associated object TAS400 is simply set to True
then the connection is already established, and you perform only an open file and
a close file: which are notably faster than establishing a connection.

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.

© SystemObjects 1997-2008 www.systemobjects.com 202


In fact, retrieving the next page of Grid400 requires only one iSeries file I/O
request.

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.

Optimizing record search


The methods GetByKeyFirstInCACHEValues, GetByKeyNextInCACHEValues,
GetByKeyPreviousInCACHEValues and GetByKeyLastInCACHEValues are the
appropriate tools to search a group of records.

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;

© SystemObjects 1997-2008 www.systemobjects.com 203


In certain cases, you may choose not to create the optimal logical file for the
process, for multiple reasons. For example : the search is for a list of customers
in a specific state that work in a particular sector of the economy ( banking, for
example, SIC code 78). The decision has been made not to create a logical file
with a key of State, SIC Code, and Name ( so as to avoid creating too many
logicals that could slow down creating records). Use the same logical that was
used in the previous example, having a key by State and Customer name. A
simple method would be to read all the record for the state of CA and select only
the ones for the banking sector. The code is similar to the one in the previous
example with one additional test on the activity sector of the company.
For certain requests, jumping records using a logical can diminish the number of
record accesses performed. For example, to search the list of companies in the
state of CA that do not work in the banking sector, select a logical with the key
fields State and Activity Sector, and write the following code:

{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;

© SystemObjects 1997-2008 www.systemobjects.com 204


Join Files Access
To join multiple files, you have two possibilities; you either use a file described
as a join file, or you create the junction in the program yourself. We are going to
present both possibilities, and you will have to select the one more appropriate
for your need.

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.

Two cases are possible; let’s study them:

1. Data is accessed online in a visual way.You have visual components of both


files in your window.
Let’s take CUSTOMER file as the master driver file and an INVOICE file as the
secondary file.
We would like to join the files on the field Customer Code.
First of all, you have to make sure that the file INVOICE has as its first key

© SystemObjects 1997-2008 www.systemobjects.com 205


field the Customer Code;if this is not the case use another logical that will
have meet this requirement.
It is sufficient to add two lines of code to the OnUpdateComponents of
File400Customer:

{File400Invoice, File400Customer: TFile400;}


{CustomerCodeIndex: Integer;}
File400Invoice.FFilterComparison:=tcEqual;
File400Invoice.FFilterValue:=File400Customer.GetValue(CustomerCodeIndex);

You can use this method to perform many joins in a chain.

2. You are going to search for records requiring a joint.


The first step is to search the master file for the first record that meets the
requirements. The second step is to verify in the join file the
requirements of the search imposed on the first master record.
Finally you have to perform step two again for the other records of the master
file that meet the requirements.

Here an example illustrating this method of search:

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:

{CustomerFile, InvoiceFile: TFile400;}


{MyCustomer, MyLastInvoice: String;}
{CustomerIndex, InvoiceDateIndex: Integer;}
CustomerFile.Open;
InvoiceFile.Open;
CustomerIndex:=CustomerFile.GetFieldIndex('IDCUSTOMER');
InvoiceDateIndex:=InvoiceFile.GetFieldIndex('INVDATE');
try
CustomerFile.GetByKeyFirstInCacheValues('CA','EQ');
While Not CustomerFile.EOF Do
Begin
try
MyCustomer:=CustomerFile.GetValue(CustomerIndex);
InvoiceFile.GetByKeyLastInCACHEValues(MyCustomer,'EQ');
MyLastInvoiceDate := InvoiceFile.GetValue( InvoiceDateIndex );
If StrToInt(Copy(MyLastInvoiceDate,1,4))>=1996 Then
{...code...}
except;
end;
CustomerFile.GetByKeyNextInCACHEValues('CA','EQ');
End;
except
© SystemObjects 1997-2008 www.systemobjects.com 206
CustomerFile.Close;
InvoiceFile.Close;
end;

© SystemObjects 1997-2008 www.systemobjects.com 207


Creating new components
To create a visual component, establish the link to the object File400:

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 AddDataObject(YourObject:TComponent; Where:Integer);


This procedure adds the object YourObject to the list. If Where is 0, then the
object is added to the end of the list and gets priority over the others; if Where is
1, then the object is added to the beginning of the list.

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 :

• ifFileChanged : the attached file has changed.


• ifCacheToScreen : request to update displayed data.
• ifNone: no action.
• ifNavigPushed : navigation button used, lost Focus.
• ifUserRightChanged : user rights changed.
• ifFieldsListChanged : list of fields changed.
• ifScreenToCache : request to update fields with visual components.
• ifUpdate : a modification happened.
• ifInsert : an insert record happened.
• ifDelete : a delete record happened.
• ifFilterChange : the filter was modified.

211: End of File


Possible causes:
After a GetPrevious, GetPreviousInCACHEValues, GetNext,
GetNextInCACHEValues, GetByKeyPrevious, GetByKeyPreviousInCACHEValues,
GetByKeyNext, GetByKeyNextInCACHEValues end of file was encountered.
Solution:
None; this is just an information message.

© SystemObjects 1997-2008 www.systemobjects.com 208


237: Record not found
Possible causes:
After a GetFirst,GetFirstInCACHEValues no records were found; the file is empty.
Solution:
None, this is just an information message.

284: Command Check


Possible causes:
The file selected to access (AS400, LibraryName, FileName, FileMember) does not
exist, and you cannot read its description or open it.
The file access parameters are not applicable, and the file does not open:
• UserRights=rgUpdate and the user has the read right only.
• Another user opened the file in exclusive mode.
• SharingRights=rgNone or rgRead and another user has opened the file in
rgUpdate;
• SharingRights=rgUpdate and it’s a file that can be opened only in read
mode (like the join logical files).
• Commit=True and no transaction was initiated.
• Commit=True and the file is not journaled on the iSeries.
The method of delete, modify, or insert was not completed because the
user did not have UserRights=rgUpdate when the file was opened.
Solution:
Modify the parameters mentioned above if they were false.

1011: Description is missing


Possible causes:
The connection to the iSeries did not occur, and the file has no description and
no operation is possible on the file (opening it for example).
Solution:
Verify your connection to the iSeries and restart your application.

General Protection Fault


Possible Cause:
The file description is accessed in local mode (see property FileDescription) and
the file description does not correspond to the file description on the iSeries.
Solution:
Delete the local file description. It will be rebuilt.

© SystemObjects 1997-2008 www.systemobjects.com 209


Class TSQL400

Parent: Tcomponent

Unit: SCDsql

The class TSQL400 is used to retrieve the results of an SQL statement. If no


logical access path is found, then the SQL capability of the iSeries is used.
Otherwise ClientObjects/400 proceeds to access the file in native mode.
Access to the resulting data is performed in the same way as with class TFile400,
except for the class TGrid400, which doesn’t recognize TSQL400 as an attached
file.

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.

© SystemObjects 1997-2008 www.systemobjects.com 210


Methods:

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.

© SystemObjects 1997-2008 www.systemobjects.com 211


Class Tnavig400

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'.

© SystemObjects 1997-2008 www.systemobjects.com 212


Properties

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:

• bkFirst: goto first record.


• bkPrior: goto prior record.
• bkNext: goto next record.
• bkLast: goto last record.
• bkUpdate: lock and modify record in process.
• bkCancel: cancel current modifications.
• bkInsert: insert a blank record.
• bkDelete: lock and delete record in process.

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:

(bkFirst); (bkPrior); (bkNext); (bkLast);

(bkUpdate);

(bkCancel); (bkInsert); (bkDelete).

© SystemObjects 1997-2008 www.systemobjects.com 213


Class TField400

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

Description of the selected field

© SystemObjects 1997-2008 www.systemobjects.com 214


The field choice is made by a Double-Click on the wanted line or by a single Click
on this field and a Click on the OK button. The Cancel button cancels the choice in
progress.
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:
{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.

© SystemObjects 1997-2008 www.systemobjects.com 215


Class TLabel400

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:

Description of the selected field

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.

© SystemObjects 1997-2008 www.systemobjects.com 216


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:
{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.

© SystemObjects 1997-2008 www.systemobjects.com 217


Class TMemo400

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:

Class object TLabel created


automatically above the object
Field400

© SystemObjects 1997-2008 www.systemobjects.com 218


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.

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.

© SystemObjects 1997-2008 www.systemobjects.com 219


Class TGrid400

Ancestor TStringGrid

Unit SCDGRID

© SystemObjects 1997-2008 www.systemobjects.com 220


Properties
AttachedFields
Type: TStringList.
This property permits to define the fields to be displayed. It is necessary to
indicate the list of the field names in question. In ‘Design’ mode, a window
permits a convivial field choice:

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).

© SystemObjects 1997-2008 www.systemobjects.com 221


CoOptions
Type: coGridOptions ( See section Types used by ScreenDesigner/400).
See also: Class TFile400
Option goWithoutRRN:
This option permits to avoid using the file record numbers when navigating. This
gives the possibility to use the Grid with the joint logical files which have the
characteristic of being able to contain several records with the same record
number. It is also necessary to have the BufferCount property of the object
File400 at 0, because the bufferization also uses the record numbers.

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.

This property can take seven different values:

• 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

© SystemObjects 1997-2008 www.systemobjects.com 222


comparison operator can be used only if the last field indicated in the
FFilterValue property corresponds to an Alphanumeric type field.

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.

© SystemObjects 1997-2008 www.systemobjects.com 223


Header
Type: TStringList.
This property permits to define the Grid400 header. It is the list of the wanted
column headings. It is initialized at the time of defining the AttachedFields
property. In ‘Design’ mode, a window permits a convivial modification of these
headings:

Present list of column headings

Input of the new column heading

Confirmation button of the new


heading

Corresponding iSeries field

Description of the corresponding


iSeries field

The change of a column heading is done by a Click on the ancient heading


indicated in the list, then by typing in the new heading and, finally, by a Click on
the confirmation button of the modification.
• The OK button confirms the modifications made.
• The Cancel button cancels the modifications made.

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).

© SystemObjects 1997-2008 www.systemobjects.com 224


Methods

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.

© SystemObjects 1997-2008 www.systemobjects.com 225


KeyDown
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 cursor is found after
the key was pressed.
Moreover, if pressing the key engendered a line exit then a verification of the
data type is made; and if the record has been modified then the modification is
made automatically on the iSeries.

Tip

BufferCount property of the associated file


This property permits to bufferize the file data ( See the definition of this
property). The value that you must indicate depends on the type of application
that you develop.

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.

© SystemObjects 1997-2008 www.systemobjects.com 226


Class TLookUp400

Ancestor SpeedButton

Unit SCDLOOK

Properties

LookUpCaption

Type: String.

This property permits define the title of the look up window.

© SystemObjects 1997-2008 www.systemobjects.com 227


LookUpFields

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:

Two buttons to change the


List of file List of selected order of selected fields
fields fields

List of the window


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 choose all the fields.

© SystemObjects 1997-2008 www.systemobjects.com 228


• The button ' <<' permits to choose no field.

• 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.

The OK button confirms the choice in progress.


The Cancel button cancels the choice in progress.

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.

© SystemObjects 1997-2008 www.systemobjects.com 229


LookUpFilter
Type: String.
This property permits to define a filter on the look up file so that the user doesn't
see all the file records. To use this property, the file defined by the LookUpFile400
property must have an access key. The filter applies solely to the first key-field.
The comparison operator is tcLike (See FFilterComparison property of the class
TFile400) and the value is the one provided by the control that you will have
chosen.

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 '... '.

© SystemObjects 1997-2008 www.systemobjects.com 230


Methods
GetControlName
Parameters: Index of the field selected: Integer.
Return: String.
See also: GetFieldName, PutControlName, UpdateControls.
Example:
{MyLookUp: TLookUp400;}
{MyIndex: Integer;}
{MyControlName: String;}
For MyIndex:=0 to MyLookUp.LookUpFields.Count-1 Do
Begin
MyControlName:=MyLookUp.GetControlName(MyIndex);
End;

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.

© SystemObjects 1997-2008 www.systemobjects.com 231


PutControlName
Parameters: Index of the field selected: Integer;
Name of the control to associate: String.
Return: None.
See also: GetFieldName, GetControlName, UpdateControls.
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 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.

© SystemObjects 1997-2008 www.systemobjects.com 232


© SystemObjects 1997-2008 www.systemobjects.com 233
Modified method

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.

© SystemObjects 1997-2008 www.systemobjects.com 234


Class SQLBuild400

Unit: SCDBUILD

The class TSQLBuild400 is used to build an SQL statement.

When you create an SQLBuild400 object, buttons, listboxes, comboboxes, and so


on, may be created on your form, depending on the object. You can create and
add your own objects to the different Componenet Palette tabs, but you do not
have to delete the standards objects. Instead, set the Visible property to False.

© SystemObjects 1997-2008 www.systemobjects.com 235


The labels and hints associated with these objectsare created in the resource file
SCDBLD32.RES. A French version of this resource file is available in the directory
Vcl\French. After you have selected the French resource file, you will need to
recompile your package.

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

Note: you can change the default.


To add a function, add the line:
Description of my function|Definition of my function
Parameters are defined like this:
• C : Alphanumeric
• N : Numeric
• D : Date/Time

© SystemObjects 1997-2008 www.systemobjects.com 236


FunctionsDateTime
Type: TStringList
This property defines the list of the functions using Date/Time values, you can
change the default one:
• Minimum of dates|MIN
• Maximum of dates|MAX
• Convert Date to String|CHAR
• Convert String to Date|DATE
• Convert String to Hour|TIME
• Convert String to TimeStamp|TIMESTAMP
• Extract Day from Date|DAY
• Extract Hour from Date|HOUR
• Extract Microseconds from Date|MICROSECOND
• Length of Date|LENGTH
• Extract Minutes from Date|MINUTE
• Extract Month from Date|MONTH
• Extract Seconds from Date|SECOND
• Extract Year from Date|YEAR
• Current Date|CURRENT DATE
• Current Hour|CURRENT TIME

• Current Timestamp|CURRENT TIMESTAMP

To add a function, add a line:


Description of my function|Definition of my function
Parameters are defined like this:
• C : Alphanumeric
• N : Numeric
• D : Date/Time

© SystemObjects 1997-2008 www.systemobjects.com 237


FunctionsNumeric
Type: TStringList
This property defines the list of the functions using numeric values, you can
change the default one:
• Minimum of numbers|MIN
• Maximum of numbers|MAX
• Absolute value|ABSVAL
• Length of number|LENGTH
• Modulo|MOD
• +|+
• -|-
• /|/
• *|*

• **|**

To add a function, add the line:


Description of my function|Definition of my function
Parameters are defined like this:
• C : Alphanumeric
• N : Numeric
• D : Date/Time

© SystemObjects 1997-2008 www.systemobjects.com 238


GroupFunctions
Type: TstringList
This property defines the list of the functions associated to the GROUP BY part of
the SQL statement:
• Sum|SUM
• Average|AVG
• Number of records|COUNT
• Minimum|MIN
• Maximum|MAX
• Variance|VAR
• Standard Deviation|STDDEV

Note: you can change the default.


To add a function, add the line:
Description of my function|Definition of my function
Parameters are defined like this:
* : All types
Operands:
This property defines the list of operands, you can change the default one:
• Less than|<
• Greater than, or equal to|>=
• Greater than|>
• Not equal to|<>
• Between|BETWEEN * AND *
• Not between|NOT BETWEEN * AND *
• In the list|IN (*,*)
• Not in the list|NOT IN (*,*)
• Like|LIKE *
• Not like|NOT LIKE
• Is null|IS NULL
• Is not null|IS NOT NULL

To add an operand, add the line:


Description of my function|Definition of my function
Parameters are defined like this:

© SystemObjects 1997-2008 www.systemobjects.com 239


* : All types
Options
Type: TSQLBuildOptions
This property defines options of the class: Deletion confirmation.
ParamsCount
Type: Word (ReadOnly)
This property gives the number of parameters defined.
SQL
Type: Array of TStringList. (ReadOnly)
This property gives the SQL statement, either with or without asking for the
values of the parameters. SQLTrue asks for the values; SQLFalse does not ask.
Table_Height
Type: Word
On the first tab, you have a scroll box that contains all the tables used to build
the query. This property defines the height of the listbox representing a table.
Table_HorizSpace
Type: Word
On the first tab, you have a scroll box that contains all the tables used to build
the query. This property defines the horizontal space between two listboxes.
Table_VertSpace
Type: Word
On the first tab, you have a scroll box that contains all the tables used to build
the query. This property defines the top property of the listbox representing the
tables
Tables
Type: Array of TListBoxFields
On the first tab, you have a scroll box which contains all the tables used to build
the query. This property returns one of those tables, represented by a listbox.
Tables0 returns the first one.
TableCount
Type: Word (ReadOnly)
On the first tab, you have a scroll box which contains all the tables used to build
the query. This property returns the number of tables.

© SystemObjects 1997-2008 www.systemobjects.com 240


Methods

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’);

© SystemObjects 1997-2008 www.systemobjects.com 241


LoadFromFile
Parameters: FileName : String
Return: None
This method loads a query definition from a file. Use method SaveToFile to reload
the definition of the query.
Example :
{MyBuilder: TSQLBuild400;}
MyBuilder.SaveToFile(‘C :\TEMP\MYQUERY.TXT’);
{. . . . . .
MyBuilder.LoadFromFile(‘C :\TEMP\MYQUERY.TXT’);

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) ;

© SystemObjects 1997-2008 www.systemobjects.com 242


Class TCall400

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:

© SystemObjects 1997-2008 www.systemobjects.com 243


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.
The research is Key Sensitive, think of capitals.

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:

© SystemObjects 1997-2008 www.systemobjects.com 244


Define every parameter in the group ‘ New Parameter ', then press the button
‘Add ' to insert it in the list.

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.

An initial value can be affected to the parameters.

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:

© SystemObjects 1997-2008 www.systemobjects.com 245


You can leave the generic name blank if you wish to display all the programs.
Otherwise, indicate the beginning of the program name followed by the character
' * ' ; you will get the corresponding program list.
The research is Key Sensitive, think of capitals.

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.

The nine parameter types are the following:


• ‘A ': Alpha-numeric (conversion in EBCDIC is automatic)
• ‘S ': Numeric extended
• ‘P ': Numeric condensed
• ‘B ': Numeric binary
• ‘F ': Numeric floating

© SystemObjects 1997-2008 www.systemobjects.com 246


• ‘L ': Date
• ‘T ': Hour
• ‘Z ': Date/Hour
• ‘H ': Buffer

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 ();

This method starts the iSeries program.


Remember that if the program iSeries never ends or contains errors then your
Delphi program can also never end: it is necessary to cancel the execution of the
program on the iSeries.
This method generates an ECO400Error exception in case of error.

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);

© SystemObjects 1997-2008 www.systemobjects.com 247


MyProg.Execute;
GetMem(MyBuff,128);
MyProg.RetrieveBuffer(0,MyBuff);
ebcdic2ascii(MyBuff+4,MyBuff+4,20);
MyBuff(24(:=char(0);
ShowMessage(‘The been worth is: ’+StrPas(MyBuff+4));
Freemem(MyBuff,128);

This method permits to recover a parameter as buffer. This method is especially


useful when a parameter is of type ‘H '. The possible conversions are to be done
by the programmer.

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;

This method permits to affect a buffer to a parameter. This method is especially


useful when a parameter is of type ‘H '. The possible conversions are to be done
by the programmer.

© SystemObjects 1997-2008 www.systemobjects.com 248


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
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

Call of the OS/400’s API


Recovering certain pieces of information on the iSeries is often faster if you use
the API of the OS/400 ( See the IBM literature). For most of these system
programs the parameters are structures ; use parameters of type ‘H ' and
manage the returned buffer ‘Offsets '. Remember that at the conversion level, the
binary numbers (often of a length of 4 bytes) on the iSeries and on the PC are in
reversed order (first byte PC= fourth byte iSeries; second byte PC= third byte
iSeries…).

© SystemObjects 1997-2008 www.systemobjects.com 249


Class TCmd400

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.

© SystemObjects 1997-2008 www.systemobjects.com 251


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.

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:

• ‘A ': Alpha-numeric (automatic translation in EBCDIC)


• ‘L ': Alpha-numeric of length 1
• ‘N ': Numeric

© SystemObjects 1997-2008 www.systemobjects.com 252


ClearParams
Parameters: None.
Return: None.
See also: Params, AddParam.
Example:
{MyCmd: TCmd400;}
MyCmd.ClearParams;
MyCmd.AddParam(‘A’,10,0);
MyCmd.Execute;
ShowMessage(‘The been worth is: ’+MyCmd.Value(0));
This method permits to cancel all variables.

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.

© SystemObjects 1997-2008 www.systemobjects.com 253


Class DataArea

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:

© SystemObjects 1997-2008 www.systemobjects.com 254


You can leave the generic name blank if you wish to display all the Data Areas.
Otherwise, indicate the beginning of the Data Area name followed by the
character ' * ' ; you will get the list of the corresponding Data Areas.

The research is Key Sensitive, think of capitals.


DataAreaType
Type: string
See also: DADecimals, DAType, DALength,
In conception mode, this property permits to define your Data Area:

By programming, use the DALength , DAType and DADecimals properties.

© SystemObjects 1997-2008 www.systemobjects.com 255


DAType
Type: Char
See also: DataAreaType, DADecimals, DALength,
This property permits to define and to know your Data Area type.
The possible values are:
• ‘A ': Alpha-numeric;
• ‘L ': Logical;
• ‘N ': Numeric.

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.

The research is Key Sensitive, think of capitals.

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.

© SystemObjects 1997-2008 www.systemobjects.com 256


Tip

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):

© SystemObjects 1997-2008 www.systemobjects.com 257


Class TDataQueue

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:

© SystemObjects 1997-2008 www.systemobjects.com 258


You can leave the generic name blank if you wish to display all the Data Queues.
Otherwise, indicate the beginning of the name of the Data Queue followed by the
character ' * ' ; you will get the list of corresponding Data Queues.
The research is Key Sensitive, think of capitals.

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)

© SystemObjects 1997-2008 www.systemobjects.com 259


JobName
Type: String READONLY
See also: JobUser, JobNumber, SenderProfile,
This property permits to know the name 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).

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.

© SystemObjects 1997-2008 www.systemobjects.com 260


LibraryName
Type: string
This property permits to define the library where the Data Queue 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 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).

© SystemObjects 1997-2008 www.systemobjects.com 261


MessageListCount
Type: LongInt READONLY
See also: MessageAvailableCount, 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 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.

© SystemObjects 1997-2008 www.systemobjects.com 262


ReceivingKeyOrder
Type: coDtaqKeyOrder ( See section Types used by ScreenDesigner/400).
See also: ReceiveByKey, ReceivingWait;
This property permits to define the access by key to the Data Queue. It is used by
the ReceiveByKey method and is applied to the key passed as parameter to this
method.

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).

© SystemObjects 1997-2008 www.systemobjects.com 263


Methods

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).

© SystemObjects 1997-2008 www.systemobjects.com 264


GetMessageJobNumberInlist
Parameters: Message index: Integer;
Work number: String;
Return: None
See also: MessageListError, MessageListCount, BufferSizeAvailable,
MessageAvailableCount, GetMessages, GetMessagesWithKey,
GetMessageValueInList, GetMessageJobUserInList, GetMessageJobNameInList,
GetMessageUserProfileInList, GetMessageKeyInList,,,
Example:
{MyDtaq: TDataQueue;}
{MyJobNumber: String;}
Yew MyDtaq.GetMessages(stAll,100,1000)>0 then
begin
ShowMessage(IntToStr(MyDtaq.MessageListCount)+
‘messages ' retrieved);
MyDtaq.GetMessageJobNameInList(1,MyJobNumber);
ShowMessage(‘First message is coming from job number: '+
MyJobNumber);
end;

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);

© SystemObjects 1997-2008 www.systemobjects.com 265


MyDtaq.GetMessageJobUserInList(1,MyJobUser);
ShowMessage(‘First message is coming from job to use: '+
MyJobUser);
end;

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.

© SystemObjects 1997-2008 www.systemobjects.com 266


GetMessages
Parameters: Access type: coDtaqSelectionType ( See section Types used by
ScreenDesigner/400).;
Length of the message to bring back : Word;
Size of the return buffer to use: Integer
Return: Number of messages returned: LongInt;
See also: MessageListError, MessageListCount, BufferSizeAvailable,
MessageAvailableCount, 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 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.

© SystemObjects 1997-2008 www.systemobjects.com 267


This function does not unstack the Data Queue messages.
The return indicates the number of messages memorized. In case of error, the
MessageListError property indicates the iSeries error code (CPF0000: no error).
The consultation of messages is done with the help of the methods:

• 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.

© SystemObjects 1997-2008 www.systemobjects.com 268


This method permits to consult messages in a Data Queue with access by key.
The first three parameters permit to define the access by key: the comparison
operator, reference key value and this key’s length. The available comparisons
are:
• dkGreaterThan: Strictly superior to,
• dkLessThan: Strictly inferior to,
• dkNotEqual: Different from,
• dkEqual: Equal to,
• dkGreaterOrEqual: Superior or equal to,
• dkLessOrEqual: Inferior or equal to.

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.

This function does not unstack the Data Queue messages.


The return indicates the number of messages memorized. In case of error, the
MessageListError property indicates the iSeries error code (CPF0000: no error).

The message consultation is done with the help of the methods:

• GetMessageValueInList,
• GetMessageJobNumberInList,
• GetMessageJobNameInList,
• GetMessageUserProfileInList,
• GetMessageKeyInList,
• GetMessageJobUserInList.

© SystemObjects 1997-2008 www.systemobjects.com 269


GetMessageUserProfileInList
Parameters: Message index: Integer;
Job user profile: String;
Return: None
See also: MessageListError, MessageListCount, BufferSizeAvailable,
MessageAvailableCount, GetMessages, GetMessagesWithKey,
GetMessageValueInList, GetMessageJobNumberInList, GetMessageJobNameInList,
GetMessageJobUserInList, GetMessageKeyInList
Example:
{MyDtaq: TDataQueue;}
{MyUserProfile: String;}
Yew MyDtaq.GetMessages(stAll,100,1000)>0 then
begin
ShowMessage(IntToStr(MyDtaq.MessageListCount)+
‘messages ' retrieved);
MyDtaq.GetMessageUserProfileInList(1,MyUserProfile);
ShowMessage(‘User profiles of the first message is: '+
MyUserProfile);
end;

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);

© SystemObjects 1997-2008 www.systemobjects.com 270


GetMem(MyMessage,MyDtaq.MessageMaxLength+1);
MyDtaq.GetMessageValueInList(1,MyMessage,Lg);
MyMessage(Lg(:=Char(0);
Ebcdic2ascii(MyMessage,MyMessage,Lg); {message is year EBCDIC string in this
sample}
ShowMessage(‘First message is: '+StrPas(MyMessage));
end;

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.

© SystemObjects 1997-2008 www.systemobjects.com 271


Receive
Parameters: None
Return: Boolean
See also: ReceiveByKey, Send, SendWithKey, Getvalue, SetValue,
ReceivingWait.
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 unstack a Data Queue message. The return permits to
know if a message has been read (True) or if the Data Queue was empty (False).
Use the GetValue method to have the message.
The ReceivingWait property is used by this method to define the response time of
receiving a message from the Data Queue.
This method can be used only if the Data Queue has been created as a type other
than KEYED.

© SystemObjects 1997-2008 www.systemobjects.com 272


ReceiveByKey
Parameters: Reference key
Return: Boolean
See also: ReceiveByKey, Send, SendWithKey, Getvalue, SetValue,
ReceivingWait, ReceivingKeyOrder
Example:
{MyDtaq: TDataQueue;}
{MyMessage: PChar;}
{Lg: LongInt;}
ReceivingKeyOrder:=dkEqual;
yew MyDtaq.ReceiveByKey(‘TCIS ') 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 from TCIS received: '+
StrPas(MyMessage));
end;

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.

© SystemObjects 1997-2008 www.systemobjects.com 273


Send
Parameters: None
Return: None
See also: SendWithKey, 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.Send;

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.

© SystemObjects 1997-2008 www.systemobjects.com 274


SetValue
Parameters: Message: PChar
Message length: LongInt
Return: None
See also: GetValue, Receive, Send, ReceiveByKey, SendWithKey
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.Send;

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.

© SystemObjects 1997-2008 www.systemobjects.com 275


Tip

Communications between iSeries Users


The TDataQueue class allows PC Users of the iSeries to communicate between
themselves.
For example, by using a DataQueue of KEYED type with as key the recipient of
the message, it is possible to send messages to other PC users and to receive all
these messages while reaching by key the Data Queue.

Communication with an iSeries program


The TDataQueue class also allows your application to interact with an iSeries
program.

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.

© SystemObjects 1997-2008 www.systemobjects.com 276


Class TMessageQueue

Ancestor TComponent

Unit: SCDMSGQ

Properties

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.

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.

© SystemObjects 1997-2008 www.systemobjects.com 279


Methods
GetMsg
Parameters: Message_received : Pchar
Return: None
This method is used to read the message received as a PChar. If you want to use
strings, see property Msg.
Example:
{MyMsgq: TMessageQueue;}
{Buffer: Pchar;
if MyMsgq.ReceiveFirst(maSame) then
begin
GetMem(Buffer,MyMsgq.MsgLength+1);
MyMsgq.GetMsg(Buffer);
BufferMyMsgq.MsgLength:=char(0);
{......
FreeMem(Buffer);
end;

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);

© SystemObjects 1997-2008 www.systemobjects.com 280


ReceiveNext
Parameters: action:TmsgAction
Return: Boolean
This method is used to receive the next message in the message queue.
Example:
{MyMsgq: TMessageQueue;}
if MyMsgq.ReceiveNext(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’);

© SystemObjects 1997-2008 www.systemobjects.com 281


© SystemObjects 1997-2008 www.systemobjects.com 282
RemoveMessageWithBookMark
Parameters: BookMark:TMsg400Bookmark
Return: Boolean
This method is used to delete a message that uses a bookmark.
Example:
{MyMsgq: TMessageQueue;}
{MyBookmark: TMsg400Bookmark;
if MyMsgq.ReceiveFirst(maSame) then
begin
MyBookmark:=MyMsgq.MsgBookmark;
{.....
MyMsgq.RemoveMessageWithBookmark(MyBookmark);
end;

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.’);

© SystemObjects 1997-2008 www.systemobjects.com 283


SetMsg
Parameters: Message_to_send : PChar;
Length_of_first_parameter :Integer
Return: None
This method prepares the message to send, using a PChar value. If you want to
use strings, see the property Msg.
Example:
{MyMsgq: TMessageQueue;}
{Buffer: Pchar;
{BufferLen: Integer;
MyMsgq.SetMsg(Buffer,BufferLen);
if MyMsgq.Send(mtInq,self) then
ShowMessage(‘Message sent.’);

© SystemObjects 1997-2008 www.systemobjects.com 284


Class TSc5250

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)

© SystemObjects 1997-2008 www.systemobjects.com 287


If the User and the Password properties are set, the QDSIGNON screen is by-
passed.
Prog
Type: String
This information corresponds to the Program/Procedure field of the QDSIGNON.
Setting this property is useless if the user and Password properties are invalid or
left to blank.

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.

The parameters are :

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.

© SystemObjects 1997-2008 www.systemobjects.com 288


Class TSc5250Panel

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.

© SystemObjects 1997-2008 www.systemobjects.com 289


Methods

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

© SystemObjects 1997-2008 www.systemobjects.com 290


Sends only the selected block of screen to the printer. If there is no selected
block, the entire screen is printed in text mode.

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.

© SystemObjects 1997-2008 www.systemobjects.com 291


© SystemObjects 1997-2008 www.systemobjects.com 292
Class TCoifs

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”.

This component works associated to TAS400 component.

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

© SystemObjects 1997-2008 www.systemobjects.com 294


The CopyFileASToStream method copies the memory image of a bitmap file into
the Stream object. See DBBitmap sample for more information.(on this path :
Instdir\Delphi 4.1\samples\DBBitmap )
If an error occurs, an exception is raised.

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.

© SystemObjects 1997-2008 www.systemobjects.com 295


CreateDir
Parameters: path:string
Return: None

The CreateDir method creates a new directory.


If an error occurs, an exception is raised.

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.

© SystemObjects 1997-2008 www.systemobjects.com 296


TDirThread

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.

© SystemObjects 1997-2008 www.systemobjects.com 297


TIFSObject
Unit: scdifs

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.

© SystemObjects 1997-2008 www.systemobjects.com 298


TCoifs exceptions classes

Units: ifstools

Description:
When using TCoifs component, if an error occurs, one of these exceptions is
raised:

• EIFSnotinitialized : IFS not initialized.

• EIFSnotAsync : ListdirectoryNext was called but Asynchronous


property wasn’t set to True.

• EIFSunknownError : Unknown Error.

• EIFSNoAs400 : No TAS400 component was defined.

• EIFSAccessDenied : Access denied.

• EIFSObjectExists : object already exists.

• EIFSObjectBusy : lobject is busy.

• EIFSObjectNotFound : object not found

• EIFSInvalidFileName :Invalid File name.

• EIFSPathTooLong : Path Too long.

• EIFSDirectoryNotEmpty : Directory is not empty.

• EIFSOpNotSupported : Operation not supported.

• EIFSPCFileNotFound : PC File not found.

© SystemObjects 1997-2008 www.systemobjects.com 299


Class TCoIFSBrowseDirs

Ancestor: TComponent

Unit: CoIFSBrowseDirs

TCoIFSBrowseDirs displays a list of Directories from the IFS in a variety of ways.


Use TCoIFSBrowseDirs to manage and display a tree of Directory in a form. Each
Directory can have a list of subdirectories associated with it. By clicking on a
node, the user can expand and collapse the associated list of subdirectories.
This control can be seen as the left 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

© SystemObjects 1997-2008 www.systemobjects.com 300


Properties

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

TCoIFSBrowseFiles displays a list of Files and Directories from the IFS in a


variety of ways.

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

© SystemObjects 1997-2008 www.systemobjects.com 302


Properties

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.

© SystemObjects 1997-2008 www.systemobjects.com 303


Methods

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.

© SystemObjects 1997-2008 www.systemobjects.com 304


TSetprop400

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.

DisplayLabel properties of the selected fields will be updated automatically with


the iSeries fields description.

© SystemObjects 1997-2008 www.systemobjects.com 305


Properties

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).

If the dataset is a TTable you will be able to :

• Modify the DisplayLabel property of the selected fields in the


TTable.

(Right click the TSetprop400 component and choose « Update


Fields description » to get the iSeries field description.)

• Fix a blocking factor by indicating a record number in the


Buffercount property.

• Use the SelectedFields property which allows you to extract only


the selected fields in a TTable.

If the Dataset is a Tquery:

• You will be able to use only the Buffercount property, nevertheless,


the blocking factor is automatically calculated for the TQuery if the
property is set to 0 (Default value = 0). In most of the cases, the
calculation will give you the optimum result.

© SystemObjects 1997-2008 www.systemobjects.com 306


SelectedFields
Type: Boolean

This property allows you to indicate that you only want to transfer through the
network, the selected fields specified in a Ttable component.

This will remarkably increase low throughput speed networks performance.

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

© SystemObjects 1997-2008 www.systemobjects.com 307


Delphi/400 Functions

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.

© SystemObjects 1997-2008 www.systemobjects.com 308


chr2b4
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 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.

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.

© SystemObjects 1997-2008 www.systemobjects.com 309


ebcdic2ascii
Module: SCDtools.
Declaration: (ascii,ebcdic:pchar;lg:word):shortint;
Utility: Conversion of a EBCDIC string into a ASCII one. Lg represents the string
length to be converted.

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

© SystemObjects 1997-2008 www.systemobjects.com 310


sixth, the buffer size used to recover the lists described above (32000, for
example).

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).

© SystemObjects 1997-2008 www.systemobjects.com 311


TcGetListMbr
Module: SCDtools.
Declaration: (hnd:shortint; SearchString:string; FileName, Libraryname:string;
listDtaara:tstrings; listdesc:tstrings; size:word): shortint;
Utility: Recuperation of a file member list. The first parameter is the connection
‘handle’ ( TAS400 class, Gethandle method permits to know this value); the
second is the research string (‘D * ': members the name of which starts with a
D); the third, the research file name ; the fourth, the research library name; the
fifth, the return parameter of the member name list (TListBox class, Items
property, for example); the sixth, the return parameter of the member
description list; the seventh, 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.

© SystemObjects 1997-2008 www.systemobjects.com 312


Types used by Delphi/400

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

© SystemObjects 1997-2008 www.systemobjects.com 313


coDtaqKeyOrder
Module: SCDtools.
The coDtaqKeyOrder type is the list of comparison operators to reach a Data
Queue message by key:
• dkGreaterThan
• dkLessThan
• dkNotEqual
• dkEqual
• dkGreaterOrEqual
• dkLessOrEqual

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

© SystemObjects 1997-2008 www.systemobjects.com 315


coTypeComparison
Module: SCDtools.
The coTypeComparison type is the list of the following constants:
• tcNone
• tcLessThan
• tcLessOrEqual
• tcEqual
• tcGreaterOrEqual
• tcGreaterThan
• tcLike

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;).

© SystemObjects 1997-2008 www.systemobjects.com 316


TypeIfFlag
Module: SCDtools.
The TypeIfFlag type is the list of the following constants:
• ifFileChanged
• ifRAMToScreen
• ifNone
• ifNavigPushed
• ifUpdatePushed
• ifUserRightChanged
• ifFieldsListChanged
• ifScreenToRAM
• ifUpdate
• ifInsert
• ifFilterFieldChanged
• ifDelete
• ifFileActiveChange
• ifEmpty
• ifNotEmpty
• ifFilterChange

© SystemObjects 1997-2008 www.systemobjects.com 317


8 Delphi/400 Deployment.

Silent Mode

Delphi/400 2007 Deployment version Setup program can be run in two different
modes:

- Normal: The user must answer to dialog boxes to install.


- Silent Mode : Nothing appears on screen.

If you want to use Delphi/400 2007 Deployment in Silent Mode, you


have to include the -s parameter to the SETUP.EXE program. You will also
have to create an .ISS file which contains the answers to these dialog boxes.

Example : SETUP -S -F1C:\INSTALL\SETUPPC.ISS

Three different ISS sample files are included in the CDROM:

• SETUPPC.ISS provides a silent mode installation only for the PC Part


• SETUPSNA.ISS provides a silent installation for both PC and iSeries parts
and using SNA Transport routers.
• SETUPTCP.ISS provides a silent installation for both PC and iSeries parts
using TCP/IP.
• Follow these steps in order to achieve a Silent Mode installation:

1° Create or modify the ISS file that you plan to use.

2° Launch Delphi/400's Setup program with the -S (Silent) and -F1 (File)
parameters: SETUP -S -F1C:\INSTALL\SETUPPC.ISS

3° Launch Delphi/400's configuration program (C:\CO411\co400cfg.exe) in order to


configure the iSeries connections. A file called ALIASES.CFG is generated. If you

© SystemObjects 1997-2008 www.systemobjects.com 318


have several PC's to configure, you can copy this file instead of using the
CO400cfg.exe program.

ISS files generalities

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.

[AS400DIALOG-0] // only for SNA Transport installation

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 class hierarchy

ScreenDesigner/400 has four specific exception classes:

EXCEPTION

ECO400ERROR TCISERROR

ECO400APPCERROR ECO400KEYERROR

These four classes inherit the Exception class (for more information, see the
Delphi literature on the exceptions).

© SystemObjects 1997-2008 www.systemobjects.com 320


Exception class presentation

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 1997-2008 www.systemobjects.com 321


Using the exception classes
In the description of certain methods and properties of the seventeen
ScreenDesigner/400 components it is indicated if they generate exceptions. If
such is the case, for example the GetFirstInRAMValues method, you have three
possibilities:

1. Not manage the exception:


MyFile.GetFirstInRAMValues; {MyFile:TFile400;}
If an exception is generated then an exception window opens and the program
leaves the procedure or the function in progress.

2. Manage the exception in a general way:


Try
MyFile.GetFirstInRAMValues; {MyFile:TFile400;}
Except
ShowMessage (' Error during first read! ');
End;
If an exception is generated then the code found in the Except section is
executed. Here, whatever the error, the personalized message box appears.

3. Manage the exception in a more precise way :


Try
MyFile.GetFirstInRAMValues; {MyFile:TFile400;}
Except
One ECO400Error Do
Begin
ShowMessage (' Error during first read! ')
End;
One E:ECO400AppcError Do
Begin
ShowMessage ('APPC error: ' +IntToStr(E.ErrorCode)+ '! ' +
#13+#10+E.MEssage+
#13+#10+'Program ises going to be ended ');
Halt;
End;
End;

Here, if an exception was generated by ScreenDesigner/400 then the


personalized message box appears. Moreover, if it is of the ECO400AppcError
type (that means an APPC error occured) then the exception is created in the E
variable and we use this variable to provide certain information to the user: the
code and the message of the error.

© SystemObjects 1997-2008 www.systemobjects.com 322


Error codes

1, "APPC DEALLOCATE NORMAL"


2, "APPC PROGRAM ERROR NO TRUNCATION"
3, "APPC PROGRAM ERROR TRUNCATION"
4, "APPC PROGRAM ERROR PURGING"
5, "APPC RESOURCE FAILURE RETRY"
6, "APPC RESOURCE FAILURE NO RETRY"
7, "APPC UNSUCCESSFUL"
8, "APPC BUSY"
10, "PROTECTION ERROR"
20, "APPC PARAMETER CHECK INVALID VERB"
21, "APPC PARAMETER CHECK INVALID CONVERSATION ID"
22, "APPC PARAMETER CHECK BUFFER CROSSED SEGMENT BOUNDARY"
23, "APPC PARAMETER CHECK TRANSACTION PROGRAM NAME LENGTH"
24, "APPC PARAMETER CHECK INVALID CONVERSATION TYPE"
25, "APPC PARAMETER CHECK BAD ALLOCATE SYNC LEVEL"
26, "APPC PARAMETER CHECK BAD RETURN CONTROL"
27, "APPC PARAMETER CHECK PIP DATA TOO LONG"
28, "APPC PARTNER LU NAME INVALID OR NOT FOUND"
29, "APPC PARAMETER CHECK CONFIRM NOT ALLOWED"
30, "APPC PARAMETER CHECK BAD DEALLOCATE TYPE"
31, "APPC PARAMETER CHECK PREPARE TO RECEIVE TYPE"
32, "APPC PARAMETER CHECK BAD FILL TYPE"
33, "APPC PARAMETER CHECK RECEIVE MAXIMUM LENGTH EXCEEDED"
34, "APPC PARAMETER CHECK UNKNOWN SEC TYPE"
35, "APPC PARAMETER CHECK RESERVED FIELD NOT ZERO"
40, "APPC STATE CHECK NOT IN CONFIRMED STATE"
41, "APPC STATE CHECK NOT IN RECEIVE STATE"
42, "APPC STATE CHECK REQUSET TO SEND BAD STATE"
43, "APPC STATE CHECK SEND IN BAD STATE"
44, "APPC STATE CHECK SEND ERROR BAD STATE"
50, "APPC ALLOCATE ERROR NO RETRY"
51, "APPC ALLOCATE ERROR RETRY"
52, "APPC ALLOCATE ERROR PROGRAM NOT AVAILABLE NO RETRY"
53, "APPC ALLOCATE ERROR TRANSACTION PROGRAM NAME NOT RECOGNIZED"
54, "APPC ALLOCATE ERROR PROGRAM NOT AVAILABLE RETRY"
55, "APPC ALLOCATE ERROR SECURITY NOT VALID"
56, "APPC ALLOCATE ERROR ON CONVERSATION TYPE"
57, "APPC ALLOCATE ERROR PIP NOT ALLOWED"
58, "APPC ALLOCATE ERROR PIP NOT CORRECT"

© SystemObjects 1997-2008 www.systemobjects.com 323


59, "APPC ALLOCATE ERROR SYNCH LEVEL"
70, "APPC DEALLOCATE ABEND PROGRAM"
71, "APPC INSUFFICIENT MEMORY"
72, "APPC MEMORY ALLOCATION ERROR"
73, "APPC TOO MANY CONVERSATIONS"
74, "APPC CONVERSATION TABLE FULL"
75, "APPC ROUTER NOT INSTALLED"
76, "APPC ROUTER WRONG LEVEL"
77, "APPC PCSWIN NOT LOADED"
78, "APPC PCSWIN OUT OF MEMORY"
79, "APPC INVALID USER ID LENGTH"
80, "APPC INVALID PASSWORD LENGTH"
81, "APPC INVALID LUNAME"
97, "Communication Manager not active"
98, "APPC ERROR UNDEFINED"
99, "APPC UNKNOWN ERROR"
100, "PC Support Router Not Started"
101, "Cannot find A2E table"
102, "Cannot find E2A table"
103, "Cannot allocate memory for Router Buffer"
104, "Cannot allocate memory for DAL Internal Buffer"
105, "Router buffer size exceeded maximum"
106, "Router buffer size too small. Must be > 271"
108, "Record Mapping Error"
111, "Record Not Available"
120, "Conversion error - Data requested exceeds data buffer size"
121, "Conversion error - Record length exceeds data buffer size"
122, "Data from target exceeds appc buffer size"
123, "Conversion error - Record length exceeds appc buffer size"
124, "Conversations exceeded maximum of 50"
125, "Record length exceed appc buffer size"
126, "Unknown Data Type in Description Area"
127, "Conversion error - Character number too long"
128, "Conversion error - Decimal Place incorrect in number"
129, "Conversion error - Character number invalid"
130, "iSeries Error Occurred"
131, "Incompatible MAP/400 version or none installed"
132, "Unknown or incorrect PC Data Type in Description Area"
133, "Conversion error - PC binary length invalid"
134, "Conversion error - PC float length invalid"
140, "Local Name Required"
141, "Host name is required parameter"
142, "Description Area Pointer is a required parameter"
© SystemObjects 1997-2008 www.systemobjects.com 324
143, "File Handle is a required parameter"
144, "Conversation not started with PLU_ALIAS specified"
145, "PLU_ALIAS required parameter is incorrect"
146, "Library/File Name Parameter incorrect"
147, "Library/File(MBR) Name Parameter incorrect"
148, "Local File Name Parameter incorrect"
149, "Command Data Pointer required parameter"
150, "Key Value is a required parameter"
151, "Member Name required parameter is incorrect"
160, "Conversion Error"
201, "Key Update Not Allowed"
205, "Cursor Not Supported"
206, "Invalid Data Record"
207, "Duplicate File Name"
208, "Duplicate Key in Different Index"
209, "Duplicate Key Same Index"
210, "Duplicate Record Number"
211, "End of file"
212, "File is Full"
213, "File in Use"
214, "File Not Found"
215, "File Space not Available"
217, "File Not Opened"
218, "Invalid File Name"
221, "Record Length Mismatch"
228, "Command not Authorized"
230, "File Temporarily Not Available"
236, "Record Number out of Bounds"
237, "Record Not Found"
245, "Invalid Key Length"
248, "Not Authorized to use Access Method"
249, "Invalid Access Method"
250, "Permanent Agent Error"
251, "Resource Limits Reached"
252, "Invalid Base File Name"
255, "Not Authorized to Directory"
258, "Existing Condition"
259, "Not Authorized to File"
260, "Invalid Request"
261, "Invalid Key Definition"
263, "Key Update not Allowed by Same Index"
264, "Invalid Key Value"
266, "Open Conflict Error"
© SystemObjects 1997-2008 www.systemobjects.com 325
267, "Open Exclusive by Same User"
268, "Concurrent Opens Exceed Maximum"
269, "Conversational Protocol Error"
273, "Record Damaged"
274, "Record In Use"
275, "Command Complete"
276, "Data Stream Syntax Error"
277, "Update Cursor Error"
278, "No Update Intent on Record"
279, "Invalid New File Name"
280, "Command Not Supported"
281, "Parameter Not Supported"
282, "Value Not Supported"
283, "Object Not Supported"
284, "Command Check"
285, "Duplicate Declared Name"
286, "Invalid Declared Name"
287, "Declare Name Not Found"
288, "Directory Full"
289, "Record Inactive"
290, "File Damaged"
291, "Load Records Count Mismatch"
292, "Not Authorized to Open Intent"
294, "File Closed with Damage"
295, "Target Not Supported"
296, "Key Value Modified after Cursor Set"
299, "DDM Undefined Error"
301, "One Field Mandatory"
302, "Unknown Field"
303, "No Key for This File"
304, "Key Length Null"
305, "Numeric Value Out Of Range"
306, "All Keys Mandatory For This Type Of Comparison OR Unknown
Comparison"
307, "In WIN.INI, group [TcGuide], variable PATH_DDS is missing"
308, "Description not present on PC"
309, "Can't create local description file"
310, "pctype can't be equal to 2"
311, "One field is missing"
312, "Separator must be different than '\000'"
313, "Bad Connection Handle"
314, "Too many files opened"
315, "Bad file handle"
© SystemObjects 1997-2008 www.systemobjects.com 326
316, "Unknown flag"
317, "Memory full for allocation"
318, "Bad field indice"
319, "Can't open file TCERROR.TXT in TcGuide directory"
320, "Bad Custom Field List"
321, "Key out of record"
322, "Bad Key Format"
323, "Buffer Corrupted"
324, "Numeric Value in Key out of range"
325, "Buffer can't exceed 32 Ko"
1001, "Property AttachedFile is missing"
1002, "Auto-jonction is not allowed"
1003, "Not a valid Comparison Value"
1004, "Property AttachedFields is missing"
1005, "Property Active must be set to false !"
1006, "File Description uncomplete : Properties AS400 or FileDescription are
missing"
1007, "Unknown Field Name"
1008, "File Description must be less than 10 characters long"
1009, "Library Name must be greater than 1 character and less than 10
characters long"
1010, "Connection Name is necessary before the file activation"
1011, "File Description is missing! Define again FileDescription"
1012, "File closed"
1013, "Numeric Field Too Large Converted to Zero"
1014, "Buffer size must be between 271 and 32767"
1015, "PLUAlias must be less than 8 characters long"
1016, "Property Transaction and Active must be set !"
1017, "No transaction started !"
1018, "File Name must be greater than 1 character and less than 10 characters
long"
1019, "Property LookUpFile400 is missing"
1020, "File without key cannot be filtered"
1021, "Member Name must be greater than 1 character and less than 10
characters long"
1022, "Filter Field must have an Attached File"
1023, "Filter Field must have an Attached Field"
1024, "Sorry, AttachedFile must have a key"
1025, "Unknown Field"
1026, "Fetch Error"
1027, "SQL Open Error"
1028, "Define on which iSeries your Program can be called"
1029, "Property iSeries is empty"
© SystemObjects 1997-2008 www.systemobjects.com 327
1030, "String limit reached"
1031, "Data Queue not defined"
1032, "Key Access only"
1033, "Key Access impossible"
1034, "Message Index out of bound"
50000, "Internal Error"
50001, "Field Type not suported"
50002, "Too many fields"
50003, "This TDataSource must be linked to a TTable400"
50004, "MasterSource is missing"
50005, "MasterSource not allowed"
50006, "Impossible on an opened table"
50100, "Update Field Description with iSeries Description"
50200, "DataSet Problem"

© SystemObjects 1997-2008 www.systemobjects.com 328


Index
Communications, 276
Components, 208
* B Composite Key, 133
*LIBL, 124, 141 b22chr, 308 Connection, 132, 202
b42chr, 308 Consulting a file, 123
Bad Connection Handle, 142 Conversions, 126
A BeforeActivation coObjType, 315
A2E, 142 TAS400, 139 coOption, 315
Access Rights, 158, 159 TFile400, 200 coOptions, 315
AddCalcField, 159 BeforeDeactivation COOptions, 222
AddParam, 246, 252 TAS400, 139 coSens, 315
amNative, 313 TFile400, 200 coSharR, 158, 315
BeforeDelete, 200 coTarget, 315
amSQL, 313
BeforeExecute, 249 coTypeComparison, 152, 222, 316
API, 308
BeforeInsert, 201 coTypeOpen, 159, 316
API of the OS/400, 249
BeforeModify, 201 coUserR, 159, 316
AS/400, 28, 29, 30, 31, 33, 34, 35, 38,
bkCancel, 213, 313 CPCW, 132
39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 52, 53, 55, 56, 57, 58, 62, bkDelete, 213, 313 Creating new components, 208
63, 64, 65, 68, 75, 79, 87, 88, 89, bkFirst, 213, 313 Création of a component, 122
90, 93, 94, 95, 96, 99, 100, 101, bkInsert, 213, 313 Création of an AS/400 file, 123
121, 122, 123, 124, 125, 126, 127, bkLast, 213, 313
128, 129, 131, 132, 133, 134, 137, bkNext, 213, 313
138, 140, 141, 142, 144, 145, 147, bkPrior, 213, 313 D
148, 149, 150, 151, 153, 155, 156, bkUpdate, 213, 313 DADecimals, 254
157, 158, 160, 161, 162, 172, 173, BufferCount, 150, 202, 226 Data Area, 122
175, 190, 191, 192, 195, 198, 199, BufferSizeAvailable, 258
Data Queue, 122
202, 203, 205, 209, 210, 212, 223, ButtonKind, 213 DataAreaName, 254
225, 226, 236, 243, 244, 245, 247, DataAreaType, 255
249, 250, 251, 253, 254, 256, 258,
261, 262, 263, 268, 269, 276, 277, C Date Format, 173
Delete, 160
285, 286, 287, 289, 291, 305, 306, CalcFields, 150 Description, 186, 202, 209, 259
308, 309, 310, 312, 313, 318, 319, calculated Fields, 123
324, 327, 328 Disconnection, 132
Calculated Fields, 121 Disinstallating, 38
AS/400 Command, 122 Cancel, 139, 200, 201, 249
AS/400 Program, 122 dkEqual, 314
Caption, 230 dkGreaterOrEqual, 314
ascii2ebcdic, 308 chr2b2, 308
atCurrent, 313 dkGreaterThan, 314
chr2b4, 309
atDelete, 313 dkLessOrEqual, 314
chr2f4, 309
atFirst, 313 chr2f8, 309 dkLessThan, 314
atInsert, 313 chr2pck, 309 dkNotEqual, 314
atKeyFirst, 313 chr2zon, 309 DoExit, 215, 225
atKeyLast, 313 ClearParams, 247 doWithBufferCount, 315
atKeyNext, 313 Click, 225, 234 dsFIFO, 314
atKeyPrevious, 313 Closing a File, 149 dsKeyed, 314
atLast, 313 coAccessMode, 313 dsLIFO, 314
atModify, 313 coActions, 313 Duplicated Field, 127
atNext, 313 coButtonKind, 213, 313
atPrevious, 313 coDtaqKeyorder, 268 E
atRRN, 313 coDtaqKeyOrder, 314
AttachedField, 214, 216, 218 coDtaqSelectionType, 267, 314 ebcdic2ascii, 310
AttachedFields, 221 coDtaqSequence, 314 ECO400AppcError, 321
AttachedFile, 215, 217, 219, 222 coGridOption, 314 ECO400KeyError, 321
Avoid connecting and disconnecting coGridOptions, 314 EOF, 152
repeatedly, 202 coLevel, 145, 314 Equal, 162
CommandLine, 250 Error
Commit, 135, 151 Command Check, 209

© SystemObjects 1997-2008 www.systemobjects.com 329


Description is missing, 209 GetDescription, 174 IndexKeys, 157
End of File, 208 GetFieldIndex, 175 InsertBlank, 189
General Protection Fault, 209 GetFieldName, 176, 231 InsertWithCacheValues, 190
Record not found, 209 GetFieldType, 176 InsertWithScreenValues, 191
Error codes, 323 GetFirst, 177 Installation, 124
ErrorCode, 321 GetFirstInCacheValues, 178 installed files, 41
Errors, 42 GetFirstInRAMValues, 322
Examples, 121 GetIndice, 215, 217, 219, 225
Execute, 247, 253 GetLast, 179 J
GetLastInCacheValues, 180 JobName, 260
GetMessageJobUserInList, 265
F GetMessageKeyInList, 266
JobNumber, 260
JobUser, 260
f42chr, 310 GetMessages, 267 Joins, 205
f82chr, 310 GetMessagesWithKey, 268
GetMessageUserProfileInList, 270
FFD, 156
FFilterComparison, 152
GetMessageValueInList, 270 K
GetNext, 181
FFilterValue, 153 Key Delimiter, 133
GetNextInCacheValues, 181
Field Description, 175 Key List, 202
GetNumberCalcFields, 182
Field Index, 175 GetNumberFields, 182 KeyDown, 226
Field Key, 202 GetPrevious, 183 KeyLength, 260
Field Keys, 203, 206 GetPreviousInCacheValues, 183 Keys, 161
Field Keys, 157, 161 GetRecordNumber, 186 KeySeparator, 153, 223
Field Length, 175 GetTotalDescription, 186
Fields, 154, 203 GetTotalFieldName, 187
File Description, 155 GetTotalFieldSeq, 187
L
FileName, 156 GetTotalKeySeq, 188 Less or Equal, 162
Files Description, 43 GetTotalNumberFields, 188 Less Than, 162
Filter, 124 GetValue, 189, 271 Level of Transaction Control,
FilterComparison, 222 Glyph, 213 145
FilterValue, 223 goWithoutRRN, 314 Library, 145, 158, 243, 256, 261
FilterWithField400, 223 Greater or Equal, 162 Library Management, 141
Filtre, 126, 222, 223, 230 Greater Than, 162 LibraryName, 157, 243
Focus, 126 Like, 162
Font, 230
Functions, 308
H List of AS/400, 134
List of the AS/400, 140
Header, 224 Lock, 192
G Hierarchy, 320 Lock a Record, 158
LockCurrent, 191
GENERAL, 89 LockOnRead, 158
GetByKeyFirst, 161 I LookUpCaption, 227
GetByKeyFirstInCacheValues, 163 IDAPI, 28, 29, 30, 53, 55, 57, 62, 63 LookUpFields, 228
GetByKeyLast, 163 ifCacheToScreen, 208, 317 LookUpFile400, 229
GetByKeyLastInCacheValues, 164 LookUpFilter, 230
ifDelete, 208, 317
GetByKeyNext, 165 LookUpFont, 230
ifEmpty, 317
GetByKeyNextInCacheValues, 166 lvALL, 315
GetByKeyPrevious, 167 ifFieldsListChanged, 208, 317
lvCHG, 314
GetByKeyPreviousInCacheValues, ifFileActiveChanged, 317
lvCS, 314
167 ifFileChanged, 208, 317
GetByRecordNumber, 168 ifFilterChange, 208
GetByRecordNumberInCacheValu ifFilterfieldChanged, 317 M
es, 169 ifInsert, 208, 317
GetCalcFieldDescription, 170 ifNavigPushed, 208, 317 Member, 146, 156
GetCalcFieldName, 170 ifNone, 208, 317 Memory, 133
GetCalcFieldSeq, 171 ifNotEmpty, 317 MessageAvailableCount, 261
GetCalcFieldValue, 171 MessageListCount, 262
ifScreenToCache, 208, 317
GetControlName, 231 ifUpdate, 208
GetCurrentInCacheValues, 172
GetDateFmt, 173
ifUpdatePushed, 317 N
ifUserRightChanged, 208, 317
GetDateSep, 173 Index, 215, 219, 225 Number of Fields, 183

© SystemObjects 1997-2008 www.systemobjects.com 330


O R tcLike, 222, 316
TCmd400, 122, 128, 250
Object of notification, 135, 145 Receive, 272 tcNone, 222, 316
OnActivation ReceiveByKey, 273 TDataArea, 122, 128, 254
TAS400, 139 ReDraw, 225 TDataQueue, 122, 128, 258
TFile400, 201 RemoveCalcField, 194 Test of the Router, 140
OnCalcFields, 121, 123, 201 RetrieveBuffer, 247 TField400, 126, 214
OnDeactivation rgNone, 158, 315 TFile400, 123, 124
TAS400, 139 rgRead, 158, 159, 315, 316 tgACTGRP, 146, 315
TFile400, 201 rgUpdate, 158, 159, 315, 316 tgJOB, 146, 315
OnDelete, 201 RRN, 125, 169, 186 TGrid400, 126, 220
OnExecute, 249
TLabel400, 127
OnInsert, 201
OnModify, 201 S TLookUp400, 127, 227
OnRead, 201 TMemo400, 127
Security Key, 35 TNavig400, 126
OnUpdateComponents, 202
SECURITY KEY, 323 TNotifyCancelEvent, 316
Open, 192
See Buffer, 246 toDefault, 159, 316
Opening a file, 149
Send, 274 toRRN, 159, 316
Optimizing, 203
SendWithKey, 274 transactional control, 124
otDATAARA, 315
Separator, 174 TSQL400, 125
otFILE, 315
Sequence Number, 187 TSQLA400Active, 210
otMSGQ, 315
SetBuffer, 248 TTransaction400, 124
otNONE, 315 SetCalcFieldValue, 195 Type, 177, 215
SetValue, 275 TypeIfFlag, 317
P SharingRights, 158 TypeOpen, 159
ssAscending, 315 Types, 313
ParamDecimals, 244, 250 ssDescending, 315
ParamDigits, 244, 251 stAll, 314
Parametre Cancel, 316 stFirst, 314 U
Params, 244, 251 stLast, 314
ParamType, 245, 252 UpdateCacheValuesWithBlank, 196
Pascal String, 185, 193 UpdateCacheValuesWithScreen, 197
PATH_DDS, 156 T UpdateControls, 232
pck2chr, 310 UpdateWithCacheValues, 198
TAS400, 124, 132 UpdateWithScreenValues, 199
PLUAlias, 141
ProgramName, 245 TCall400, 122, 128, 243 UserRights, 159
Protection Error, 142 tcEqual, 222, 316
TcGetListDataArea, 310
PutCacheFieldPValue, 193
TcGetListDataQueue, 311
V
PutControlName, 232
TcGetListFile, 311 Vallidation, 145
TcGetListLib, 311 Value, 185, 189, 194, 246, 252, 256
Q TcGetListMbr, 312 vertical scroll bar, 126
TcGetListProg, 312
QCMN, 132 tcGreaterOrEqual, 222, 316
tcGreaterThan, 222, 316 Z
tcLessOrEqual, 222, 316
zon2chr, 312
tcLessThan, 222, 316

© SystemObjects 1997-2008 www.systemobjects.com 331


Delphi/400 Object Pascal RAD solution for iSeries

C++Builder/400 C++ RAD development tool for iSeries

ActiveObjects/400 ActiveX iSeries components for


Visual Basic and Visual C++

UpdateObjects/400 Automatically deploy, install and update


all Windows-based applications across
any iSeries network or via the Internet.

CDSpool/400 Save, compress, index, archive and restore your iSeries


spool files on the network or on CD-ROM.

CDSpool System Archive and restore iSeries spool files.

eXchangeData/400 Bi-directional multi-format data exchange between iSeries and


Windows-based systems.

JACi400 A complete software suit to modernize and develop your


new System i web applications.

© SystemObjects 1997-2008 www.systemobjects.com 332


Let's keep in touch at:

SystemObjects Corporation
432 Park Avenue South
New York, NY 10016
USA
«(212) 295-2124
¬ (212) 295-2125
| [email protected]

SystemObjects International Ltd.


Devlin House
36 St George Street
Mayfair - London W1R 9FA
United Kingdom
« +44 (0) 20 7529 1467
¬+44 (0) 20 7529 1468
| [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

© SystemObjects 1997-2008 www.systemobjects.com 333

You might also like