Results for "Sub file"
Subfile Types



Explain about sub files in AS/400.

If we want to access multiple records, then we have to go sub-files. There are three types of sub-files.

                    i.          Load all by this method we have to load only 9999 records. Here the page up and 
                    page down has been control by system. In this method sub-file size is greater than  
                    sub-file page.

                  ii.          Load on demand [SIZ>PAG] by this method we can load only 9999 records. Here 
                   the page up control can be controlled by system and user controls the page down. In 
                   this method sub-file size is greater than sub-file page.
          iii.     Load on demand [SIZ=PAG] by the method we can load unlimited records.Here user     
                    controls both of the Page-up and Page-down. In this method sub-file size is equal to sub- 
                    file page. This type is more advantage

Unknown Saturday, 1 June 2013
Subfile keywords


Explain all Subfile keywords.

SFLENTER - This record level keyword used to assign as a roll-up key. You can define another key for enter purpose.

SFLINZ - This record level keyword is used to initialize the Subfile.

SFLLIN - This record level keyword is used to define how many spaces are to be inserted between Subfile records.

SFLMSG - This record level keyword, which identifies the subfile, is a Message Subfile.

            SFLMSGID - This record level keyword is used as like as SFLMSG. Here you just put the  
            message ID instead of hard coding the message text.

SFLMSGKEY - This record level keyword is used to specify the field used as message key.

SFLMSGRCD - This record level keyword is used to specify what line #, where the message has to be displayed.

SFLPGMQ - This keyword specifies the program message queue that confirms the Subfile records for a message Subfile.

SFLNXTCHG - This record level keyword is used to mark the Subfile records as being changed.

SFLPAG - This record level keyword is used to determine how many Subfile records to show per display screen.

SFLROLVAL - This record level keyword identifies the no. records to roll, whenever a roll-up/roll-down key is pressed.

SFLSIZ - This record level keyword is used to set the initial size of Subfile

SFLDROP - This record level keyword. The program first displays the Subfile in truncated mode [display in one line form]. When the user presses the associated key, it will display folded form.

SFLFOLD - This record level keyword. The program first displays the Subfile in folded mode [display in multiple line form]. When the user presses the associated key, it will display truncated form.

SFLMODE - This record level keyword is used to tell whether the Subfile is in drop mode or fold mode. If the mode = 1 means Drop mode and the mode is 0 means Fold mode.

SFLEND - Controls the display of  “plus sign”.
SFLRCDNBR - Controls what Subfile page is displayed and where cursor goes.

SFLRNA – Record not active used to make the file inactive.

Unknown
Check your subfile skills


WHY SUBFILES IN AS400 

1. Explain Subfile.
To access multiple records at a time, we can use subfiles. It makes easy the user task that he can work with group of record. It has two record formats.
1.      Subfile Record
2.      Subfile Control Record

2.  What is a Subfile control record?
The record that controls the display of the record format and text information

3.  What is a Subfile record format?
The record that contains the displayable data.

4.  What must follow the SFLCTL keyword in the Subfile control record?
The name of the Subfile Record Format.


5. What are the mandatory keywords for declare Subfile.
SFL, SFLCTL, SFLDSP, SFLSIZ and SFLPAG
SFL
                        It defines the record is Subfile record.
SFLCTL
                        It defines the record is a control record.
SFLDSP
                        It is to display the data is the display screen.
SFLSIZ
                        It identifies the Subfile size. The max size for Load all is 9999.
SFLPAG
It identifies the no. of record to be displayed at a time. For load all it should be less than SFLSIZ

6. What is Relative Record Number [RRN]?
Relative Record Number [RRN] is a unique numeral value used to position records in Subfile.

7.  What DDS keywords are required when defining a control record format?
SFLCTL, SFLDSPCTL, SFLPAG, SFLSIZ.

8.  What are the 3 types of subfiles?
Single page, expandable and load-all.

9.  Which type of Subfile has the better performance?
Single page.

10.  What is a Subfile record number?
The internal value associated with the each Subfile record.

11. What does ‘O.S 400 controlling of Subfile’ mean?
In Load All Subfile if we press the Page Up or Page Down key the control will not go to the program and the O.S.400 will take the control and redisplay the preceding or succeeding records.
This simplifies the coding and if the beginning or end of Subfile reached then the O.S 400 will automatically display the message like ‘End Of File Reached’.

12. Why would one take control over rolling of Subfile record?
It will reduce the time taken to redisplay the records if there is large records. If we define the roll key then the control will return to program while the roll key is pressed. The program then adds new records and display.

13. How will you get a Plus sign in Subfile?
By specifying the SFLEND keyword. If we specify *More with SFLEND then the word MORE will be at lower right corner which indicates more records are there in Subfile than displaying and if end of file reached then it will display ‘BOTTOM’.

