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!

Generating Additional Records in Hold File

Status
Not open for further replies.

Sean466

Programmer
Mar 27, 2003
12
0
0
CA
I have a file called YEARS containing unique years: 2002, 2003, 2004, ..., 2010. I would like to store the years in a hold file, with one exception. For the current year only (2004), I want to write 2 different records to the hold file: 'First half 2004', and 'Second half 2004'.

I looked into join and match, but neither seemed to do what I need.

Anybody know how to do this?

Thanks for your assistance!
 
Sean,

if I understand correctly, you'll need something like this

DEFINE FILE YEARS
-* assuming the format is YY or numeric
NEW_YEAR/A15 = IF OLD_YEAR EQ '2004'
THEN 'First Half ' | EDIT(OLD_YEAR)
ELSE EDIT(OLD_YEAR);
END

TABLE FILE YEARS
PRINT NEW_YEAR
BY OLD_YEAR NOPRINT
ON TABLE HOLD AS NEW_YEARS
END
 
Craigiep,

I need the hold file to look like this:
2002
2003
First half 2004
Second half 2004
2005
2006
...

So one of the records from the table (2004) needs to be split off into 2 different records, and all the others stay as they are.

Thanks,
Sean
 
Sean,

sorry about that, I must have been sleeping.

DEFINE FILE YEARS
-* assuming the format is YY or numeric
FIRST_YEAR/A15 = IF OLD_YEAR EQ '2004'
THEN 'First Half 2004
ELSE EDIT(OLD_YEAR);
SECOND_YEAR/A15 = IF OLD_YEAR EQ '2004'
THEN 'Second Half 2004'
ELSE EDIT(OLD_YEAR);
END

TABLE FILE YEARS
PRINT FIRST_YEAR
BY OLD_YEAR
ON TABLE HOLD AS NEW_YEARS
END

-* then append the second field to this file
FILEDEF NEW_YEARS DISK new_years.ftm (APPEND
-RUN

TABLE FILE YEARS
PRINT SECOND_YEAR
BY OLD_YEAR
WHERE OLD_YEAR EQ '2004'
ON TABLE HOLD AS NEW_YEARS
END
-*
-* you might want to sort the file now so that it's in order
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top