RPGIV编程问题百解(22)一个程序中,对同一个文件并行操作
问题:
一个问题一直困绕着我,在一个程序中,对同一个文件可以操作码?
回答1:
FTestPF if e k disk
FTestPFAlt if e k disk Usropn
F Rename(TSTRCD : TSTRCDALT )
D OvrDbf C CONST('Ovrdbf File(TESTPFALT) Tofile-
D (*LIBL/TESTPF) OPNSCOPE(*JOB)')
Downside is that TestPFAlt would have to be overriden (both to compile and
run), but it allows you to read the same file throug two open data paths:
Read testpf;
Read testPFAlt; // actually a second ODP to TestPF
回答2:
If you are at 6.1 (probably not, eh?), then you can use EXTDESC and EXTFILE.
FTestPF if e disk
FTestPF2 if e disk extdesc('TESTPF')
F extfile(*extdesc)
F rename(TSTRCD:TSTRCD2)
EXTDESC is new with 6.1 and it tells the compiler where to get the external
field definitions.
回答3:
Try using ExtFile, Rename and Prefix keywords for the second instance of your
file and use external DS for one or both of them.
FTestPF if e disk
FTestPF2 if e disk
F extfile('TESTPF')
F rename(TSTRCD:TSTRCD2)
F Prefix(PF2)
D DsPF2 E DS ExtName(TestPF)
D Prefix(PF2)
回答4:
FTestPF if e disk PREFIX('PF.')
FTestPF2 if e disk PREFIX('PF2.')
F extfile('TESTPF')
F rename(TSTRCD:TSTRCD2)
D PF DS LikeRec(TSTRCD)
D PF2 DS LikeRec(TSTRCD) // Could also use LikeREC(TSTRCD2)
This assumes you have a logical TESTPF2 over the physical TESTPF which is
nothing more than a format file in this case.
阅读(854) | 评论(0) | 转发(0) |