Focal Point
[SOLVED] Issue when using MATCH

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3807056436

November 12, 2013, 11:21 AM
hainguyen
[SOLVED] Issue when using MATCH
I have this issue when using MATCH to combine records:
  
MATCH FILE HOLDA
PRINT FIELDA
BY FIELDB
BY FIELDC
RUN
FILE HOLDB
PRINT FIELDA
BY FIELDB
BY FIELDC
RUN
AFTER MATCH HOLD AS HOLD_TEMP_RT OLD-OR-NEW
Then, the output I got is :
FIELDB  FIELDC  FIELDA
BBB     CCC
BBB     CCC
BBB     CCC     AAA

This meant I just got 1 value of Field A although I have values of this field for all records. If I change PRINT FIELDA to BY FIELDA, it displays all but it will sort FIELDA, I don't want FIELDA is sorted, anyone have solution for this ? I also tried SUM FIELDA but it didn't work.
Thanks in advance.


This message has been edited. Last edited by: hainguyen,


WebFOCUS 7.7.03
Windows, All Outputs
November 12, 2013, 01:55 PM
Prarie
quote:
OLD-OR-NEW


Not knowing your data...play with above

try OLD-AND-NEW
November 12, 2013, 02:45 PM
hainguyen
quote:

Let me edit my example code as following:
MATCH FILE HOLDA
PRINT FIELDA1
BY FIELDB1
BY FIELDC1
RUN
FILE HOLDB
PRINT FIELDA2
BY FIELDB2
BY FIELDC2
AFTER MATCH HOLD AS HOLD_TEMP_RT OLD-OR-NEW
END
Then, the output I got is :
FIELDB FIELDC FIELDA
B1B1B1 C1C1C1
B2B2B2 C2C2C2
B3B3B3 C3C3C3 A3A3A3

It supposes to have value A1A1A1 in the first record and A2A2A2 in the second record but if I use PRINT in FIELDA1 and FIELDA2, it doesn't show up those data. And I need to use OLD-OR-NEW because data in these HOLD files is different.

This message has been edited. Last edited by: hainguyen,


WebFOCUS 7.7.03
Windows, All Outputs
November 12, 2013, 03:47 PM
Waz
Can you post the source records ?


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!

November 12, 2013, 08:05 PM
j.gross
I am surprised you got anything. There should not be a RUN before the AFTER MATCH HOLD, and there should be an END after.

Can we see the actual code?
November 13, 2013, 02:55 AM
Dave
I think:

MATCH FILE HOLDA
SUM FIELDA
BY FIELDB
BY FIELDC
RUN
FILE HOLDB
SUM FIELDA
BY FIELDB
BY FIELDC
AFTER MATCH HOLD AS HOLD_TEMP OLD-OR-NEW
END


Or perhaps SUM ALL.FIELDA

try it.

Good luck,
Dave


_____________________
WF: 8.0.0.9 > going 8.2.0.5
November 13, 2013, 03:51 AM
Wep5622
MATCH is a strange beast, but as far as I understand, your initial example would result in a file containing:
FIELDB
FIELDC
FIELDA
FIELDA

Meaning that there are TWO fields in the result named FIELDA. Perhaps you're just not printing the correct one?
You can check that using ?FF HOLD_TEMP_RT

If that's your issue, does this fare better?
SET ASNAMES = ON
SET HOLDLIST = PRINTONLY

MATCH
FILE HOLDA
PRINT FIELDA AS FIELDAA
BY FIELDB
BY FIELDC
RUN
FILE HOLDB
PRINT FIELDA AS FIELDBA
BY FIELDB
BY FIELDC
AFTER MATCH HOLD AS HOLD_TEMP_RT OLD-OR-NEW
END
-RUN

TABLE FILE HOLD_TEMP_RT
PRINT COMPUTE FIELDA/??? = IF FIELDAA IS MISSING THEN FIELDBA ELSE FIELDAA;
BY FIELDB
BY FIELDC
END



WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
November 13, 2013, 04:59 AM
Twanette
Using PRINT as the verb in the first part of a MATCH file simply isn't a good idea!

Along the same thought process as @Wep5622's post:

What do you want your output to be?
Because if you weren't expecting to see _two_ FIELDA columns, then perhaps MATCH FILE isn't what you want to use.

If you wanted all HOLDA records, followed by all HOLDB records, then perhaps you need to use "MORE" e.g.

TABLE FILE HOLDA
PRINT FIELDA
BY FIELDB
BY FIELDC
MORE
FILE HOLDB
ON TABLE HOLD AS HOLD_TEMP_RT
END



WebFOCUS 8.2.06 mostly Windows Server
November 13, 2013, 02:13 PM
hainguyen
Waz: My code is the mess now so that's why I use the sample code.
j.gross: Sorry, I mistyped it. I changed it.
Dave/Wep5622/Twanette: Thanks for your suggestion but they seem didn't work in my case. Please let me explain more detail my report. I need to get TDLine in READ_TEXT function so I need to pass some parameters to this function. I used the loop to pass each set of values for parameters each time to get TDLine, then I use MATCH to merge these records and save them to 1 Hold file. Then I just need to print this HOLD file to get the complete report. The issue I got is for 1 set of values, in my sample code, I get 1 line of FIELDB, one line of FIELDC but many lines of FIELDA and these lines need to be kept in the original order ( I can't sort them). I tried to use MATCH and I got the issue as I mentioned above. I can't get full FIELDA for all set of values or if I use BY for FIELDA, this field will be sorted and this will be wrong. I think I am so close with the solution but it seems I never touch it.


WebFOCUS 7.7.03
Windows, All Outputs
November 13, 2013, 03:23 PM
Waz
quote:
My code is the mess now so that's why I use the sample code


I was asking for the source data for the two tables.

Understanding this helps in getting the code right.


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!

November 13, 2013, 03:52 PM
hainguyen
My code is almost like below except I used the loop statement to pass data to TDNAME, LText is the field I want to get from READ_TEXT.

 
MATCH FILE HOLDA
     BY HOLDA.HOLDA.EINA_MATNR AS 'MATNR'
     BY HOLDA.HOLDA.EINA_INFNR AS 'INFNR'
     BY HOLDA.HOLDA.EINA_LIFNR AS 'LIFNR'
     BY	J3.LINES.LINES_TDLINE AS 'LTEXT'
WHERE (J3.READ_TEXT.HEADER_TDID EQ 'BT') AND ( J3.READ_TEXT.HEADER_TDOBJECT EQ 'EINE' ) AND ( J3.READ_TEXT.HEADER_TDSPRAS EQ 'E' ) AND ( J3.READ_TEXT.HEADER_TDNAME EQ '1111' );
RUN
FILE HOLDA
     BY HOLDA.HOLDA.EINA_MATNR AS 'MATNR'
     BY HOLDA.HOLDA.EINA_INFNR AS 'INFNR'
     BY HOLDA.HOLDA.EINA_LIFNR AS 'LIFNR'
     BY	J3.LINES.LINES_TDLINE AS 'LTEXT'
WHERE (J3.READ_TEXT.HEADER_TDID EQ 'BT') AND ( J3.READ_TEXT.HEADER_TDOBJECT EQ 'EINE' ) AND ( J3.READ_TEXT.HEADER_TDSPRAS EQ 'E' ) AND ( J3.READ_TEXT.HEADER_TDNAME EQ '2222' );
AFTER MATCH HOLD AS HOLD_MAT_RT OLD-OR-NEW
END
RUN
TABLE FILE HOLD_MAT_RT 
	 BY MATNR 
	 BY INFNR 
	 BY LIFNR 
	 BY LTEXT 
ON TABLE PCHOLD FORMAT HTML
 

This message has been edited. Last edited by: hainguyen,


