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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Conversion: Combining two files with ADD()

Status
Not open for further replies.

karlomutschler

Programmer
Jun 5, 2001
75
0
0
DE
Hi all,

File1.tps contains data from a previous period.
File2.tps contains data from the current period.

These two files need to be combined in such a way
that the data of File2.tps is ADDed to File1.tps
without overwriting the existing records in File1.tps .
i.e.
IF TPS1:NUMBER = TPS:NUMBER THEN CYCLE.

Can somebody help me with this task ?

TIA and kind regards
Karlo Mutschler
 
1. I'm asuming that both files have Identical structures.
2. I'll using a "Process" On File2.tps.
3. Embed "take record"

Code:
!"..the data of File2.tps is ADDed to File1.tps
!without overwriting the existing records in File1.tps"
TPS:PrimaryKeyField = TPS1:PrimaryKeyField
IF Access:File1.Fetch(KeyField) = LEVEL:BENING !
  !The record already exists on both files
  !Update only some fields
  TPS:SomeField = TPS1:SomeField 
  TPS:SomeField = TPS1:SomeField 
  !..
  Access:File1.Update()
ELSE
  !Record does NOT exists on File1
  Access:File1.Insert()
  !********** If the files has identical field structures
  TPS:RECORD = TPS1:RECORD !Copy fields from File2 to File1
  !***********
  !*********** Use this if ONLY some field has the same name
  !TPS:RECORD :=: TPS1:RECORD
  !********** 
  Access:File1.Update()
END
[\code]  

 -----
carabez@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top