Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     "[SOLVED]"Many-to-Many merge with Match File?

Read-Only Read-Only Topic
Go
Search
Notify
Tools
"[SOLVED]"Many-to-Many merge with Match File?
 Login/Join
 
Member
posted
Is there any way using Match File to get the desired output from the two files listed below?

File 1
ID R_date
1 1/15/2008
1 2/17/2009
2 4/19/2012

File 2
ID A_date
1 11/19/2006
1 1/12/2012
1 10/16/2005
2 4/19/2003
2 8/17/2001


Desired Output
ID R_date A_date
1 1/15/2008 11/19/2006
1 1/15/2008 1/12/2012
1 1/15/2008 10/16/2005
1 2/17/2009 11/19/2006
1 2/17/2009 1/12/2012
1 2/17/2009 10/16/2005
2 4/19/2012 4/19/2003
2 4/19/2012 8/17/2001

This message has been edited. Last edited by: Mark Allen Harris,


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 7 | Registered: August 27, 2012Report This Post
Expert
posted Hide Post
Did you check out the MATCH FILE Command? What do you think of the AFTER MATCH OLD-OR-NEW? That specifies that all records from both the old data source and the new data source appear in the HOLD file. This is the default if the AFTER MATCH line is omitted.

Is that your desired result?
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Member
posted Hide Post
I tried OLD-OR-NEW. It gives me all the records in both files, but not all the possible combinations.


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 7 | Registered: August 27, 2012Report This Post
Virtuoso
posted Hide Post
A conditional JOIN may work:

FILEDEF FILE1 DISK FILE1.FTM
-RUN
-WRITE FILE1 11/15/2008
-WRITE FILE1 12/17/2009
-WRITE FILE1 24/19/2012
-*
FILEDEF FILE1MAS DISK FILE1.MAS
-RUN
-WRITE FILE1MAS FILENAME=FILE1,$
-WRITE FILE1MAS  SEGNAME=ONE,SEGTYPE=S0,$
-WRITE FILE1MAS   FIELDNAME=ID,,FORMAT=I5,ACTUAL=A1,$
-WRITE FILE1MAS   FIELDNAME=R_DATE,,FORMAT=MDYY,ACTUAL=A10,$
-*
FILEDEF FILE2 DISK FILE2.FTM
-RUN
-WRITE FILE2 111/19/2006
-WRITE FILE2 11/12/2012
-WRITE FILE2 110/16/2005
-WRITE FILE2 24/19/2003
-WRITE FILE2 28/17/2001
-*
FILEDEF FILE2MAS DISK FILE2.MAS
-RUN
-WRITE FILE2MAS FILENAME=FILE2,$
-WRITE FILE2MAS  SEGNAME=ONE,SEGTYPE=S0,$
-WRITE FILE2MAS   FIELDNAME=ID,,FORMAT=I5,ACTUAL=A1,$
-WRITE FILE2MAS   FIELDNAME=A_DATE,,FORMAT=MDYY,ACTUAL=A10,$
-RUN
-*
JOIN FILE FILE1 AT ID TO MULTIPLE FILE FILE2 AT ID AS J1
     WHERE FILE1.ID EQ FILE2.ID ;
END
-*
TABLE FILE FILE1
 PRINT *
END

Otherwise, you could create an indexed file from FILE2 and use a standard JOIN:

TABLE FILE FILE2
 BY ID
 BY A_DATE
 ON TABLE HOLD AS FILE2HLD FORMAT FOCUS INDEX ID
END
-*
JOIN CLEAR *
JOIN ID IN FILE1 TO ALL ID IN FILE2HLD AS J1
-*
TABLE FILE FILE1
 PRINT R_DATE A_DATE
 BY ID
 ON TABLE SET BYDISPLAY ON
END


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Expert
posted Hide Post
Good to see conditional joins being touted.

Another WebFOCUS hidden gem.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Member
posted Hide Post
I created an indexed file from FILE2 and that worked. Thanks for the help.

