Here's one for ya all,
I'm in a JD Edwards shop (only RPG III allowed) and I have an application that has an option to add notes to individual entries. This worked fine with users entering note after note until someone asked if there was a way to insert or delete a line.
Well, this sparked my imagination, of course my mouth said "sure" before my brain could think, so now I'm faced with this challenge. I've been toying with it and have come across some issues I can't seem to get around.
If they request insertion, (I have a sequence number field that is 7,1 and I added an option field so they could enter 1=insert, 2=edit and 4=delete) no problem I add .5 to the sequence number of the line just above (where they entered the 1), write the record to the sfl and display the screen positioning the the cursor to the new inserted record then, write the record to the file after they enter whatever. Then, the programn listed below is called to resequence the entries and then the sfl is reloaded. It's all worked pretty well until...
Here's the issue; if there are 99 lines and the new line causes line 100, everything goes wacky after that. So I added code to adjust the count....
What I mean by "wacky" is this;
If there are 101 lines, the line count is ...98, 99, 100, 100, 101
If I continue to add lines, ...98, 99, 100, 100, 101, 102, 103... AND the lines gets mixed up, out of order.
Any ideas or suggestions?
I'm in a JD Edwards shop (only RPG III allowed) and I have an application that has an option to add notes to individual entries. This worked fine with users entering note after note until someone asked if there was a way to insert or delete a line.
Well, this sparked my imagination, of course my mouth said "sure" before my brain could think, so now I'm faced with this challenge. I've been toying with it and have come across some issues I can't seem to get around.
If they request insertion, (I have a sequence number field that is 7,1 and I added an option field so they could enter 1=insert, 2=edit and 4=delete) no problem I add .5 to the sequence number of the line just above (where they entered the 1), write the record to the sfl and display the screen positioning the the cursor to the new inserted record then, write the record to the file after they enter whatever. Then, the programn listed below is called to resequence the entries and then the sfl is reloaded. It's all worked pretty well until...
Here's the issue; if there are 99 lines and the new line causes line 100, everything goes wacky after that. So I added code to adjust the count....
Code:
FTDNPF UF E K DISK * C *ENTRY PLIST C PARM USER 10 C PARM ITM# 40 * C KEY KLIST C KFLD USER C KFLD ITM# * C KEY1 KLIST C KFLD USER C KFLD ITM# C KFLD $$KEY * C Z-ADD0 COUNT 60 C Z-ADD0 @ITER 60 * Set low key. C Z-ADD.1 $$KEY 71 * Position file. C KEY1 SETLLTDNPF * Count records. C *IN99 DOUEQ*ON C KEY READETDNPF N 99 C *IN99 IFEQ *OFF C ADD 1 COUNT C ENDIF C ENDDO * Multiply count to bypass lower numbers. C SELEC C COUNT WHLE 100 C COUNT MULT 10 @ITER C COUNT WHLE 1000 C COUNT MULT 100 @ITER C ENDSL * Set high key. C Z-ADD9999999 $$KEY * Resequence from end of file to eliminate lower numbers C KEY1 SETGTTDNPF C *IN99 DOUEQ*ON C KEY REDPETDNPF 99 C *IN99 IFEQ *OFF C Z-ADD@ITER TNSEQ# C UPDATTNPFR C SELEC C COUNT WHLE 100 C SUB 10 @ITER C COUNT WHLE 1000 C SUB 100 @ITER C ENDSL C @ITER IFEQ 0 C LEAVE C ENDIF C ENDIF C ENDDO * Set high key. C Z-ADD9999999 $$KEY * Resequence from end of file. C KEY1 SETGTTDNPF C *IN99 DOUEQ*ON C KEY REDPETDNPF 99 C *IN99 IFEQ *OFF C Z-ADDCOUNT TNSEQ# C UPDATTNPFR C SUB 1 COUNT C COUNT IFEQ 0 C LEAVE C ENDIF C ENDIF C ENDDO * C SETON LR
If there are 101 lines, the line count is ...98, 99, 100, 100, 101
If I continue to add lines, ...98, 99, 100, 100, 101, 102, 103... AND the lines gets mixed up, out of order.
Any ideas or suggestions?



Comment