Using QUSRTVUS API in COBOL

240 pts.
Tags:
API
AS/400
COBOL 400
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

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    You need to show us your code. We can't know what values you should use without seeing how you set it up. -- Tom
    125,585 pointsBadges:
    report
  • asakla
    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                         
    240 pointsBadges:
    report
  • TomLiotta
    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
    125,585 pointsBadges:
    report
  • asakla
    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 ?
    240 pointsBadges:
    report
  • TomLiotta
    ...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
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following