I'm trying to make a subfile program which will display a list of accounts. Users will be able to do five things: select option 2 to edit the record, select option 4 to remove the record from the list, select option 5 to view the account details press F3 to exit the program and press F5 to refresh the screen.
If the user picks either option or 5 a window will popup showing the account details. They can leave the window by pressing F12(Cancel) or press Enter in option 2 to save changes and return to the list. I am encountering an issue where after I exit the popup window and press F5 the program will hang. F3 still works to exit the program but the options can no longer be used. I did some debugging and found that if I exit the popup window and execute LoadSubfile my Fetch statement will get the first record as it is supposed to but my checking for %eof returns true and my program does not continue the loading. Below is the code I am using:
This code is based on the sample program from the article http://www.rpgpgm.com/2016/05/exampl...odern-rpg.html
I've been trying to fix this for half a day but I seem to be stuck. Am I missing something?
Also, any suggestions on how to delete records from the subfile without deleting records from the PF? My user wants to be able to delete records from the subfile because they plan on writing the contents of the subfile to a PF. They don't want to delete them from the source file, just exclude some records from being written to the destination file.
If the user picks either option or 5 a window will popup showing the account details. They can leave the window by pressing F12(Cancel) or press Enter in option 2 to save changes and return to the list. I am encountering an issue where after I exit the popup window and press F5 the program will hang. F3 still works to exit the program but the options can no longer be used. I did some debugging and found that if I exit the popup window and execute LoadSubfile my Fetch statement will get the first record as it is supposed to but my checking for %eof returns true and my program does not continue the loading. Below is the code I am using:
Code:
... LoadSubfile(); if (Dspf.Exit); leave; elseif (Dspf.Refresh); LoadSubfile(); iter; endi; if (Dspf..SflDsp); ReadSubfile(); endif; *inlr= *on; dcl-proc LoadSubfile; SflDspCtl = *off; SflDsp = *off; SflClear = *on; write CTL01; SflDspCtl = *on; SflDsp = *on; SflClear = *off; @opt = ''; clear #RRN; exec sql declare ListOfAccts cursor for select distinct(acctnum) from TRANSFILE TF where TF.prod in (33,34) and TF.banknum = :#banknum and TF.postdate = :#datejul; if (checkSQL() = *off); exec sql open ListOfAccts; if (checkSQL() = *off); exec sql fetch ListOfAccts into :@acctnum; dow checkSQL() = *of; if (%eof); leave; endif; exec sql select cusnum from CustFile CF where TF.banknum = CF.banknum and CF.account = :@acctnum; if (checkSQL() = *off); #RRN = #RRN + 1; write SFL01; endif; exec sql fetch next ListOfAccts into :@acctnum; enddo; endif; endi; if (#RRN > 1); Dsp.SflDsp = *on; endif; end-proc; dcl-proc ReadSubfile; dow (1-1); readc sfl01; if (%eof); leave; endif; if (@opt = '4'); confirmation(); if (#confirm = 'Y'); <code to delete record rom sfl01> endi; endif; if (@opt = '5'); dow (1=1); if (Dspf.CANCEL); leave; endi; exfmt dtlwin; enddo; endif; @opt = ''; update sfl01; enddo; end-proc;
I've been trying to fix this for half a day but I seem to be stuck. Am I missing something?
Also, any suggestions on how to delete records from the subfile without deleting records from the PF? My user wants to be able to delete records from the subfile because they plan on writing the contents of the subfile to a PF. They don't want to delete them from the source file, just exclude some records from being written to the destination file.
Comment