Running the QSPOLJBQ API

135 pts.
Tags:
API
IBM iSeries
RPGLE
I am calling this API that is an RPG program. When I run the program in debug mode it runs fine and displays all my jobques on the screen. When I enddbg, the program only goes through the code 1 time. Would anyone know why this is happening?

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi,

Do you get any messages in the joblog when you run in debug? Are you running the same object with debug and without debug (is there another one in your library list)?

Regards,

Martin Gilbert.

Hi Martin, thanks for responding. There are no special messages in the job log and I only have the object in one library so it is the same object with debug as without. I have supplied an example of my code. It I run it in debug and step through line of code, it will run fine and display 37 job queues. But If I end debug and just call the problem, it will only display 1 job queue. It’ like it only sees 1 record instead of 37 records running by the debug mode. Any help on this would be very much appreciated.

=============================================================

You don’t show us any values that were returned from the call to QGYGTLE. In particular, you don’t show us the content of your ListInfo data structure after each call. And your code shows that you don’t test any of the values.

If you don’t check what the API returns, you have no way of knowing what happens. You can’t ask us because we can’t run your program to check for you.

You need to check subfields in your data structure. What value is returned in ListStatus? Is the list still being built? Is the list primed and ready to be built?

What reason do you have to start looping if you haven’t checked to see if the list is ready yet?

If it runs in debug, it will be running at human speed. When it runs outside of debug, it will run at system speed. It will <i>appear</i> to work in debug because you are forcing it to run a thousand times slower. It doesn’t run properly outside of debug because you don’t check to see if it’s ready to proceed.

Also, you haven’t told us anything about your system environment. Do you have a proper setup for the list server program to run in?

Your program is pretty good as far as it goes. It just needs to be finished.

Tom

=============================================================

The following example generates a list of all job queues in QGPL and then displays them on the screen.

D* Open List of Job Queues (QSPOLJBQ) API Prototype
D OpnLstJobQ Pr ExtPgm(‘QSPOLJBQ’)
D oRcvVar Like(OJBQ0100)
D iRcvVarLen 10i 0
D iRcvVarFmt 8a
D oListInfo 80a
D iFilter Like(Filter)
D iSort Like(Sort)
D iNbrRecs 10i 0
D iAPIError Like(APIError)

D* Get List Entries (QGYGTLE) API Prototype
D GetListEntries Pr ExtPgm(‘QGYGTLE’)
D oRcvVar Like(OJBQ0100)
D iRcvVarLen 10i 0
D iRqsHandle 4a
D oListInfo 80a
D iNbrRecs 10i 0
D iStartRec 10i 0
D oAPIError Like(APIError)

D* Close List (QGYCLST) API Prototype
D CloseList Pr ExtPgm(‘QGYCLST’)
D iRqsHandle 4a
D oAPIError Like(APIError)

D* Format of Open List Information
D ListInfo Ds
D TotalRecs 10i 0
D RecsRtn 10i 0
D ReqsHandle 4a
D RecLen 10i 0
D Complete 1a
D Timestamp 13a
D ListStatus 1a
D 1a
D InfoLen 10i 0
D FirstRec 10i 0
D 40a

D* Format of Filter for API Call
D Filter Ds
D FilterLen 10i 0 Inz(%Len(Filter))
D Jobq 10a
D JobqLib 10a
D ActSubSys 10a
D 1a Inz(x’00′)

D* Format of Sort for API Call
D Sort Ds
D NbrKeys 10i 0 Inz(0)
D KeyStartPos 10i 0 Inz(0)
D KeyLen 10i 0 Inz(0)
D KeyType 5i 0 Inz(x’00′)
D SortOrder 1a Inz(x’00′)
D 1a Inz(x’00′)

D* Format of Receiver Variable for API Call
D OJBQ0100 Ds
D oJobq 10a
D oJobqLib 10a
D oJobqSts 1a
D oSbsName 10a
D oSbsLib 10a
D 3a
D oNbrJobs 10i 0
D oSeqNbr 10i 0
D oMaxAct 10i 0
D oCurAct 10i 0
D oDesc 50a

D* Standard API Error Data Structure
D ApiError DS
D ApiBytes 10I 0 Inz(%Size(ApiError))
D ApiBytesOut 10I 0
D ApiErrID 7A
D ApiReserved 1A
D ApiErInDta 256A

