You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

9.3 ACCESS_FILE

Reads records from any file in the system including files not known to LANSA. 


Warning:

When using this BIF ensure that the file and/or member exists. The job will fail if the file and/or member do not exist on the system.

The file must be opened before you can read records from it.

You cannot change a file/member once the file is open. To access a new file/member you must first close the open file/member.

If a library is not specified, the first file matching the requested file name in the library list will be used.

If a member is not specified the first member of the file will be used.


Arguments

No

Type

Req/ Opt

Description

Min Len

Max Len

Min Dec

Max Dec

1

A

Req

Action:

OPEN -
Open the file

READ -
Read a record

CLOSE -
Close the file

4

5



2

A

Req

File name

1

10



3

A

Opt

Library name

Default *LIBL

1

10



4

A

Opt

Member name

1

10



Return Values

No

Type

Req/ Opt

Description

Min Len

Max Len

Min Dec

Max Dec

1

A

Opt

Return Code

OK - Action completed

ER - Error occurred

EF - End of File

2

2



2

A

Opt

Returned data block 1

1

256



3

A

Opt

Returned data block 2

1

256



4

A

Opt

Returned data block 3

1

256



5

A

Opt

Returned data block 4

1

256



6

A

Opt

Returned data block 5

1

256



7

A

Opt

Returned data block 6

1

256



8

A

Opt

Returned data block 7

1

256



9

A

Opt

Returned data block 8

1

256



If the records on the file are longer than 256 bytes, bytes 1-256 of the record will be returned in data block 1, bytes 257-512 of the record in data block 2, bytes 513-768 of the record in data block 3, etc.

Example

To read the first 10 records from a requested file and member.

DEFINE     FIELD(#FILENM) TYPE(*CHAR) LENGTH(10)

DEFINE     FIELD(#LIBRARY) TYPE(*CHAR) LENGTH(10)

DEFINE     FIELD(#MEMBER) TYPE(*CHAR) LENGTH(10)

DEFINE     FIELD(#RETCOD) TYPE(*CHAR) LENGTH(2)

DEFINE     FIELD(#DATA1) TYPE(*CHAR) LENGTH(256)

**********

REQUEST  FIELDS(#FILENM #LIBRARY #MEMBER)


USE      BUILTIN(ACCESS_FILE) WITH_ARGS(OPEN #FILENM #LIBRARY

         #MEMBER) TO_GET(#RETCOD)


DOUNTIL  COND('(#I *GE 10) *OR (#RETCOD *NE OK)')

USE      BUILTIN(ACCESS_FILE) WITH_ARGS(READ #FILENM) 

         TO_GET(#RETCOD #DATA1)


* < process data1 >


ENDUNTIL


USE        BUILTIN(ACCESS_FILE) WITH_ARGS(CLOSE #FILENM....) TO_GET(#RETCOD)

  • No labels