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] Query on MATCH

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Query on MATCH
 Login/Join
 
Gold member
posted
Hello Everyone,

I have the below input screen

DATE (1001).............:
STATE (AZ, CA, LA).....:
CAR (123, 456, 789)......:
INV (C10013801A)..........:

And the existing code is as below.
[ code ]

MATCH ACDTE
ON MATCH CONTINUE
ON NOMATCH TYPE
"THIS DATE IS NOT ON THE D/B."
MATCH CAR
ON MATCH CONTINUE
ON NOMATCH TYPE
"THIS CAR IS NOT ON THE D/B FOR MATCH STATE
ON MATCH CONTINUE
ON NOMATCH TYPE
"THIS ST IS NOT in D/B FOR MATCH INV
ON NOMATCH TYPE
" ON MATCH ACTIVATE PDATE
ON MATCH COMPUTE
PDATE = 'CANCEL';
ON MATCH UPDATE PDATE
ON MATCH TYPE
"THE PAYMENT DATE HAS BEEN CANCELLED FOR DATA VIA FIDEL
END
-RUN -EXIT

[ code ]

Now I need to add a value in the STATE field "ALL" ie

DATE [1001)............................:
STATE [AZ, CA, LA, ALL)................:
CARRIER [123, 456, 789)................:
INVOICE NUMBER [C10013801A)............:

and Make a match on the THREE remaining values [previously 4 Values: DATE, STATE, CARRIER, and RAP INVOICE.)
provided by the end user: DATE, CARRIER, and RAP INVOICE.
When an exact match is found, modify the following field:
PAY_DATE change value to ‘CANCEL’

When selection for STATE equal ALL,
change PAY_DATE to equal ‘CANCEL” for all records that match on DATE, CARRIER and RAP_INVOICE
values provided on the input screen.

please guide how to accomplish this task.

Thanks in advance...


Best Regards,
Poryes

Focus Mainframe 7.6.5

This message has been edited. Last edited by: Kerry,
 
Posts: 64 | Registered: February 24, 2010Report This Post
Virtuoso
posted Hide Post
Please place your code examples between [ code ] and [ /code ] markers.

You cannot skip a key with MATCH logic, so you will need to use NEXT and CASE logic. Something like the sample code below is a start - I can't test this code, so I doubt it is execution-ready. As an alternative to using NEXT logic, it might be easier to TABLE the data using the user input, HOLD the results, and use the HOLD file as input to the MODIFY. This approach would allow you to use straight MATCH logic. Also, if your STATE field does not have a length of at least three, you won't be able to use 'ALL' as an input. The ACTIVATE command is not necessary because the COMPUTE automatically activates the field.

MODIFY FILE <filename>

MATCH ACDTE 
 ON MATCH CONTINUE 
 ON NOMATCH TYPE 
  "THIS DATE IS NOT ON THE D/B." 
 ON NOMATCH REJECT

MATCH CAR 
 ON MATCH IF STATE EQ 'ALL' GOTO STATE_LOOP ;
 ON MATCH CONTINUE 
 ON NOMATCH TYPE 
  "THIS CAR IS NOT ON THE D/B FOR <ACTDTE "
 ON NOMATCH REJECT

MATCH STATE 
 ON MATCH CONTINUE 
 ON NOMATCH TYPE 
  "THIS ST IS NOT in D/B FOR <CAR FOR <ACTDTE " 
 ON NOMATCH REJECT

MATCH INV 
-* ON MATCH ACTIVATE PDATE 
 ON MATCH COMPUTE PDATE = 'CANCEL'; 
 ON MATCH UPDATE PDATE 
 ON MATCH TYPE 
  "THE PAYMENT DATE HAS BEEN CANCELLED FOR <CAR FOR <INVNO " 
 ON NOMATCH TYPE 
  "<INV IS AN INCRCT INV FOR <CAR <STATE " 
 ON NOMATCH REJECT
 ON MATCH/NOMATCH GOTO TOP

CASE STATE_LOOP
 NEXT STATE
  ON NEXT GOTO INV_LOOP
  ON NONEXT GOTO TOP
ENDCASE

CASE INV_LOOP
 NEXT INV
 ON NEXT IF D.INV NE INV GOTO INV_LOOP ;
 ON NEXT COMPUTE PDATE = 'CANCEL'; 
 ON NEXT UPDATE PDATE 
 ON NEXT TYPE 
  "THE PAYMENT DATE HAS BEEN CANCELLED FOR <CAR FOR <INVNO "
 ON NEXT ACTIVATE ACDTE CAR STATE INV
 ON NEXT/NONEXT GOTO STATE_LOOP
