Вы находитесь на странице: 1из 21

SUBFILES

A subfile is a temporary area in memory to store records written to & read from a display file device. These records are handled as a unit for screen I/O. They may be used for any of the database file maintenance functions where more than one record is to be displayed at one time: For inquiry processing, a subfile may be created to read a group of records from a database file & load them to display file. For update processing, subfile can be used to store group of records read from a database file. User can update all or selected records. For addition processing, we can use subfile to load the new records that may be edited before writing them to physical file. For deletion processing, a subfile may be created to load a group of records that may be deleted. Subfiles are created like any display file with SEU or SDA. However they must include special keywords that control their loading, display & processing functions. At least 2 record formats must be specified in the display file that supports a subfile. The subfile record defines the area where the data is stored. Subfile control record defines the processing functions. Processing functions include number of records to display on the screen, display of subfile data etc. Subfile Processing - Sequence of operations o For inquiry, addition, update & delete, records are read from a database file & written to a subfile one at a time until the subfile is full or until end of database file is reached. o After the subfile is full or the database file is at the end of file, all the records in the subfile are displayed by one operation. o Depending on the type of processing the displayed records may be individually reviewed, changed or deleted. o For Add, Update & Delete each record is read from the subfile & the related database file modified accordingly. An RPG program that processes a subfile must define it in the File Specification entry for the related display file. A keyword for a record counter, the continuation symbol the keyword SFILE & the subfile record name must be specified in the definition of a display file. Keywords o SFL: Record level keyword that specifies the subfile record format. o SFLCTL: Record level keyword, which specifies the subfile control record format. It controls functions like display, clearing & initialization.

________________________________________________________________________ 04: Subfiles Page 1 of 21

SFLSIZ: A record level control record keyword, which specifies the number of records that may be loaded in the subfile. . This value should be either equal to or greater than the SFLPAG value. Maximum no of records that can be loaded in a subfile is 9,999.

o SFLNXTCHG: This is a record-level keyword on the subfile record format. While processing subfile record READC opcode is commonly used. READC reads only the changed records. MDT (modified data tag) is associated with each record. When user makes changes in the subfile record MDT is switched on. Some times it may be a need to process all the records of a subfile, SFLNXTCHG forces READC to read each and every record as if it is a changed record. Consider the situation that user has validates the data and displays the screen of the subfile. If the user just pressed Enter key instead of correcting the errors, READC will not sense the changed records. Thus if SFLNXTCHG is provided, it will forces READC to read each record as a changed record in a subfile. o SFLRCDNBR: This is a field level keyword on the subfile control record format to specify that the page of the subfile to be displayed. It will display the page containing the record whose relative record number is in this field. If you do not specify this keyword, the OS/400 program displays the first page of the subfile by default. Using the optional parameter value CURSOR with keyword SFLRCDNBR causes the cursor to be positioned on that record upon display. o SFLPAG: This is a record level keyword for control record format. It specifies the number of records that may be displayed on screen at a time. The number follows the keyword and is enclosed in parentheses. You typically determine this number by calculating the number of available screen lines, after taking into account all other lines to be displayed along with the subfile. o SFLDSP: This keyword displays the subfile when the RPG/400 program issues an output operation. o SFLCLR: Clears a subfile of all records before new records are loaded. An option indicator is required for this keyword, or the system would clear the subfile on every output operation to the control record. The indicator often is the reverse of the indicator used for keywords SFLDSP and SFLDSPCTL, so that you clear the subfile in one output operation and display the subfile and the control-record information in a second output operation. o SFLINZ: Initializes all records in a subfile. Alpha fields are initialized to blanks & numeric fields to zero.

________________________________________________________________________ 04: Subfiles Page 2 of 21

o SFLDSPCTL: Displays control record format and enables SFLDSP. The fields or literals from the control record format are displayed one time, as headings, before the list of subfile records. o SFLEND: This keyword displays a plus sign in the lower right corner of the screen. The plus sign indicates that subfile contains some more records that can be displayed on the screen. The plus sign will not be displayed if subfile is at end. An indicator should condition this keyword. When the indicator causes SFLEND to be in effect, the system does not display a plus sign. Thus, the program should turn on the indicator for SFLEND, and disable PAGEDOWN with the opposite indicator when no additional matching records remain to be put into the subfile. o SFLRNA: This keyword is used with SFLINZ for initialization of a subfile with no active records. A user may key in data into blank subfile. SFLRNA must be specified when SFLINZ keyword is included in the coding of the subfile. o SFLMSG: Specifies a subfile record error that is included in the control record format & displays on the error message line. o SFLDROP: Controls the folding of records when they are too long to display at one time on the screen. This keyword is used along with a command key that the workstation user may press to display the folded format of the subfile record. Note: Keywords like SFLCLR, SFLDSPCTL, and SFLEND etc are usually conditioned by an indicator, which is turned on in an RPG program at the appropriate time in the processing cycle.

