Tape I/O From a Program

Typically, applications written in RPG or COBOL will perform data record input and output (I/O) to database files. However, in some applications these files may be so large, that you never store them on disk. You store them on tape, and process them sequentially by application programs, either for input or for output, but not both at once. On the System i platform, this is done using a tape file object.

Such applications have the same requirements for control and tracking of the media on which the operations are performed as do media used for normal save and restore operations. This chapter discusses how you can use these types of tape file I/O applications with BRMS.

The example in Figure 15 shows typical tape file processing from an application. It is a simple RPG program which writes the alphabet 100 times to a tape.

Figure 15. Sample Program to Perform Tape File I/O
FTAPFIL  O   F      26            SEQ                              
F******************************************************************
F*   Program: TAPFIL                                               
F*   Purpose: This program will write the 26 letters of the        
F*            alphabet to a file on tape through a tape file.  The 
F*            alphabet is written 100 times.                       
F*                                                                 
F******************************************************************
C                     DO   100                       Loop 100 times
C                     EXCPTALPHA                     Write alphabet
C                     END                            End of loop   
C*                                                                 
C                     SETON                    LR    End the program
O*******************************************************************
O*  Exception output defining the alphabet to be written            
O*                                                                  
O*******************************************************************
OTAPFIL  E                ALPHA                                     
O                                   24 'ABCDEFGHIJKLMNOPQRSTUVWX'   
O                                   26 'YZ'                         

This application requires a tape file object to be created such that the program can address the tape drive. You can create this with the CRTTAPF command as follows:

                           Create Tape File (CRTTAPF)                           
                                                                                
 Type choices, press Enter.                                                     
                                                                                
 File . . . . . . . . . . . . . .   TAPFIL        Name                          
   Library  . . . . . . . . . . .     BRMTAPF     Name, *CURLIB                 
 Tape device  . . . . . . . . . .   *NONE         Name, *NONE                   
                + for more values                                               
 Volume identifier  . . . . . . .   *NONE         Character value, *NONE        
                + for more values                                               
 Tape reels specifications:                                                     
   Label processing type  . . . .   *SL           *SL, *NL, *NS, *BLP, *LTM     
   Number of reels  . . . . . . .   1             1-255                         
 Sequence number  . . . . . . . .   1             1-16777215, *END, *NEXT       
 Tape label . . . . . . . . . . .   TAPEFILXMP                                  
 File type  . . . . . . . . . . .   *DATA         *DATA, *SRC                   
 Text 'description' . . . . . . .   'Tape file example'                         
                                                                                
                                                                                
                                                                                
                                                                         Bottom 
 F3=Exit   F4=Prompt   F5=Refresh   F10=Additional parameters   F12=Cancel      
 F13=How to use this display        F24=More keys                               

Once you create the tape file, you can process the program. However, for flexibility, you may have noticed that we have not specified a tape device name. So before you process the program TAPFIL, we need to perform an override of the tape file with the OVRTAPF command, as follows:

                         Override with Tape File (OVRTAPF)                      
                                                                                
 Type choices, press Enter.                                                     
                                                                                
 File being overridden  . . . . .   TAPFIL        Name                          
 Overriding to tape file  . . . .   *FILE         Name, *FILE                   
   Library  . . . . . . . . . . .                 Name, *LIBL, *CURLIB          
 Device . . . . . . . . . . . . .   TAP03         Name                          
                + for more values                                               
 Volume identifier  . . . . . . .                 Character value, *NONE        
                + for more values                                               
 Tape reels specifications:                                                     
   Label processing type  . . . .                 *SL, *NL, *NS, *BLP, *LTM     
   Number of reels  . . . . . . .                 1-255                         
 Sequence number  . . . . . . . .                 1-16777215, *END, *NEXT       
 File label . . . . . . . . . . .                                               
 Record length  . . . . . . . . .                 Number, *CALC                 
 Block length . . . . . . . . . .                 1-524288, *CALC               
 Buffer offset  . . . . . . . . .                 Number, *BLKDSC               
 Record block format  . . . . . .                 *F, *FB, *V, *VB, *D, *DB...  
                                                                        More... 
 F3=Exit   F4=Prompt   F5=Refresh   F12=Cancel   F13=How to use this display    
 F24=More keys                                                                  

This associates the tape file name to the tape device. Notice that the volume ID field is not specified.

Next we can call the program, as follows:

       CALL BRMTAPF/TAPFIL

The records are written to the tape.



[ Top of Page | Previous Page | Next Page | Contents | Index ]