December 04, 2006, 10:34 AM
djacksonmerging files
Hello to All,
I have created two ftm files and I wish to merge the two into one file.
I have created them using 'ON TABLE HOLD filename FORMAT ALPHA'.
Can someone tell me how to merge them together?
thanks
David
December 04, 2006, 10:49 AM
<Tim Howard_ABCBS>Try using the use statement. The qualifications are that both file structures need to be the same.
USE
HOLD1 AS HOLD1
HOLD2 AS HOLD1
END
December 04, 2006, 11:02 AM
JimRiceHi Donna,
Here's one way that works for me:
TABLE FILE CAR
PRINT CAR
BY COUNTRY
WHERE COUNTRY IN ('ENGLAND', 'FRANCE')
ON TABLE HOLD AS HOLD_A FORMAT ALPHA
END
-*
TABLE FILE CAR
PRINT CAR
BY COUNTRY
WHERE COUNTRY IN ('ITALY', 'JAPAN')
ON TABLE HOLD AS HOLD_B FORMAT ALPHA
END
-***********************************************
-* COMBINE FILES HOLD_A AND HOLD_B INTO HOLD_C *
-* THEN FILEDEF HOLD_A WITH HOLD_C.FTM *
-***********************************************
CMD COPY HOLD_A.FTM + HOLD_B.FTM HOLD_C.FTM
FILEDEF HOLD_A DISK HOLD_C.FTM
-*
TABLE FILE HOLD_A
PRINT CAR
BY COUNTRY
END
Jim
December 04, 2006, 11:04 AM
Tony ADonna,
If you wish to take advantage of Tim's suggestion then you will have to ensure, as Tim states, that the structures are the same and this will apply to columns names as well as number of columns. e.g the .mas files must be identical. The other requirement would be to change your HOLD AS xxxxxx FORMAT ALPHA to FORMAT FOCUS as the USE statement relates to FOCUS files.
An alternative, to allow you to retain the ALPHA formatting of your data, would be to concatenate them, either by reissuing the FILEDEF with an (APPEND extension or, if using MVS, OS 390, Z/OS etc, take advantage of the DYNAM CONCAT facility. On other platforms you can use system commands to combine the files as per Jims post.
Assuming that you are Windows based then you would have code something like this -
FILEDEF HOLD1 DISK HOLD1.FTM
-RUN
TABLE FILE CAR
SUM RCOST DCOST
BY COUNTRY
BY CAR
WHERE COUNTRY EQ 'ENGLAND'
ON TABLE HOLD AS HOLD1 FORMAT ALPHA
END
-RUN
FILEDEF HOLD1 DISK HOLD1.FTM (APPEND
-RUN
TABLE FILE CAR
SUM RCOST DCOST
BY COUNTRY
BY CAR
WHERE COUNTRY EQ 'FRANCE'
ON TABLE HOLD AS HOLD1 FORMAT ALPHA
END
-RUN
TABLE FILE HOLD1
PRINT *
END
-RUN
Just to emphasise the point, the file layouts MUST be identical if you use the USE syntax or they must have the same number of columns and formats if you use the FILEDEF method.
T
December 04, 2006, 11:13 AM
TexasStingraydjackson,
Here is a easy way. Lets say you called the files; FILEA and FILEB. If you just want to report from them then all you have to do is
TABLE FILE FILEA
PRINT ...
MORE
FILE FILEB
ON TABLE HOLD AS FILEC
END
TABLE FILE FILEC
PRINT
...
END
Hope this helps