Identifying the Subfile within the File Specification

RPG IV requires you to identify a subfile within the File Specification of the display file with which you want to associate the subfile. You associate the subfile and relative record number field with a workstation file by using keyword SFILE in the Keywords area of the File Specification (positions 4480).
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 Ffilename++IPEASFRlen+LKlen+AIDevice+.Keywords++++++++++++++++++++ +++++++++ FSECTIONL IF E K DISK FSECTINQC CF E WORKSTN SFILE(SFLSECT:RRN) F INDDS(Indicators)

________________________________________________________________________ 04: Subfiles Page 3 of 21

*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++++++++++++++++ ++++ A* Subfile control record format for course inquiry application A R CTLSECT SFLCTL(SFLSECT) A SFLPAG(15) A SFLSIZ(80) A 50 SFLCLR A N50 SFLDSPCTL A N50 SFLDSP

File Specification Entries The subfile record format name, a colon (:), and the field to be used to store the relative record number appear within parentheses following the SFILE keyword. Relative record number simply means the position of the record within the subfile (e.g., first subfile record, second subfile record). This field is needed because RPG IV writes records to a subfile (and retrieves records from a subfile) based on the value of the relative record number. Paging through the Subfile In some cases, there may be more records to be displayed than can fit on the screen. In this case, the system uses the value specified for SFLSIZ to retrieve the records into the subfile. The system displays the number of records specified by SFLPAG. As the user presses the Page Down or Roll keys, subsequent records from the subfile are displayed, replacing the records on the screen.

Easiest Method to Code: Load All Subfile

________________________________________________________________________ 04: Subfiles Page 4 of 21

In our first version of this display file, SFLSIZ is defined with a value of 80, and the value of SFLPAG is 15. This approach involves defining the subfile size large enough to hold the maximum expected number of records and then loading all the appropriate data into the subfile before any record display. This method is the easiest to code but results in the slowest initial response time. Once display begins, however, paging through the subfile is fast.
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++++++++++++++++ ++++ ... * Record format for subfile A R SFLSECT SFL A SECTNO R O 4 14 A INSTR R O 4 23 A ROOM R O 4 41 A DAYS R O 4 49 A BEGTIME R Y O 4 57EDTWRD('0 : ') A ENROLL R Y O 4 66EDTCDE(3) * Record format for subfile control A R CTLSECT SFLCTL(SFLSECT) A SFLPAG(15) A SFLSIZ(80) A 50 SFLCLR A N50 SFLDSPCTL A N50 SFLDSP A OVERLAY A COURSENO 6A O 1 28 A 1 35'Course Information' A 3 12'Section' A 3 24'Instructor' A 3 41'Room' A 3 49'Days' A 3 57'Time' A 3 64'Enroll.'

Footer Record Definition

________________________________________________________________________ 04: Subfiles Page 5 of 21

The display file will also include a footer record definition, which contains prompts about active function keys. This record format is needed because the control record format cannot reference screen lines that would fall both above the subfile display (i.e., the column headings) and below the subfile (the function key prompts).
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++++++++++++++++ ++++ ... * Footer record format A R FOOTER A 21 2'Press Enter to continue.' A 23 2'F3=Exit F12=Cancel'

Pseudocode for an application

In our application, once the user has entered the desired course, the program needs to use that value to access the appropriate records in logical file SECTIONL and write them to the subfile. Loading the subfile continues until no additional appropriate records (i.e., no more sections for that course) exist. Then the subfile can be displayed. The following pseudocode illustrates the logic needed for this application. WHILE user wants to continue Display inquiry screen IF user doesnt want to exit Access start of appropriate sections IF section not found Turn on error indicator ELSE Clear subfile Load subfile Display subfile ENDIF ENDIF ENDWHILE Pseudocode for Loading the Subfile Because SFLPAG is less than SFLSIZ the system will handle any user request to page up or page down. The pseudocode for loading the subfile using this method of handling subfiles is as follows: Read a matching section record WHILE there are more appropriate section records Increment relative record number Write a record to the subfile Read a matching section record ENDWHILE Complete DDS for Display File

