免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 4286 | 回复: 13
打印 上一主题 下一主题

菜鸟请教个问题,如果在程序中取到LIB下的OBJ及MBR? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-11-30 10:39 |只看该作者 |倒序浏览
菜鸟请教个问题,如果在程序中取到LIB下的OBJ及MBR?

目前想做一个仿PDM的小工具,通过读PF下定义的LIB,能通过12逐级进入OBJ、MBR,没做过这种应用,没有头绪,大侠们指点下,谢谢!

论坛徽章:
0
2 [报告]
发表于 2009-11-30 11:00 |只看该作者

回复 #1 xj6875 的帖子

要列出一个library中的所有object, 还有列出文件中的所有member, 正规的办法是使用api,这样比较难些。 不过对于初学者玩玩的程序可以使用以下的简便办法

用cl

1)  OVRPRTF FILE(QPDSPLIB) HOLD(*YES)   
2)  DSPLIB LIB(YOUR_LIB) OUTPUT(*PRINT)
3)  CPYSPLF FILE(QPDSPLIB) TOFILE(MY_LIB/MY_DBF) SPLNBR(*LAST)   

结果将library清单输出的文件MY_DBF中去。你在自己从该为文件中截取所需要得OBJECTS.
要拿到MEMBER的清单比较容易:
DSPFD FILE(YOUR_LIB/YOUR_FILE) TYPE(*MBRLIST) OUTPUT(*OUTFILE) OUTFILE(YOUR_LIB/YOUR_MBRL)

因为DSPFD 可以直接输出到文件,
那就不需要拷贝SPOOLFILE再截取了。

生成的临时文件可以放在QTEMP中。这样在你登出系统后就可以被自动清除了。

其实列出LIBRARY中的OBJECTS还可以用DSPOBJD命令,这个命令也可以输出到输出文件中去,省去了拷贝SPOOLFILE的麻烦。不过从SPOOLFILE拷贝也是技巧之一,可以练习一下。不是每个命令都可以有输出文件的。

希望我提供的信息对你有用。

[ 本帖最后由 franliu 于 2009-11-30 17:41 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2009-11-30 17:22 |只看该作者
楼上 麻烦你把API的功能讲一下呗 看看用什么样的API怎么实现

论坛徽章:
0
4 [报告]
发表于 2009-11-30 17:32 |只看该作者

回复 #3 lizi211314 的帖子

1) list object API:

List Objects (QUSLOBJ) API

Required Parameter Group:

1         Qualified user space object         Input         Char(20)
2         Format name         Input         Char(
3         Object and library name         Input         Char(20)
4         Object type         Input         Char(10)

Optional Parameter Group 1:

5         Error Code         I/O         Char(*)

Optional Parameter Group 2:

6         Authority control         Input         Char(*)
7         Selection control         Input         Char(*)

Optional Parameter Group 3:

8         Auxiliary storage pool (ASP) control         Input         Char(*)


Default Public Authority: *USE

Threadsafe: Yes

The List Objects (QUSLOBJ) API lets you generate a list of object names and descriptive information based on specified selection parameters. Start of change This API returns information similar to the Display Object Description (DSPOBJD) command. An advantage over the DSPOBJD command is that you can perform authority checking on the objects and libraries. You can get a list of objects with only a certain status, which you cannot do with the DSPOBJD command. End of change The QUSLOBJ API places the list in the specified user space. The generated list replaces any existing list in the user space.

论坛徽章:
0
5 [报告]
发表于 2009-11-30 17:35 |只看该作者

回复 #3 lizi211314 的帖子

2) list member API
List Database File Members (QUSLMBR) API

  Required Parameter Group:

