1. PF对应DDS
- FMT A* .....A*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8
- *************** Beginning of data **********************************************
- 0001.00 *
- 0002.00 A UNIQUE
- 0003.00 A R RCUST
- 0004.00 A CUSNO 5A
- 0005.00 A CUSNM 30
- 0006.00 A CUSAD 30
- 0007.00 A CUSCT 30
- 0008.00 A CUSST 2
- 0009.00 A CUSCP 9
- 0010.00 A CUSPH 10 0
- 0011.00 A K CUSNO
- ****************** End of data *************************************************
2. RPG Source
- FMT * *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8
- *************** Beginning of data *****************************************
- 0001.00 *
- 0002.00 FCUSTOMER2 IF E K DISK
- 0003.00 *
- 0005.00 C MOVE '60003' CUSNO
- 0006.00 C CUSNO CHAIN RCUST 3738
- 0007.00 C *IN37 DSPLY
- 0008.00 C *IN38 DSPLY
- 0009.00 C CUSNM DSPLY
- 0011.00 C SETON LR
- 0012.00 C RETURN
- ****************** End of data ********************************************
如果对一个要进行CHAIN操作的外部没有声明Record Address Type(即默认为空),那你在用CHAIN查询时一般是不能得到想要的结果的.(如果查询的刚好是第一条呢??)
看下Reference对Record Address Type的说明:
Position 34 (Record Address Type)
Entry Explanation
Blank Relative record numbers are used to process the file.
Records are read consecutively.
Record address file contains relative-record numbers.
For limits processing, the record-address type (position 34) is the same as the type of the file being processed.
A Character keys (valid only for program-described files specified as indexed files or as a record-address-limits file).
... ...
K Key values are used to process the file. This entry is valid only for externally described files.
其他值也都是valid only for program-described file. 不讨论program-described file.
Relative Record Numbers也是就大名鼎鼎的RRN!
明白了吧,不说明Record Address Type的情况下默认文件是按RRN顺序读取的,此时用READ操作自然是不会有问题的,但是如果用CHAIN的话...MLGB,看资料时也没人提醒下,我CHAIN了一下午也没找到数据,可数据明明是有的啊!!!!
额外的猜想:
1. 不声明K,用CHAIN找第一天Record能找到不?
2012-10-22 19:44:12刚测试了下,还是读不到的...看来CHAIN操作的FILE必须声明K.
2. 声明K,但不使用CHAIN而用READ,可以吗?
2012-10-22 19:52:40测试了下,声明K后可以用READ操作,但是这次读取的顺序不是按RRN顺序读的.
1. 下图是声明为K,用READ读取的结果
2. 下图是没声明K,直接用READ读取的
3. 下图是PF中的RRN顺序
PS:自学真的苦逼啊.
阅读(1071) | 评论(0) | 转发(0) |