I Have created a display file using Screen Design Aid that contains a subfile and a window that is used to pop up and add record to the subfile. On the window I simply just want to have two control functions.
-Enter to add the record and close the window -F3 to go back to previous subfile page.
I have a problem where my program seems to go on a infinite loop whenever I open the window and press any other Fn key besides those defined buttons.
See my Job in WRKACTJOB taking up a load of CPU
I would like to somehow disable input from all other keys to prevent users from getting this error and taking up system resources.
Here is my DDS code
A*%%TS SD 20210608 183039 JAL REL-V7R3M0 5770-WDS
A*%%EC
A DSPSIZ(27 132 *DS4)
A R PRTWNDW
A*%%TS SD 20190630 072251 JAL REL-V7R2M0 5770-WDS
A WINDOW(6 14 8 85)
A PRTMSG# 80 O 4 3
A PRTMSG2# 80 O 5 3
A 1 31'Print Message Window'
A R ADDWNDW
A*%%TS SD 20210608 183039 JAL REL-V7R3M0 5770-WDS
A CA03(03 'Previous')
A CA02(02 'Add/Update')
A WINDOW(2 12 22 105)
A 2 36'ADD COST DISTRIBUTION RECORD'
A 5 4'Supplier:'
A 7 4'Brand:'
A 9 4'Exp A/c:'
A 11 4'Sub-Total:'
A 14 4'ASB:'
A 15 4'Supplier:'
A 13 4'Cost Split'
A 17 4'Check:'
A CSSUPC# 6A B 5 18
A CSEXCD# 3A B 9 18
A CSSTTL# 9Y 2B 11 18EDTCDE(2)
A CSASST# 3Y 0B 14 18EDTCDE(2)
A CSSPST# 3Y 0B 15 18EDTCDE(2)
A CSCHCK# 3A B 17 18
A CSSUPN# 30A O 5 32
A CSBRNM# 30A O 7 32
A CSEXNM# 30A O 9 32
A CSCHNM# 30A O 17 32
A CSBRNO# 3A B 7 18
A ADDMSG# 80A O 19 4COLOR(WHT)
A 21 4'F2 = Add/Update Record'
A COLOR(WHT)
A 21 31'F12 = Previous'
A COLOR(WHT)
A R DUMMY ASSUME
A OVERLAY
A 1 2' '
A R CMTDATA SFL
A*%%TS SD 20210608 152830 JAL REL-V7R3M0 5770-WDS
A ACNAME R O 7 4REFFLD(APVENDR/ACNAME R50FILES/VAPV-
A END)
A BRBRDSC R O 7 37REFFLD(ANPBRNDR/BRBRDSC ANPLIB/ANPB-
A RND)
A CMEXCD R O 7 69REFFLD(ANPCSTCMTR/CMEXCD ANPTEST/AN-
A PCSTCMT)
A CMSTTL R O 7 92REFFLD(ANPCSTCMTR/CMSTTL ANPTEST/AN-
A PCSTCMT)
A CMBCSP R O 7109REFFLD(ANPCSTCMTR/CMBCSP ANPTEST/AN-
A PCSTCMT)
A CMSCSP R O 7117REFFLD(ANPCSTCMTR/CMSCSP ANPTEST/AN-
A PCSTCMT)
A R CMTCTL SFLCTL(CMTDATA)
A*%%TS SD 20210608 175516 JAL REL-V7R3M0 5770-WDS
A CA12(12 'Previous')
A CA02(02 'Add')
A CA06(06 'Modify')
A CA07(07 'Delete')
A CA09(09 'Print')
A OVERLAY
A 42 SFLDSP
A 41 SFLDSPCTL
A 40 SFLCLR
A 45 SFLEND(*MORE)
A SFLSIZ(0100)
A SFLPAG(0015)
A 1 56'PO Cost Distribution'
A 3 4'PO Number:'
A FLD001 11A O 3 16
A 3 37'PO Sub-total:'
A FLD003 9Y 2O 3 52EDTCDE(2)
A 3 69'Current Sub-total:'
A FLD004 9Y 2O 3 89EDTCDE(2)
A 5 4'Supplier'
A 5 37'Brand'
A 5 69'Exp A/C'
A 5 92'Sub-total'
A 5109'BPI'
A 5117'Supplier'
A R CMTFOOT
A*%%TS SD 20210608 173541 JAL REL-V7R3M0 5770-WDS
A KEEP
A 25 3'F2 = Add Record'
A COLOR(WHT)
A 25 22'F6 = Modify Record'
A COLOR(WHT)
A 25 44'F7 = Delete Record'
A COLOR(WHT)
A 25 66'F9 = Print Supplier Copy'
A COLOR(WHT)
A 25 94'F12 = Previous'
A COLOR(WHT)
And here is the RPGLE so far
FANPPORCMT CF E WorkStn
F SFILE(CMTDATA:RRN#)
FVAPVEND IF A E K Disk
D FileInfo DS
D KeyPressed 369 369
D EnterKey C CONST(x'F1')
***
/free
// Internal Procedure Prototypes
dcl-pr ClrVndSfile end-pr;
dcl-pr LoadVndSfile end-pr;
dcl-pr DspVndSfile end-pr;
// Stand alone variables
dcl-s RRN# packed(4);
//Main Program--------------------------------//
// Initialize
*in40 = *off;
*in41 = *off;
*in42 = *off;
*in45 = *off;
// While F12 is not pressed display screen
DoW *in12 = *off;
ClrCmtSfile();
LoadCmtSfile();
DspCmtSfile();
if *in02 = *on;
*in02 = *off;
exfmt addwndw;
dow *in03 = *off;
if KeyPressed = EnterKey;
*in03 = *on;
endif;
enddo;
endif;
EndDo;
*Inlr = *On;
//End Main**************************************//
//Clear Subfile Procedure---------------//
dcl-proc ClrCmtSfile;
*in40 = *on;
write cmtctl;
*in40 = *off;
RRN# = 0;
end-proc;
//*********************************************//
//Load Subfile Procedure----------------//
dcl-proc LoadCmtSfile;
RRN# = RRN# + 1;
acname = ' Supplier Testing';
brbrdsc = 'Brand Testing';
cmexcd = ' Expense testing';
cmsttl = 1333330;
cmbcsp = 50;
cmscsp = 50;
write cmtdata;
end-proc;
//*********************************************//
//Display Subfile Procedure-------------//
dcl-proc DspCmtSfile;
*in41 = *on;
*in42 = *on;
write cmtfoot;
exfmt cmtctl;
*in41 = *off;
*in42 = *off;
end-proc;
//*********************************************//
/end-free
In this loop, if KeyPressed is not equal to EnterKey when the loop starts, *in03 will remain *off forever. I'm guessing you need another EXFMT inside the loop.
dow *in03 = *off;
if KeyPressed = EnterKey;
*in03 = *on;
endif;
enddo;