WebFOCUS 7.7.03
Windows, All Outputs
November 13, 2013, 04:13 PM
Waz
quote:
data for the two tables


Either sample or real


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!

November 13, 2013, 04:23 PM
hainguyen
This is real.


WebFOCUS 7.7.03
Windows, All Outputs
November 14, 2013, 06:00 AM
Twanette
Hi,

Based on what you want to do, I still don't think you should be using MATCH FILE.

quote:
I use MATCH to merge these records and save them to 1 Hold file. Then I just need to print this HOLD file to get the complete report.


Based on the code you sent, try this:

TABLE FILE HOLDA
PRINT J3.LINES.LINES_TDLINE AS 'LTEXT'
     BY HOLDA.HOLDA.EINA_MATNR AS 'MATNR'
     BY HOLDA.HOLDA.EINA_INFNR AS 'INFNR'
     BY HOLDA.HOLDA.EINA_LIFNR AS 'LIFNR'
     BY	J3.LINES.LINES_TDLINE AS 'LTEXT'
WHERE (J3.READ_TEXT.HEADER_TDID EQ 'BT') AND ( J3.READ_TEXT.HEADER_TDOBJECT EQ 'EINE' ) AND ( J3.READ_TEXT.HEADER_TDSPRAS EQ 'E' ) AND ( J3.READ_TEXT.HEADER_TDNAME EQ '1111' );
MORE
FILE HOLDA
WHERE (J3.READ_TEXT.HEADER_TDID EQ 'BT') AND ( J3.READ_TEXT.HEADER_TDOBJECT EQ 'EINE' ) AND ( J3.READ_TEXT.HEADER_TDSPRAS EQ 'E' ) AND ( J3.READ_TEXT.HEADER_TDNAME EQ '2222' );
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SET ASNAMES ON
ON TABLE HOLD AS HOLD_MAT_RT  
END
 
TABLE FILE HOLD_MAT_RT 
PRINT LTEXT
	 BY MATNR 
	 BY INFNR 
	 BY LIFNR 
	 BY LTEXT 
ON TABLE PCHOLD FORMAT HTML
END



WebFOCUS 8.2.06 mostly Windows Server
November 15, 2013, 03:12 PM
hainguyen
Thanks Twanette. This totally works in my case. Just wanna change your code a little bit. ON TABLE should be at the first table. Look like all my issues are solved just by MORE.
  

TABLE FILE HOLDA
PRINT J3.LINES.LINES_TDLINE AS 'LTEXT'
     BY HOLDA.HOLDA.EINA_MATNR AS 'MATNR'
     BY HOLDA.HOLDA.EINA_INFNR AS 'INFNR'
     BY HOLDA.HOLDA.EINA_LIFNR AS 'LIFNR'
     BY	J3.LINES.LINES_TDLINE AS 'LTEXT'
WHERE (J3.READ_TEXT.HEADER_TDID EQ 'BT') AND ( J3.READ_TEXT.HEADER_TDOBJECT EQ 'EINE' ) AND ( J3.READ_TEXT.HEADER_TDSPRAS EQ 'E' ) AND ( J3.READ_TEXT.HEADER_TDNAME EQ '1111' );
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SET ASNAMES ON
ON TABLE HOLD AS HOLD_MAT_RT  
MORE
FILE HOLDA
WHERE (J3.READ_TEXT.HEADER_TDID EQ 'BT') AND ( J3.READ_TEXT.HEADER_TDOBJECT EQ 'EINE' ) AND ( J3.READ_TEXT.HEADER_TDSPRAS EQ 'E' ) AND ( J3.READ_TEXT.HEADER_TDNAME EQ '2222' );

END
 
TABLE FILE HOLD_MAT_RT 
PRINT LTEXT
	 BY MATNR 
	 BY INFNR 
	 BY LIFNR 
	 BY LTEXT 
ON TABLE PCHOLD FORMAT HTML
END



WebFOCUS 7.7.03
Windows, All Outputs