!
! SLMREPMOD.CMD - SOURCE LIBRARY REPLACE MODULE PROCEDURE
!
!  EDIT NUMBER = 0002
!  EDITED BY: D.B.CURTIS  4 APR 80  17:05
!
!
SET DICTIONARY SLIB
DELETE REPLACE-MODULE;
DEFINE PROCEDURE REPLACE-MODULE
READY MODS
READY MODHIST
READY INIT-DOM
FIND INIT IN INIT-DOM
SELECT FIRST INIT
FIND A IN MODS WITH SUB-PROJECT = INIT.ISP AND PROCESS = *.PROCESS AND
	MODULE-TITLE = *.MODULE
SELECT FIRST A
IF A.STATUS NE "UPDAT" THEN BEGIN
	DISPLAY "MODULE NOT AVAILABLE FOR REVISION"
	FIND A IN A WITH SUB-PROJECT = "JUNK"
	END
FIND B IN MODHIST WITH SUB-PROJECT = A.SUB-PROJECT AND PROCESS = A.PROCESS AND
	MODULE-TITLE = A.MODULE-TITLE AND STATUS = "EXTREV" ,"REPLAC" SORTED BY STATUS
PRINT ALL MODULE-IDENT-EXTRACTED(-),DATE-EXTRACTED(-),DATE-RETURNED(-),
	EXTRACTORS-NAME(-),STATUS(-) OF B
FIND B IN B WITH EXTRACTORS-NAME = *.NAME AND STATUS = "EXTREV"
SORT B BY ACCESID
SELECT LAST B
IF B.MODULE-IDENT-EXTRACTED NE  A.MODULE-IDENT THEN BEGIN
	DISPLAY "EXTRACTED ID AND CURRENT DO NOT MATCH"
	DISPLAY "REPLACEMENT ABORTED"
	FIND A IN A WITH SUB-PROJECT = "JUNK"
	FIND B IN B WITH SUB-PROJECT = "JUNK"
	END
READY MODS MODIFY
READY MODHIST MODIFY
MODIFY USING BEGIN
	LAST-INSERTION-DATE = INIT.IDAT
	STATUS = "REVIS"
	MODULE-IDENT=*.NEW-IDENT
	ACCESS-NUMBER = A.ACCESS-NUMBER + 1
	END OF A
READY MODS READ
DISPLAY A.SUB-PROJECT
DISPLAY A.PROCESS
DISPLAY A.MODULE-TITLE
FIND AA IN MODS WITH SUB-PROJECT=A.SUB-PROJECT AND PROCESS = A.PROCESS AND
	MODULE-TITLE = A.MODULE-TITLE
FIND A IN AA
RELEASE AA
SELECT LAST A
MODIFY USING BEGIN
	TRACE = *.TRACE
	MODULE-IDENT-RETURNED = A.MODULE-IDENT
	DATE-RETURNED = INIT.IDAT
	STATUS = "REPLAC"
	END OF B
FINISH INIT-DOM
 PRINT SLFILE(-),".",SLEXT(-),"/RP=[",B.GROUP(-),",",B.MEMBER(-),"]",
	MFILE(-),".",MEXT(-),SKIP 1,
	SLFILE(-),".",SLEXT(-),"/MH:",A.MODULE-TITLE(-),":",MODHIG(-),":",MODLOW(-),
	":REV:",ACCESS-NUMBER(-) ON LIBREPDTR.TMP


END-PROCEDURE
DEFINEP REPLACE-MODULE 2,UIC,[*,*],R
