Problem solve Get help with specific problems with your technologies, process and projects.

Making sure all data is received in a non-keyed interface

p>Problem: Making sure all data is received in a non-keyed interface PMEMBER file with trailer record types and notifying operations if situation occurs, ILE Example.

Solution: Using the Information Data Structure (INFDS) to capture total number of records RECCNT, using that number to go to the last record of the file, but be careful the last record may not be the trailer record, checking for ?9? in position 1 field PRTYPE in file PMEMBER.

Key Points: Use user control to open and close file for file pointers, if trailer is found ok, pointer must be reset to beginning of file to start reading file at the beginning. The last record of the file may be a blank record, so 1 is subtracted from RECCNT to start reading backward. In the file in the do loop until record is found or record not found.

If trailer record is not found, the file member name is passed to CLP- DMBR573C and removed from the input file PMEMBER, as well as a message being sent to the operator notifying of the missing trailer.

0257.00  *****************************************************************       
0258.00  *  MAINLINE                                                             
0259.00  *****************************************************************       
0261.00  C                            EXSR      CKTRLER                                    
0262.00  C     TRLFLG        IFEQ      'Y'                                        
0263.00  C                           CLOSE     PMEMBER                                    
0264.00  C                           OPEN      PMEMBER                                    
0265.00  C                           OPEN      MEMBER                                     
0266.00  C                           READ      PMEMBER                                99

	 Code inbetween

295.00 	 C                          ENDIF

0505.00  *****************************************************************     
0506.00  *Check for Trailer  record                                             
0507.00 C     CKTRLER       BEGSR                                              
0508.00 C              OPEN      PMEMBER                                  
0509.00 C       PRTYPE        DOUGT     *BLANK                                   
0510.00 C          *IN91         OREQ      '1'                                      
0511.00 C     RECCNT        CHAIN     PMEMBER                            91    
0512.00 C          *IN91         IFEQ      '0'                                      
0513.00 C      PRTYPE        ANDGT     *BLANK                                   
0514.00 C      PRTYPE        IFEQ      $TRL                                     
0515.00 C                             MOVE      'Y'           TRLFLG                     
0516.00 C                             ENDIF                                              
0517.00 C                             ELSE                                               
0518.00 C                              SUB       1             RECCNT                     
0519.00 C                             ENDIF                                              
0520.00 C                             ENDDO
0521.00 C*Test to see if Trailer Record                                      
0522.00 C     TRLFLG         IFEQ      'N'                                    
0523.00 C                            OPEN      MEMBER                                 
0524.00 C                            MOVE      *ON           *IN90                    
0525.00 C                            ADD       1             WKEXTP                   
0526.00 C                            MOVEA     ERR(3)        RSERR2                   
0527.00 C                           EXCEPT    TRLERR                                 
0528.00 C                           CLOSE     MEMBER                                 
0529.00 C                           CALL      'DMBR573C'    RMVMBR                   
0530.00 C                           ENDIF                                            
0531.00 C                           ENDSR                                            
0533.00  *****************************************************************
0534.00  *   Initialize Sub-Routine                                        
0535.00  ***************************************************************** 
0536.00 C     *INZSR        BEGSR                                          
0554.00 C                          MOVE      'N'           TRLFLG
0555.00 C     RMVMBR        PLIST                                    
0556.00 C                   PARM                    PFLIB            
0557.00 C                   PARM                    PFNAME           
0558.00 C                   PARM                    MEMNME           
0559.00 C                   PARM                    INLIB            
0560.00 C                   PARM                    INFIL            
0561.00 C                   PARM                    INMBR            
0566.00 C                          ENDSR                                        

	*************** Beginning of data ***********************************************
0001.00 	             PGM        PARM(&PFLIB &PFNAME &MEMNME &INLIB &INFIL +              
0002.00 	                          &INMBR)                                                
0003.00 	             DCL        VAR(&PFLIB) TYPE(*CHAR) LEN(10)                          
0004.00 	             DCL        VAR(&PFNAME) TYPE(*CHAR) LEN(10)                         
0005.00 	             DCL        VAR(&MEMNME) TYPE(*CHAR) LEN(10)                         
0006.00 	             DCL        VAR(&INLIB) TYPE(*CHAR) LEN(10)                          
0007.00 	             DCL        VAR(&INFIL) TYPE(*CHAR) LEN(10)                          
0008.00 	             DCL        VAR(&INMBR) TYPE(*CHAR) LEN(10)                          
0009.00 	             DCL        VAR(&USERID) TYPE(*CHAR) LEN(10)                         
0010.00 	             DCL        VAR(&MSGDTA) TYPE(*CHAR) LEN(256)                        
0011.00 	             CHGVAR     VAR(%SST(&MSGDTA 1 10)) VALUE(&INFIL)                    
0012.00 	             CHGVAR     VAR(%SST(&MSGDTA 11 20)) VALUE(&INMBR)                   
0013.00 	             CHGVAR     VAR(%SST(&MSGDTA 21 30)) VALUE(&INLIB)                   
0014.00 	             RTVJOBA USER(&USERID)                                               
0015.00 	             RMVM       FILE(&PFLIB/&PFNAME) MBR(&MEMNME)                        
0016.00 	             MONMSG     MSGID(CPF4102 CPF7310)                                   
0017.00 	             SNDUSRMSG  MSGID(USR5613) MSGF(QAPIMSG) MSGDTA(&MSGDTA) +           
0018.00 	                          MSGTYPE(*INQ) TOUSR(&USERID)                           
0019.00 	             ENDPGM

Dig Deeper on RPG iSeries programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.