Link to home
Start Free TrialLog in
Avatar of bhagatali
bhagataliFlag for United States of America

asked on

QUSEC - "Pointer not set for location referenced error"

Hi All,

I have a file which lists the name of a few hundred files. Using RPG, i loop through all records in the file and or every record read, I call the QUSRMBRD API to fetch the number of records in a member. I am handling the error using QUSEC. When I hit a file which has no members, I capture the CPF message, set the record count to 0 and move on to the next record in the list file.

C     RECORDCNT     BEGSR                                        
C                                                                
C                   EVAL      nBufLen = %SIZE(MBRD0200)          
C                   EVAL      InObject = SYS_TNAME               
C                   EVAL      ObjectLib =  InObject  + InLibrary 
C                                                                
C     ObjectLib     DSPLY                                        
C                                                                
C                   CALL      'QUSRMBRD'                         
C                   PARM                    MBRD0200             
C                   PARM                    nBufLen              
C                   PARM                    Fmt                  
C                   PARM                    ObjectLib            
C                   PARM                    MemberName           
C                   PARM                    bOvr                 
C                   PARM                    QUSEC                
C                                                    
C                   IF        (QUSBAVL > 0)          
C     QUSEI         DSPLY                            
C                   EVAL      RecCount = 0           
C                   CLEAR                   QUSEI    
C                   CLEAR                   QUSERVED 
C                   ENDIF                            
C                                                    
C     RecCount      DSPLY                            
C                   EVAL      *INLR = *ON            
C                   ENDSR      
 

Open in new window


This was working fine as long as i have the QUSEC declared in my program as follows:

DQUSEC            DS                          
D QUSBPRV                 1      4B 0         
D QUSBAVL                 5      8B 0         
D QUSEI                   9     15            
D QUSERVED               16     16            
D ERRC0100               17    274    Varying
 

Open in new window


If i replace the above definition with the line below I get a "Pointer not set for referenced error":

D/COPY QSYSINC/QRPGLESRC,QUSEC

Open in new window


The pointer error shows up at run-time after the QUSRMBRD processes a file that has no members. Here is an extract of the job log:

DSPLY  CPF3C26                                                       
DSPLY           0                                                    
Pointer not set for location referenced.                             
Pointer or parameter error (C G D F).                                
C                                                                    
Pointer or parameter error (C G D F).                                
C                                                                    
Application error.  MCH3601 unmonitored by LTCFILESUB at statement   
  0000000249, instruction X'0000'. 

Open in new window

                                 

Please help.

Regards
Ali.
Avatar of Gary Patterson, CISSP
Gary Patterson, CISSP
Flag of United States of America image

What's in the copybook?  Look carefully and see what's different.  Watch out for commented-out fields.

- Gary Pattterson
Avatar of bhagatali

ASKER

This is what is in there:

There are some differences, but i am not able to figure out why they are causing a pointer not set for reference and what I can do to overcome that.


D***************************************************************** 
DQUSEC            DS                                               
D*                                             Qus EC              
D QUSBPRV                 1      4B 0                              
D*                                             Bytes Provided      
D QUSBAVL                 5      8B 0                              
D*                                             Bytes Available     
D QUSEI                   9     15                                 
D*                                             Exception Id        
D QUSERVED               16     16                                 
D*                                             Reserved            
D*QUSED01                17     17                                 
D*                                                                 
D*                                      Varying length             
DQUSC0200         DS                                               
D*                                             Qus ERRC0200    
D QUSK01                  1      4B 0                          
D*                                             Key             
D QUSBPRV00               5      8B 0                          
D*                                             Bytes Provided  
D QUSBAVL14               9     12B 0                          
D*                                             Bytes Available 
D QUSEI00                13     19                             
D*                                             Exception Id    
D QUSERVED39             20     20                             
D*                                             Reserved        
D QUSCCSID11             21     24B 0                          
D*                                             CCSID           
D QUSOED01               25     28B 0                          
D*                                             Offset Exc Data 
D QUSLED01               29     32B 0                          
D*                                             Length Exc Data 
D*QUSRSV214              33     33                             
D*                                             Reserved2       
D*                                                             
D*QUSED02                34     34                             
D*                                                             
D*                                      Varying Length    @B1A 

Open in new window

The error means that you are referencing a variable that has a null pointer assigned.  Usually this happens when you pass a parameter that wasn't set in the calling program.  In your program with the hardcoded QUSEC, , QUSEC is a total of 274 bytes long.  

In the copy book, QUSEC is 16 bytes long.  

That's probably what is causing the problem, directly or indirectly.  Do you (or the called API) attempt to reference something past the 16th byte of QUSEC?

You probably need to provide at least one byte for the error structure.

- Gary Patterson

ASKER CERTIFIED SOLUTION
Avatar of Member_2_276102
Member_2_276102

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
Hi Ali,

Thee is a diference between teh file discribed and the copy member version:

File discribed:
-----------------
D ERRC0100               17    274    Varying

Copy Member:
------------------
D*QUSED01                17     17                                 
D*                                      Varying length          

Open in new window


Why is the copy-member field only one position end the other 258?
Why is there a star in the remark position on column 7?
and Varying should be used without length
Both points could be the problem.

Regards,
Murph