RVM Array Question

I hope everyone is having a good day. I am looking for a way to maintain the entire hierarchy all the way back to site, even when only a few items within that hierarchy have been added to the array. I.E. the RVM should always be the name of the site, even if it only includes 2 zones.

I am using an Array called sites to build my RVM list.  I had it creating the owner of the zones earlier day, but I was not able to get it to loop and export all the zones listed from the array. I hope this makes since. Can someone please help? 

-----------------------------------------------------------------------------------------------------------------------------------
$* !RVMEXPORTFOLDER = 'C:\AVEVA\RVM_OUTPUT\' - PATH FOR THE RVM/ATT OUTPUT 
-----------------------------------------------------------------------------------------------------------------------------------

--!RVMEXPORTFOLDER = ('/C:\AVEVA\RVM_OUTPUT\FP-21-0021_LP5\RVM-P\')
!RVMEXPORTFOLDER = ('/C:\AVEVA\RVM_OUTPUT\')
-----------------------------------------------------------------------------------------------------------------------------------
$* !RVMEXPORTFOLDER = 'C:\AVEVA\RVM_OUTPUT\' - PATH FOR THE RVM/ATT OUTPUT 
-----------------------------------------------------------------------------------------------------------------------------------


!RVMEXPORTFOLDER = ('/C:\AVEVA\RVM_OUTPUT\')



-----------------------------------------------------------------------------------------------------------------------------------
$* ADD SITE NAME TO THE ARRAY - EXAMPLE "!SITES = !!COLLECTALLFOR(|SITE|,|MATCHW(NAME,'*01*')|,WORL)"
$* COLLECTS ALL SITES FOR INCLUSION IN RVM GENERATION.   UNCOMMENT ADDITIONAL ROWS AS NEEDED.	
-----------------------------------------------------------------------------------------------------------------------------------

!SITES = !!COLLECTALLFOR(|ZONE|,|MATCHW(NAME,'*ZONE-EQUIPMENT-AREA02-B01*')|,WORL)		
!SITES.APPENDARRAY(!!COLLECTALLFOR(|ZONE|,|MATCHW(NAME,'*ZONE-EQUIPMENT-AREA02-B02*')|,WORL))
--!SITES.APPENDARRAY(!!COLLECTALLFOR(|ZONE|,|MATCHW(NAME,'*ZONE-EQUIPMENT-AREA02-B02*')|,WORL))


--Q VAR !SITES

$* INITIALISE VARIABLES

!ITEMS = !SITES	


-----------------------------------------------------------------------------------------------------------------------------------
$* REMOVE ATT FILE FROM THE ARRAY - EXAMPLE "SKIP IF (MATCHW ('$!ITEMS[$!K].NAME','*PIPING*'))" *.* WILL RUN ALL ATT FILES
-----------------------------------------------------------------------------------------------------------------------------------

!RESULT = ARRAY()


DO !K INDICES !ITEMS

SKIP IF (MATCHW ('$!ITEMS[$!K].NAME','*STEP*'))
SKIP IF (MATCHW ('$!ITEMS[$!K].NAME','*.*'))
SKIP IF (MATCHW ('$!ITEMS[$!K].NAME','*.*'))
SKIP IF (MATCHW ('$!ITEMS[$!K].NAME','*.*'))
SKIP IF (MATCHW ('$!ITEMS[$!K].NAME','*.*'))

!RESULT.APPEND('$!ITEMS[$!K].NAME')
-- Q VAR !RESULT

ENDDO


----------------------------------------------------------------------------------------------------------------------------------- 
$* START THE RVM PROGRESS
-----------------------------------------------------------------------------------------------------------------------------------


do !NAMERVM values !ITEMS

 var !COLL coll all for $!NAMERVM
 	
LABEL /ALL

	EXPORT AUTOCOLOUR RESET
	EXPORT AUTOCOLOUR ON
	-- EXPORT AUTOCOLOUR OFF

	-- EXPORT AUTOCOLOUR DISPLAYEXPORT ON
	EXPORT AUTOCOLOUR DISPLAYEXPORT OFF

	-- EXPORT REPR ON
	EXPORT REPR OFF

	-- REPRE INSU ON TRANSL 75
	REPRE INSU OFF

	-- REPRE OBST ON TRANSL 75
	REPRE OBST OFF

	REPRE TUBE ON
	-- REPRE TUBE OFF

	-- REPRE CENT OFF
	-- EXPORT IMPLIED TUBE SEPARATE
	EXPORT FILENOTE ''
	EXPORT HOLES ON
	

	EXPORT SYSTEM /EXPDRI.SO
				
		!type = !!ce.attribute( |TYPE| )	
		
		do !INDX indices !COLL

	--	skip if(TYPE of $!COLL[$!INDX] eq |TUBI|)
		
		
			 
		
		if ( !type NEQ |SITE| ) then
		   
			!namervm = NAME OF OWNER
			--!NAMEATTR =  '/' & !namervm.after('/').REPLACE(|/|,|_|)	
			EXPORT FILE $!RVMEXPORTFOLDER$!OWNER$N.RVM OVER
			EXPORT  $!COLL[$!INDX]
			
			EXPORT FINISH
		else
			--SAVE THE NAME OF THE CE SITE
			--!NAMEOFCESITE = !!CE.NAME
			--EXPORT FILE $!RVMEXPORTFOLDER$!NAMEOFCESITE$N.RVM OVER
			--EXPORT  $!NAMEOFCESITE
			--EXPORT FINISH
		endif	
		
	--	Q VAR !Array
	ENDDO


ENDDO
-- Q VAR !ALLEXPORT
Q VAR !COLL