Thus far, no one has suggested using Match File. Does Match File not work with Many-to-Many merges?


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 7 | Registered: August 27, 2012Report This Post
Expert
posted Hide Post
quote:
Good to see conditional joins being touted.
Conditional JOIN: 1 ... MATCH FILE: 0 (in this round)
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Virtuoso
posted Hide Post
A bit longer and convoluted but the opportunity to use: SET CARTESIAN=ON

  
EX -LINES 10 EDAPUT MASTER,MARK,C,MEM
FILENAME=MARK, SUFFIX=FOC
 SEGNAME=DUM, SEGTYPE=S1
  FIELDNAME=DUM,DUM,A1,$
 SEGNAME=R1, SEGTYPE=S1, PARENT=DUM
  FIELDNAME=ID1,ID1,I2,$
  FIELDNAME=DATE1,DATE1,MDYY,$
 SEGNAME=R2, SEGTYPE=S1, PARENT=DUM
  FIELDNAME=ID2,ID2,I2,$
  FIELDNAME=DATE2,DATE2,MDYY,$
-RUN
CREATE FILE MARK
MODIFY FILE MARK
FREEFORM DUM ID1 DATE1
MATCH DUM
ON NOMATCH INCLUDE
ON MATCH CONTINUE
MATCH ID1
ON NOMATCH INCLUDE
ON MATCH INCLUDE
DATA
DUM='T',ID1=1,DATE1='01/15/2008',$
DUM='T',ID1=1,DATE1='02/17/2009',$
DUM='T',ID1=2,DATE1='04/19/2012',$
END
MODIFY FILE MARK
FREEFORM DUM ID2 DATE2
MATCH DUM
ON NOMATCH INCLUDE
ON MATCH CONTINUE
MATCH ID2
ON NOMATCH INCLUDE
ON MATCH INCLUDE
DATA
DUM='T',ID2=1,DATE2='11/19/2006',$
DUM='T',ID2=1,DATE2='01/12/2012',$
DUM='T',ID2=1,DATE2='10/16/2005',$
DUM='T',ID2=2,DATE2='04/19/2003',$
DUM='T',ID2=2,DATE2='08/17/2001',$
END
 
SET CARTESIAN=ON
TABLE FILE MARK
PRINT ID1 ID2 DATE1 DATE2
BY DUM NOPRINT
ON TABLE HOLD
END
TABLE FILE HOLD
PRINT *
WHERE ID1 EQ ID2;
END


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Virtuoso
posted Hide Post
@ Mark - As you may already know, use of the SUM verb instead of PRINT is the method by which one-to-many and many-to-many merges are formed with MATCH logic. In your case though, multiple dates can exist for the same key value (ID), so SUMming at the ID level only would cause dates to be lost. But adding a BY phrase at the date level to prevent losing dates would give you a merge based on ID and date combinations instead of ID only, which is not what you want. So the answer to your question is unfortuantely No, MATCH logic will not produce the desired results in this situation.

By the way, one drawback to the JOIN approach is that IDs found in FILE2 that are not also in FILE1 will be excluded from the output.

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Member
posted Hide Post
Thanks for confirming what I suspected about Match File in this particular case. I appreciate all the comments back. I'm new enough that I don't understand everything in all the comments but I was able to get a JOIN to work by putting an index on FILE2. I get back all possible combinations, so I'm up an running.

Does anybody know how I can indicate that my question has been resolved and to close the post?


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 7 | Registered: August 27, 2012Report This Post
Virtuoso
posted Hide Post
If you scroll back to your original post (after login), there should be an icon in the lower right hand corner to EDIT the post. Click on the icon and put "[SOLVED]" at the front of the subject for the post.


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Master
posted Hide Post
I would have thought that MATCH FILE would work...but using OLD-AND-NEW instead of OLD-OR-NEW. Just need to make ID a by field. Am I missing something?


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
 
Posts: 674 | Location: Guelph, Ontario, Canada ... In Focus since 1985 | Registered: September 28, 2010Report This Post
Member
posted Hide Post
I used OLD-OR-NEW. I wanted to retain all cases from both files even if they didn't have an ID match in the other file. I used BY on ID and tried all combinations using PRINT and SUM (i.e., PRINT PRINT, PRINT SUM, SUM PRINT, AND SUM SUM). I was never able to produce a cartesian product.


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 7 | Registered: August 27, 2012Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     "[SOLVED]"Many-to-Many merge with Match File?

Copyright © 1996-2020 Information Builders