________________________________________________________________________ 04: Subfiles Page 6 of 21

This is the complete DDS for the display file. Notice that the control record format includes the record-level keyword OVERLAY so that the footer record format will not be erased when the subfile is displayed.
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 AAN01N02N03T.Name++++++RLen++TdpBLinPosFunctions+++++++++++++++++++++++ ++++ * Display file SECTINQC, coded for loading the entire subfile at once A INDARA A CA03(03 'F3=Exit') A CA12(12 'F12=Cancel') A REF(SECTIONS) * Record format of initial inquiry screen A R CRSEINQ A BLINK A 1 28'Course Inquiry' A 3 2'Type value, then Enter.' A 5 5'Course number . .' A COURSENO 6A B 5 24 A 90 ERRMSG('Course not found' 90) A 23 2'F3=Exit F12=Cancel' * Record format for subfile A R SFLSECT SFL A SECTNO R O 4 14 A INSTR R O 4 23 A ROOM R O 4 41 A DAYS R O 4 49 A BEGTIME R Y O 4 57EDTWRD('0 : ') A ENROLL R Y O 4 66EDTCDE(3) * Record format for subfile control A R CTLSECT SFLCTL(SFLSECT) A SFLPAG(15) A SFLSIZ(80) A 50 SFLCLR A N50 SFLDSPCTL A N50 SFLDSP A OVERLAY A COURSENO 6A O 1 28 A 1 35'Course Information' A 3 12'Section' A 3 24'Instructor' A 3 41'Room' A 3 49'Days' A 3 57'Time' A 3 64'Enroll.' * Footer record format A R FOOTER A 21 2'Press Enter to continue.' A 23 2'F3=Exit F12=Cancel'

RPG IV Implementation of Pseudocode

________________________________________________________________________ 04: Subfiles Page 7 of 21

The following code illustrates the RPG IV implementation of the design we've depicted in pseudocode. We will look at some parts of it.

FSECTIONL IF E K DISK FSECTIONQC IF E WORKSTN SFILE(SFLSECT:RRN) F INDDS(Indicators) D RRN S 20 D Indicators DS 99 D Exit 3 3N D Cancel 12 12N D SflClr 50 50N D CrsNotFnd 90 90N C** Calculations for Subfile application when entire subfile is loaded C** before any display takes place C** Partial keylist to access SectionL file by C** C CourseKey KLIST C KFLD CourseNo C** C** Process loop until user wants to exit C** C DOW NotExist C EXFMT CrseInq C** C IF Not Exist C CourseKey SETLL SectionL C** C** If no matching section in file, turn on the error indicator C** C IF Not %Equal(SectionL) C EVAL CrseNotFnd = *ON C** C ELSE C** C** Otherwise clear and then load subfile C** C EXSR ClearSF C EXSR LoadSF C** C** Write Footer to the screen, then display Subfile via control rec C** C WRITE FOOTER C EXFMT CtlSect

ENDIF

________________________________________________________________________ 04: Subfiles Page 8 of 21

C** C ENDIF C ENDDO C** C EVAL *INLR = *ON C RETURN C** C** Subroutine to clear the subfile and set the RRN = 0 C** C BEGSR C EVAL SflClr = *ON C WRITE CtlSect C EVAL SflClr = *OFF C EVAL RRN=0 C ENDSR C** C** Subroutine to load the subfile until no more records in /section C** C LoadSF BegSR C CourseKey READE

Clearing the Subfile

________________________________________________________________________ 04: Subfiles Page 9 of 21

The subfile is cleared in subroutine ClearSF. First the indicator used to condition the SFLCLR display file keyword is set on. Then the CTLSECT subfile control record format is displayed using the WRITE operation.
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++ ++++ CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq .... CL0N01Factor1+++++++Opcode(E)+Extendedfactor2+++++++++++++++++++++++++++++ * Subroutine to clear the subfile and reset RRN to 0 C ClearSF BEGSR C EVAL SflClr = *ON C WRITE CtlSect C EVAL SflClr = *OFF C EVAL RRN = 0 C ENDSR