1         Qualified user space name         Input         Char(20)
2         Format name         Input         Char(
3         Qualified database file name         Input         Char(20)
4         Member name         Input         Char(10)
5         Override processing         Input         Char(1)

  Optional Parameter:

6         Error code         I/O         Char(*)

  Service Program Name: QUSLMBR

  Default Public Authority: *USE

  Threadsafe: Conditional; see Usage Notes.

The List Database File Members (QUSLMBR) API generates a list of database file members and places the list in a specified user space. When you specify a generic member name, you can generate a subset of the member list. You can use the QUSLMBR API with database file types *PF, *LF, and *DDMF. The generated list replaces any existing information in the user space. The file members listed in the user space are not in any predictable order. To retrieve additional information about each member in the list, see the Retrieve Member Description (QUSRMBRD) API.

You can use the QUSLMBR API to:

    * List members more quickly than by using the *MBRLIST value on the TYPE parameter of the Display File Description (DSPFD) command.
    * Retrieve information for all of the members of a database file more quickly and easily than by multiple calls to the Retrieve Member Description (QUSRMBRD) API. It is your discretion to decide which API best suits the needs of your application. For example, if you want to selectively retrieve member descriptions for a subset of the member list, you might want to use both the QUSLMBR and QUSRMBRD APIs.
    * Ensure that the last date the source was changed matches the date of the source used to create the object.


Authorities and Locks

User Space Authority
    *CHANGE
User Space Library Authority
    *EXECUTE
File Authority
    *OBJOPR
User Space Lock
    *EXCLRD
File Lock
    *SHRRD


Required Parameter Group

Qualified user space name
    INPUT; CHAR(20)

    The user space that is to receive the created list. The first 10 characters contain the user space name, and the second 10 characters contain the name of the library where the user space is located. You can use these special values for the library name:
    *CURLIB         The job's current library
    *LIBL         The library list

Format name
    INPUT; CHAR(

    The content and format of the information returned for each member. The possible format names are:
    MBRL0100         Member name
    MBRL0200         Member name and source information This format requires more processing than the MBRL0100 format.
    MBRL0310         Member name and basic description. The member information is the same as that generated by the Retrieve Member Description (QUSRMBRD) API using format MBRD0100. This format requires more system processing and takes longer to produce than the MBRL0200 format.
    MBRL0320         Member name and expanded description. The member information is the same as that generated by the Retrieve Member Description (QUSRMBRD) API using format MBRD0200. The additional information requires more system processing and takes longer to produce than the MBRL0310 format.
    MBRL0330         Member name and full description. The member information is the same as that generated by the Retrieve Member Description (QUSRMBRD) API using format MBRD0300. The additional information requires more system processing and takes longer to produce than the MBRL0320 format.
    For more information, see MBRL0100 List Data Section, MBRL0200 List Data Section, or MBRL0300 List Data Section.

Qualified database file name
    INPUT; CHAR(20)

    The name of the database file whose member names are to be placed in the list. The first 10 characters contain the database file name, and the second 10 characters contain the name of the library where the file is located. You can use these special values for the library name:
    *CURLIB         The job's current library
    *LIBL         The library list

Member name
    INPUT; CHAR(10)

    A specific member name, a generic member name, or this special value:
    *ALL         All members

Override processing
    INPUT; CHAR(1)

    Whether overrides are to be processed. The following character values are used:
    0         No override processing
    1         Override processing

论坛徽章:
0
6 [报告]
发表于 2009-11-30 20:07 |只看该作者
都是英文的,看得晕晕的

论坛徽章:
0
7 [报告]
发表于 2009-11-30 22:16 |只看该作者

回复 #1 xj6875 的帖子

练习方法:
1.使用dspfd将obj输出到一个文件假设为objf,将mbr输出到一个文件假设为mbrf
  (命令事例:
    DSPFD FILE(XXXXX) TYPE(XXXXXX) OUTPUT(*OUTFILE) OUTFILE(XXXXXXXX)
   )
2.建立一个dspf,内容为你想要的.(想要有msgf加一个msgf)
3.开始写rpg程序,专门实现你的功能,rpg程序使用的文件至少有dspf,objf,mbrf...


自己练习把,,祝你成功..

论坛徽章:
0
8 [报告]
发表于 2009-12-01 08:46 |只看该作者
You can use the QUSLFLD API

  *-----------------------------------------*      
  * QUSLFLD Return Variables Data Structure *      
  *-----------------------------------------*      
D FLDL0100        DS                              
D  FieldName                    10a               
D  DataType                      1a               
D  Use                           1a               
D  OutBuffPos                   10i 0              
D  InBuffPos                    10i 0              
D  FldLen                       10i 0              
D  Digits                       10i 0              
D  Decimals                     10i 0              
D  FldText                      50a               
D  EditCode                      2a               
D  ColumnHead1                  20a               
D  ColumnHead2                  20a               
D  ColumnHead3                  20a               
D  IntrnlFldName                10a              
D  AltrnFldName                 30a              
D  LenAltFldNam                 10i 0            
D  NumDBCS                      10i 0            
D  NullsAllowed                  1a              
D  DateTimeFmt                   4a              
D  DateTimeSep                   4a              
D  VarLenFldInd                  1a              
D  FldTxtCCSID                  10i 0            
D  FldDtaCCSID                  10i 0            
D  FldClmCCSID                  10i 0            
D  FldEdtWCCSID                 10i 0            
D  UCS2DsplLen                  10i 0            
D  FldDtaEncSch                 10i 0            
D  MaxLrgObjFLn                 10i 0            
D  PadLenLgObj                  10i 0            
D  LenUsrDefNam                 10i 0            


*----------------------------------------*                             
* GetFldInfo - Get the Field Information *                             
*----------------------------------------*                             
C     GetFldInfo    Begsr                                               
C                   Eval      IFile_Libr = IFile + ILib                 
C                   Eval      IFile_Libr = %Xlate(LoCase:UpCase:IFile_LIBR
C                   Eval      IRecFmt    = %Xlate(LoCase:UpCase:IFmt)   
C                   Call      'QUSLFLD'                                 
C                   Parm                    UsrSpcName                  
C                   Parm      'FLDL0100'    IFormatName                 
C                   Parm                    IFile_Libr                  
C                   Parm                    IRecFmt                     
C                   Parm      '0'           IOverride                  
C                   Parm                    ErrCtl                     
*                                                                     
C                   Endsr

论坛徽章:
0
9 [报告]
发表于 2009-12-01 08:50 |只看该作者
顺便说一下,调用os/400提供的api有两种方式:
1)动态;
2)静态;
一般情况下,*PGM程序员可以动态调用api。可以使用动态调用,不一定可以静态调用。

论坛徽章:
0
10 [报告]
发表于 2009-12-01 09:12 |只看该作者
谢谢各位,
franliu的简单的方法确实简单,但不知道效率怎么样?因为这个程序不是想玩玩,而是真的要给开发人员使用;
system API的文档我也看到了,不过没看明白?入口怎么赋值 ?出口怎么取到?是不是要用C写呀?

passthru说的API我没看明白在我的问题中是做什么用的,不好意思啊,能不能再给讲讲,下边是找到的关于这个API的文档
The List Fields (QUSLFLD) API generates a list of fields
within a specified file record format name. The list of fields is
placed in a specified user space. The generated list
replaces any existing information in the user space. You can
use the QUSLFLD API only with database file types, such as
*PF, *LF, and *DDMF, and device file types, such as *ICFF
and *PRTF.
You can use the QUSLFLD API to:
Ÿ Generate a list of field format names.
Ÿ Gather additional information about specific field formats.
Ÿ Create a product similar to the Structured Query Language
(SQL) using the Open Query File (OPNQRYF)
command.
Ÿ Create applications similar to the data file utility (DFU).
Ÿ Create a compiler supporting externally described data.
Ÿ Create applications that use data defined to the system.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP