Open list of Objects using QGYOLOBJ API

415 pts.
Tags:
API
AS/400
IBM iSeries
ILE c
iseries v5r4
Hi, I'm trying to use the QGYOLOBJ API to get all the objects from one type but always gave me invalid results into the List Information str:
 
struct SelectionControl
{
    Qgy_Olobj_SelControl_t selControl ;
    char status;
};
struct Receiver
{
    Qgy_Olobj_RecVar_t receiver ;
    Qgy_Olobj_KeyData_t keys ;
} ;
int main ()
{
    int numToRet = 1000 ;
    Receiver * receiver = new Receiver [1000] ;
    int szRec = sizeof ( Receiver) * numToRet;
    Qgy_Olobj_ListInfo_t listInfo ;
    Qgy_Olobj_SortInfo_t sortInfo ;
    sortInfo.Num_Keys = 0 ;
    char qualifPgm [20] ;
    strncpy ( qualifPgm , "*ALL      " , 10 ) ;
    strncpy ( qualifPgm +10 , "QGPL      " , 10 ) ;
    char type [10] ;
    strncpy ( type , "*USRSPC   " , 10 ) ;
Qgy_Olobj_AuthControl_t authCtrl ;
    authCtrl.Format_Length = sizeof(authCtrl) ;
    authCtrl.Call_Level = 1 ;
    authCtrl.Obj_Auth_Offset = 0 ;
    authCtrl.Lib_Auth_Offset = 0 ;
    authCtrl.Num_Lib_Auth = 0 ;
    authCtrl.Num_Obj_Auth = 0 ;
 SelectionControl selControl ;
    selControl.selControl.Format_Length = sizeof(selControl);
    selControl.selControl.Num_Status = 1;
    selControl.selControl.Sel_or_Omit_Status = 0;
    selControl.selControl.Status_Offset = sizeof(selControl);
    //selControl.selControl.Reserved = 0x0 ;
    selControl.status = '*';
    int numKeys = 1;
    errorCode_t errorCode ;
    errorCode.ec_fields.Bytes_Provided = sizeof (errorCode) ;
    Qwc_JIDF0100_t jobInfo ;
    strncpy ( jobInfo.Job_Name , "*INT      " , 10 ) ;
    Qgy_Olobj_ASPControl_t aspCtrl ;
    aspCtrl.Format_Length = 24 ;
    strncpy( aspCtrl.ASP_Device_Name, "*SYSBAS   ", 10 )  ;
    strncpy( aspCtrl.ASP_Search_Type, "          ", 10 )  ;
int keyFields[1] ;
    keyFields[0] = 301 ;
    QGYOLOBJ  (receiver,         /* Receiver variable             */
                    szRec   ,           /* Length of receiver variable   */
                    &listInfo,          /* List Information              */
                    numToRet   ,        /* Number of records to return   */
                    &sortInfo,          /* Sort Information              */
                    qualifPgm,          /* Object and Library name       */
                    type ,              /* Object type                   */
                    &authCtrl,          /* Authority control             */
                    &selControl,        /* Selection control             */
                    numKeys   ,         /* Number of fields to return    */
                    keyFields,                  /* Key of fields to return       */
                    &errorCode,         /* Error code                    */
                    "*         ",       /* void * Job identification info */
                    &jobInfo ,          /* void * Fmt job ID info*/
                    &aspCtrl );         /* void * Auxiliary storage
                                       pool (ASP) control        @B0A*/
   printf ( "Total Records [%d]n" , listInfo.Total_Records)  ;
   printf ( "Info Complete [%c]n" , listInfo.Info_Complete)  ;
   printf ( "Returned %d" , listInfo.Records_Retd);
    return 0 ;
}
Where can be wrong ? 


