ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

SUBFILE reviewed

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SUBFILE reviewed

    Hey all!!!!
    Thanks for ur help previously here is my code recorected
    As mentioned before My objective is to enter the sales person number and then to show me in sub file all the customer related to this sales person
    The compile is now without errors but in the execution the loaded file never get load wutever value I enter any idea whyâ?¦..
    thanks in advance!


    PHYSICAL AND LOGICAL FILE

    CUSTSF (PF)

    Code:
    0001.00      A          R CUSTPFR                                       
    0002.00      A            CUSTID         7A                             
    0003.00      A            CUSTNAME      16A                             
    0004.00      A            CUSTADDR      10A                             
    0005.00      A            CUSSLS         4A                             
    0006.00      A          K CUSTID
    CUSTSFL(LF)

    Code:
    0001.00      A          R CUSTPFR                   PFILE(CUSTSF)      
    0002.00      A          K CUSSLS

    DISPLAY FILE : TSTSF

    Code:
    0001.00      A                                      REF(NAKH/CUSTSF CUSTPFR)
    0002.00      A********************************************************      
    0003.00      A          R ENTSLS                                            
    0004.00      A                                      CF03(03)                
    0005.00      A                               O  2 20'LIST CUSTOMERS'        
    0006.00      A            CUSSLS    R        B  2 46                        
    0007.00      A*********************************************************     
    0008.00      A          R SFDATA                    SFL                     
    0009.00      A            CUSTID    R        O  4  7                        
    0010.00      A            CUSTNAME  R        O  4 16                        
    0011.00      A            CUSTADDR  R        O  4 32                        
    0012.00      A**********************************************************    
    0013.00      A          R SFCTL                     SFLCTL(SFDATA)          
    0014.00      A                                      SFLPAG(0015)            
    0015.00      A                                      SFLSIZ(0045)            
    0016.00      A                                      OVERLAY                 
    0017.00      A  50                                  SFLCLR             
    0018.00      A  50                                  SFLDSP             
    0019.00      A  50                                  SFLDSPCTL          
    0020.00      A  50                                  SFLEND(*MORE)      
    0021.00      A                                  2  4'SALESPERSON#'     
    0022.00      A            CUSSLS    R        O  2 17                   
    0023.00      A                                  3  4'CUSTOMER#'        
    0024.00      A                                  3 15'NAME'             
    0025.00      A                                  3 50'ADDRESS'          
    0026.00      A          R CMDKEYS                                
    0027.00      A                                 24 40'F3=EXIT'


    RPG PROGRAM


    Code:
    0001.00 FTSTSF     CF   E             WORKSTN                                  
    0002.00 F                                     SFILE(SFDATA:REC#)               
    0003.00 FCUSTSFL   IF   E           K DISK                                     
    0004.00 DREC#             S              5  0 INZ(1)                           
    0005.00 D******************************************************************    
    0006.00 C                   DOW       *IN03=*OFF                               
    0007.00 C                   EXFMT     ENTSLS                                   
    0008.00 C                   IF        *IN03=*OFF                               
    0009.00 C                   EXSR      CLRSF                                    
    0010.00 C                   EXSR      LODSF                                    
    0011.00 C                   WRITE     CMDKEYS                                  
    0012.00 C                   EXFMT     SFCTL                                    
    0013.00 C                   ENDIF                                              
    0014.00 C                   ENDDO                                              
    0015.00 C                   EVAL      *INLR = *ON                              
    0016.00 C                   RETURN         
    0017.00 C     CLRSF         BEGSR                                              
    0018.00 C                   EVAL      *IN50 = *OFF                             
    0019.00 C                   WRITE     SFCTL                                    
    0020.00 C                   EVAL      *IN50 = *ON                              
    0022.00 C                   EVAL      REC# = *ZERO                             
    0023.00 C                   ENDSR                                              
    0024.00 C     LODSF         BEGSR                                              
    0026.00 C     CUSSLS        CHAIN     CUSTSFL                                   
    0027.00 C                   IF        NOT%FOUND(CUSTSFL)                        
    0030.00 C     CUSSLS        READE     CUSTSFL                                   
    0031.00 C                   DOW       NOT%EOF(CUSTSFL)                          
    0033.00 C                   ADD       1             REC#                        
    0034.00 C                   WRITE     SFDATA                                    
    0035.00 C     CUSSLS        READE     CUSTSFL                             
    0036.00 C                   ENDDO                                         
    0037.00 C                   ENDIF                                         
    0038.00 C     REC#          IFEQ      *ZERO                               
    0039.00 C                   ADD       1             REC#                  
    0040.00 C                   CLEAR                   SFDATA                
    0041.00 C                   MOVEL     '*NO RECORDS*'CUSTNAME              
    0042.00 C                   WRITE     SFDATA                              
    0043.00 C                   ENDIF  
    0044.00 C                   ENDSR

  • #2
    Re: SUBFILE reviewed

    Good for you........whats next

    have a great weekend

    jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: SUBFILE reviewed

      You're not read the LF. Line 26 chains to the subfile the you reade the subfile only if is NOT FOUND. Change the chain on line 26 to a setll and delete line 27 & 37:

      PHP Code:

      0024.00 C     LODSF         BEGSR  
                     c
      *  Set File Pointer to customer                             
      0026.00 C     CUSSLS        Setll     CUSTSFL                                   
                    C
      *  Read the customer record                        
      0030.00 C     CUSSLS        READE     CUSTSFL  
                    c
      read all                                 
      0031.00 C                   DOW       NOT 
      %EOF(CUSTSFL)                          
      0033.00 C                   ADD       1             REC#                        Increment subfile rec
      0034.00 C                   WRITE     SFDATA                                  Write Subfile record 
      0035.00 C     CUSSLS        READE     CUSTSFL                          Read next cust rec   
      0036.00 C                   ENDDO                                                  e
      Not eof
                    C
      *                  
                    
      c* If no records written the write message                       
      0038.00 C     REC
      #          IFEQ      *ZERO                               
      0039.00 C                   ADD       1             REC#                           add one to rec cnt
      0040.00 C                   CLEAR                   SFDATA                       Clear Fields
      0041.00 C                   MOVEL     
      '*NO RECORDS*'CUSTNAME    No recs     
      0042.00 C                   WRITE     SFDATA                              
      0043.00 C                   
      ENDIF                                                      eRec# = *zero 
                     
      c*
      0044.00 C                   ENDSR 
      And for your own good add more comments to describe what you are doing. This way in the future it become easier to read and know what is going on. Your code is too cramed making it illegible.

      Good Luck
      Bill
      Last edited by jamief; November 18, 2006, 01:08 PM. Reason: formatting - i better learn to read also ;)
      Bill
      "A good friend will bail you out of jail,
      A true friend would be sitting beside you saying,
      'Wow, that was fun.'"

      Comment

      Working...
      X