14. How does CLRL work? Compare it with OVERLAY.
This keyword is used to Clear and Control specific number of lines from the screen. It also helps to overlap two record formats without the first format is being cleared completely. Only those lines cleared from the first format are deleted, all other lines will remain in the screen.
If we specify CLRL (*NO) for a format then no line will be cleared. So if a record format is overlayed then the lines of the previous format will not be deleted but just overlayed.
It is not in case of OVERLAY. If any line in the first format in the overlaps then the complete format will be deleted before next format display.

15. What do you mean by SFLRCDNBR?
                        It means Subfile record number. This is used in load all type.
Suppose we are living in third page and if we press Enter key, then the control will go to first page. So if we move the position of 378 to 379 of the File Information Data Structure to a hidden field then the RRN value and Subfile Record Number will be same. So the control will be in the living page.
We cannot use SFLRCDNBR and SFLROLVAL simultaneously.

16.  What does the SFLNXTCHG keyword mean?
It means Subfile Next Change. It activates the READC operation and mark records as changed records.

Suppose the READC operation reads fifth or sixth changed record and if modify a second or first record then READC wont read that record. For this we activate the SFLNXTCHG keyword with an indicator. So if we change a record that indicator will seton and READC will read all changed record.

Unknown
MESSAGE Subfiles


MESSAGE Subfiles

Create the message file and the error messages. Issue the following commands:

MESSAGE SUBFILE:

CRTMSGF MSGF(MYLIB/TSTMSGF)

ADDMSGD MSGID(ERR0001) MSGF(MYLIB/TSTMSGF) MSG('Example of error message')


DISPLAY FILE:

Message Subfile:

A          R MSGSFL                       SFL         
A                                                        SFLMSGRCD(24)
A            M@MSGK                      SFLMSGKEY   
A            M@PGMQ                      SFLPGMQ(10) 

Message Subfile Control:

A          R MSGCTL                       SFLCTL(MSGSFL) 
A  41                                         SFLDSP         
A  43                                         SFLDSPCTL      
A  40                                         SFLCLR         
A  42                                         SFLEND         
A                                                        SFLSIZ(0010)   
A                                                        SFLPAG(0001)   


RPG PROGRAM:

Initialize Message Subfile in Extended ‘F’ Specification as below

F                                     SFILE(MSGSFL:W$RRN1)

Subroutine - Clear Message Subfile

C     #CLRMG        BegSr                                             
 *                                                                     
C                   SetOn                                       40              
C                   SetOff                                       414243                 
C                   Write     MsgCtl                                  
C                   SetOff                                       4041 
C                   SetOn                                       4243 
C                   Z-Add     *ZERO         W$RRN1           
 *                                                                    
C                   EndSr                                             

Clear Subroutine:

Setoff           SFLDSP, SFLDSPCTL
Seton  SFLCLR
Setoff SFLEND
Clear   MSGCTL
Setoff SFLDSP, SFLCLR
Seton  SFLDSPCTL,SFLEND

Subroutine - Write Message Subfile

C     #SDMSG        BegSr                                        
 *                                                               
C                   SetOn                                        41
C                   Call             'SSM720C1'                         
C                   Parm                              P$MGID            7  
C                   Parm           'CCCMSGF   '  P$MSGF          10  
C                   Parm                                       P$MGVL           80  
C                   Parm                                       P$MSGK            4  
C                   Parm                                       P$CSTS             1  
 *                                                               
C                   Eval            M@MSGK = P$MSGK                    
C                   Add             1             W$RRN1               
C                   Write           MsgSfl                             
 *                                                               
C                   Eval            P$MGVL = *BLANK                    
 *                                                                
C                   EndSr                                        

CL PROGRAM:

PGM                       PARM(&MSGID &MSGF &MSGVAL &MSGKEY &CMPSTS)  
DCL                        VAR(&MSGID) TYPE(*CHAR) LEN(7)              
DCL                        VAR(&MSGF) TYPE(*CHAR) LEN(10)              
DCL                       VAR(&MSGVAL) TYPE(*CHAR) LEN(80)            
DCL                        VAR(&MSGKEY) TYPE(*CHAR) LEN(4)             
DCL                        VAR(&CMPSTS) TYPE(*CHAR) LEN(1)             
CHGVAR                  VAR(&CMPSTS) VALUE('0')                     
SNDPGMMSG           MSGID(&MSGID) MSGF(*LIBL/&MSGF) +           
                                      MSGDTA(&MSGVAL) KEYVAR(&MSGKEY)           
MONMSG                 MSGID(CPF0000) EXEC(CHGVAR VAR(&CMPSTS) +   
                                      VALUE('1'))                                
EXIT:       ENDPGM                                                 


Using RRN to Chain to Subfiles

We can use RRN to chain to subfile to read all records (this might be particularly useful in EDITABLE subfiles since we may have to read all records)

