Focal Point
Modify - single segment file question

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

July 27, 2008, 10:48 PM
Anatess
Modify - single segment file question
Hi,

I'm not the greatest at MODIFY processing. Okay, what I got is a single segment focus db. What I need to do is match on the key fields then, ON NOMATCH INCLUDE, then ON MATCH, check one of the fields to see if that field matches the input file, if it does, then REJECT. If it doesn't, then update that field and update a timestamp field.

So, I started with something like this:
DEFINE FILE INFILE
STAMP1/HYYMDs=HGETC(8,STAMP1);
END
TABLE FILE INFILE
PRINT FIELD1
      STAMP1
BY    KEYFIELD1
BY    KEYFIELD2
ON TABLE SET ASNAMES ON
ON TABLE HOLD
END
-RUN
MODIFY TESTFILE
FIXFORM FROM HOLD
MATCH KEYFIELD1 KEYFIELD2
ON NOMATCH INCLUDE
ON MATCH

... not sure what to say here... 
    something to the effect of
    IF FIELD1 FROM HOLD = FIELD1 FROM TESTFILE
       THEN REJECT
    ELSE
       UPDATE FIELD1 STAMP1

END


I tried it this way and it didn't work. I think it's because FIELD1 is on the same segment as the keyfields not a child segment, so the second MATCH won't work...

MATCH KEYFIELD1 KEYFIELD2
ON NOMATCH INCLUDE
ON MATCH CONTINUE
MATCH FIELD1
ON NOMATCH UPDATE FIELD1 STAMP1
ON MATCH REJECT
END


That particular code gives me a (FOC411) THE ACTION AFTER 'ON NOMATCH' IS INVALID: UPDATE error.

I'm on 7.1.4.

Thanks for the assistance.


WF 8.1.05 Windows
July 28, 2008, 12:41 AM
Danny-SRL
Anatess,

  
DEFINE FILE INFILE
STAMP1/HYYMDs=HGETC(8,STAMP1);
END
TABLE FILE INFILE
PRINT FIELD1
      STAMP1
BY    KEYFIELD1
BY    KEYFIELD2
ON TABLE SET ASNAMES ON
ON TABLE HOLD
END
-RUN
MODIFY TESTFILE
FIXFORM FROM HOLD
MATCH KEYFIELD1 KEYFIELD2
ON NOMATCH INCLUDE
ON MATCH IF FIELD1 EQ D.FIELD1 THEN GOTO TOP;
ON MATCH UPDATE STAMP1
DATA ON HOLD
END



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

July 28, 2008, 02:12 AM
Tony A
Anatess,

Because it is a single segment file, what Danny suggests above will work perfectly. However, if you ever encounter a multiple segment file then you might need to use -
VALIDATE field[/format] = expression;
ON VALID action
ON INVALID action

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
July 28, 2008, 02:27 AM
Danny-SRL
Anatess,

Tony's addendum is to the point. Also, by using the VALIDATE command you can also type out some comments about rejected input records.

I think I was a bit elliptic in my example. To be a bit more explicit, in MODIFY any field name - in your example FIELD1 - is interpreted by MODIFY as coming from the input - in your example the HOLD file. In order to access the same field in the database - the FOCUS file - you add the D. prefix to the field name - D is a mnemonic for Database.

I hope this makes the subject clearer.


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

July 28, 2008, 09:39 AM
Anatess
Danny, Tony,
You guys are the best! Your proposed solution worked perfectly.

Side note: I posted a question on the Microsoft discussion group on some such and it's been almost 2 weeks and the only response I got was - are you sure this is what you want to do? Sigh.

I love Focal Point!


WF 8.1.05 Windows