Writing Records to the Subfile Record Format The subfile is loaded in the LoadSF subroutine by writing records to the subfile record format based on the relative record number field, which is incremented before each successive WRITE operation. Subroutine to load the subfile until no more section records C LoadSF BEGSR C CourseKey READE SectionL C DOW NOT %EOF(SectionL) C EVAL RRN=RRN+1 C WRITE SFLSect C CourseKey READE SectionL C ENDDO C ENDSR

Displaying the Footer and Subfile ________________________________________________________________________ 04: Subfiles Page 10 of 21

After clearing and loading the subfile, the program displays the footer using the WRITE operation rather than the EXFMT since a user response to the footer is not needed. Then the program displays the subfile by executing the subfile control record format.
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq .... CL0N01Factor1+++++++Opcode(E)+Extendedfactor2+++++++++++++++++++++++++++++ ... C EXSR ClearSF C EXSR LoadSF * Write footer to screen and then display subfile via control record fo rmat. C WRITE Footer C EXFMT CtlSect

Subfile Size One Greater Than Page

o Retrieving More Records Than a Page Holds There are several different methods for loading records into a subfile in order to display them. The first method entails setting the subfile size one more than the page size. When more records are retrieved than will fit on the page, a plus sign will display in the lower right corner of the display. o Subfile Automatically Expanded When the user attempts to scroll to the next page, control returns to the program, which must load an additional page (if additional appropriate records exist). When the system loads an additional page, it automatically expands the subfile, regardless of its stated size. The user can page back up through the subfile records already loaded and the system will automatically handle it. o PAGEDOWN and ROLLUP Besides setting the SFLSIZ one greater than the SFLPAG, you must add the PAGEDOWN keyword (or its equivalent, ROLLUP) and associate it with an indicator to let the system send control back to the program when the user attempts to scroll to records not yet in the subfile. You can condition PAGEDOWN on an indicator that you set in your program based on whether more matching records are available in the data file.

________________________________________________________________________ 04: Subfiles Page 11 of 21

*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++++++++++++++++ ++++ ... ... * Record format for subfile control A R CTLSECT SFLCTL(SFLSECT) A SFLPAG(15) A SFLSIZ(16) A 50 SFLCLR A N50 SFLDSPCTL A N50 SFLDSP A OVERLAY A N95 PAGEDOWN(21 'Page Down') A 95 SFLEND A SFLRCD 4S 0H SFLRCDNBR(CURSOR) A COURSENO 6A O 1 28 A . . .

SFLEND

*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++++++++++++++++ ++++ ... ... * Record format for subfile control A R CTLSECT SFLCTL(SFLSECT) A SFLPAG(15) *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 A SFLSIZ(16) A 50 SFLCLR A N50 A N50 A A N95 A 95 A A SFLDSPCTL SFLDSP OVERLAY PAGEDOWN(21 'Page Down') SFLEND SFLRCDNBR(CURSOR) 1 28

SFLRCD COURSENO

4S 0H 6A O

________________________________________________________________________ 04: Subfiles Page 12 of 21

Using the optional parameter value CURSOR with keyword SFLRCDNBR causes the cursor to be positioned on that record upon display.
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++++++++++++++++ ++++ ... ... * Record format for subfile control A R CTLSECT SFLCTL(SFLSECT) A SFLPAG(15) A SFLSIZ(16) A 50 SFLCLR A N50 SFLDSPCTL A N50 SFLDSP A OVERLAY A N95 PAGEDOWN(21 'Page Down') A 95 SFLEND A SFLRCD 4S 0H SFLRCDNBR(CURSOR) A COURSENO 6A O 1 28

________________________________________________________________________ 04: Subfiles Page 13 of 21

Indicators for PAGEDOWN and SFLEND

The RPG program must include the indicators needed for the PAGEDOWN and SFLEND keywords. We will name the fields for these indicators similar to the keywords they condition in the display file.
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++ ++++ * Indicator data structure D Indicators DS 99 D Exit 3 3N D Cancel 12 12N D PagDwn 21 21N D D D SflClr CrsNotFnd SflEnd 50 90 95 50N 90N 95N

