nmvfd18
asked on
Programmer
Using a subfile where users can add and delete data on the subfile screen. When they delete a record everything works fine. When I try to add a record, after the subfile is initialized with SFLCLR the subfile load blows up with "an attempt to write a duplicate record" error. In some other posts I saw the SFLCLR clears the subfile but not the display, but cannot stop the error from happeneing. I can put my code out there if necessary. I am a fairly experienced programmer in RPG but have never encountered this problem before, I have wrote subfiles before. Hope you an help.
ASKER
Here is the DDS:
R SFL01 SFL
** SFLNXTCHG
ZMAORD 1A B 10 4
ZMZIP1 5A B 10 18
26 DSPATR(RI)
ZMCITY 15A O 10 34
ZMSTAT 2A O 10 64
R CTL01 SFLCTL(SFL01)
SFLPAG(0009)
SFLSIZ(0010)
CF06(06 'Add Record')
CA12(12 'Return')
N33 ROLLUP(28 'roll more data')
RTNCSRLOC(&RECNAM &FLDNAM)
OVERLAY
32 SFLDSP
31 SFLDSPCTL
33 SFLEND(*MORE)
N31 SFLCLR
27 SFLMSG('Not a valid zip cod
RECNAM 10A H
FLDNAM 10A H
SETRRN 4S 0H SFLRCDNBR
Here is the Rpg free code:
begsr initsfl;
*in31 = *Off;
*In32 = *Off;
*In33 = *Off;
rrn1 = *zero;
rrn2 = *zero;
*In28 = *Off;
*In98 = *Off;
setrrn = *zeros;
LSTRRN1 = *zeros;
setrrn2 = *zeros;
LSTRRN2 = *zeros;
Write Ctl01;
Write Ctl02;
*in31 = *On;
rrn1 = 1;
begsr loadsfl;
if zzone <> *blanks;
rrn1 = *zeros;
setrrn = *zeros;
lstrrn1 = *zeros;
setll (zzone) opb803l1;
dow rrn1 < 09;
reade (zzone) opb803l1;
end803 = %eof;
if not %eof and zzone = zrzone;
zmaord = *blanks;
zmzip1 = zrzipcode;
zmcity = *blanks;
zmstat = *blanks;
exsr verify_zip;
else;
zmaord = *blanks;
zmzip1 = *blanks
zmcity = *blanks
zmstat = *blanks
*in26 = *off;
endif;
rrn1 += 1;
setrrn = rrn1;
write sfl01;
setrrn = rrn1;
lstrrn1 = rrn1;
enddo;
else;
rrn1 = 1;
setrrn = 1;
lstrrn1 = 1;
dow rrn1 < 08;
rrn1 += 1;
if not %eof ;
zmaord = *blanks;
zmzip1 = *blanks;
zmcity = *blanks;
zmstat = *blanks;
write sfl01;
endif;
enddo;
endif;
setrrn = rrn1;
lstrrn1 = rrn1;
if end803 = *on;
*in33 = *on;
end803 = *off;
endif;
*in32 = *on;
endsr;
// Edit Data - USA
begsr editdata;
if zzone = svzone and zsrch = svsrch;
load = 'N';
endif;
readc sfl01;
dow not %EOF;
if zmaord = 'D' or zmaord = 'd';
load = 'Y';
chain (zmzip1) byzip;
if zzone = zrzone and zmzip1 = zrzipcode;
delete byzip;
endif;
endif;
if zmaord = 'A' or zmaord = 'a';
load = 'Y';
zrzone = zzone;
zrzipcode = zmzip1;
exsr verify_zip;
if *in26 = *off;
chain (zmzip1) byzip;
if %found and zzone = *blanks;
*in91 = *on;
else;
*in84 = *on;
endif;
else;
write byzip;
*in85 = *on;
lstrrn1 += 1;
setrrn = lstrrn1;
rrn1 = lstrrn1;
write sfl01;
endif;
endif;
clear zmaord;
if zmzip1 = *blanks;
*in26 = *off;
endif;
if *in26 = *on;
*in27 = *on;
endif;
readc sfl01;
enddo;
if *in26 = *off and *in84 = *off;
exsr initsfl;
exsr loadsfl;
endif;
endsr;
R SFL01 SFL
** SFLNXTCHG
ZMAORD 1A B 10 4
ZMZIP1 5A B 10 18
26 DSPATR(RI)
ZMCITY 15A O 10 34
ZMSTAT 2A O 10 64
R CTL01 SFLCTL(SFL01)
SFLPAG(0009)
SFLSIZ(0010)
CF06(06 'Add Record')
CA12(12 'Return')
N33 ROLLUP(28 'roll more data')
RTNCSRLOC(&RECNAM &FLDNAM)
OVERLAY
32 SFLDSP
31 SFLDSPCTL
33 SFLEND(*MORE)
N31 SFLCLR
27 SFLMSG('Not a valid zip cod
RECNAM 10A H
FLDNAM 10A H
SETRRN 4S 0H SFLRCDNBR
Here is the Rpg free code:
begsr initsfl;
*in31 = *Off;
*In32 = *Off;
*In33 = *Off;
rrn1 = *zero;
rrn2 = *zero;
*In28 = *Off;
*In98 = *Off;
setrrn = *zeros;
LSTRRN1 = *zeros;
setrrn2 = *zeros;
LSTRRN2 = *zeros;
Write Ctl01;
Write Ctl02;
*in31 = *On;
rrn1 = 1;
begsr loadsfl;
if zzone <> *blanks;
rrn1 = *zeros;
setrrn = *zeros;
lstrrn1 = *zeros;
setll (zzone) opb803l1;
dow rrn1 < 09;
reade (zzone) opb803l1;
end803 = %eof;
if not %eof and zzone = zrzone;
zmaord = *blanks;
zmzip1 = zrzipcode;
zmcity = *blanks;
zmstat = *blanks;
exsr verify_zip;
else;
zmaord = *blanks;
zmzip1 = *blanks
zmcity = *blanks
zmstat = *blanks
*in26 = *off;
endif;
rrn1 += 1;
setrrn = rrn1;
write sfl01;
setrrn = rrn1;
lstrrn1 = rrn1;
enddo;
else;
rrn1 = 1;
setrrn = 1;
lstrrn1 = 1;
dow rrn1 < 08;
rrn1 += 1;
if not %eof ;
zmaord = *blanks;
zmzip1 = *blanks;
zmcity = *blanks;
zmstat = *blanks;
write sfl01;
endif;
enddo;
endif;
setrrn = rrn1;
lstrrn1 = rrn1;
if end803 = *on;
*in33 = *on;
end803 = *off;
endif;
*in32 = *on;
endsr;
// Edit Data - USA
begsr editdata;
if zzone = svzone and zsrch = svsrch;
load = 'N';
endif;
readc sfl01;
dow not %EOF;
if zmaord = 'D' or zmaord = 'd';
load = 'Y';
chain (zmzip1) byzip;
if zzone = zrzone and zmzip1 = zrzipcode;
delete byzip;
endif;
endif;
if zmaord = 'A' or zmaord = 'a';
load = 'Y';
zrzone = zzone;
zrzipcode = zmzip1;
exsr verify_zip;
if *in26 = *off;
chain (zmzip1) byzip;
if %found and zzone = *blanks;
*in91 = *on;
else;
*in84 = *on;
endif;
else;
write byzip;
*in85 = *on;
lstrrn1 += 1;
setrrn = lstrrn1;
rrn1 = lstrrn1;
write sfl01;
endif;
endif;
clear zmaord;
if zmzip1 = *blanks;
*in26 = *off;
endif;
if *in26 = *on;
*in27 = *on;
endif;
readc sfl01;
enddo;
if *in26 = *off and *in84 = *off;
exsr initsfl;
exsr loadsfl;
endif;
endsr;
ASKER
Program works fine with the subfile initialize and load of the subfile. If the user puts a 'D' to delete a record, program works fine and redisplays the data with the deleted subfile removed. Its when a user tries to take an 'A' to add a record, that I get a Write a duplicate error message on SFL01. This occurs in the LOADSFL subroutine after the INITSFL subroutine is run. Again it appears that the SFLCLR is not clearing the SFL01 file. Any help you can provide would be great, this is very frustrating.
ASKER
I can provide the dump, but don't know what that would tell you, indicators 31 and 32 are on and the RRN1 field = 1. It is a lot of data to post, but if you still need it, just let me know.
I see a number of issues with the code, but it's hard to tell if any of them relate; not enough of the program is shown. However, it's not clear what the exact problem is because [loadsfl] could possibly issue that error in two locations in the code. Which WRITE instruction is failing? I assume it's the first WRITE because you say "...the RRN1 field = 1", and it apparently never equals (1) for the other WRITE.
In the second DOW-loop in [loadsfl], why do you only WRITE to subfile records 2 through 8? In the first DOW-loop, you WRITE to subfile records 1 through 9.
Tom
In the second DOW-loop in [loadsfl], why do you only WRITE to subfile records 2 through 8? In the first DOW-loop, you WRITE to subfile records 1 through 9.
Tom
ASKER
Tom:
The issue not whether I write subfile records 2 - 9 or 1 - 8, 3 people have looked at the code and tried to fix the problem multiple ways. The program runs through the subroutine initsfl and loadsfl with no problem the first time. The subfile is displayed on the screen and the user can either add or delete records. I they delete a record, the editdata, deletes the record from the file, i run through initsfl and loadsfl and the subfile is re-displayed with the record gone. The problem occurs on the add, they add a record, which is verified to be valid, it is added to the file, and then i run through the initsfl and loadsfl and when it writes the first record in the subfile, I get the writing a duplicate record on the subfile. this occurs whether it is 1-9 or 2-8. The problem appears that the subfile clear is not working or is not clearing the display, but I don't know why this should only happen when I am trying to add a record and not on the delete. Any help in this matter would be appreciated.
The issue not whether I write subfile records 2 - 9 or 1 - 8, 3 people have looked at the code and tried to fix the problem multiple ways. The program runs through the subroutine initsfl and loadsfl with no problem the first time. The subfile is displayed on the screen and the user can either add or delete records. I they delete a record, the editdata, deletes the record from the file, i run through initsfl and loadsfl and the subfile is re-displayed with the record gone. The problem occurs on the add, they add a record, which is verified to be valid, it is added to the file, and then i run through the initsfl and loadsfl and when it writes the first record in the subfile, I get the writing a duplicate record on the subfile. this occurs whether it is 1-9 or 2-8. The problem appears that the subfile clear is not working or is not clearing the display, but I don't know why this should only happen when I am trying to add a record and not on the delete. Any help in this matter would be appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It is the first write that fails in loadsfl. The second write was added just to write blanks records.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you are having problems and this is a new program, you might want to do yourself a favor and start with a good, working model subfile program.
In his book, Subfiles in Free-Form RPG, Kevin Vandever has great sample code (that works). The examples in this book and the previous fixed-format version have formed the basis of thousands and thousands of subfile programs that are running in production in shops all over the world.
- Gary Patterson
In his book, Subfiles in Free-Form RPG, Kevin Vandever has great sample code (that works). The examples in this book and the previous fixed-format version have formed the basis of thousands and thousands of subfile programs that are running in production in shops all over the world.
- Gary Patterson
ASKER
Sorry Gary and Tom. I have stepped through the program in debug already, and I do not see the error. I will do it again, just to be sure and also send you the program and the dump the way you asked.
Thanks. Glad to hear you've already tried stepping through in debug. You know, it looks like this is a small, simple program. I wouldn't mind loading a copy onto my test system and looking at it, as long as you can give me some data that doesn't have anything confidential in it.
Here's how:
Create a lib called EELIB.
Create a source physical file in EE, and put a copy of the source for the program and any dependent objects (DDS for the dspf, dds for an PF and LF) into it. Make a copy of any required pf containing test data (noting confidential, please!) into EE. No need to put the compiled program or display file in there - I can just compile it. If there are special compile instructions, make sure you include them.
Create a save file called EE in QGPL
SAVLIB the EELIB to the save file.
Download the savf using FTP to your PC (do a binary transfer!) and post it as an attachment here. If it is too big, zip it first.
FTP myas400
(Log in)
>binary
>get /QSYS.QGPL/EE.SAVF c:\somefolderonyourpc\EE.S AVF
Here's how:
Create a lib called EELIB.
Create a source physical file in EE, and put a copy of the source for the program and any dependent objects (DDS for the dspf, dds for an PF and LF) into it. Make a copy of any required pf containing test data (noting confidential, please!) into EE. No need to put the compiled program or display file in there - I can just compile it. If there are special compile instructions, make sure you include them.
Create a save file called EE in QGPL
SAVLIB the EELIB to the save file.
Download the savf using FTP to your PC (do a binary transfer!) and post it as an attachment here. If it is too big, zip it first.
FTP myas400
(Log in)
>binary
>get /QSYS.QGPL/EE.SAVF c:\somefolderonyourpc\EE.S
ASKER
Gary: Did everything correct except when I do the get statement in the FTP i get the following:
200 POST subcommand request successful
550 Request rejected
Can I use iseries Navigator to bring the file to the pc?
200 POST subcommand request successful
550 Request rejected
Can I use iseries Navigator to bring the file to the pc?
Looks like your system administrator is using an FTP exit program to secure FTP. You may need to talk to your system admin in order to get rights to use FTP.
I always use FTP for this.
Just tried using Navigator to drop a SAVF on my desktop but it didn't work.
- Gary
I always use FTP for this.
Just tried using Navigator to drop a SAVF on my desktop but it didn't work.
- Gary
GET /QSYS.LIB/QGPL.LIB/EE.SAVF...
Assuming NAMEFMT 1...Or:
GET QGPL/SAVF...
Assuming NAMEFMT 0.Tom
@Tom: Since AS/400 FTP server automatically switches to NAMEFMT 1 if the pathname starts with "/", I've decided to just avoid the whole NAMEFMT conversation altogether and stick to the IFS naming convention unless it is important to the conversation. I just make sure to specify full paths.
Never understood why we needed two path naming formats in the first place when the IFS format handles everything.
Never understood why we needed two path naming formats in the first place when the IFS format handles everything.
@Gary:
Two name formats were needed during the earliest days after the TCP/IP Utilities became free of charge and the IFS was introduced. Too many scripts already existed for financial institutions, etc., and those earliest accounts weren't ones that could be irritated. Those early scripts all had only NAMEFMT 0 available.
But the IFS format still needs the .LIB qualifiers for QSYS and QGPL regardless of defaults. Defaulting is why I used "assuming" rather than adding the NAMEFMT directly in the script.
Tom
Two name formats were needed during the earliest days after the TCP/IP Utilities became free of charge and the IFS was introduced. Too many scripts already existed for financial institutions, etc., and those earliest accounts weren't ones that could be irritated. Those early scripts all had only NAMEFMT 0 available.
But the IFS format still needs the .LIB qualifiers for QSYS and QGPL regardless of defaults. Defaulting is why I used "assuming" rather than adding the NAMEFMT directly in the script.
Tom
@Tom:
I didn't realize until just now that there was a typo in my earlier PUT statement! Thanks for spotting it and correcting it.
- Gary
I didn't realize until just now that there was a typo in my earlier PUT statement! Thanks for spotting it and correcting it.
- Gary
ASKER
Still getting the same error as above. The file on the PC will have an extension of SAVF? Is that a legitimate file extension?
Tom pointed out a problem with my PUT statement. Corrected, it looks like this:
FTP myas400
(Log in)
>binary
>get /QSYS.LIB/QGPL/LIB/EE.SAVF c:\somefolderonyourpc\EE.S AVF
As far as you "extension" questions goes:
Windows file extensions are a convention, and are optional. There is no "legitimate" or "not legitimate" (unless an extension uses illegal characters, perhaps and violates file naming rules, I suppose). This is an AS/400 Save File, and since the AS/400 FTP server requires the SAVF extension on its side when using this name format, I tend to use the same extension on the PC file that is created. But you don't have to.
If you want to use a different extension to use on the Windows side (or no extension at all if you prefer), feel free.
That 500 error is often the result of a security issue. It means that your security administrator has an FTP Exit Point program in place, and that program has decided to reject your FTP request. Exit Point programs provide an extra layer of security for sensitive services like FTP. If you get a 500 every time you try to use FTP, that is probably the cause, and you'll need to get help from a system administrator to use FTP.
- Gary Patterson
FTP myas400
(Log in)
>binary
>get /QSYS.LIB/QGPL/LIB/EE.SAVF
As far as you "extension" questions goes:
Windows file extensions are a convention, and are optional. There is no "legitimate" or "not legitimate" (unless an extension uses illegal characters, perhaps and violates file naming rules, I suppose). This is an AS/400 Save File, and since the AS/400 FTP server requires the SAVF extension on its side when using this name format, I tend to use the same extension on the PC file that is created. But you don't have to.
If you want to use a different extension to use on the Windows side (or no extension at all if you prefer), feel free.
That 500 error is often the result of a security issue. It means that your security administrator has an FTP Exit Point program in place, and that program has decided to reject your FTP request. Exit Point programs provide an extra layer of security for sensitive services like FTP. If you get a 500 every time you try to use FTP, that is probably the cause, and you'll need to get help from a system administrator to use FTP.
- Gary Patterson
The .SAVF extension is recognized by FTP servers running on AS/400s. It's not required on the PC, but the FTP server will do an automatic step or two for anyone needing to restore the savefile.
There's another typo. The path to your savefile should begin with /QSYS.LIB. The second node needs to be /QGPL.LIB. That second node in the example has a "/" where a "." needs to be.
Tom
There's another typo. The path to your savefile should begin with /QSYS.LIB. The second node needs to be /QGPL.LIB. That second node in the example has a "/" where a "." needs to be.
Tom
Tom: Thanks again. Pushing "submit" without giving it a good proofread, first.
ASKER
Gary & Tom:
I have solved the problem. I was writing a message to the display file before the cleat and load. Once I commented out the message, it program refreshed like I thought it would. Thank you for your help.
I have solved the problem. I was writing a message to the display file before the cleat and load. Once I commented out the message, it program refreshed like I thought it would. Thank you for your help.
Glad you got it fixed.
- Gary
- Gary
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
- Gary Patterson