225 pts.
 Using QUSRTVUS API in COBOL
I want to list all the Job Schedule entries and save them in a Physical file , I used API QWCLSCDE to fetch that list in a User Space , then I did a QUSRTVUS to load the data in my COBOL program. As the variable Starting position and Length of data are Binary, and I am passing values 1 and 28 to the same. The user space returned is of 1024 bytes but its not from the starting point. It comes from somewhere in the middle, meaning the Generic Header, Input Parameters and all are missing. Please let me know the proper values to be passes in these parameters to fetch the User space from starting and also how do I increment the Binary variables to fetch the next set of data

Software/Hardware used:
AS400 , i series COBOL
ASKED: February 13, 2013  10:03 AM
UPDATED: February 13, 2013  1:08 PM

Answer Wiki:
Last Wiki Answer Submitted:  Be the first to answer this question.
All Answer Wiki Contributors:  Be the first to answer this question. Michael Tidmarsh   11,390 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

You need to show us your code. We can’t know what values you should use without seeing how you set it up. — Tom

 107,995 pts.

 

HI Tom , 

 
Paameters setup of QUSRTVUS
05 QUSR-REC.                                              
   10 QUSRSPN      PIC X(20) VALUE “MJSDTMGRSPMIUOALLV1″. 
   10 QUSRSTR      PIC 9(04) COMP VALUE 1  .              
   10 QUSRLNG      PIC 9(04) COMP VALUE 28.               
   10 QUSRDTA      PIC X(5000) VALUE SPACES.              
Calling of the API 
CALL “QUSRTVUS” USING QUSRSPN    
                      QUSRSTR    
                      QUSRLNG    
                      QUSRDTA    
END-CALL                         
 225 pts.

 

First, you can’t use 9(04) COMP variables. Those would only only define 2-byte integers, and the API asks for 4-byte integers. Make those 9(09) COMP instead. And if you start in position 1 and retrieve 28 bytes, you’re only getting the first 28 bytes of the 64-byte User Area of the space. To get to the list, you first need to retrieve the 4-byte binary offset value beginning in position 125 (offset 124) of the header. Use the offset that you retrieve to access the list entries rather than using (1). And be aware that it’s an offset value, not a position; so you’ll need to increment it by (1) before sending it into QUSRTVUS again. — Tom

 107,995 pts.

 

Hi Tom , Thanks .I made the changes, But how do i fetch the header information , Meaning to fetch the header information what values i need to pass in  the start variable and Length variable ?

 225 pts.

 

…to fetch the header information what values i need to pass in  the start variable and Length variable ?
 
I don’t know what values you want. It depends on where you want to start in the headers and how much of the headers you want to retrieve.
 
The link I gave diagrams possible ares that you might need or be interested in. Offsets are shown.
 
You can use the QUSPTRUS API to retrieve a pointer to the space. The offsets to the pointer address are shown in the diagram.
 
If you don’t want to use QUSPTRUS, you can use the QUSRTVUS API, as you showed. Instead of an offset for a pointer, you use the position to start your retrieval.
 
Offsets use a zero base for the start of the space. Positions use (1) as the start of the space. You used QUSRTVUS, so you would take an offset value from the diagram and add (1) to it for the position. The position is the “starting value”.
 
But I don’t know where you want to start. Try different starting positions and lengths, retrieve some values and look at them. Compare what you retrieve to the format definitions in the documentation. That’s how you will learn.
 
Tom

 107,995 pts.