ENDCASE
 
DATA VIA FIDEL 
END

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
Gold member
posted Hide Post
Thanks Dan for your quick response. I'll test and see if the code works correctly.


Best Regards,
Poryes


WebFOCUS 7.6.13

Mainframe
all output (Report in mainframe)
 
Posts: 64 | Registered: February 24, 2010Report This Post
Virtuoso
posted Hide Post
I added one line to the code I posted earlier - an ACTIVATE statement in CASE INV_LOOP.


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Virtuoso
posted Hide Post
Mixing MATCH and NEXT logic can be tricky, and after my earlier posting, it occurred to me that the database pointer could get lost for the MATCHed fields during the looping NEXT updates. Hopefully, this new logic will eliminate that problem. Essentially, this code captures user input for STATE in CASE AT START, a special case that runs only once at the beginning of the MODIFY process; if the user enters 'ALL' for STATE, the logic should loop through the states for the ACDTE and CAR entered by the user, MATCH each ACDTE/CAR/STATE/INV combination in turn, and update PDATE; if the user enters a specific STATE, the logic should MATCH ACDTE/CAR/STATE/INV and update PDATE for that single record. Again, this code has not been tested, so very likely requires some additional work.

MODIFY FILE <filename>
GOTO INV_UPDATE

CASE INV_UPDATE
 MATCH ACDTE 
  ON MATCH CONTINUE 
  ON NOMATCH TYPE 
   "THIS DATE IS NOT ON THE D/B." 
  ON NOMATCH GOTO TOP

 MATCH CAR 
  ON MATCH IF STATE EQ 'ALL' GOTO STATE_NEXT ;
  ON MATCH CONTINUE 
  ON NOMATCH TYPE 
   "THIS CAR IS NOT ON THE D/B FOR <ACTDTE "
  ON NOMATCH GOTO TOP

 MATCH STATE 
  ON MATCH CONTINUE
  ON NOMATCH TYPE 
   "THIS ST IS NOT IN D/B FOR <CAR FOR <ACTDTE " 
  ON NOMATCH GOTO TOP

 MATCH INV 
  ON MATCH COMPUTE PDATE = 'CANCEL'; 
  ON MATCH UPDATE PDATE 
  ON MATCH TYPE 
   "THE PAYMENT DATE HAS BEEN CANCELLED FOR <CAR FOR <INV " 
  ON NOMATCH TYPE 
   "<INV IS AN INCORRECT INV FOR <CAR <STATE " 
  ON MATCH/NOMATCH IF STATE_INPUT EQ 'ALL' GOTO REMATCH_KEYS ;
  ON MATCH/NOMATCH GOTO TOP
ENDCASE

CASE STATE_NEXT
 NEXT STATE
  ON NEXT COMPUTE STATE = D.STATE ;
  ON NEXT GOTO INV_UPDATE
  ON NONEXT GOTO TOP
ENDCASE

CASE REMATCH_KEYS
 ACTIVATE RETAIN ACDTE CAR STATE
 MATCH ACDTE CAR STATE
  ON MATCH GOTO STATE_NEXT
  ON NOMATCH TYPE
   "ERROR: THIS SHOULD NEVER HAPPEN"
  ON NOMATCH GOTO EXIT
ENDCASE

CASE AT START
 COMPUTE STATE_INPUT/A3 = STATE ;
ENDCASE
 
DATA VIA FIDEL 
END


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Gold member
posted Hide Post
Thank you Dan, I have slightly modified the code and it worked fine.


WebFOCUS 7.6.13

Mainframe
all output (Report in mainframe)
 
Posts: 64 | Registered: February 24, 2010Report This Post
Gold member
posted Hide Post
Dan,

There are some 5 records which will match the inputs provided in the screen

I/p screen

DATE (1001).............:
STATE (AZ, CA, LA).....:
CAR (123, 456, 789)......:
INV (C10013801A)..........:

All the matching records should have a PDATE value of 'CANCEL'.

But when I excute the code its not updating the pdate to cancel.

Pls suggest what was the problem.

Best Regards,
Poryes


WebFOCUS 7.6.13

Mainframe
all output (Report in mainframe)
 
Posts: 64 | Registered: February 24, 2010Report This Post
Virtuoso
posted Hide Post
Are some of the records being updated, or none of them? Previously you said your code was working fine, so has something changed?


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Gold member
posted Hide Post
Dan,

There were NO records updated with the table.

Yeah previously the code was working, ie.., It will update only the first record PDATE value to 'CANCEL' but not all the records.
Requirement is to update all the 5 Matching records PDATE value to 'CANCEL'

Please advice...

Best Regards,
Poryes