How It Works In this variation, subroutine LoadSF reads and writes only 15 records to the subfile. If no additional appropriate sections remain before reading 15 records, the program turns on the SFLEND indicator to disable scrolling past the last subfile page, and the loop ends. To determine whether additional pages can be built, the subroutine reads one additional record after loading an entire subfile page before displaying the new page.
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq .... CL0N01Factor1+++++++Opcode(E)+Extendedfactor2+++++++++++++++++++++++++++++ * Subroutine to load one page of subfile or until no more records exist * First record of page already read by CHAIN or previous READE C LoadSF BEGSR C EVAL SflRcd = RRN + 1 * Loop 15 times to load the page. C DO 15 C EVAL RRN = RRN + 1 C WRITE SFLSect C CourseKey READE SectionL C EVAL SflEnd = NOT %FOUND(SectionL) * Early exit if no more matching records C IF SflEnd C LEAVE C ENDIF C ENDDO C ENDSR

Return of Control

________________________________________________________________________ 04: Subfiles Page 14 of 21

After displaying the screen the first time, each time control returns to the program from the screen, if the Page Down key triggered the return; the program must load the next page of the subfile and return control to the screen. In the mainline, a loop of load-anddisplay continues until the user presses some key other than the Page Down key.
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq .... CL0N01Factor1+++++++Opcode(E)+Extendedfactor2+++++++++++++++++++++++++++++ ... C EXSR ClearSF C EXSR LoadSF * Initialize SFLEND indicator to off. C EVAL SflEnd = *OFF * Write footer to screen and then display subfile via control record fo rmat. C WRITE Footer C EXFMT CtlSect * Loop to load page and display as long as user presses page key. C DOW PagDwn C EXSR LoadSF C EXFMT CtlSect C ENDDO

Size not Automatically Expanded ________________________________________________________________________ 04: Subfiles Page 15 of 21

When you set the subfile size equal to the page size, the system does not automatically expand the size of the subfile. Besides changing the SFLSIZ, you need to add either a PAGEUP (or ROLLDOWN) keyword or some way of enabling the program to move backwards through the records. When the subfile size is the same as the page size, scrolling forward replaces the existing page with the next page, and scrolling backward requires loading records into the subfile.
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 AAN01N02N03T.Name++++++RLen++TdpBLinPosFunctions++++++++++++++++++ +++++++++ ... ... A R CTLSECT SFLCTL(SFLSECT) A SFLPAG(15) A SFLSIZ(15) A 50 SFLCLR A N50 SFLDSPCTL A N50 SFLDSP A OVERLAY A N95 PAGEUP (20 'Page Up') A 95 SFLEND A CA05(05 'Restart sections') A COURSENO 6A O 1 28

Subfile size same as the page size

When the subfile size is the same as the page size, scrolling forward replaces the existing page with the next page, and scrolling backward requires loading records into the subfile. Rather than enable the Page Up key, we will enable the F5 key.
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++++++++++++++++ ++++ . . . ... * Record format for subfile control A R CTLSECT SFLCTL(SFLSECT) A SFLPAG(15) A SFLSIZ(15) A 50 SFLCLR A N50 SFLDSPCTL A N50 SFLDSP A OVERLAY A N95 PAGEDOWN (21 'Page Down') A 95 SFLEND A CA05(05 'Restart sections') A COURSENO 6A O 1 28

Clearing and Loading Subfile Each Time

________________________________________________________________________ 04: Subfiles Page 16 of 21

Previous versions of this program would clear and load the subfile once and then load additional pages into the subfile in response to the user scrolling forward. In this version, we must clear and load the subfile each time the user either scrolls or presses F5. If the user scrolls, the program should put the next set of section records into the subfile. If the user presses F5, the program will chain to the first section record again and load the first set of records back into the subfile.
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq .... CL0N01Factor1+++++++Opcode(E)+Extendedfactor2+++++++++++++++++++++++++++++ . . . * Loop until user no longer wants to scroll or restart the section. C DOU NOT Refresh AND NOT PagDwn * If user wants to restart section, chain and reload subfile. C IF Refresh C CourseKey CHAIN SectionL C ENDIF * Clear and load subfile; then write footer and display subfile page. C EXSR ClearSF C EXSR LoadSF C WRITE Footer C EXFMT CtlSect C ENDDO

Subfiles and Changed Records


o READC The READC (Read Next Changed Record) operation used only with subfiles enables the user not just to inspect the data but also to make changes in the data. The READC operation requires a subfile name in Factor2. Generally used within a loop, the READC operation reads only those records from a subfile that were changed during a prior EXFMT operation.

*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+. .. 8 CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq .... C READC SFLSect

When no changed subfile records remain to be read, the %EOF built-in function is set on. Because of the READC operation, a user can make as many changes as necessary to various records in the subfile in a single display; all these changes can then be written to the data file when control is returned to the program.

