Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1291817
  • 博文数量: 287
  • 博客积分: 11000
  • 博客等级: 上将
  • 技术积分: 3833
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-16 08:43
文章分类
文章存档

2013年(15)

2012年(17)

2011年(17)

2010年(135)

2009年(85)

2008年(18)

分类: 系统运维

2009-12-01 09:00:09

     RPGIV编程技巧(7)动态调用API,获取PF member信息

     写在前面:
     用400提供的API技术获取一个LIB下的member list比较麻烦,技术难度较高,要通过调用4个API才能做到。不如直接用CL对DSPFD进行编程来得容易。不过,通过这4个API的调用过程,知道400对外开发提供的一个处理流程轮廓,知道通过API获取怎么样的信息。member list只是API提供PF信息中的一部分。

     用400 API提供的API获取一个LIB下的PF的member list,1)需要创建用QUSCRTUS API创建这个LIB的PF的用户空间,即把系统对这个LIB的PF的定义结构信息装入内存结构变量中;2)用QUSLMBR API获取这个LIB/PF的member list信息;3)用QUSPTRUS API通过一个定义在一个指针上的DS结构把这个用户空间中有关这个LIB/PF信息引入到程序中;4)用QUSDLTUS API删除这个用户定义的空间(待续)。通过处理得到完整的转载member list的Member数组。我把这段处理代码定义成一个UDF程序工具可以直接调用。

     H DEBUG DATFMT(*ISO) nomain
      *
      /copy MyLib/QTXTSRC,TlsPrDSp
     p GetMbrLst       b                   export
     d GetMbrLst       pi              *
     d #Lib                          10
     d #File                         10
      * Create User Space
     dqUsCrtUs         pr                  extpgm('QUSCRTUS')
     d QualUspName                   20a
     d ExtAttr                       10a
     d InitSize                       9b 0
     d InitVal                        1a
     d PublicAuth                    10a
     d UsDescription                 50a
     d Replace                       10a
     d Error_Code                    16a
      * List DataBase File Members
     d qUslMbr         pr                  extpgm('QUSLMBR')
     d QualUspName                   20a
     d FormatName                     8a
     d QualFileName                  20a
     d MemberName                    10a
     d OvrProcess                     1a
     d Error_Code                    16a
      * Retrieve Pointer of UserSpace (QUSPTRUS)
     d qUsPtrUs        pr                  extpgm('QUSPTRUS')
     d QualUspName                   20a
     d Pointer                         *
     d Error_Code                    16a
      *---------------------------------------------------------------------
      * Var. Create Userspace
     d QualUspName     s             20a
     d ExtAttr         s             10a
     d InitSize        s              9b 0
     d InitVal         s              1a
     d PublicAuth      s             10a
     d UsDescription   s             50a
     d Replace         s             10a
     d Error           s             16
     d*QualUspName     s             20a
     d FormatName      s              8a
     d QualFileName    s             20a
     d MemberName      s             10a
     d OvrProcess      s              1a
     d*Error           s             16a
      * Var. Retrieve Pointer to User Space
     d*QualUspName     s             20a
     d Pointer         s               *
     d Pointer2        s               *
     d*Error           s             16a
     d #Lib            s             10a
     d #File           s             10a
     d MbrDs           ds                  based(Pointer)
     d BytesReturn                    9b 0
     d BytesAvail                     9b 0
     d DataBaseFile                  10a
     d DataBaseLib                   10a
     d DataBaseMbr                   10a
     d FileAttr                      10a
     d SourceType                    10a
     d CreateDate                    13a
     d SourceChg                     13a
     d MbrText                       50a
     d SourceFile                     1a
     d RemoteFile                     1a
     d Log_Phy_File                   1a
     d ODPsharing                     1a
     d Reserved                       2a
     d CurNumRcd                      9b 0
     d NumDelRcd                      9b 0
     d DataSpaceSize                  9b 0
     d AccPathSize                    9b 0
     d NumPfm                         9b 0
     d ChangeDateTime                13a
     d SaveDateTime                  13a
     d RstDateTime                   13a
     d ExpirDate                      7a
     d Reserved2                      6a
     d NumDaysUsed                    9b 0
     d DateLastUse                    7a
     d UseResetDate                   7a
     d Reserved3                      2a
     d DataSpaceMult                  9b 0
     d AccPathSizeM                   9b 0
     d MbrTextCCSID                   9b 0
     d Offset0200Inf                  9b 0
     d Len0200Inf                     9b 0
     d Reserved4                     14a
     d SortDs          ds
     d#ChangeDateTime                13a
     d#MbrName                       10a
     d RetDs           ds                  based()
     d Members                       23    dim(999) descend inz(*all' ')
      *
     d x               s              3s 0
     d            s               *
      * Used to fill Generic Header
     d Fld192          s            192a   based(pointer)
      * Generic Header Format 0100
     d GHF0100         ds
     d GH_UserArea                   64a
     d GH_SizeOfHeade                 9b 0
     d GH_Structure                   4a
     d GH_Format                      8a
     d GH_APIused                    10a
     d GH_DatTimeCrt                 13a
     d GH_InfSts                      1a
     d GH_SizeUsp                     9b 0
     d GH_OffInpParm                  9b 0
     d GH_SizeInpParm                 9b 0
     d GH_OffHeadSec                  9b 0
     d GH_SizeHeadSec                 9b 0
     d GH_OffLstData                  9b 0
     d GH_SizeLstData                 9b 0
     d GH_NumListEntr                 9b 0
     d GH_SizeEntry                   9b 0
     d GH_CCSIDofData                 9b 0
     d GH_CountryID                   2a
     d GH_LanguageID                  3a
     d GH_SubsLstInd                  1a
     d GH_Reserved42                 42a
     d Fld32           s             32a   based(pointer)
      * List Data Section
     d ListDataSec     ds
     d LD_MemberName                 10a
     d LD_Reserved2                   2a
     d LD_OffMbrDesc                  9b 0
     d LD_Reserved16                 16a
      *
      /free
          // Create Userspace
           QualUspName = 'MBRLIST QTEMP ';
           ExtAttr = 'EXT_ATTR ';
           InitSize = 65000;
           InitVal = X'00';
           PublicAuth ='*ALL ';
           UsDescription = 'User Space created ' +
                           'by PGM:GETMBRDAT';
           Replace = '*YES ';
           callp qUsCrtUs(QualUspName:ExtAttr:InitSize:
                          InitVal:PublicAuth:UsDescription:
                          Replace:Error);
          //Get member list
          FormatName='MBRL0320';
          QualFileName = #File + #Lib;
          MemberName='*ALL';
          OvrProcess='1';
          callp qUslMbr(QualUspName:FormatName:
                        QualFileName:MemberName:OvrProcess:
                        Error)

          //Retrieve Pointer to User Space
          callp qUsPtrUs(QualUspName:Pointer:Error);
          //Fill Generic Header
          GHF0100 = %triml(Fld192);
          //Point to ListDataSection
          Pointer = Pointer + GH_OffLstData;
          //Fill ListDataSection
          ListDataSec = %triml(Fld32);
          //Point on first Entry
          Pointer = Pointer + LD_OffMbrDesc - GH_OffLstData;

          do GH_NumListEntr;
             x = x + 1;
             #MbrName = DataBaseMbr;
             #ChangeDateTime = ChangeDateTime;
             Members(x) = %triml(SortDs);
             Pointer = Pointer + BytesReturn + 6;
          enddo;
          Members = %subarr(Members);

          return ;
          *inlr = *on;
      /end-free
     p                 e

 

阅读(1720) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~