跌打滚爬中的小菜鸟...
分类: 其他UNIX
2013-09-18 15:49:42
RPG09
FMT FX FFilename++IPEASF.....L.....A.Device+.Keywords+++++++++++++++
*************** Beginning of data ***************************
0001.00 FITEMLMAS IF E K DISK
0002.00
0003.00 D RecKey DS LikeRec(ITEMASEA:*key)
0004.00
0005.00 /free
0006.00 // set key then chain
0007.00 Read ITEMASEA;
0008.00 Eval RecKey.Itnbr='A10020-24';
0009.00 Eval RecKey.Recid='A';
0010.00 Setgt %kds(Reckey) ITEMLMAS;
0011.00 If %Found(ITEMLMAS);
0012.00 Dsply 'Found';
0013.00 Else;
0014.00 Dsply 'Not Found';
0015.00 Endif; //如果不READP而直接READ的话则读到是第一条record!!!( ?H70843-19)本来我以为会是A10020-7!!!!
0016.00 Readp ITEMASEA; //2013-7-16 14:10:29好吧,刚又试了下先READ后READP发现直接读到了A10020-7!!!艹,太怪异了
0017.00 Dsply ITNBR;
0018.00 DSPLY RECID;
0019.00
0020.00 Read ITEMASEA;
0021.00 Dsply ITNBR;
0022.00 DSPLY RECID;
0023.00
0024.00 Eval *inlr=*on;
0025.00 Return;
0026.00 /end-free
****************** End of data ***************************
RPG10
FMT FX FFilename++IPEASF.....L.....A.Device+.Keywords++++++++++++++
*************** Beginning of data **************************
0001.00 FITEMLMAS IF E K DISK
0002.00
0003.00 D RecKey DS LikeRec(ITEMASEA:*key)
0004.00
0005.00 /free
0006.00 // set key then chain
0007.00 Read ITEMASEA;
0008.00 Eval RecKey.Itnbr='A10020-24';
0009.00 Eval RecKey.Recid='A';
0010.00 Setll %kds(Reckey) ITEMLMAS;
0011.00 If %Equal(ITEMLMAS);
0012.00 Dsply 'Found';
0013.00 Else;
0014.00 Dsply 'Not Found';
0015.00 Endif;
0016.00
0017.00 Eval *inlr=*on;
0018.00 Return;
0019.00 /end-free
结果如下:
另外一个例子, 比较%Equal和%Found的区别:
FMT FX FFilename++IPEASF.....L.....A.Device+.Keywords++++++++++++++
*************** Beginning of data **************************
0001.00 FITEMLMAS IF E K DISK
0002.00
0003.00 D RecKey DS LikeRec(ITEMASEA:*key)
0004.00
0005.00 /free
0006.00 // set key then chain
0007.00 Read ITEMASEA;
0008.00 Eval RecKey.Itnbr='A10020-23';
0009.00 Eval RecKey.Recid='A';
0010.00 Setll %kds(Reckey) ITEMLMAS;
0011.00 If %Equal(ITEMLMAS); //记住,一般%Equal只用于SETLL和LOOPUP中
0012.00 Dsply 'Equal';
0013.00 Else;
0014.00 Dsply 'Not Equal';
0015.00 Endif;
0016.00
0017.00 If %Found(ITEMLMAS); //用于CHAIN,SETGT,SETLL,DELETE, CHECK,CHECKR,SCAN中
0018.00 Dsply 'Found';
0019.00 Else;
0020.00 Dsply 'Not Found';
0021.00 Endif;
0022.00
0023.00 Eval *inlr=*on;
0024.00 Return;
0025.00 /end-free
****************** End of data **********************
结果如下: (最后那两个dsply)