4

I've started to do some programming in ILE RPG and I'm curious about one thing - what exactly is the record format? I know that it has to be defined in physical/logical/display files but what exactly it does? In an old RPG book from 97 I've found that "Each record format defines what is written to or read from the workstation in a single I/O operation"

In other book I have found definition that record format describe the fields within a record(so for example length, type like char or decimal?).

And last, what exactly means that "every record within a physical file must have an identical record layout"?

I'm a bit confused right now. Still not sure what is record format :F.

mike
  • 1,233
  • 1
  • 15
  • 36
h00jraq
  • 85
  • 1
  • 8

4 Answers4

4

Still not sure what is record format :F

The F Specification: This specification is also known as the File specification. Here we declare all the files which we will be using in the program. The files might be any of the physical file, logical file, display file or the printer file. Message files are not declared in the F specification.

what exactly means that "every record within a physical file must have an identical record layout"?

Each and every record within one physical file has the same layout.

Let's make a record layout of 40 characters.

----|---10----|---20----|---30----|---40
20150130  DEBIT     00002100
20150130  CREDIT    00012315

The bar with the numbers is not part of the record layout. It's there so we can count columns.

The first field in the record layout is the date in yyyymmdd format. This takes up 8 characters, from position 1 to position 8.

The second field is 2 blank spaces, from position 9 to position 10.

The third field is the debit / credit indicator. It takes up 10 characters, from position 11 to position 20.

The fourth field is the debit / credit amount. It takes up 8 positions, from position 21 to position 28. The format is assumed to be 9(6)V99. In other words, there's an implied decimal point between positions 26 and 27.

The fifth field is more blank spaces, from position 29 to position 40.

Every record in this file has these 5 fields, all defined the same way.

Gilbert Le Blanc
  • 50,182
  • 6
  • 67
  • 111
  • 4
    The record format is exactly as the book describes it: it's an I/O buffer. If you are familiar with C, it is very much like a struct(). The record format gives a name to the particular arrangement of fields within the buffer. – Buck Calabro Jan 30 '15 at 16:54
2

A "record format" is a named structure that is used for device file I/O. It contains descriptions of each column in the 'record' (or 'row'). The specific combination of data types and sizes and the number and order of columns is hashed into a value that is known as the "record format identifier".

A significant purpose is the inclusion by compilers of the "record format identifier" in compiled program objects for use when the related file is opened. The system will compare the format ID from the program object to the current format ID of the file. If the two don't match, the system will notify the program that the file definition has changed since the program was compiled. The program can then know that it is probably going to read data that doesn't match the definitions that it knows. Nearly all such programs are allowed to fail by sending a message that indicates that the format level has changed, i.e., a "level check" failed.

The handling of format IDs is rooted in the original 'native file I/O' that pre-dates facilities such as SQL. It is a part of the integration between DB2 and the various program compilers available on the system.

The 'native' database file system was developed using principles that eventually resulted in SQL. A SQL table should have rows that all hold the same series of column definitions. That's pretty much the same as saying "every record within a physical file must have an identical record layout".

Physical database files can be thought of as being SQL tables. Logical database files can be thought of as being SQL views. As such, all records in a physical file will have the same definitions, but there is some potential variation in logical files.

user2338816
  • 2,163
  • 11
  • 11
  • The whole concept makes much more sense when you consider certain files (LFs, DPSFs, PRTFs, …) are allowed to have *multiple* record formats in one source member. (LFs have restrictions with key fields in multiple record format files.) – PoC Jun 26 '21 at 08:43
2

A record format It's something you learn in old school. You read a file (table) and update/write through a record format.

DSPFD FILE(myTable)

Then you can see everything about the file. The record format name is in there.

danny117
  • 5,581
  • 1
  • 26
  • 35
1

New or Young Developers believe that every record in a physical file must be identical, but in ancient times, the dinosaurs walk on earth and in one single file you could have several types of records or "record formats", so as the name indicates a record format is the format of a record within a file.

Jairo R. Flores
  • 724
  • 4
  • 11
  • 1
    Although it's true that in `ancient times` there could be several types of records, a physical database file in the AS/400 series of systems will allow only a single record format. A "record format" is a specific term in those systems, and it indicates a specific, single record structure. – user2338816 Feb 04 '15 at 08:05
  • The concepts of fields, tables, schemas, etc. etc. are relatively new. In older versions of the iSeries this concepts doesn't existed. You had **flat files**. With this flat files the **record format** has to be defined within the programs. But its ok. This discussion has no benefit. – Jairo R. Flores Feb 04 '15 at 15:31
  • No, flat files on AS/400 series systems always had a single (unstructured) record format. That is unchanged even today. However, as you noted, a program could (and still can) provide a program-described structure that overlaid the record format of the file. A look at the external file description would verify that only a single record format existed in the database; and for a **physical file**, only a single **record format** could be referenced in a program. But multiple "record names" (different definition from the "record format" name) could be described. – user2338816 Feb 05 '15 at 02:50