I have written the below focus mainframe code wherein i am deleting transactions from the focus database using MODIFY feature. I want to log all the deleted transaction. The LOG ACCEPT only only the accepted transaction i.e. 4 in below case. If we see the output of the below code, it shows that there are 649 lines deleted. Can i log all those 649 line deleted in some PS file using some command
MODIFY FILE R5482M01.BASE.POL.NUM CHECK 99999 LOG NOMATCH ON NMACH LOG DUPL ON DUPL LOG ACCEPT ON ACCPT FIXFORM BASE.POL.NUM/7 PLN.CH.EF.DY/8 PL.LST.CH.DY/8 MATCH BASE.POL.NUM ON MATCH CONTINUE ON NOMATCH REJECT MATCH PLN.CH.EF.DY PL.LST.CH.DY ON MATCH DELETE DATA ON TSSTDEL END
This message has been edited. Last edited by: Kerry,
FOCUS version 7.6.7. Windows Excel
March 27, 2010, 10:48 AM
Dan Satchell
Unfortunately, since a single transaction deletes dozens or hundreds of records in this case, the logging of transactions will not produce a list of all deleted records. You might be able to accomplish this with the use of NEXT and CASE logic, but the MODIFY code becomes complicated.
The easiest approach may be to generate a list of records that meet the delete criteria before-hand. How is file TSSTDEL created? Is it the result of a TABLE FILE? If so, you could print a report of all records that meet the delete criteria before running the MODIFY and then verify that the number of lines (&LINES) from the report matches the number of deleted segments (&DELTD) from the MODIFY.
EDIT: Sorry, but I mistakenly said that &LINES should equal &DELTD. &DELTD will exceed &LINES because &LINES will equal the number of report records, while &DELTD will equal the number of deleted segments - in this case one record consists of many segments.
Otherwise, CASE/NEXT logic might look something like this. Mixing MATCH and NEXT logic can be dangerous so proceed with caution. This example arbitrarily assumes two key levels below PL.LST.CH.DY (keyname4 and keyname5) - keyname5 being the last key in the table hierarchy.
MODIFY FILE R5482M01.BASE.POL.NUM
FIXFORM BASE.POL.NUM/7 PLN.CH.EF.DY/8 PL.LST.CH.DY/8
GOTO KEYMATCH
CASE KEYMATCH
MATCH BASE.POL.NUM PLN.CH.EF.DY PL.LST.CH.DY
ON MATCH GOTO KEYNEXT
ON NOMATCH REJECT
ON NOMATCH GOTO TOP
ENDCASE
CASE KEYNEXT
NEXT <keyname4>
ON NEXT GOTO LOGDELS
ON NONEXT GOTO DELRECS
ENDCASE
CASE LOGDELS
NEXT <keyname5>
ON NEXT TYPE ON DELTRANS
"will be deleted: <BASE.POL.NUM <PLN.CH.EF.DY <PL.LST.CH.DY <keyname4 <keyname5 "
ON NEXT GOTO LOGDELS
ON NONEXT GOTO KEYREMATCH
ENDCASE
CASE KEYREMATCH
ACTIVATE RETAIN BASE.POL.NUM PLN.CH.EF.DY PL.LST.CH.DY <keyname4>
MATCH BASE.POL.NUM PLN.CH.EF.DY PL.LST.CH.DY <keyname4>
ON MATCH GOTO KEYNEXT
ON NOMATCH TYPE
"NOMATCH error in CASE KEYREMATCH: This should NEVER happen!!!"
ON NOMATCH GOTO EXIT
ENDCASE
CASE DELRECS
ACTIVATE RETAIN BASE.POL.NUM PLN.CH.EF.DY PL.LST.CH.DY
MATCH BASE.POL.NUM PLN.CH.EF.DY PL.LST.CH.DY
ON MATCH TYPE ON DELTRANS
"deleted: <BASE.POL.NUM <PLN.CH.EF.DY <PL.LST.CH.DY "
ON MATCH DELETE
ON MATCH GOTO TOP
ON NOMATCH TYPE
"NOMATCH error in CASE DELRECS: This should NEVER happen!!!"
ON NOMATCH GOTO EXIT
ENDCASE
CASE AT START
CHECK 99999
LOG NOMATCH ON NMACH
LOG DUPL ON DUPL
LOG ACCEPT ON ACCPT
ENDCASE
DATA ON TSSTDEL
END
This message has been edited. Last edited by: Dan Satchell,
WebFOCUS 7.7.05
March 29, 2010, 10:29 AM
Doren Perruccio
Allocate a file to write transactions to. Exp: DELTRANS
After match of transaction to be deleted:
ON MATCH TYPE ON DELTRANS “d.field d.field d.field”
Where d. are data values from the database
Next command ON MATCH DELETE
Mainframe FOCUS 7.6.7 all output
March 30, 2010, 03:51 AM
Kofi
I think Dan make good point of many segment database.
If you have many segment and not the one then use Dan's suggested and not rely on single MATCH like Doren suggest.
If only single segmented then ON MATCH DELETE be OK.
Kofi
Client Server 8.1.05: Apache; Tomcat;Windows Server 2012 Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012
March 30, 2010, 04:41 AM
Dan Satchell
I just discovered an error in the MODIFY code I posted earlier. In CASE DELRECS I had specified "ON MATCH/NOMATCH GOTO EXIT", but in the case of ON MATCH, the logic should GOTO TOP. I have corrected my earlier post.
WebFOCUS 7.7.05
March 31, 2010, 07:57 AM
GamP
Of course, you could also do a TABLE first, selecting all the records that are going to be deleted (using the same transaction file as you'll be using in the modify), hold it to a file that you can archive, and then do the modify.