Hello,
I want to change the below program to use variable library names, but I can't figure out how to do this because of the external data structures (ExtName)? I've found that I can use a 21A variable to build a library/file name and then couple this with USROPN for the file, which is fine but ExtName requires a literal value - is my only option here to individually list each field, i.e. newFile.Field1 = oldFile.Field1, newFile.Field2 = oldFile.Field2 etc.? I really want to avoid doing this because there are 317 fields in the file...
Note: I want to do this in RPG, rather than SQL as I'm currently using SQL INSERT and want to compare the two.
I want to change the below program to use variable library names, but I can't figure out how to do this because of the external data structures (ExtName)? I've found that I can use a 21A variable to build a library/file name and then couple this with USROPN for the file, which is fine but ExtName requires a literal value - is my only option here to individually list each field, i.e. newFile.Field1 = oldFile.Field1, newFile.Field2 = oldFile.Field2 etc.? I really want to avoid doing this because there are 317 fields in the file...
Note: I want to do this in RPG, rather than SQL as I'm currently using SQL INSERT and want to compare the two.
Code:
h Option(*NoDebugIO)
* Files
foldFile IF E K DISK ExtFile('LIBRARY1/FILE1')
f ExtDesc('LIBRARY1/FILE1')
f Rename(FILE1R:FILE1RO)
fnewFile IF A E K DISK ExtFile('LIBRARY2/FILE1')
f ExtDesc('LIBRARY2/FILE1')
f Rename(FILE1R:FILE1RN)
* Data structures
d oldFileDS E DS ExtName('LIBRARY1/FILE1')
d Prefix(oDS_)
d newFileDS E DS ExtName('LIBRARY2/FILE1')
d Prefix(nDS_)
* MAIN LINE
/Free
// Position after week
SetGt (02:20:19:33) oldFile;
ReadE (02) oldFile;
// Copy all records after week into new file
DoW not %EoF(oldFile);
newFileDS = oldFileDS;
Write FILE1RN;
ReadE (02) oldFile;
EndDo;
// End of processing
*InLr = *On;
Return;
/End-Free




Comment