Differences

This shows you the differences between two versions of the page.

Link to this comparison view

list_members [2019/03/18 11:39]
list_members [2021/04/05 11:23] (current)
Line 1: Line 1:
 +====== List Members ======
  
 +<sxh>
 +     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...
 +                     PR                  extpgm('QUSLMBR')
 +      userspace                    20A   const
 +      format                        8A   const
 +      filename                     20A   const
 +      member                       10A   const
 +      ovrProcessing                 1A   const
 +      error                              likeds(QUSEC) options(*nopass)
 +
 +
 +       main();
 +       *inlr = *on;
 +
 +
 +     P main            B
 +
 +     D abnormallyEnded...
 +                                   N
 +     D library                     10A
 +     D filename        S             10A
 +     D usPtr                         *
 +     D usHeader        DS                  likeds(tmpl_userspace_header)
 +                                         based(usPtr)
 +     D userspace_attr  DS                  likeds(tmpl_userspace_attributes)
 +     D usName          S             10A
 +     D usLib                       10A   inz('QTEMP')
 +     D dataPtr                       *
 +     D usData          DS                  qualified based(dataPtr)
 +       member                      10A
 +       sourceType                  10A
 +       creationDate                13A
 +       lastChanged                 13A
 +       description                 50A
 +       ccsid                       10I 0
 +     D i                           10I 0
 +     D lastChanged                   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);
 +
 +                     E
 +</sxh>
 +
 +{{tag>devel ibm rpg}}