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.
So what I am trying to do is to merge the two tables ( lets say the TABLE1 is the master and TABLE2 is the detail ) so that only the first unique record in TABLE1 is matched ot all similar records in TABLE2 and the other records ( together with all other unmatched in TABLE1 and TABLE2 ) are printed as well. In the example given ( the '*' only indicates what of the same records must be matched ) the result should be something like :
I've tried using a combination of the join and match command but only with a close similarity to the result expected. Any suggestions to the problem would be very appreciated. Thanks in advance.This message has been edited. Last edited by: Kerry,
MATCH FILE MFD1
SUM COL1
BY COL1 AS JOINFLD
RUN
FILE MFD2
SUM COL2
BY COL2 AS JOINFLD
AFTER MATCH HOLD OLD-OR-NEW
END
TABLE FILE HOLD
PRINT COL1 AS 'IN FILE 1'
COL2 AS 'IN FILE 2'
BY JOINFLD
END
Hope this helps ...
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007
Thanks very much for the replies - MATCH that uses SUM with FST. and then PRINT for the second table is a close decision but another problem occurs - the similar records in the master are not printed.
( RECORD_1 (**) ___________ - unmatched in master RECORD_2 (**) ___________ - unmatched in master RECORD_2 (***) ___________ - unmatched in master )
so if there is some way to include them would be great. I suppose using MORE after taking the similar records in the master table and adding empty columns would solve fully the problem but I was wondering if it could be done only with a MATCH block.
Ginny: I thought about that but a JOIN TO ALL would join the similar records in the master to all the corresponding records in the detail. And maybe that way a decision could arise but it won't be short either way.
What you have advised me + filtering and MORE does the job.
e.g. for the example j.gross gave :
MATCH FILE FILE1
SUM FST.DATA1 ...
BY KEY1 AS KEY
RUN
FILE FILE2
PRINT DATA2 ...
BY KEY2 AS KEY
AFTER MATCH HOLD AS TMP1 OLD-OR NEW
END
-RUN
-*** FILTERING THOSE LEFT IN THE MASTER AND SKIPPED IN THE MATCH
DEFINE FILE FILE1
<TEMP COLUMNS THAT ARE MISSING IN FILE1 BUT ARE IN FILE2 > = '';
END
-RUN
TABLE FILE FILE1
PRINT *
<+ COLUMNS FROM DEFINE>
WHERE <BY_FILEDS> EQ LAST <BY_FIELDS>
ON TABLE HOLD AS UNMATCHED_MASTER
END
-RUN
TABLE FILE TMP1
PRINT *
ON TABLE HOLD AS TMP1
MORE
FILE UNMATCHED_MASTER
END
-RUN
This message has been edited. Last edited by: Martin_fmi,
To accomplish that, use - an initial HOLD to distinguish first vs. later rows for each key in Master, - a pair of Match files (to hold the first Master record merged against Detail records, and separately hold the remaining master records), - and finally MORE to combine the MATCH outputs:
-* PULL SPECIMEN MASTER AND DETAIL DATA
TABLE FILE CAR
COUNT ENTRIES NOPRINT
BY SEATS AS KEY1
BY COUNTRY AS ALPHA
BY CAR AS BETA
IF COUNTRY EQ ITALY OR JAPAN
ON TABLE SET ASNAMES ON AND HOLDLIST PRINTONLY
ON TABLE HOLD AS MASTER
RUN
COUNT ENTRIES NOPRINT
BY SEATS AS KEY2
BY COUNTRY AS GAMMA
BY CAR AS DELTA
IF COUNTRY EQ ENGLAND
ON TABLE SET ASNAMES ON AND HOLDLIST PRINTONLY
ON TABLE HOLD AS DETAIL
END
-RUN
-* now down to business:
-* (SEATS is the "Key"; Key1 and Key2 are included in the matches and final result for clarity)
-* 1. Add sequence number (LIST) to Master record. --> HOLD1
TABLE FILE MASTER
LIST ALPHA BETA
BY KEY1
ON TABLE HOLD AS HOLD1
END
-RUN
-* 2. Merge first Master with Detail recordS. --> HOLD2
MATCH FILE HOLD1
WRITE ALPHA BETA KEY1
BY KEY1 AS KEY
IF LIST EQ 1
RUN
FILE DETAIL
PRINT GAMMA DELTA KEY2
BY KEY2 AS KEY
AFTER MATCH HOLD AS HOLD2 OLD-OR-NEW
END
-RUN
-* 3. Nominal "Merge" of the other Master rows with a null Detail record. --> HOLD3, same columns as 2
MATCH FILE HOLD1
PRINT ALPHA BETA KEY1
BY KEY1 AS KEY
IF LIST GE 2
RUN
FILE DETAIL
PRINT GAMMA DELTA KEY2
BY KEY2 AS KEY
IF KEY2 EQ 0
IF KEY2 NE 0
AFTER MATCH HOLD AS HOLD3 OLD
END
-RUN
-* 4. combine:
TABLE FILE HOLD2
PRINT KEY1 ALPHA BETA
KEY2 GAMMA DELTA
BY KEY UNDER-LINE
MORE
FILE HOLD3
END
- Jack Gross WF through 8.1.05
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005