Focal Point
[Solved] Problem with a match for loading data.

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

June 26, 2014, 05:43 PM
andrekilik
[Solved] Problem with a match for loading data.
Hi everyone, I'm pretty new to FOCUS, and having a few problems with it over the last few weeks. All the past problems I've had I could find an answer around here without posting. This time it was not the case, so I need some help from you guys.

The prolem is in this piece of code, I need to load the data from TEMPFILE, into SECURITY file, but it NEVER moves the data from the USERID field, which in my security file is the INDEX, and the main data I need on the file for further processing and reporting.
MATCH FILE TEMPFILE
PRINT USERID 
      FIRST_NAME_BF AS FIRST_NAME
      LAST_NAME_BF AS LAST_NAME
      LEVEL_BFOR AS LEVEL
BY USERID 
RUN
FILE SECURITY
PRINT USERID
BY USERID
AFTER MATCH HOLD OLD-NOT-NEW
END
MODIFY FILE SECURITY
FIXFORM FROM HOLD
MATCH USERID 
ON NOMATCH INCLUDE
END


Can someone tell me what I'm doing wrong? This piece of code is a copy of another program that does a similar function, and still this one's not moving the key field properly.
The data on the file gets like this, inserting only the first record and then rejecting all others, saying that its a duplicate of the key
USERID        FIRST_NAME        LAST_NAME
------        ----------        ---------
              ANDRE             CASARINI

What I think even weird, is that it rejects the transactions saying that it has no userid, but shows me the userid in the transaction data:
(FOC405) TRANS 1 REJECTED DUPL: ROOT
CHKCASA ANDRE CASARINI

I really have no idea why this is happening. Any help will be highly appreciated, if you need any further info, please let me know.

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


FOCUS 7.6
Mainframe, Outputs available
June 27, 2014, 05:30 AM
Tony A
Hi Andre and welcome to the Point,

I am guessing that the USERID fields are exactly the same format?

What is the format of the SECURITY table?

This may not be exactly the same as your scenario but may help.
Note that I am using SUM (my preference for this - should avoid duplicates in any event).
Also I am not repeating the USERID into the output - you only need it once in each MATCH part. To stop the USERID being repeated in the second MATCH component, I am using another field but renaming it as NOTUSED, I then COMPUTE this within the MODIFY to prevent a FOC419 failure.
-* Preparation section
-* This is only to get something similar to your scenario
EX -LINES 6 EDAPUT MASTER, SECURITY, C, MEM, FILE=SECURITY, SUFFIX=FOC
SEGNAME=SEG01
FIELDNAME=USERID      ,A10    ,A10   , FIELDTYPE=I, $
FIELDNAME=FIRST_NAME  ,A10    ,A10   , $
FIELDNAME=LAST_NAME   ,A15    ,A15   , $
FIELDNAME=LEVEL       ,A04    ,A04   , $
-RUN
CREATE FILE SECURITY
-RUN

DEFINE FILE EMPDATA
  USERID/A10 = EDIT(LASTNAME,'9999999$')||EDIT(FIRSTNAME,'9$');
END

TABLE FILE EMPDATA
  SUM FIRSTNAME AS FIRST_NAME
      LASTNAME  AS LAST_NAME
      DIV       AS LEVEL
   BY USERID
WHERE DIV EQ 'CORP'
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SET ASNAMES ON
ON TABLE HOLD AS BASEDATA
END
-RUN

MODIFY FILE SECURITY
FIXFORM FROM BASEDATA
MATCH USERID
  ON MATCH REJECT
  ON NOMATCH INCLUDE
DATA ON BASEDATA
END
-RUN
-* End of preparation section

MATCH FILE EMPDATA
  SUM FIRSTNAME AS FIRST_NAME
      LASTNAME  AS LAST_NAME
      DIV       AS LEVEL
   BY USERID
RUN
FILE SECURITY
  SUM LEVEL AS NOTUSED
   BY USERID
AFTER MATCH HOLD AS LOADDATA OLD-NOT-NEW
END

MODIFY FILE SECURITY
COMPUTE NOTUSED/A4 = '';
FIXFORM FROM LOADDATA
MATCH USERID
  ON MATCH REJECT
  ON NOMATCH INCLUDE
DATA ON LOADDATA
END
-RUN
gives -
NUMBER OF RECORDS SELECTED=       41  LINES=     41
NUMBER OF RECORDS SELECTED=        8  LINES=      8
LINES OF MATCH OUTPUT     =       33
TRANSACTIONS:         TOTAL =    33  ACCEPTED=    33  REJECTED=     0
SEGMENTS:             INPUT =    33  UPDATED =     0  DELETED =     0

Good luck

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 
June 27, 2014, 10:37 AM
andrekilik
Hi Tony, thanks for the quick reply. Your solution helped me, it's now working.


FOCUS 7.6
Mainframe, Outputs available
June 27, 2014, 11:38 AM
Tony A
Hi Andre,

That's good to hear!

T