WebFOCUS 7.6.13

Mainframe
all output (Report in mainframe)
 
Posts: 64 | Registered: February 24, 2010Report This Post
Virtuoso
posted Hide Post
The code I suggested is designed to update only one record for each set of key values for ACDTE, CAR, STATE, and INV. Are there multiple records in your data with the same key values?


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Gold member
posted Hide Post
Yes Dan, We have multiple records with same key values for ACTDTE,CAR,INV.

So all the matching values for ACTDTE, CAR, INV and all the combination of STATE values will be retreived and update the PDATE value to CANCEL.

Eg:

TABLE FILE
PRINT *
WHERE DATE EQ 1004
WHERE CAR EQ '123'
WHERE INV EQ 'D20012345'
END

It retrieved 5 records with the same values (ACTDTE,CAR,INV) except for STATE.

DATE CAR STATE INV PDATE PDATE
1004 123 AZ D20012345 100402
1004 123 NY D20012345 100402
1004 123 GA D20012345 100402
1004 123 AL D20012345 100402
1004 123 NC D20012345 100402





My i/p screen and values I supplied,

DATE [1001)............................: 1004
STATE [AZ, CA, LA, ALL)................: ALL
CARRIER [123, 456, 789)................: 123
INVOICE NUMBER [C10013801A)............: D20012345

It has to change the values for PDATE to CANCEL for all the 5 records. ie If STATE = ALL then all the matchig records should be retrieved and changed PDATE to CANCEL.

Pls Let me know how to accomplish this

Best Regards,
Poryes


WebFOCUS 7.6.13

Mainframe
all output (Report in mainframe)
 
Posts: 64 | Registered: February 24, 2010Report This Post
Virtuoso
posted Hide Post
Try this:

MODIFY FILE <filename>
 COMPUTE STATE_INPUT/A3=;
 IF STATE EQ 'ALL' GOTO STATE_ALL ;
 GOTO INV_UPDATE

CASE STATE_ALL
 COMPUTE STATE_INPUT/A3 = 'ALL';
 GOTO INV_UPDATE
ENDCASE

CASE INV_UPDATE
 MATCH ACDTE 
  ON MATCH CONTINUE 
  ON NOMATCH TYPE 
   "THIS DATE IS NOT ON THE D/B." 
  ON NOMATCH GOTO TOP

 MATCH CAR 
  ON MATCH IF STATE EQ 'ALL' GOTO STATE_NEXT ;
  ON MATCH CONTINUE 
  ON NOMATCH TYPE 
   "THIS CAR IS NOT ON THE D/B FOR <ACTDTE "
  ON NOMATCH GOTO TOP

 MATCH STATE 
  ON MATCH CONTINUE
  ON NOMATCH TYPE 
   "THIS ST IS NOT IN D/B FOR <CAR FOR <ACTDTE " 
  ON NOMATCH GOTO TOP

 MATCH INV 
  ON MATCH COMPUTE PDATE = 'CANCEL'; 
  ON MATCH UPDATE PDATE 
  ON MATCH TYPE 
   "THE PAYMENT DATE HAS BEEN CANCELLED FOR <CAR FOR <INV " 
  ON NOMATCH TYPE 
   "<INV IS AN INCORRECT INV FOR <CAR <STATE " 
  ON MATCH/NOMATCH IF STATE_INPUT EQ 'ALL' GOTO REMATCH_KEYS ;
  ON MATCH/NOMATCH GOTO TOP
ENDCASE

CASE STATE_NEXT
 NEXT STATE
  ON NEXT COMPUTE STATE = D.STATE ;
  ON NEXT GOTO INV_UPDATE
  ON NONEXT GOTO TOP
ENDCASE

CASE REMATCH_KEYS
 ACTIVATE RETAIN ACDTE CAR STATE
 MATCH ACDTE CAR STATE
  ON MATCH GOTO STATE_NEXT
  ON NOMATCH TYPE
   "ERROR: THIS SHOULD NEVER HAPPEN"
  ON NOMATCH GOTO EXIT
ENDCASE
 
DATA VIA FIDEL 
END


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Gold member
posted Hide Post
Thanks Dan,

I'm in the process of testing and will get back to you If have any issues.

Best regards,
Poryes


WebFOCUS 7.6.13

Mainframe
all output (Report in mainframe)
 
Posts: 64 | Registered: February 24, 2010Report This Post
Gold member
posted Hide Post
while I was testing, I found the below issues.

Below are the matching records.

DATE CAR STATE INV PDATE PDATE
1004 123 AZ D20012345 100402
1004 123 NY D20012345 100402
1004 123 GA D20012345 100402
1004 123 AL D20012345 100402
1004 123 NC D20012345 100402

