I have two files that I would like to combine. File A has ten columns and 50 rows while File B only has one column and one row. I would like to append the one column in File B to each row in File A. Is there a way to do this? I can't merge or match because neither file has any fields in common.
WebFOCUS 7.1.4, Windows XP
February 07, 2008, 05:51 PM
GinnyJakes
Create a phony key for file A and have the value be the same value for each record (like 1) then hold it.
Do the same for file B only hold that one as a focus file index phonykey.
First, Lindbo, edit your signature block on your profile to tell us your current system and versions, and where you are located, and a bit about who you are and your experience level. Second, i would have said read up on MacGyver and cartesian products, but it seems your case is quite simple.. if FILEB has only 1 col and 1 row, then it would seem to contain just one single element of information. So why not 1.read FILEB into a flat file 2.read that flat file with a -READ , thus forming an &var for that one single element. 3. issue a define on FILEA defining a new field whose value is that constant 4. table FILEA along with the newly defined field. Ok so far? Here's an example:
-* here's file B
TABLE FILE CAR
PRINT COUNTRY IF CAR IS 'JAGUAR'
ON TABLE SAVE AS VERYSILLY
END
-RUN
-READ VERYSILLY &MYCOUNTRY.A10
-TYPE &MYCOUNTRY
.* should show you that &MYCOUNTRY = 'ENGLAND';
.* now for the fileA bit
DEFINE FILE CAR
NEWCOUNTRY/A10 WITH COUNTRY = '&MYCOUNTRY';
-* nb: no quotes if your value is a number
-* nb: remember the WITH fieldname when you define a var that is a constant;
-*the define has no idea what segment to stick the new field to;
-*if you're not reading a multisegment focus file, then it doesn't matter
END
TABLE FILE CAR
PRINT * NEWCOUNTRY
ON TABLE whatever
END
Just FYI, for us Pointy heads, the word APPEND suggests vertical concatenation. What you're talking about would be more of a horizontal thing, like a JOIN would be.This message has been edited. Last edited by: susannah,
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
February 11, 2008, 04:30 PM
lindbo
Thank you for all the help. The flat file suggestion worked beautifully!
WebFOCUS 7.1.4, Windows XP
February 11, 2008, 04:53 PM
FrankDutch
The flat file suugestion is good, but if this is a file with one field and one record you can also say
TABLE FILE CAR PRINT * 'this is field xxx' END
But if your one field table is changing every time, the solution Susannah proposed is better....
Frank
prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7