Rrn = 1
DoWhile Rrn <= SubfileRrn
Rrn     Chain  Subfile
         
(….xxx….)
Update Subfile
Rrn = Rrn + 1
EndDo

(Update the subfile if you want errors to be highlighted)


All records can also be read from a subfile by making SFLNXTCHG = ON and then doing a READC.

Unknown Friday, 31 May 2013
Checking Record Locks While Updating PF in Subfiles




Checking Record Locks While Updating PF in Subfiles





RPGLE

Check for %STATUS after doing a CHAIN(E) to file.

If %STATUS = 01218, then record is locked.

RPG

Check for status code 01218 in the file information data structure (INFDS).

Declare INFDS to “F” specification in “Keywords” column – INFDS FILEDS

Now, declare FILEDS as below

I FIELDS                 DS
I                                     *STATUS       STAT

Now, in program, after CHAIN, check for STAT = 01218




Unknown Thursday, 30 May 2013
MESSAGE Subfiles



MESSAGE Subfiles

Create the message file and the error messages. Issue the following commands:

MESSAGE SUBFILE:

CRTMSGF MSGF(MYLIB/TSTMSGF)

ADDMSGD MSGID(ERR0001) MSGF(MYLIB/TSTMSGF) MSG('Example of error message')


DISPLAY FILE:

Message Subfile:

A          R MSGSFL                       SFL         
A                                                        SFLMSGRCD(24)
A            M@MSGK                      SFLMSGKEY   
A            M@PGMQ                      SFLPGMQ(10) 

Message Subfile Control:

A          R MSGCTL                       SFLCTL(MSGSFL) 
A  41                                         SFLDSP         
A  43                                         SFLDSPCTL      
A  40                                         SFLCLR         
A  42                                         SFLEND         
A                                                        SFLSIZ(0010)   
A                                                        SFLPAG(0001)   


RPG PROGRAM:

Initialize Message Subfile in Extended ‘F’ Specification as below

F                                     SFILE(MSGSFL:W$RRN1)

Subroutine - Clear Message Subfile

C     #CLRMG        BegSr                                             
 *                                                                     
C                   SetOn                                       40              
C                   SetOff                                       414243                 
C                   Write     MsgCtl                                  
C                   SetOff                                       4041 
C                   SetOn                                       4243 
C                   Z-Add     *ZERO         W$RRN1           
 *                                                                    
C                   EndSr                                             

Clear Subroutine:

Setoff SFLDSP,SFLDSPCTL
Seton  SFLCLR
Setoff SFLEND
Clear  MSGCTL
Setoff SFLDSP,SFLCLR
Seton  SFLDSPCTL,SFLEND

Subroutine - Write Message Subfile

C     #SDMSG        BegSr                                        
 *                                                               
C                   SetOn                                        41
C                   Call             'SSM720C1'                         
C                   Parm                              P$MGID            7  
C                   Parm           'CCCMSGF   '  P$MSGF          10  
C                   Parm                                       P$MGVL           80  
C                   Parm                                       P$MSGK            4  
C                   Parm                                       P$CSTS             1  
 *                                                               
C                   Eval            M@MSGK = P$MSGK                    
C                   Add             1             W$RRN1               
C                   Write           MsgSfl                             
 *                                                               
C                   Eval            P$MGVL = *BLANK                    
 *                                                                
C                   EndSr                                        

CL PROGRAM:

PGM                       PARM(&MSGID &MSGF &MSGVAL &MSGKEY &CMPSTS)  
DCL                        VAR(&MSGID) TYPE(*CHAR) LEN(7)              
DCL                        VAR(&MSGF) TYPE(*CHAR) LEN(10)              
DCL                       VAR(&MSGVAL) TYPE(*CHAR) LEN(80)            
DCL                        VAR(&MSGKEY) TYPE(*CHAR) LEN(4)             
DCL                        VAR(&CMPSTS) TYPE(*CHAR) LEN(1)             
CHGVAR                  VAR(&CMPSTS) VALUE('0')                     
SNDPGMMSG           MSGID(&MSGID) MSGF(*LIBL/&MSGF) +           
                                      MSGDTA(&MSGVAL) KEYVAR(&MSGKEY)           
MONMSG                 MSGID(CPF0000) EXEC(CHGVAR VAR(&CMPSTS) +   
                                      VALUE('1'))                                
EXIT:       ENDPGM                                                 


Using RRN to Chain to Subfiles

We can use RRN to chain to subfile to read all records (this might be particularly useful in EDITABLE subfiles since we may have to read all records)

Rrn = 1
DoWhile Rrn <= SubfileRrn
Rrn     Chain  Subfile
         
(….xxx….)
Update Subfile
Rrn = Rrn + 1
EndDo

(Update the subfile if you want errors to be highlighted)


All records can also be read from a subfile by making SFLNXTCHG = ON and then doing a READC.

Unknown