ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Session or Device error

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

  • Session or Device error

    Hi there,

    Can someone hep me with the session or device error.
    I get this error,

    Cannot read record #01CTL from file PGM1 at device QPADEV005H.
    C
    Session or device error occurred in file PGM1.

    Message . . . . : Cannot read record #01CTL from file PGM1 at device
    QPADEV005H.
    Cause . . . . . : If record #01CTL is not a subfile or pull-down menu, write
    record #01CTL to file PGM1 before trying to read it or specify INZRCD
    keyword in DDS for record #01CTL, create the file PGM1 again, and read
    without a previous write. If record #01CTL is a subfile control record
    format, ensure that SFLDSPCTL keyword is in effect when the program displays
    the subfile. If record #01CTL is a pull-down menu record format, perform the
    read to the record format with the MNUBARDSP keyword to determine if a
    pull-down menu has been selected. A read is not allowed to a pull-down menu
    record format until a pull-down menu has been selected.

    Not sure what is the error, I am not trying to show an empty subfile. RRN has a value.

    DDS:
    Code:
    A                                      DSPSIZ(24 80 *DS3)                  
    A                                      REF(*LIBL/FILEB FILEBR)            
    A                                      CHGINPDFT(HI CS UL)                
    A                                      PRINT                              
    A                                      CA03                                
    A                                      CA05                                
    A                                      CA12                                
    A                                      WDWBORDER((*DSPATR RI) (*CHAR '    -
    A                                          '))                            
    A N52                                  PAGEDOWN(41)                        
    A  53                                  PAGEUP(42)                        
    
    A          R #01SFL                    SFL                              
    A            S_DIALOGUE    70A  O  3  2DSPATR(RI)                      
    A          R #01CTL                    SFLCTL(#01SFL)                  
    A  50                                  SFLDSP                          
    A  51                                  SFLDSPCTL                        
    A N50N51                               SFLCLR                          
    A  52                                  SFLEND(*MORE)                    
    A                                      SFLSIZ(0020)                    
    A                                      SFLPAG(0019)                    
    A                                  2  2MSGCON(020 ERR0747 *LIBL/ERRMSGF)  
    A                                      COLOR(RED)                      
    A            RRN01          4S 0H                                      
    
    A          R #01CTLN                                                  
    A*                                     FRCDTA                          
    A*                                     CLRL(*NO)                      
    A  99        S_MSGTXT      79A  O 23  2DSPATR(RI)                      
    A            S_YES          1A  I 22 31DFT('#')                        
    A                                      CHECK(ER)                      
    A                                 22 33MSGCON(020 ERR0077 *LIBL/ERRMSGF)
    A          R #ASSUME                                                        
    A                                      KEEP                            
    A                                      ASSUME                          
    A                                  1  3' '                            
    A          R #FRCDTA                                                  
    A                                      FRCDTA                          
    A                                      CLRL(*NO)

    RPGLE snippets:

    Code:
    fPGM1      cf   e             workstn usropn                      
    f                                     sfile(#01sfl:ctl01.rrn01)  
    f                                     infds(d_pgm1d)        
    
    dcl-ds Ctl01 extname('PGM1':'#01CTL':*all)  qualified end-ds;
    dcl-ds CtlN01 extname('PGM1':'#01CTLN':*all) qualified end-ds;
    dcl-ds Sfl01 extname('PGM1':'#01SFL':*all) qualified end-ds;  
    
    
    c     sr_scr01      begsr                                          
    
    c                   exsr      sr_prep01                            
    
    c                   dou       *inkc or *inkl or (w_redisp = *off)  
    
    c                   if        *inu8 = *off                          
    c*                  exfmt     #01scr                                
       LoadSubfile01();                                                
       write #01CTL Ctl01;                                              
       write #01CTLN CtlN01;                                            
    [COLOR=#FF0000][B]read #01CTL Ctl01;  [/B][/COLOR]              [B][COLOR=#FF0000]//fails here[/COLOR][/B]                              
       read #01CTLN CtlN01;                                            
    c                   endif                                          
    
    c                   movea     w_indoff      *in(21)                
    c                   eval      *in99    = *off                      
    c                   eval      w_redisp = *off                      
    
    c                   select                                        
    ?* F3 pressed?                              
    c                   when      *inkc          
                        leave;                  
    ?* F12 pressed?                              
    c                   when      *inkl          
                        leave;                  
    ?* F5 pressed?                              
    c                   when      *inke          
    c                   exsr      sr_text        
    ?* Enter pressed?                            
     * Validate ---------------------------      
      when NOT Validate01();                    
        w_redisp = *on;                          
    c                   other                    
    
    c                   endsl                    
    
    c                   enddo                  
    c                   endsr
    
    
    dcl-proc LoadSubfile01;                              
    //----------------------------------------------------
    dcl-s i uns(10) inz(1);                              
     //===================================================
     // Clear Subfile ----------------------------        
     Ctl01.rrn01 = *zero;                                
     *in50       = *off;                                  
     *in51       = *off;                                  
     *in52       = *off;                                  
     write #01CTL;                                        
     *in50       = *on;                                  
     *in51       = *on;                                  
     i = FirstNum;                                        
    
     //-------------------------------------------      
    clear Ctl01.rrn01;                                
    // Load based on Record Numbers only --------      
    dow Ctl01.rrn01 < SflSize;                        
      // Add to subfile -----------------------        
    
      if FullTextArray(i) = *blank AND                
        FullTextArray(i+1) = *blank AND                
        I <= (%elem(FullTextArray) - 1);              
        leave;                                        
      endif;                                          
    
      // Add to subfile -----------------------        
      Ctl01.rrn01 += 1;                                
      Sfl01.S_DIALOGUE = FullTextArray(i);            
      //---------------------------------------        
      write #01SFL Sfl01;                              
      //---------------------------------------        
      i += 1;                                        
      enddo;                                        
    
      // No Records -------------------------------  
      if Ctl01.rrn01 = *zero;                        
         *IN52       = *on;                          
         *IN50       = *off;                        
         return;                                    
      endif;                                        
    
      // Indicate Page Up -------------------------  
      *IN52       = *on;                            
      if FirstNum = 1;                              
      *IN52       = *off;                            
    endif;                                          
    
    // Indicate Page Down -----------------------    
    *in52    = *on;                                  
    if (FirstNum + SflSize - 1 < NumofRecs);        
    *IN52    = *off;                                
    endif;                          
    
    //===============================
    end-proc;                      
    
    
    *========================================
    *  Validate Screen 01 -------------------
    *========================================
      dcl-proc Validate01;                  
        dcl-pi Validate01 ind end-pi;        
          //=================================
          w_redisp = *off;                  
    
          select;                            
          when *IN42 = *on;                  
            FirstNum -= SflSize;            
            if FirstNum < 1;                
              reset FirstNum;                
            endif;                          
            w_redisp = *on;                  
    
            return *on;                            
          // Page Down ----------------------------
          when *in41 = *on;                        
            FirstNum += SflSize;                  
            w_redisp = *on;                        
            return *on;                            
          // Subfile Selection --------------------
          endsl;                                  
    
          //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
          return *on;                              
    
          //=======================================
      end-proc;

    Thank you in advance for going through my code and helping me.

  • #2
    You are writing data to the display file via data structures. However, you seem to have forgotten that the indicators such as 50 and 51 are ALSO part of the display, and therefore must be set inside the data structure.

    The error message tells you that for a subfile control record, you MUST have previously written it with SFLDSPCTL turned on. However, you are not turning it on. It is conditioned by indicator 51 in the Ctl01 data structure, but you never turn on indicator 51 in the Ctl01 data structure.

    You should go through your code and find all of the lines like this:
    Code:
     *in50       = *on;                                  
     *in51       = *on;
    Change them to this:

    Code:
     Ctl01.in50       = *on;                                  
     Ctl01.in51       = *on;
    Good luck

    Comment


    • #3
      Corrected both the issues and it works!
      Greatly appreciate you taking time to check and reply. Thanks a lot Scott.
      Have a nice day!

      Comment

      Working...
      X