PDA

View Full Version : Appending non-contiguous fields



Guest.Visitor
01-01-1995, 02:00 AM
I have a database with over 150 fields, of which I would like to treat quite a number of them as one. Unfortunately, the fields is question are scatered all over the place. Is there a way to append this fields together (obviously without having to move each one of them) into a data structure. Is it possible to use RPGIV's pointer support for this purpose? TIA

Guest.Visitor
05-16-2000, 04:17 PM
Alan, If these are character fields, you could concatenate them together. You should be able to use a data structure without a move unless the fields are already defined in a data structure. If that is the case, SQL may help. David Morris

Guest.Visitor
05-16-2000, 05:05 PM
Create a file with the fields in the order you want; cpyf *map *drop then cpyf *nochk into a file with concatenated fields. bobh

B.Myrick
05-16-2000, 05:42 PM
Alan, I am assuming that you want to create a new physical file on the system. IF that is so, create a new file with the fields in the order that you want them. Next: cpyf library/oldfile library/newfile mbropt(*add)fmtopt(*map) Then: rnmobj library/oldfile *file oldfilebkp rnmobj library/newfile *file oldfile This gives the file with the fields in the order you want them. Now you have to compile the objects that reference the file. Including, any dds, clp, etc. that references the file. If I have assumed wrong(happens)and you want have the fields in a certain order only for a program, then use a data structure that reorders the fields. The drawback is that if any field is already referenced in another data structure, you cannot re-define with the same field name. You would have to define a new field name in the data structure and perform an EVAL operation to populate when read. If you want to permamently join two or more fields, you need to write a quick and dirty program that uses a data structure to reformat the fields and write the data structure to a new file. Then follow the steps in the first example for renaming and compiling. Hope this helps, Bret Myrick

David Abramowitz
05-17-2000, 03:25 AM
In RPG you can use a Data Structure for this purpose. You can also define a logical file with the CAT keyword. Dave

Guest.Visitor
05-17-2000, 07:07 AM
Thanks for your suggestions. Indeed, I already have a data structure with these fields. I was hoping that another data structure could (point) be used to append these fields together. Can a data structure be created based of fields pointing to another field on a different data structure? If so, how? TIA