Link to home
Start Free TrialLog in
Avatar of Philip_Lang
Philip_Lang

asked on

Subfile - relative-record number error - attemp to write a duplicate record to file

I want to create a subfile that has its records populated from a screen(ie)
display screen and not from reading a input file.

From the Add_record_screen once all fields are populated
It adds a record to the subfile from which the add_ record_screen was called from.
 
when writing to the subfile I get the following error
write a duplicate record to file
ASKER CERTIFIED SOLUTION
Avatar of daveslater
daveslater
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Philip_Lang
Philip_Lang

ASKER

It's RPGLE

Cheers
Philip.
Name - EESFL
Type - DSPF
SrcFile QDDSSRC

A                                      DSPSIZ(24 80 *DS3)          
A          R F01SFL                    SFL                          
A            SELS1          1A  B  6  4CHECK(ER)                    
A            CODES1         5A  O  6  7                            
A            DESCS1        30A  O  6 14                            
A          R F01CTL                    SFLCTL(F01SFL)              
A                                      OVERLAY                      
A                                      CF03(03 'EXIT')              
A  31                                  SFLDSP                      
A                                      SFLDSPCTL                    
A N31                                  SFLCLR                      
A  31                                  SFLEND(*MORE)                
A                                      SFLSIZ(0014)                
A                                      SFLPAG(0013)                
A            RRN1           4  0H      SFLRCDNBR                    
A                                  1  3'Simple subfile entry'      
A                                  3  3'Code....'                  
A            CODEC1         5A  B  3 12CHGINPDFT                    
A  50                                  DSPATR(PR)                  
A N50                                  DSPATR(UL)                          
A                                  3 19'Description....'                    
A            DESCC1        30   B  3 35                                    
A                                  5  3'Sel  Code  Description'            
A                                      DSPATR(UL)                          
A          R F01FTR                                                        
A                                      OVERLAY                              
A                                 22  3'                                  -
A                                                                         -
A                                              '                            
A                                      DSPATR(UL)                          
A                                 23  3'F3=Exit'                            
Name -anything
Type - RPGLE
SrcFile QRPGLESRC

h                                                                                                
 ** Simple subfile test                                                                          
 ** Note RRN in SFile is the same as RRN in display file                                        
FEESFL     cf   E             workstn Sfile(F01SFL:RRn1)                                        
 ** variables to store first and last record                                                    
D RRN1l           s                   Like(RRN1)                           Last RRN              
D RRN1f           s                   Like(RRN1)                           First RRN            
 ** Loop to Free                                                                                
C                   DO        *HIVAL                                                            
 ** Show subfile? *in31 = Yes or ease not *in31 = Clear subfile                                  
C                   EVAL      *IN31 = RRN1L > 0                            Records to show      
 ** Show screens                                                                                
C                   write     F01Ftr                                                            
C                   Exfmt     F01Ctl                                                            
 ** exit on F3                                                                                  
C                   If        *in03                                                              
C                   Eval      *inlr = *on                                                        
C                   Return                                                                      
C                   Endif                                                                        
C                                                                                  
 ** Check for selection - ignore if selection already made                        
C                   if        *in31 and Not *In50                                  
 ** Record selected with a value                                                  
C                   Readc     F01sfl                                              
C                   If        Not %eof and Sels1 <> ' '                            
 ** *in50 = Protect code - move subfile fields to control fields                  
C                   Eval      *in50 = *on                                          
C                   Eval      CodeC1 =Codes1                                      
C                   Eval      DescC1 = Descs1                                      
 ** save RRN number & re-display                                                  
c                   eval      RRN1f=rrn1                                          
C                   Iter                                                          
C                   Endif                                                          
C                   Endif                                                          
 ** Add or update subfile                                                          
C                   If        *in50                                                
 ** Access exisitied RRN to update description                                    
c     rrn1f         chain     F01Sfl                                              
c                   clear                   Sels1                                  
C                   Eval      Descs1 = Descc1                        
C                   Update    F01Sfl                                  
 **                                                                  
C                   else                                              
 ** Add new record to the end of the sub file                        
C                   eval      RRN1 = RRN1L + 1                        
C                   Eval      Codes1 =Codec1                          
C                   Eval      Descs1 = Descc1                        
C                   write     F01Sfl                                  
c                   Eval      RRN1l = RRN1                            
c                   eval      RRN1f=rrn1                              
C                   Endif                                            
 ** Clear control fields                                              
C                   clear                   CodeC1                    
C                   clear                   DescC1                    
C                   clear                   *in50                    
                                                                     
C                   enddo                                            



Have fun



dave