I have given the i/p which satiesfies with the above five records.
Once I filled the i/p screen and ENTER, below are the messages......

D20012345 IS AN INCORRECT INVOICE FOR 123. FOR D20012345 .
THE PAYMENT DATE HAS BEEN CANCELLED FOR 123 FOR D20012345 .
D20012345 IS AN INCORRECT INVOICE FOR 123. FOR D20012345 .
THE PAYMENT DATE HAS BEEN CANCELLED FOR 123 FOR D20012345 .

TRANSACTIONS: TOTAL = 4 ACCEPTED = 4 REJECTED = 0
SEGMENTS INPUT = 0 UPDATED = 28 DELETED = 0

Not sure why I'm getting the above messages and also there are 5 records which satiesfies the above input records but it was giving ACCEPTED = 4 UPDATED = 28

please let me know how to resolve this.

Best Regards,
Poryes


WebFOCUS 7.6.13

Mainframe
all output (Report in mainframe)
 
Posts: 64 | Registered: February 24, 2010Report This Post
Virtuoso
posted Hide Post
You need to expand your messages so they include all of the relevant information. This should give you a better understanding of which transactions are updating and which are failing. For example:

  ON MATCH TYPE 
   "THE PAYMENT DATE HAS BEEN CANCELLED FOR ACDTE:<ACDTE CAR:<CAR STATE:<STATE INV:<INV " 
  ON NOMATCH TYPE 
   "<INV IS AN INCORRECT INV FOR ACDTE:<ACDTE CAR:<CAR STATE:<STATE " 


You can also use the MODIFY ECHO and TRACE facilities to help debug your code. The TRACE facility, in particular, should be helpful in following the logic flow of the MODIFY code for a transaction. This link provides further info about these facilities:

MODIFY command syntax

The UPDATED=28 result indicates that 28 PDATE values were updated. Therefore you should have 28 messages indicating which records were updated. It is very surprising that your post only shows 2 update messages. Were there more? In addition, it is impossible to assess these results without seeing both the master description for the file you are updating and the MODIFY code. Please post the master description and your MODIFY code.

Finally, as I said earlier, mixing MATCH and NEXT logic can be very tricky. Is it possible you could avoid this issue with a different approach? For example, can you use -PROMPT or -CRTFORM with TABLE and MODIFY to accomplish your task?

-SET &MSG = ' ';
-*
-:TOP
-CRTFORM BEGIN
-"DATE (1001).................: <&DATE/4"
-"STATE (AZ, CA, LA, or ALL)..: <&STATE/3"
-"CAR (123, 456, 789).........: <&CAR/3"
-"INV (C10013801A)............: <&INV/10"
-" "
-"<D.&MSG "
-CRTFORM END
-*
-SET &STATEX = IF &STATE EQ 'ALL' THEN '$*' ELSE &STATE ;
-*
TABLE FILE filename
 PRINT ACDTE CAR STATE INV
 WHERE ACDTE EQ '&DATE'
 WHERE CAR   EQ '&CAR'
 WHERE STATE EQ '&STATEX'
 WHERE INV   EQ '&INV'
 ON TABLE HOLD
END
-*
-RUN
-IF &LINES GT 0 GOTO :UPDATE ;
-SET &MSG = 'No records match your input.';
-GOTO :TOP
-*
-:UPDATE
MODIFY FILE filename
 FIXFORM FROM HOLD
 MATCH ACDTE CAR STATE INV
  ON MATCH COMPUTE PDATE = 'CANCEL'; 
  ON MATCH UPDATE PDATE 
  ON MATCH TYPE 
   "THE PAYMENT DATE HAS BEEN CANCELLED FOR ACDTE:<ACDTE CAR:<CAR STATE:<STATE INV:<INV " 
  ON NOMATCH TYPE 
   "<INV IS AN INCORRECT INV FOR ACDTE:<ACDTE CAR:<CAR STATE:<STATE " 
  ON NOMATCH REJECT
 DATA ON HOLD
END
  

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
Gold member
posted Hide Post
Below is the Master file description.