Software/Hardware used:
v5r4,QGYOLOBJ

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: 14  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
    ...but always gave me invalid results into the List Information str What does that mean? What error are you receiving? What values are incorrect? When does an error appear? Tom
    125,585 pointsBadges:
    report
  • GraceP
    Hi, The results of the
    printf ( "Total Records [%d]n" , listInfo.Total_Records)  ;
    printf ( "Info Complete [%c]n" , listInfo.Info_Complete)  ;
    printf ( "Returned %d" , listInfo.Records_Retd);
    
    are : Total Records [1077952576] Info Complete [ ] Returned 1077952576 Which can not be possible :S because I just have 6 user spaces into the QGPL library, ooops , I forgot the error verification... which now gave me the CPF3C21 ... :$ ummm ....
    415 pointsBadges:
    report
  • GraceP
    changing the
     selControl.selControl.Status_Offset = sizeof(selControl);
    
    by
     selControl.selControl.Status_Offset = 20 ;
    
    and removing the last 3 parameters of the input I could obtain correct results : Total Records [1] Info Complete [ C] Returned 1 but, I want to pass the ASP as parameter, What type of information is required into the Optional Parameter Group 1?
    415 pointsBadges:
    report
  • GraceP
    well ... changing the last part of the call to API
     QGYOLOBJ  (receiver,
    ..., 
      "*         ",       /* void * Job identification info */
                        &jobInfo ,          /* void * Fmt job ID info*/
                        &aspCtrl );         /* void * Auxiliary storage*/
    
    by
     QGYOLOBJ  (receiver,
       ... ,
      jobId ,             /* void * Job identification info */
      "JIDF0000",          /* void * Fmt job ID info*/
      &aspCtrl );         /* void * Auxiliary storage */
    
    Solves the question ... is not necessary the jobInfo var. A remainder for read carefully the documentation :S
    415 pointsBadges:
    report
  • TomLiotta
    Total Records [1077952576] As you might know, that number is the binary value of a 4-byte sequence of blanks, x'40404040'. It would likely indicate that nothing was returned and that the errorCode values probably ought to be checked. Of course, that's a reverse of the way things should be... Check errorCode first, then... But you're getting it working. Post back if more problems appear. Tom
    125,585 pointsBadges:
    report
  • GraceP
    A problem appear ... and seems as is because I'm using *MODULE for different parts of the program, there is not problem when is just an single *PGM because I guess is a single Job , but when I call another modules before to call the next entries ... the program ends ... but in background the wrkactjob show me that I'm using a lot of resources , It is possible that this problem ( I only get the first rows ) occurs by calling another modules ?
    415 pointsBadges:
    report
  • TomLiotta
    It is possible that this problem ( I only get the first rows ) occurs by calling another modules ? Yes, it's possible; but I can't think of a reason it would make a difference. Without seeing the code, there's no way to know what would be happening. Assuming everything is coded okay, calling a procedure in a different *MODULE in the same program shouldn't make a difference for an 'Open List...'. Tom
    125,585 pointsBadges:
    report
  • GraceP
    Some code from the main loop of the program: When I execute the QGYSERVER starts but not ends when the program ends .... ( looks like if it is doing the extra calls , but lost the connection with the main *PGM )
     do {
    	ptr = getNextElements(handler, &getListInfo, recordsRtd, receiver, &errorCode);
    
    	if (getListInfo.Info_Complete == 'C' || getListInfo.Info_Complete == 'P') {
    		for (int i = 0; i < getListInfo.Records_Returned; i++) {
    			
    			strncpy ( qualifObj.objLib , ((Qgy_Olobj_RecVar_t *) ptr)->Obj_Lib , 10) ;
    			strncpy ( qualifObj.objName , ((Qgy_Olobj_RecVar_t *) ptr)->Obj_Name , 10) ;
    
    			module3.method2(&qualifObj);
    
    			if (strcmp(module3.method1(), "*YES") == 0) {
    				module2.method1(&qualifObj);
    			}
    			ptr = ptr + getListInfo.Record_Length;                            
    		}
    	}
    	handler = getListInfo.Request_Handle;
    	recordsRtd = getListInfo.First_Buffer_Record + getListInfo.Records_Returned;
    
    	printf(" %d + %d - 1 < %d  &&  [%x] n ", getListInfo.First_Buffer_Record, getListInfo.Records_Returned, getListInfo.First_Buffer_Record + getListInfo.Records_Returned - 1, getListInfo.Total_Records, listInfo.List_Status );
    
    
    } while (getListInfo.First_Buffer_Record + getListInfo.Records_Returned - 1 < getListInfo.Total_Records && listInfo.List_Status != '2');
    
    the printf ... : 1 + 70 - 1 < 70 && [46] // this is strange 1 + 70 - 1 < 70 ... but with the single *PGM , which works correctly, it has the same output, nevertheless still do the remain cycles until get all the elements :S
    415 pointsBadges:
    report
  • TomLiotta
    Your getNextElements() proc calls to the QGYGTLE API, and your program calls the QGYCLST API before it ends, right? Tom
    125,585 pointsBadges:
    report
  • GraceP
    yes , only close the list if the listInfo.List_Status = 2 or the total of records returned is equals to getListInfo.Total_Records
    415 pointsBadges:
    report
  • TomLiotta
    only close the list if... ...or when you're finished with it and don't want any more entries from it. Can you show how getNextElements() calls QGYGTLE? Tom
    125,585 pointsBadges:
    report
  • GraceP
    it is very simple
    char *  getNextElements (char * handler , Qgy_Gtle_ListInfo_t * getListInfo,
     int next , char * receiver , errorCode_t * errorCode )
    {
    
    
        QGYGTLE(receiver, TAM , handler, getListInfo, RECORSREQ,
                next, errorCode);
    
        if (errorCode ... 
            return 0 ;
        }
    
        return receiver ;
    
    } This job QGYSERVER will be end at the final of the execution ? because still remains
    415 pointsBadges:
    report
  • TomLiotta
    You have szRec back up in main. But I see TAM used instead down in getNextElements(). Does TAM use szRec? Same question for numToRet and RECORSREQ. Assuming those are macros, the code could be useful to see. Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    This job QGYSERVER will be end at the final of the execution ? As far as I know, that job will run until you close the list or until the job that requested the list ends. It may take time for it to end if your job ends and hasn't closed the list. Ending your program shouldn't affect the QGYSERVER job if the job that called your program is still running. Other programs in the job might use the list after your program finishes, so the list server job won't go away. Are you submitting your program to batch? If you are, the QGYSERVER job should end fairly soon, though it might continue until it finishes building the entire list. If you look at the QGYSERVER job on the WRKACTJOB display, what shows in the 'Function' column? You tagged the question with V5R4, and I've seen QGYSERVER get hung in V5R4. It was always after ending a job without closing the list. I had to use ENDJOBABN to end the QGYSERVER job. I don't know if that's related though nor do I know if it specific to V5R4. The only times that I know of when the list wasn't closed was during test runs. 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