Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying One Record Content To Another Record Format

Status
Not open for further replies.

Skittle

ISP
Sep 10, 2002
1,528
US
Is there a simple way of copying an entire record to another file record?

I have two files that are the same format except for the field names. Each field has the same length in both formats and I need to set each field in file 2 from each field in file 1.

I'm looking for a MOVE RECORD command or an EVAL option that will copy the entire record in onestep rather than me having to code an EVAL for each field in the file.

Dazed and confused.

Remember.. 'Depression is just anger without enthusiasum'.
 
what you do is a copyfile. The example below copies file kytrucks from the jimlib to a file called kytruck2 in the jimlib the FMTOPT ( of *nochk ), says copy I will be responsilbe for the data. You should also use the the replace option of (*replace). enter cpyf and press Command 4, for a prompt screen,, complete the first screen, then press command 10, and page down a few times to see the FMTOPT.

CPYF FROMFILE(JIMLIB/KYTRUCKS) TOFILE(JIMLIB/KYTRUCK2) FMTOPT(*NOCHK)
 
Not quite what I'm after. I want to copy data within an RPG program for a specific record. Issuing a CL command would be way to inefficient ( QCMDEXEC ).

Dazed and confused.

Remember.. 'Depression is just anger without enthusiasum'.
 
so you want to do this on a reoccuring basis,, when some conditions happens.. you want to replace the record in file 2, with the one from file 1.
 
If the field names differ by only the first few characters, use the PREFIX keyword to rename the fields of one of them to be the same as the other.

Alternatly, you can rename the individual fields for one of them in the I-specs, and then you just read the input file and write the output file.

-- Francis
I'd like to change the world, but I can't find the source code.
 
How about defining a DS for each file format, the just EVAL DS2 = DS1 ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top