________________________________________________________________________ 04: Subfiles Page 17 of 21

*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq .... C READC SFLSect C DOW NOT %EOF C FullKey CHAIN SectionL C IF %FOUND(SectionL) C UPDATE SecRec C ENDIF C READC SFLSect C ENDDO

Hidden Fields The field for SFLRCDNBR can be a hidden field. You signify a hidden field by entering an H in position 38 (Usage) of the DDS specifications. Hidden fields do not include a screen-location specification because, although they are part of the screen, they are not displayed. Your program can write a value to a hidden field and read the field's value, but the user cannot see or change the value of the field.

MESSAGE SUBFILES ________________________________________________________________________ 04: Subfiles Page 18 of 21

To create a message subfile record type required is SFLMSG and Subfile control format. This will be the code in your DDS: A R SFLMSG A A A MSGID A PGNAM A* A R SFLMSGC A A A A N30 A A A A PGNAM SFL TEXT ('Message Subfile') SFLMSGRCD (24) SFLMSGKEY SFLPGMQ (10) SFLCTL (SFLMSG) OVERLAY SFLDSP SFLDSPCTL SFLEND SFLSIZ (0002) SFLPAG (0001) SFLINZ SFLPGMQ (10)

o SFLMSGRCD (Subfile Message Record) Keyword. Specifying the SFLMSGRCD keyword on the subfile record format identifies this subfile as a message subfile. The parameter value specified causes the subfile to appear on line 24 of the display. The fields MSGID and PGNAM are user-defined names given to the two fields required for the subfile record format for a message subfile. The only specifications allowed for them are their names and the SFLMSGKEY and SFLPGMQ keywords, in the order shown. This subfile is paged by the OS/400 program when the display station user presses a Page Up or a Page Down key. The SFLEND keyword allows the OS/400 program to display a plus sign whenever the subfile can be paged up. o SFLMSGKEY (Subfile Message Key) Keyword: -To select messages from a program message queue for display, your program places a message reference key in this field. o SFLDSP (Subfile Display) Keyword:- Use this record-level keyword on the subfile control record format so that the OS/400 program displays the subfile when your program sends an output operation to the subfile control record format. If you do not use an option indicator with this keyword, a page of subfile records is displayed on every output operation to the subfile control record format.

o SFLDSPCT (Subfile Display Control) Keyword: - Use this record-level keyword on the subfile control record format so that the OS/400 program displays

________________________________________________________________________ 04: Subfiles Page 19 of 21

fields in the subfile control record format when your program sends an output operation to the subfile control record format. If you do not use an option indicator with this keyword, the subfile control record is displayed on every output operation to the subfile control record format o SFLEND (Subfile End) Keyword: -Use this record-level keyword on the subfile control record format to permit the display of a plus sign (+) or text (More... or Bottom) in the lower right display location occupied by the subfile or a scroll bar. The plus sign or More... text indicates that the work station user can move the text lines on the subfile to display more records by pressing the Page Up key o SFLSIZ (Subfile Size) Keyword: - Use this record-level keyword on the subfile control record format to specify the number of records in the subfile. The maximum number of records allowed is 9999. This keyword is required for the subfile control record format. o SFLPAG (Subfile Page) Keyword: - Use this record-level keyword on the subfile control record format to specify the number of records in the subfile to be displayed at the same time. How does a RPG program send messages to message subfile? 1. First clear your program message queue by calling a CL program containing command RMVMSG. The only parameter to this CL program will be your RPG program name. This should be done before writing anything in any other control record format of your display file. 2. Then while sending messages to your program message queue, call another CL program containing command SNDPGMMSG. The parameters to this CL program will be Message file name and Message Identifier. This CL program will fetch required message from specified message file and will send that message to your program message queue. 3. Now job of RPG as well as CL program is over. Now its responsibility of OS/400, which will load your message subfile with messages in your program message queue.

4. If there are more than one message in your message subfile, + sign will be displayed. By positioning cursor on message subfile and be pressing Page Down key will display remaining messages one by one.

________________________________________________________________________ 04: Subfiles Page 20 of 21

CL Program (SNDPGMM SG)

Message File

RPG Program

Program Message Queue CL Program (RMVMSG)

Message Subfile

________________________________________________________________________ 04: Subfiles Page 21 of 21

Вам также может понравиться