User Tools

Site Tools


list_members

List Members

     H dftactgrp(*no) actgrp(*caller) bnddir('MYBNDDIR')

      /if not defined(QUSEC)
      /define QUSEC
      /copy QSYSINC/QRPGLESRC,QUSEC
      /endif


      /include '/usr/local/include/libc_h.rpgle'
      /include '/usr/local/include/userspace_h.rpgle'


     D listFileMembers...
     D                 PR                  extpgm('QUSLMBR')
     D  userspace                    20A   const
     D  format                        8A   const
     D  filename                     20A   const
     D  member                       10A   const
     D  ovrProcessing                 1A   const
     D  error                              likeds(QUSEC) options(*nopass)


       main();
       *inlr = *on;


     P main            B

     D abnormallyEnded...
     D                 S               N
     D library         S             10A
     D filename        S             10A
     D usPtr           S               *
     D usHeader        DS                  likeds(tmpl_userspace_header)
     D                                     based(usPtr)
     D userspace_attr  DS                  likeds(tmpl_userspace_attributes)
     D usName          S             10A
     D usLib           S             10A   inz('QTEMP')
     D dataPtr         S               *
     D usData          DS                  qualified based(dataPtr)
     D   member                      10A
     D   sourceType                  10A
     D   creationDate                13A
     D   lastChanged                 13A
     D   description                 50A
     D   ccsid                       10I 0
     D i               S             10I 0
     D lastChanged     S               D

       usName   = 'LISTMEMBER';
       library  = 'MYLIB     ';
       filename = 'MYFILE    ';

       clear QUSEC;
       userspace_create(usName + usLib : *blank : 4096 : X'00' : '*ALL' :
                       'List Members' : '*YES' : QUSEC );

       // change user space attributes to autoextend
       clear QUSEC;
       userspace_attr.size = 1;       // 1=attribute will be changed
       userspace_attr.key = 3;        // 3=extensibility attribute
       userspace_attr.dataLength = 1;
       userspace_attr.data = '1';     // user space is extensible
       userspace_changeAttributes(usLib : usName+usLib : userspace_attr:QUSEC);

       clear QUSEC;
       userspace_retrievePointer(usName + usLib : usPtr : QUSEC);

       listFileMembers( usName + usLib : 'MBRL0200' : filename + library :
                          '*ALL' : '1' : QUSEC);

       // iterate through retrieved members
       for i = 0 to usHeader.nmbrEntries - 1;
         dataPtr = usPtr + usHeader.offsetList + (i * usHeader.entrySize);

         monitor;
           // lastchanged Format : EJJMMDDHHMMSS
           // E = Epoche : 0 = 19xx , 1 = 2xxx (Jahr)
           lastChanged = %date(%subst(usData.lastChanged : 2 : 6) : *YMD0);

         on-error *all;
           dsply usData.member;
           dsply %trimr('Invalid date: ' + usData.lastChanged);
         endmon;

         if (i > 10);
           leave;
         endif;
       endfor;

       on-exit abnormallyEnded;
         userspace_delete(usName + usLib : QUSEC);

     P                 E

list_members.txt · Last modified: 2019/03/18 10:39 by mihael