如何在 RPGLE 中更新从子文件到物理文件的不同记录?
How to UPDATE DIFFERENT RECORD from subfile to physical file in RPGLE?
如何将不同记录的值从 SUBFILE 更新到物理文件?
画面如下图所示:
我要更新的值是从 4.12 到 4.13 的美元。
这是我的实体文件:
在我按下回车键后,值只会在屏幕上更新,但是当我运行qry检查物理文件时,没有任何变化发生。我应该怎么办?请帮我。提前致谢:)
我的担忧:
现在,它更新了,但它只是更新了下一个值或最新日期的最新值。我的意思是,我尝试编辑 5 月 31 日的美元价值,但当我按下回车键并刷新屏幕时,我不知道为什么 6 月 1 日的美元价值发生了变化。而且,我也尝试同时更新另一个值,但只有 USD 是更新的值。那我该怎么办?
多条记录只有一条更新
尝试这样的事情
UPDSR Begsr
MoveL(P) 'UPDATE' Mode
*******Exgdat Chain Curexg 9091
******* If *In91 = *On
******* Leavesr
******* Endif
******* If *In90 = *Off
******* Movel(p) Date Date2
******* Movel(p) USD USD2
******* Movel(p) GBP GBP2
******* Movel(p) EUR EUR2
******* Movel(p) AUD AUD2
******* Movel(p) SGD SGD2
// make a generic 10 alpha field to control your loop
movel *blank @@Change 10A
*like Define Date2 @@DispDate
@@change = 'First';
dow @@change <> *blank; //loop to check for date change
clear @@change;
@@DispDate = Date2; // what is the date used to display
@@gcod = 'USD'
exsr $ForDisplay;
USD2 = @@grat;
@@gcod = 'GBP'
exsr $ForDisplay;
GBP2 = @@grat;
@@gcod = 'EUR'
exsr $ForDisplay;
EUR2 = @@grat;
@@gcod = 'AUD'
exsr $ForDisplay;
AUD2 = @@grat;
@@gcod = 'SGD'
exsr $ForDisplay;
SGD2 = @@grat;
Seton 02
N12 Exfmt Screen
if Date2 <> @@DispDate; //the user changed the date!
@@change = 'Change';
endif;
enddo;
******* User's answers
Movel(p) Date2 Date
Movel(p) USD2 USD
@@gcod = 'USD';
@@grat = usd;
exsr $UpdateRec;
Movel(p) GBP2 GBP
@@gcod = 'GBP';
@@grat = gbp;
exsr $UpdateRec;
Movel(p) EUR2 EUR
@@gcod = 'EUR';
@@grat = eur;
exsr $UpdateRec;
Movel(p) AUD2 AUD
@@gcod = 'AUD';
@@grat = aud;
exsr $UpdateRec;
Movel(p) SGD2 SGD
@@gcod = 'SGD';
@@grat = sgd;
exsr $UpdateRec;
******* select
******* exgcod wheneq 'USD'
******* move usd exgrat
******* exgcod wheneq 'GBP'
******* move gbp exgrat
******* exgcod wheneq 'EUR'
******* move eur exgrat
******* exgcod wheneq 'AUD'
******* move aud exgrat
******* exgcod wheneq 'SGD'
******* move sgd exgrat
******* endsl
*******N12 Update Currec
eval MSG ='Record updated'
******* Endif
Setoff 91
Endsr
**---------------------------------
Begsr $ForDisplay;
*** Using CHAIN(N) to avoid locking the file, this is to load the screen
** Assumption that the fspec for Curexg has a key list of exgdat, exgcod
** if it does not exist, you will need to create a logical that has one
*like Define exgcod @@gcod
*like Define exgrat @@grat
clear @@grat;
chain(n) ( Date : @@gcod ) Curexg;
if %found(Curexg);
@@grat = exgrat;
endif;
Endsr;
**---------------------------------
Begsr $UpdatRec;
if *in12 = *off; //allowed to update?
chain ( Date : @@gcod ) Curexg;
exgrat = @@grat;
if %found(Curexg); //exists, update it
update Currec;
else; //record doesn't exist yet, possibly new currency, new rec
Exgdat = Date;
Exgcod = @@gcod;
write Currec;
endif;
endif;
Endsr;
**---------------------------------
使用 CHGPF 命令更改 CUREXG 文件,使其具有 2 个关键字段:EXGDAT 和 EXGCOD
A R CURREC
A EXGDAT L
A EXGCOD 3A
A EXGRAT 5P 2
A K EXGDAT
A K EXGCOD
CHGPF FILE(CUREXG) SRCFILE(QDDSSRC) SRCMBR(CUREXG)
然后,在 RPG 中,使用 EXGDAT 密钥和第二个 EXGCOD 密钥链接到 CUREXG 文件:
/free
chain ( exgdat: 'USD' ) currec ;
if %found ;
exgrat = usd ;
update currec ;
endif ;
/end-free
如何将不同记录的值从 SUBFILE 更新到物理文件?
画面如下图所示:
我要更新的值是从 4.12 到 4.13 的美元。
这是我的实体文件:
在我按下回车键后,值只会在屏幕上更新,但是当我运行qry检查物理文件时,没有任何变化发生。我应该怎么办?请帮我。提前致谢:)
我的担忧: 现在,它更新了,但它只是更新了下一个值或最新日期的最新值。我的意思是,我尝试编辑 5 月 31 日的美元价值,但当我按下回车键并刷新屏幕时,我不知道为什么 6 月 1 日的美元价值发生了变化。而且,我也尝试同时更新另一个值,但只有 USD 是更新的值。那我该怎么办?
多条记录只有一条更新 尝试这样的事情
UPDSR Begsr
MoveL(P) 'UPDATE' Mode
*******Exgdat Chain Curexg 9091
******* If *In91 = *On
******* Leavesr
******* Endif
******* If *In90 = *Off
******* Movel(p) Date Date2
******* Movel(p) USD USD2
******* Movel(p) GBP GBP2
******* Movel(p) EUR EUR2
******* Movel(p) AUD AUD2
******* Movel(p) SGD SGD2
// make a generic 10 alpha field to control your loop
movel *blank @@Change 10A
*like Define Date2 @@DispDate
@@change = 'First';
dow @@change <> *blank; //loop to check for date change
clear @@change;
@@DispDate = Date2; // what is the date used to display
@@gcod = 'USD'
exsr $ForDisplay;
USD2 = @@grat;
@@gcod = 'GBP'
exsr $ForDisplay;
GBP2 = @@grat;
@@gcod = 'EUR'
exsr $ForDisplay;
EUR2 = @@grat;
@@gcod = 'AUD'
exsr $ForDisplay;
AUD2 = @@grat;
@@gcod = 'SGD'
exsr $ForDisplay;
SGD2 = @@grat;
Seton 02
N12 Exfmt Screen
if Date2 <> @@DispDate; //the user changed the date!
@@change = 'Change';
endif;
enddo;
******* User's answers
Movel(p) Date2 Date
Movel(p) USD2 USD
@@gcod = 'USD';
@@grat = usd;
exsr $UpdateRec;
Movel(p) GBP2 GBP
@@gcod = 'GBP';
@@grat = gbp;
exsr $UpdateRec;
Movel(p) EUR2 EUR
@@gcod = 'EUR';
@@grat = eur;
exsr $UpdateRec;
Movel(p) AUD2 AUD
@@gcod = 'AUD';
@@grat = aud;
exsr $UpdateRec;
Movel(p) SGD2 SGD
@@gcod = 'SGD';
@@grat = sgd;
exsr $UpdateRec;
******* select
******* exgcod wheneq 'USD'
******* move usd exgrat
******* exgcod wheneq 'GBP'
******* move gbp exgrat
******* exgcod wheneq 'EUR'
******* move eur exgrat
******* exgcod wheneq 'AUD'
******* move aud exgrat
******* exgcod wheneq 'SGD'
******* move sgd exgrat
******* endsl
*******N12 Update Currec
eval MSG ='Record updated'
******* Endif
Setoff 91
Endsr
**---------------------------------
Begsr $ForDisplay;
*** Using CHAIN(N) to avoid locking the file, this is to load the screen
** Assumption that the fspec for Curexg has a key list of exgdat, exgcod
** if it does not exist, you will need to create a logical that has one
*like Define exgcod @@gcod
*like Define exgrat @@grat
clear @@grat;
chain(n) ( Date : @@gcod ) Curexg;
if %found(Curexg);
@@grat = exgrat;
endif;
Endsr;
**---------------------------------
Begsr $UpdatRec;
if *in12 = *off; //allowed to update?
chain ( Date : @@gcod ) Curexg;
exgrat = @@grat;
if %found(Curexg); //exists, update it
update Currec;
else; //record doesn't exist yet, possibly new currency, new rec
Exgdat = Date;
Exgcod = @@gcod;
write Currec;
endif;
endif;
Endsr;
**---------------------------------
使用 CHGPF 命令更改 CUREXG 文件,使其具有 2 个关键字段:EXGDAT 和 EXGCOD
A R CURREC
A EXGDAT L
A EXGCOD 3A
A EXGRAT 5P 2
A K EXGDAT
A K EXGCOD
CHGPF FILE(CUREXG) SRCFILE(QDDSSRC) SRCMBR(CUREXG)
然后,在 RPG 中,使用 EXGDAT 密钥和第二个 EXGCOD 密钥链接到 CUREXG 文件:
/free
chain ( exgdat: 'USD' ) currec ;
if %found ;
exgrat = usd ;
update currec ;
endif ;
/end-free