View previous topic :: View next topic
|
Author |
Message |
SVazifdar
New User
Joined: 21 Apr 2006 Posts: 14
|
|
|
|
I used the PUTENV example to dynamically allocate files and it works fine. However I would like to enhance the program to do the following and would like know if it is possible.
I have a file that has header records for several customers and detail records. However the header and details for the same customer appear at different places in the file. At the present time I do not want to sort the file.
Customer1
Details
Customer2
Details
Customer1
Details
Customer3
Details
Customer1
Details
Customer4
Details
I have a program that dynamically allocates files and writes records to the files.
I allocate the file for customer1, write records, and close the file for customer1. That works fine. Next I allocate file for customer2, write records, and close the file. That works fine.
Now I would to process customer1 again so I want reopen the previously allocate file for customer1 and append records to it. Is that possible and how could it be done. Please help.
Thanks
S. Vazifdar |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Is that possible and how could it be done. |
It can in assembler. . . Most organizations do not want to increase the amount of assembler code they must maintain. I don't know about PUTENV. Sorry.
You might consider initially reading the file as it is, making a copy of the records needed for your process and sorting those copied records. The originial file would remain as it is and the copy would be in the order needed for your process. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi,
You might try to use a MOD disposition. If that doesn't work, a FREE=CLOSE along with the MOD might do the trick. |
|
Back to top |
|
|
Douglas Wilder
Active User
Joined: 28 Nov 2006 Posts: 305 Location: Deerfield IL
|
|
|
|
If you do not close nor free the file for customer1 and use a different ddname for customer2, you could just write to the customer1 and customer2 files as needed. Otherwise you would need to free the ddname and re-allocate customer1 with disp=mod. This will add a lot of overhead to the process, and I believe that it would save resources to sort the file so that this is not needed. |
|
Back to top |
|
|
|