ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

subfile

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

  • subfile

    Hi Jamie

    Could u plz check my prgm:

    Code:
    FSGCUSL1 IF  E           K        DISK
    FPROMPT  CF  E                    WORKSTN
    F                                        RRN1  KSFILE PMPTS
    E*                   ERR     1   1 30
    C           *IN12     DOUEQ*ON
    C                     WRITEFOOTER
    C                     EXFMTPMPTC
    C           *IN12     IFEQ *ON
    C                     MOVE *ON       *INLR
    C                     ENDIF
    C           SRCH      IFNE WSCUS
    C                     MOVE WSCUS     SRCH
    C                     MOVE *ON       *IN31
    C                     WRITEPMPTC
    C                     MOVE *OFF      *IN31
    C                     Z-ADD0         RRN1
    C           SRCH      SETLLSGCUSL1
    C                     EXSR SUBLD
     *------
    C                     EXSR READ
    C                     ENDIF
    C                     ENDDO
    C*
    C           *INZSR    BEGSR
    C*          *ENTRY    PLIST
    C*                    PARM           CUSID
    C                     Z-ADD0         RRN1    40
    C           *LIKE     DEFN WSCUS     SRCH
    C                     EXSR SUBLD
    C                     ENDSR
    C           SUBLD     BEGSR
    C                     Z-ADDRRN1      LSTRRN
    C*---
     C           *IN99     DOUEQ*ON
     C                     READ SGCUSL1                  99
     C           *IN99     IFEQ *ON
     C                     LEAVE
     C                     ENDIF
     C                     ADD  1         RRN1
     C                     WRITEPMPTS
     C                     ENDDO
     C*---
     C           RRN1      IFGT 0
     C                     MOVE *ON       *IN30
     C                     ELSE
     C                     MOVE *OFF      *IN30
     C                     ENDIF
     C*
     C           LSTRRN    IFNE RRN1
     C                     ADD  1         LSTRRN
    C                     END
    C*
    C                     ENDSR
     *----------
    C           READ      BEGSR
    C                     Z-ADD0         RRN1
    C                     Z-ADD0         READCS  40
    C                     MOVE *OFF      *IN99
    C           *IN99     DOUEQ*ON
    C                     READCPMPTS                    99
    C           *IN99     IFEQ *ON
    C                     LEAVE
    C                     ENDIF
    C                     ADD  1         READCS
    C           READCS    IFGT 1
    C                     MOVE *ON       *IN80
    C                     ENDIF
    C                     ENDDO
    C                     ENDSR

    I have first loaded all the records into the subfile n displayed on the screen and then based on the value entered on the POsition TO field the records are again displayed on the screen, so after this i have used EXSR READ stmt but it is not executing tht stmt it is simply coming out of the ENDIF and ENDDO

    yyyyyyyyyyyy?

  • #2
    Re: subfile

    Im only doing this cause your working on this on a Saturday.
    How did we ever code this way It took me 20 minutes to figure out the select
    statement.


    PHP Code:
         H*                                                                            
         
    FSGCUSL1 IF  E           K        DISK                                        
         FPROMPT  CF  E                    WORKSTN                                     
         F                                        RRN1  KSFILE PMPTS                   
          
    *=====================================================                       
          *      
    M A I N      L I  N  E                                                
          
    *=====================================================                       
          *                                                                            
          * 
    loadup the subfile                                                         
          
    *                                                                            
         
    C                     EXSR $CLR1                                              
         C                     EXSR $LOAD1                                             
          
    *                                                                            
         
    C           @SCRN1    DOWEQ'Y'                                                
         
    C                     WRITEFOOTER                                             
         C                     EXFMTPMPTCR                                             
         C                     SELEC                                                   
         C           
    *IN12     WHEQ *ON                                                
         C                     MOVE 
    'N'       @SCRN1         
         C                     OTHER                                 
         C           SRCH      IFNE 
    *BLANKS                          
         C                     EXSR $CLR1                            
         C           SRCH      SETLLSGCUSL1                          
         C                     EXSR $LOAD1                           
         C                     CLEARSRCH                             
         C                     
    ELSE                                  
         
    C                     EXSR $PROC                            
         C                     
    ENDIF                                 
         
    C                     ENDSL                                 
         C                     ENDDO                                 
          
    *                                                          
         
    C                     MOVE *ON       *INLR                  
          
    *=====================================================     
          *  
    $LOAD1 Load subfile number one.                       
          *=====================================================     
         
    C           $LOAD1    BEGSR                                 
         C                     READ SGCUSL1                  99      
         C           
    *IN99     DOWEQ*OFF                             
          
    *                                                          
         
    C                     ADD  1         RRN1                                  
         C                     WRITEPMPTS                                           
          
    *                                                                         
         
    C                     READ SGCUSL1                  99                     
         C                     ENDDO                                                
         C                     Z
    -ADDRRN1      SAVRRN                                
         C                     ENDSR                                                
          
    *=====================================================                    
          *  
    $CLR1 Clear subfile number one.                                      
          *=====================================================                    
         
    C           $CLR1     BEGSR                                                
          
    *                                                                         
          *  
    Ive never seen your DDS so...here is what Ive done                     
          
    *  You need to clear the subfile ALWAYS before loading it                 
          
    *  to clear you need sflclr to be on and write the control                
          
    *  record.                                                                
          *  *
    IN30 sfldspctl                                                      
          
    *  *IN31 sfldsp                                                         
          
    *  *IN32 sflclr                                                         
          
    *                                                                         
         
    C                     MOVE *OFF      *IN30                              
         C                     MOVE 
    *OFF      *IN31                              
         C                     MOVE 
    *ON       *IN32                              
         C                     WRITEPMPTCR                                       
         C                     MOVE 
    *ON       *IN30                              
         C                     MOVE 
    *ON       *IN31                              
         C                     MOVE 
    *OFF      *IN32                              
          
    *                                                                      
         
    C                     Z-ADD*ZEROS    RRN1                               
         C                     Z
    -ADD*ZEROS    SAVRRN                             
         C           
    *LOVAL    SETLLSGCUSL1                                      
          
    *                                                                      
         
    C                     ENDSR                                             
          
    *=====================================================                 
          *  
    $PROC Process the subfile                                         
          
    *=====================================================                 
         
    C           $PROC     BEGSR                                             
          
    *                                                                      
         
    C                     MOVE *BLANKS   SC1ERR  1                          
          
    *                                                                      
         
    C                     DO   SAVRRN    X                       
         C           X         CHAINPMPTS                99           
         C           
    *IN99     IFEQ *OFF                              
          
    *                                                           
         
    C                     SELEC                                  
         C           OPTION    WHEQ 
    '1'                               
         
    C*****                EXSR $OPT1                             
         C           OPTION    WHEQ 
    '2'                               
         
    C*****                EXSR $OPT2                             
         C                     OTHER                                  
         C                     MOVE 
    'Y'       SC1ERR                  
         C
    *****                ERROR                                  
         C                     ENDSL                                  
          
    *                                                           
         
    C           SC1ERR    IFEQ *BLANKS                           
         C                     CLEAROPTION                            
         C                     UPDATPMPTS                             
         C                     
    ENDIF                                  
          *                                                           
         
    C                     ENDIF                                  
                                                                      
         
    C                     ENDDO                                                     
          
    *                                                                              
         
    C                     ENDSR                                                     
          
    *=====================================================                         
          *  *
    INZSR -  Initial one time run subroutine                                   
          
    *=====================================================                         
         
    C           *INZSR    BEGSR                                                     
         C           
    *ENTRY    PLIST                                                     
         C                     PARM           CUSID    5                                      
          
    *                                                                              
          *  
    Setup some variables                                                        
          
    *                                                                              
         
    C                     Z-ADD0         RRN1    40                                 
         C                     MOVEL
    'Y'       @SCRN1  1                                  
         C                     Z
    -ADD*ZEROS    SAVRRN  40                                 
         C                     Z
    -ADD*ZEROS    X       40                                 
          
    *                                                                              
         
    C                     ENDSR                                                     
          
    *===================================================== 
    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

      Hi Jamie

      Have u written the code for me or u have got the code from somewhere else.

      Can u tell wt was the problem in my code.

      thanks

      Comment


      • #4
        Re: subfile

        I wrote it from scratch.......its not complete you have to do that but...IMO its much easier to read.

        I dont know nor do I have the time to look its Saturday

        You arnt clearing your subfile on the position to..........thats a big problem
        then you were writting the subfile record again thats another problem......

        the rest I have no idea.


        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

        Working...
        X