Focal Point
Need Maintain Help

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

November 17, 2005, 09:16 AM
dhofman
Need Maintain Help
I have been trying to do a MAINTAIN to match two files together and if the records match, update a date. However I cannot get it to work no matter what I tried. Here is what I have and hopefully someone can help:

Hold 1 is Format Focus Index A1 A2 A3 A4 (this is the "database" if you will)
Hold 2 has the same keys but is only sorted in the key order (ie. by A1 by A2 by A3 by A4. no indexing or format).

Using Maintain, I am trying to match the records in Hold 2 to the database (hold 1) However it is not working. If there is a match, I need to update a date field on the database record that matched (the date field is not a key field). Hold 2 will contain records that are on the database and some that are not. If there is no match, I want to reject the record and move onto the next on Hold 2.

No matter what I try, my results are 1 Commit and nothing is updated when I know that around 150 records should be updated.

Can someone please help? It would be much appreciated. Thanks!
November 17, 2005, 01:23 PM
TexasStingray
A simple TABLE FILE and MODIFY Will Work
  
DEFINE FILE HOLD2
MYDATE/MDYY = 1117205;
END

TABLE FILE HOLD2
PRINT
MYDATE
BY A1
BY A2
BY A3
BY A4
ON TABLE HOLD AS NEWDATA
END

MODIFY FILE HOLD1
FIXFORM FROM NEWDATA
MATCH A1 A2 A3 A4
ON NOMATCH REJECT
ON MATCH UPDATE MYDATE
DATA ON NEWDATA
END 


Good Luck




Scott

Ok. That worked! Thanks Texas Stingray. However..............

I realize I need to take it a level higher than what I talked about in my original post due to requirements changes. Plus I forgot to mention a couple things.

Hold1 is still the same, however there may be duplicates. There is no way to a complety unique key because I could add records later on in my process by a different key resulting in this key being that same as something that already exists.
Hold2 is the same but there may be duplicates in the hold file.

What I need to do is match Hold2 records one at a time to the database(hold1) by the key. If I find a match, I need to set a date on the database for that record touching no other data for that record. Also, I need to delete that record from Hold2. If I find a match and there are duplicates on the database for that key, I need to keep the record on Hold2 and go to the next record on Hold2.
If I do not find a match on the database, I want to keep the record is Hold2 for later processing and go to the next record on Hold2.

Hopefully someone can help we with these changes to my dilemna. I appreciate it
Thanks.
Here is the code that you need. THis compares the code in file B to the codes in file A. IF found, update the date field in file A and delete the record from file B. If not found, move to the next row of B - Mark

cssmhd: MAINTAIN FILE HOLDA AND HOLDB
MODULE IMPORT(MNTUWS)
FOR ALL NEXT HOLDB.CODE INTO STK
FOR ALL NEXT HOLDA.CODE INTO STK2
COMPUTE DATE1/A10 = TODAY2();
COMPUTE DATE2/MDYY = DATE1;
COMPUTE DATE3/YYMD = DATE2;
COMPUTE I/I3=1;
COMPUTE J/I3=1;
REPEAT STK.FOCCOUNT
COMPUTE J=1;
REPEAT STK2.FOCCOUNT
IF STK(I).CODE = STK2(J).CODE THEN BEGIN
COMPUTE STK2(J).XDATE = DATE3;
UPDATE HOLDA.XDATE FROM STK2(J);
DELETE HOLDB.CODE FROM STK(I);
GOTO EXITREPEAT
ENDBEGIN
COMPUTE J=J+1;
ENDREPEAT
COMPUTE I=I+1;
ENDREPEAT
END
Thanks! This helps tremendously and is much simpler than what I came up with.