FILE=(FILE NAME), SUFFIX=FOC
SEGNAME=DATESEG, SEGTYPE=S1
FIELDNAME=DATE ,ALIAS=ACDTE ,FORMAT=I4L ,FIELDTYPE=I,$
SEGNAME=CARSEG, SEGTYPE=S1, PARENT=DATESEG
FIELDNAME=CAR ,ALIAS=CAR1 ,FORMAT=A4 ,FIELDTYPE=I,$
FIELDNAME=CAR_NAME ,ALIAS=CARNAME ,FORMAT=A45 ,$
FIELDNAME=CAR_NAME1 ,ALIAS=CARN1 ,FORMAT=A45 ,$
FIELDNAME=CAR_CY ,ALIAS=CARC1 ,FORMAT=A45 ,$
FIELDNAME=RP_SUP ,ALIAS=SUP1 ,FORMAT=A9 ,$
FIELDNAME=RP_SUP ,ALIAS=SUP2 ,FORMAT=A3 ,$
FIELDNAME=PR_SUP ,ALIAS=PSUP ,FORMAT=A9 ,$
SEGNAME=STSEG, SEGTYPE=S1, PARENT=CARSEG
FIELDNAME=STATE ,ALIAS=ST ,FORMAT=A3 ,FIELDTYPE=I,$
FIELDNAME=RAP_AD ,ALIAS=ADD1 ,FORMAT=A11 ,$
SEGNAME=INVSEG, SEGTYPE=S1, PARENT=STSEG
FIELDNAME=RP_INV ,ALIAS=INV1 ,FORMAT=A13 ,FIELDTYPE=I,$
FIELDNAME=PAY_REF ,ALIAS=REFNO ,FORMAT=A10 ,$
FIELDNAME=PAY_DT ,ALIAS=PDATE ,FORMAT=A6 ,$
FIELDNAME=TR_DATE ,ALIAS=TDATE ,FORMAT=I6 ,$
FIELDNAME=CAR_MA ,ALIAS=MACT ,FORMAT=A4 ,$
FIELDNAME=CAR_SA ,ALIAS=SACT ,FORMAT=A4 ,$
FIELDNAME=FNCD_CO ,ALIAS=FNCD ,FORMAT=A4 ,$
FIELDNAME=EXP_CO ,ALIAS=EXT ,FORMAT=A5 ,$
FIELDNAME=RC_CG ,ALIAS=RC ,FORMAT=A9 ,$
FIELDNAME=RC_OG ,ALIAS=RO ,FORMAT=A9 ,$
FIELDNAME=AM ,ALIAS=AT ,FORMAT=P11.2 ,$
END

Modify code.

MODIFY FILE (filename)
COMPUTE STATE_INPUT/A3=;
IF STATE EQ 'ALL' GOTO STATE_ALL ;
GOTO INV_UPDATE

CASE STATE_ALL
COMPUTE STATE_INPUT/A3 = 'ALL';
GOTO INV_UPDATE
ENDCASE

CASE INV_UPDATE
MATCH ACDTE
ON MATCH CONTINUE
ON NOMATCH TYPE
"THIS DATE IS NOT ON THE D/B."
ON NOMATCH GOTO TOP

MATCH CAR
ON MATCH IF STATE EQ 'ALL' GOTO STATE_NEXT ;
ON MATCH CONTINUE
ON NOMATCH TYPE
"THIS CAR IS NOT ON THE D/B FOR <ACTDTE "
ON NOMATCH GOTO TOP

MATCH STATE
ON MATCH CONTINUE
ON NOMATCH GOTO TOP

MATCH INV
ON MATCH COMPUTE PDATE = 'CANCEL';
ON MATCH UPDATE PDATE
ON MATCH TYPE
"THE PAYMENT DATE HAS BEEN CANCELLED FOR <CAR FOR <INV "
ON NOMATCH TYPE
"<INV IS AN INCORRECT INV FOR <CAR <STATE "
ON MATCH/NOMATCH IF STATE_INPUT EQ 'ALL' GOTO REMATCH_KEYS ;
ON MATCH/NOMATCH GOTO TOP
ENDCASE

CASE STATE_NEXT
NEXT STATE
ON NEXT COMPUTE STATE = D.STATE ;
ON NEXT GOTO INV_UPDATE
ON NONEXT GOTO TOP
ENDCASE

CASE REMATCH_KEYS
ACTIVATE RETAIN ACDTE CAR STATE
MATCH ACDTE CAR STATE
ON MATCH GOTO STATE_NEXT
ON NOMATCH TYPE
"ERROR: THIS SHOULD NEVER HAPPEN"
ON NOMATCH GOTO EXIT
ENDCASE

DATA VIA FIDEL
END

Please have a look and thanks in advance.....

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


WebFOCUS 7.6.13

Mainframe
all output (Report in mainframe)
 
Posts: 64 | Registered: February 24, 2010Report This Post
Virtuoso
posted Hide Post
I don't see any glaring problems. As I mentioned in my last post, try using the MODIFY TRACE facility to debug your code.


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report 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] Query on MATCH

Copyright © 1996-2020 Information Builders