BPX1GGE (getgrent) example

The following code accesses the group database starting with the next available entry and continuing until end of file on the database. It returns a structure identifying information about each group entry in the database. For the callable service, see getgrent (BPX1GGE, BPX4GGE) — Sequentially access the group database. For the data structure, see BPXYGIDS — Map data returned for getgrnam and getgrpid. AMODE 64 callers use BPX4GGE (getgrent) example.
                                              
GGELOOP  DS    0H                                                       
         CALL  BPX1GGE,              Access the group database         +
               (RETVAL,              Return value: 0 or ->BPXYGIDS     +
               RETCODE,              Return code                       +
               RSNCODE),             Reason code                       +
               VL,MF=(E,PLIST)       ---------------------------------- 
         ICM   R8,B'1111',RETVAL                                        
         BZ    CHKGGERR              Error or end of file               
         USING GIDS,R8                                                  
*        access the group structure                                     
         DROP  R8                                                       
         B     GGELOOP               Check next group entry             
CHKGGERR DS    0H                                                       
         ICM   R8,B'1111',RETCODE                                       
         BZ    GGEEOF                End of file                        
*        handle error as needed                                         
GGEEOF   DS    0H