sub files

32
SUBFILES 1

Upload: ajay-kumar-akurathi

Post on 26-Aug-2014

129 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Sub Files

SUBFILES

1

Page 2: Sub Files

Objectives

To understand the concepts of Subfile programming

2

Page 3: Sub Files

Prerequisites

Basic knowledge of RPG programming concepts.

3

Page 4: Sub Files

Course Outline

The concepts of subfiles Subfile Record Formats Subfile Control-Record Formats Types of Subfiles Subfile design using SDA. Subfile Processing Subfile validation and database updates. Addition and Modification Program Update and Delete Program Coding a message subfile.

4

Page 5: Sub Files

Sub file Display

5

Page 6: Sub Files

Introduction to Sub files

A group of records that have the same record format and are read from and written to a display station in one operation.

A subfile differs from other physical files in the following ways:

It is temporary, existing only until the RPG program that creates and owns it ends.

Within a subfile, each field’s description also identifies its screen location and its display attributes.

6

Page 7: Sub Files

Introduction to Subfiles (Contd.)

Subfile is displayed a “page” at a time.

Number of records in a subfile must also be specified in the DDS.

One display file can contain more than one subfile, and up to 12 subfiles can be active concurrently.

7

Page 8: Sub Files

Create Subfile

8

Page 9: Sub Files

Use of Subfiles

Subfiles can be used:

To view the output.

To request for more information about one of the items on the display.

To change one or more of the records.

9

Page 10: Sub Files

Use of Subfiles(Contd..)

To input data with no validity checking

To input data with validity checking

Combination of display with modification and the input of new records.

10

Page 11: Sub Files

Record Formats of a Subfile

Records in a subfile are specified in the DDS for the file.

A Subfile has 2 record formats: Subfile Control Record Format Subfile Record Format

The subfile record format must precede the subfile control record format.

Footer record is optional to create a subfile display. If used, definition of the function keys is given here.

11

Page 12: Sub Files

Subfile Control Record Format

Defines the attributes of the subfile, the search input field, constants, and function keys.

Defines the constants to be used as column headings for the subfile record format.

12

Page 13: Sub Files

Data Description Specifications for a subfile Control-record format

13

Page 14: Sub Files

Subfile Record Format

The subfile record format declares

Field’s name

Field’s definition.

Field definitions can either be specified explicitly or by reference to a field definition in a physical file

Handles the physical read, write, or control operations of a subfile

14

Page 15: Sub Files

Data Description Specifications for a subfile record format

15

Page 16: Sub Files

Subfile Keywords

Keywords used:

SFL - identifies the record format as a subfile

SFLCTL - name of the associated subfile

SFLCLR - indicates when the subfile should be cleared

SFLDSPCTL- indicates when to display the subfile control record

16

Page 17: Sub Files

Subfile Keywords

SFLDSP - indicates when to display the subfile

SFLPAG - indicates the total number of records in a page

SFLSIZ - indicates the number of records the subfile can contain. Maximum – 9999

SFLEND - Displays a plus sign, by default, to indicate when there are more records in subfile. Specify *MORE to display text.

17

Page 18: Sub Files

Subfile Keywords (Contd.)

SFLFOLD - Specifies the CA or CF key used to fold Multiformat subfile to single line format.

SFLDROP - Initially displays only the first line of the subfile records, and reacts to a function key by switching into a multiline format.

SFLINZ - Initializes all the records in a subfile

SFLNXTCHG- Modifies the subfile record so that it is read on a get-next-changed

operation16

Page 19: Sub Files

Subfile Keywords (Contd.)

SFLRCDNBR - Specifies which page of the subfile record should be displayed.

SFLCSRRRN - Returns the relative record number of the subfile record on which the

cursor is placed. OVERLAY - Displays the record without first clearing the screen.

ROLLUP - Indicator is set on in the program when the user presses the Roll Up key.

19

Page 20: Sub Files

Subfile Keywords (Contd.)

ROLLDOWN - Indicator is set on in the program when the user presses the Roll Down key HELP - Allows the user to press the Help key for a displayed message that describes the valid function keys.

PUTRETAIN - Allows the value that is entered in the SRHCOD field to be kept in the display.

18

Page 21: Sub Files

Specifying Keywords in Subfile

19

Page 22: Sub Files

Example of Sub file record formats A R S01 SFL A S1BUSY 13A O 8 28 A S1TENT 13A O 8 44 A S1OUTO 13A O 8 60 A S1UNKN 13A O 8 76 A R C01 SFLCTL(S01) A SFLSIZ(0011) A SFLPAG(0010) A OVERLAY A 27 SFLDSP A 28 SFLDSPCTL A N27 SFLCLR A 29 SFLEND

20

Page 23: Sub Files

Types of Subfiles

Load All Subfile Loads all records of the file into a large subfile before displaying the first screen

Single Page Subfile Loads a single page of records and displays the subfile

Expanding Subfile Loads the records to fill a single page and displays the subfile

21

Page 24: Sub Files

LOAD ALL Subfile

SFLSIZ value should be one more than SFLPAG value.

Record Limit is 9999.

Automatic support for ROLLUP and ROLLDOWN keys.

User has to wait until entire file is loaded.

Data is only updated when the subfile is reloaded.

Changes made to the data after the subfile is loaded will not be apparent.

22

Page 25: Sub Files

SINGLE PAGE Subfile

Replaces the page with the next/previous page of data.

Subfile size(SFLSIZ) value is equal to SFLPAG.

Both ROLLUP & ROLLDOWN keys should be handled.

Preferred for working with dynamic data.

Uses least memory.

No limit to the number of records.23

Page 26: Sub Files

EXPANDING Subfile

Adds a page at a time to the subfile.

SFLSIZ value should be one more than the subfile page(SFLPAG) value.

Record Limit is 9999.

Automatic support for ROLLUP but ROLLDOWN key should be handled.

Pages added when the Page down key is pressed are up-dated at the time they are added to the subfile.

24

Page 27: Sub Files

Example of Expanding Subfile

Handling of page down key

Subfile size 1 greater than subfile page

25

Page 28: Sub Files

Using Subfile in a program

To use a subfile the following basic operations should be performed in the high level language program

Initialize the subfile by reading records from database file and writing them to subfile.

Send subfile to the display in one output operation using subfile control record format.

26

Page 29: Sub Files

Using Subfile in a program(Contd..)

After the user reviews the records, changes them, or enters new records) read the subfile control record format

Process each record in subfile individually, updating the database file or writing new records to the database file as required.

26

Page 30: Sub Files

Important Terms used with Subfiles

Relative Record Number(RRN)

A number which associates a file record to the location in the file where the record resides.

READC Operation

An RPG opcode strictly used with subfiles.

It returns the next changed subfile record to the program.

27

Page 31: Sub Files

Summary

The concepts of subfiles Subfile Record Formats Subfile Control-Record Formats Types of Subfiles Subfile design using SDA. Subfile Processing Subfile validation and database updates. Addition and Modification Program Update and Delete Program Coding a message subfile.

31

Page 32: Sub Files

Thank You