D* Work fields
D wRecNo s 10i 0 Inz(*Zeros)
D wRcvVarLen s 10i 0 Inz(%Len(OJBQ0100))
D wRcvVarFmt s 8a Inz(‘OJBQ0100′)
D wNbrRecs s 10i 0 Inz(1)
D wReply s 1a Inz(*Blanks)

C* Prepare the Filter data structure to retrieve the job queues we want…
C Eval Jobq = ‘*ALL’
C Eval JobqLib = ‘QGPL’
C Eval ActSubSys = *Blanks

C* Call the API to build the list…
C CallP OpnLstJobq(OJBQ0100 : wRcvVarLen :
C wRcvVarFmt : ListInfo : Filter : Sort :
C wNbrRecs : APIError)

C* Once the list has been created we can read through it using the
C* GetListEntry (QGYGTLE) API…

C* Read through all records in the list…
C For wRecNo = 1 to TotalRecs

C* Call the API to read an entry from the list…
C CallP GetListEntries(OJBQ0100 : wRcvVarLen :
C ReqsHandle : ListInfo : wNbrRecs : wRecNo :
C APIError)

C* Display the name of the job queue and get the next record…
C oJobq Dsply
C EndFor

C ‘*Finished*’ Dsply wReply

C* Finally close the list and exit the program…
C CallP CloseList(ReqsHandle : APIError)

C Eval *InLR = *On
C Return

Discuss This Question: 7  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
  • Gilly400
    Hi, Is the one OUTQ that it shows the last one from your list by any chance? Regards, Martin.
    23,730 pointsBadges:
    report
  • Cwc
    I suspect that your code is looping through the job queue names just fine, whether through debug or not. The DSPLY operation is intended to be just a quick and easy way for a program to communicate to the requestor via a message, generally for a temporary solution such as validating output during testing. I have found that its behavior can be influenced by settings external to the program. Check the message logging options for your interactive job (via the DSPJOB command). Ensure that they're not set for *NOLIST or level 0, for example. I have noticed different behavior depending on which invocation level an interactive job is currently in (such as when you press F10 from PDM, or call the QCMD program to get a new command line). If you created a subfile so that your program could load all the JobQ names and then display that subfile on the screen, you could then verify the behavior, as well as not requiring the user to have to press Enter each time to see the next JobQ. Or if you just look through your job log, you'll probably see that all the names do get displayed, but the screen isn't pausing due to the factors above.
    4,290 pointsBadges:
    report
  • ISERIESTECH
    AActually I do have my job logging set up correctly. I have this line of code in my CL. (CHGJOB LOG(4 00 *SECLVL) LOGCLPGM(*YES)) rite before I call my RPGLE program.. When I look through my job log, I only see the first outque displayed when running not in debug mode. Please see below. When I run it in debug mode I get 37 different jobqueues listed in the job log, so I know it works running in debug. 6 > call XSPOLJBQPG DSPLY BUSINT DSPLY QGPL DSPLY *Finished* I am actually writing the job queue names to a work file that I created and I have the DSPLY command commented out so it is working somewhat like a subfile. I just wanted to get this version of the program working with the DSPLY command without having to run it in debug mode. What I was trying to accomplish was to write out all the names of my outqueues and libraries to a PF and then call another program to do analysts type stuff.
    135 pointsBadges:
    report
  • Cwc
    Okay, to narrow it down, what about this? In the For loop, you could add a DSPLY statement for displaying the value of the TotalRecs variable for each iteration, to verify that it is finding all the JobQs from the API call?
    4,290 pointsBadges:
    report
  • ISERIESTECH
    I finally got it to work another way. I replaced my FOR statment with a Do somany times and it seems to work ok.. Thank you both for all of your suggestionswith this matter. This is a great website to ask questions and I look foward to using it again in the future. Thanks Again Guyes!!!!!
    135 pointsBadges:
    report
  • Junky
    I see that a work around was found, but was curious as to where TotalRecs gets loaded with a value other than 0??
    95 pointsBadges:
    report
  • Junky
    See it now - in the ListInfo data structure being loaded by the API. Thought that might have been why the program wasn't looping thru all the items. Guess not.
    95 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