<MvCOMMENT>
|
| Miva Merchant v4.x
|
| This file and the source codes contained herein are the property 
| of Miva Corporation.  Use of this file is restricted to the specific 
| terms and conditions in the License Agreement associated with this 
| file.  Distribution of this file or portions of this file for uses
| not covered by the License Agreement is not allowed without a written 
| agreement signed by an officer of Miva Corporation.
| 
| Copyright 1998-2001 Miva Corporation.  All rights reserved.
| http://www.miva.com/
|
| dBase III Database Layer
| $Source: /home/cvs/merchant/Merchant/features/rpd/rpd_db.mv,v $
|
| Prefix         : MER-RPD-DB
| Next Error Code: 0    
| Next Text ID   : 3    
|
</MvCOMMENT>

<MvFUNCTION NAME = "RPD_Store_Create">
	<MvASSIGN NAME = "l.ok" VALUE = 1>	
	<MvCREATE NAME = "RelatedProducts"
			  DATABASE = "{ g._DB_Store_Directory $ 'relprod.dbf' }"
			  FIELDS = "product_id 	NUMBER,
						relprod_id	NUMBER">
	<MvIF EXPR = "{ MvCREATE_Error }">
		<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-DTB-00377', MvCREATE_Error ) }">
	<MvELSE>
		<MvASSIGN NAME = "g._DB_Store_RelatedProduct_Open" VALUE = 1>
	</MvIF>

	<MvIF EXPR = "{ l.ok }">
		<MvMAKEINDEX NAME = "RelatedProducts"
					 INDEXFILE = "{ g._DB_Store_Directory $ 'relprodp.mvx' }"
					 EXPRESSION = "{ RelatedProducts.d.product_id $ ':' $ padl( RelatedProducts.d.relprod_id, 10, '0' ) }"
					 FLAGS = "nounique, ascending">
		<MvIF EXPR = "{ MvMAKEINDEX_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-DTB-00378', MvMAKEINDEX_Error ) }">
		</MvIF>
	</MvIF>
	<MvIF EXPR = "{ l.ok }">
		<MvMAKEINDEX NAME = "RelatedProducts"
					 INDEXFILE = "{ g._DB_Store_Directory $ 'relprodr.mvx' }"
					 EXPRESSION = "{ RelatedProducts.d.relprod_id }"
					 FLAGS = "nounique, ascending">
		<MvIF EXPR = "{ MvMAKEINDEX_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-DTB-00379', MvMAKEINDEX_Error ) }">
		</MvIF>
	</MvIF>

	<MvIF EXPR = "{ l.ok }">
		<MvCLOSE NAME = "RelatedProducts">
		<MvASSIGN NAME = "g._DB_Store_RelatedProduct_Open" VALUE = 0>
	</MvIF>

	<MvIF EXPR = "{ l.ok }">
		<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ StoreKey_Insert( 'RelatedProducts', 1 ) }">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "RPD_Store_Pack" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_RelatedProduct() }">
	<MvIF EXPR = "{ l.ok }">
		<MvPACK NAME = "RelatedProducts">
		<MvIF EXPR = "{ MvPACK_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-DTB-00391', MvPACK_Error ) }">
		<MvELSE>
			<MvCLOSE NAME = "RelatedProducts">
			<MvASSIGN NAME = "g._DB_Store_RelatedProduct_Open" VALUE = 0>
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "RPD_Store_Delete">
	<MvASSIGN NAME = "l.directory" VALUE = "{ g.MerchantPath $ padl( Stores.d.id, 8, '0' ) $ '/' }">

	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'relprod.dbf' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'relprodp.mvx' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'relprodr.mvx' ) }">

	<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>

<MvFUNCTION NAME = "RPD_Store_Close" STANDARDOUTPUTLEVEL = "">
	<MvIF EXPR = "{ g._DB_Store_RelatedProduct_Open }">
		<MvCLOSE NAME = "RelatedProducts">
		<MvASSIGN NAME = "g._DB_Store_RelatedProduct_Open" VALUE = 0>
	</MvIF>
</MvFUNCTION>

<MvFUNCTION NAME = "_DB_Store_Open_RelatedProduct" STANDARDOUTPUTLEVEL = "" ERROROUTPUTLEVEL = "syntax, expression">
	<MvASSIGN NAME = "l.ok" VALUE = 1>
	<MvIF EXPR = "{ NOT g._DB_Store_RelatedProduct_Open }">

		<MvOPEN NAME = "RelatedProducts"
				DATABASE = "{ g._DB_Store_Directory $ 'relprod.dbf' }" 
				INDEXES = "{ g._DB_Store_Directory $ 'relprodp.mvx, ' $ g._DB_Store_Directory $ 'relprodr.mvx' }">
		<MvIF EXPR = "{ MvOPEN_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-DTB-00366', MvOPEN_Error ) }">
		<MvELSE>
			<MvASSIGN NAME = "g._DB_Store_RelatedProduct_Open" VALUE = 1>
			<MvFILTER NAME = "RelatedProducts" FILTER = "{ NOT RelatedProducts.d.deleted }">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Product_Delete_RelatedProduct" PARAMETERS = "id">
	<MvIF EXPR = "{ _DB_Store_Open_RelatedProduct() }">
		<MvPRIMARY NAME = "RelatedProducts" INDEX = "{ g._DB_Store_Directory $ 'relprodp.mvx' }">

		<MvFIND NAME = "RelatedProducts" VALUE = "{ l.id }" EXACT>
		<MvWHILE EXPR = "{ ( NOT RelatedProducts.d.EOF ) AND ( RelatedProducts.d.product_id EQ l.id ) }">
			<MvDELETE NAME = "RelatedProducts">
			<MvSKIP NAME = "RelatedProducts" ROWS = 1>
		</MvWHILE>

		<MvPRIMARY NAME = "RelatedProducts" INDEX = "{ g._DB_Store_Directory $ 'relprodr.mvx' }">

		<MvFIND NAME = "RelatedProducts" VALUE = "{ l.id }" EXACT>
		<MvWHILE EXPR = "{ ( NOT RelatedProducts.d.EOF ) AND ( RelatedProducts.d.relprod_id EQ l.id ) }">
			<MvDELETE NAME = "RelatedProducts">
			<MvSKIP NAME = "RelatedProducts" ROWS = 1>
		</MvWHILE>
	</MvIF>
	<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>

<MvFUNCTION NAME = "RelatedProduct_FindNext_All" PARAMETERS = "prod_id, offset, search" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvSKIP NAME = "Products" ROWS = 1>

	<MvIF EXPR = "{ NOT Products.d.EOF }">
		<MvASSIGN NAME = "l.newoffset" VALUE = "{ l.offset + 1 }">
		<MvASSIGN NAME = "l.found" VALUE = 1>
	</MvIF>

	<MvIF EXPR = "{ l.found }">
		<MvFUNCTIONRETURN VALUE = "{ l.newoffset }">
	<MvELSE>
		<MvFUNCTIONRETURN VALUE = 0>
	</MvIF>
</MvFUNCTION>

<MvFUNCTION NAME = "RelatedProduct_FindNext_Unassigned" PARAMETERS = "prod_id, offset, search" STANDARDOUTPUTLEVEL = "">

	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvASSIGN NAME = "l.newoffset" VALUE = "{ l.offset + 1 }">

	<MvSKIP NAME = "Products" ROWS = 1>
	<MvWHILE EXPR = "{ ( NOT Products.d.EOF ) AND ( NOT l.found ) }">
		<MvFIND NAME = "RelatedProducts" VALUE = "{ l.prod_id $ ':' $ padl( Products.d.id, 10, '0' ) }" EXACT>

		<MvIF EXPR = "{ RelatedProducts.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = 1>
			<MvWHILESTOP>
		</MvIF>

		<MvASSIGN NAME = "l.newoffset" VALUE = "{ l.newoffset + 1 }">
		<MvSKIP NAME = "Products" ROWS = 1>
	</MvWHILE>

	<MvIF EXPR = "{ l.found }">
		<MvFUNCTIONRETURN VALUE = "{ l.newoffset }">
	<MvELSE>
		<MvFILTER NAME = "Products" FILTER = "{ NOT Products.d.deleted }">
		<MvFUNCTIONRETURN VALUE = 0>
	</MvIF>
</MvFUNCTION>

<MvFUNCTION NAME = "RelatedProduct_FindNext_Assigned" PARAMETERS = "prod_id, offset, search" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvASSIGN NAME = "l.newoffset" VALUE = "{ l.offset + 1 }">
	<MvSKIP NAME = "RelatedProducts" ROWS = 1>

	<MvWHILE EXPR = "{ ( NOT RelatedProducts.d.EOF ) AND ( RelatedProducts.d.product_id EQ l.prod_id ) AND ( NOT l.found ) }">
		<MvFIND NAME = "Products" VALUE = "{ RelatedProducts.d.relprod_id }" EXACT>
		<MvIF EXPR = "{ NOT Products.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = 1>
			<MvWHILESTOP>
		</MvIF>

		<MvASSIGN NAME = "l.newoffset" VALUE = "{ l.newoffset + 1 }">
		<MvSKIP NAME = "RelatedProducts" ROWS = 1>
	</MvWHILE>

	<MvIF EXPR = "{ l.found }">
		<MvFUNCTIONRETURN VALUE = "{ l.newoffset }">
	<MvELSE>
		<MvFILTER NAME = "Products" FILTER = "{ NOT Products.d.deleted }">
		<MvFUNCTIONRETURN VALUE = 0>
	</MvIF>
</MvFUNCTION>

<MvFUNCTION NAME = "RelatedProduct_Customer_FindFirst_Product" PARAMETERS = "cust_code, prod_id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	
	<MvIF EXPR = "{ _DB_Store_OPEN_RelatedProduct() }">
		<MvPRIMARY NAME = "RelatedProducts" INDEX = "{ g._DB_Store_Directory $ 'relprodp.mvx' }">
		<MvFIND NAME = "RelatedProducts" VALUE = "{ l.prod_id $ ':' }">

		<MvWHILE EXPR = "{ ( NOT RelatedProducts.d.EOF ) AND ( RelatedProducts.d.product_id EQ l.prod_id ) AND ( NOT l.found ) }">
			<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.product_found" VALUE = "{ Runtime_Product_Find_ID( l.cust_code, RelatedProducts.d.relprod_id ) }">

			<MvIF EXPR = "{ l.product_found }">
				<MvASSIGN NAME = "l.found" VALUE = 1>
				<MvWHILESTOP>
			</MvIF>

			<MvSKIP NAME = "RelatedProducts" ROWS = 1>
		</MvWHILE>
	</MvIF>

	<MvIF EXPR = "{ l.found }">
		<MvFUNCTIONRETURN VALUE = 1>
	<MvELSE>
		<MvFUNCTIONRETURN VALUE = 0>
	</MvIF>
</MvFUNCTION>

<MvFUNCTION NAME = "RelatedProduct_Customer_FindNext_Product" PARAMETERS = "cust_code, prod_id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvSKIP NAME = "RelatedProducts" ROWS = 1>
	<MvWHILE EXPR = "{ ( NOT RelatedProducts.d.EOF AND ( RelatedProducts.d.product_id EQ l.prod_id ) ) AND ( NOT l.found ) }">
		<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.product_found" VALUE = "{ Runtime_Product_Find_ID( l.cust_code, RelatedProducts.d.relprod_id ) }">
		<MvIF EXPR = "{ l.product_found }">
			<MvASSIGN NAME = "l.found" VALUE = 1>
			<MvWHILESTOP>
		</MvIF>

		<MvSKIP NAME = "RelatedProducts" ROWS = 1>
	</MvWHILE>

	<MvIF EXPR = "{ l.found }">
		<MvFUNCTIONRETURN VALUE = 1>
	<MvELSE>
		<MvFUNCTIONRETURN VALUE = 0>
	</MvIF>
</MvFUNCTION>

<MvFUNCTION NAME = "RelatedProduct_Find_ID" PARAMETERS = "product_id, relatedproduct_id" STANDARDOUTPUTLEVEL = "">
	<MvIF EXPR = "{ _DB_Store_OPEN_RelatedProduct() }">
		<MvPRIMARY NAME = "RelatedProducts" INDEX = "{ g._DB_Store_Directory $ 'relprodp.mvx' }">
		<MvFIND NAME = "RelatedProducts" VALUE = "{ l.product_id $ ':' }">

		<MvWHILE EXPR = "{ ( NOT RelatedProducts.d.EOF ) AND ( RelatedProducts.d.product_id EQ product_id ) }">
			<MvIF EXPR = "{ RelatedProducts.d.relprod_id EQ relatedproduct_id }">
				<MvFUNCTIONRETURN VALUE = 1>
			<MvELSE>
				<MvSKIP NAME = "RelatedProducts" ROWS = 1>
			</MvIF>
		</MvWHILE>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = 0>
</MvFUNCTION>

<MvFUNCTION NAME = "RelatedProduct_Insert" PARAMETERS = "product_id, relatedproduct_id" STANDARDOUTPUTLEVEL = "">
	<MvIF EXPR = "{ _DB_Store_Open_RelatedProduct() }">
		<MvASSIGN NAME = "l.find" VALUE = "{ RelatedProduct_Find_ID( product_id, relatedproduct_id ) }">

		<MvIF EXPR = "{ l.find }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-RPD-DB00000">
				<MvLOCALIZED-TOKEN NAME = "product_id" VALUE = "{ encodeentities( l.product_id ) }">
				<MvLOCALIZED-TOKEN NAME = "relatedproduct_id" VALUE = "{ encodeentities( l.relatedproduct_id ) }">

				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Product '%product_id%' and '%relatedproduct_id%' are already in RelatedProducts Database</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-DTB-00367', l.error ) }">
		<MvELSE>
			<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ _DB_Store_Open_Products() }">
			<MvIF EXPR = "{ l.ok }">
				<MvPRIMARY NAME = "Products" INDEX = "{ g._DB_Store_Directory $ 'prd_id.mvx' }">
				<MvFIND NAME = "Products" VALUE = "{ l.product_id }" EXACT>
				<MvIF EXPR = "{ Products.d.EOF }">
					<MvLOCALIZED NAME = "l.error" ID = "MER-RPD-DB00001">
						<MvLOCALIZED-TOKEN NAME = "product_id" VALUE = "{ encodeentities( l.product_id ) }">
						<MvLOCALIZED-TEXT LANGUAGE = "en-US">Product '%product_id%' not found </MvLOCALIZED-TEXT>
					</MvLOCALIZED>

					<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-DTB-00368', l.error ) }">
				<MvELSE>
					<MvPRIMARY NAME = "Products" INDEX = "{ g._DB_Store_Directory $ 'prd_id.mvx' }">
					<MvFIND NAME = "Products" VALUE = "{ l.relatedproduct_id }" EXACT>
					<MvIF EXPR = "{ Products.d.EOF }">
						<MvLOCALIZED NAME = "l.error" ID = "MER-RPD-DB00002">
							<MvLOCALIZED-TOKEN NAME = "product_id" VALUE = "{ encodeentities( l.relatedproduct_id ) }">
							<MvLOCALIZED-TEXT LANGUAGE = "en-US">Product '%product_id%' not found</MvLOCALIZED-TEXT>
						</MvLOCALIZED>

						<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-DTB-00369', l.error ) }">

					<MvELSE>
						<MvASSIGN NAME = "RelatedProducts.d.product_id" VALUE = "{ l.product_id }">
						<MvASSIGN NAME = "RelatedProducts.d.relprod_id" VALUE = "{ l.relatedproduct_id }">
						<MvADD NAME = "RelatedProducts">
					</MvIF>
				</MvIF>
			</MvIF>
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "RelatedProduct_Delete" PARAMETERS = "product_id, relatedproduct" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvIF EXPR = "{ _DB_Store_Open_RelatedProduct() }">
		<MvPRIMARY NAME = "RelatedProducts" INDEX = "{ g._DB_Store_Directory $ 'relprodp.mvx' }">
		<MvASSIGN NAME = "l.found" VALUE = "{ RelatedProduct_Find_ID( l.product_id, l.relatedproduct ) }">
		<MvIF EXPR = "{ l.found }">
			<MvDelete NAME = "RelatedProducts">
			<MvUPDATE NAME = "RelatedProducts">
		</MvIF>
	</MvIF>
	<MvFILTER NAME = "RelatedProducts" FILTER = "{ NOT RelatedProducts.d.deleted }">

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "RelatedProduct_CheckAssigned" PARAMETERS = "prod_id, relprod_id" STANDARDOUTPUTLEVEL = "">
	<MvIF EXPR = "{ _DB_Store_Open_RelatedProduct() }">
		<MvPRIMARY NAME = "RelatedProducts" INDEX = "{ g._DB_Store_Directory $ 'relprodp.mvx' }">
		<MvFIND NAME = "RelatedProducts" VALUE = "{ l.prod_id $ ':' }">
		<MvWHILE EXPR = "{ ( NOT RelatedProducts.d.EOF ) AND ( RelatedProducts.d.product_id EQ l.prod_id ) }">
			<MvIF EXPR = "{ RelatedProducts.d.relprod_id EQ l.relprod_id }">
				<MvFUNCTIONRETURN VALUE = 1>
			<MvELSE>
				<MvSKIP NAME = "RelatedProducts">
			</MvIF>
		</MvWHILE>
	</MvIF>
	<MvFUNCTIONRETURN VALUE = 0>
</MvFUNCTION>

<MvFUNCTION NAME = "RelatedProduct_FindOffset_Unassigned" PARAMETERS = "prod_id, offset, search" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvASSIGN NAME = "l.newoffset" VALUE = "{ l.offset + 1 }">

	<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.db_store_prod_open" VALUE = "{ _DB_Store_Open_Products() }">
	<MvDO FILE = "{ g.Module_Feature_RPD_DB }" NAME = "l.db_store_rep_open" VALUE = "{ _DB_Store_Open_RelatedProduct() }">

	<MvIF EXPR = "{ l.db_store_prod_open AND l.db_store_rep_open }">
		<MvPRIMARY NAME = "Products" INDEX = "{ g._DB_Store_Directory $ 'prd_id.mvx' }">
		<MvPRIMARY NAME = "RelatedProducts" INDEX = "{ g._DB_Store_Directory $ 'relprodp.mvx' }">

		<MvDO FILE = "{ Module_Library_DB }" NAME = "l.filter" VALUE = "{ _Product_Filter( l.search ) }">
		<MvFILTER NAME = "Products" FILTER = "l.filter" FILTER_TYPE = "variable">

		<MvSKIP NAME = "Products" ROWS = "{ l.offset }">
		<MvWHILE EXPR = "{ ( NOT Products.d.EOF ) AND ( NOT l.found ) }">
			<MvFIND NAME = "RelatedProducts" VALUE = "{ l.prod_id $ ':' $ padl( Products.d.id, 10, '0' ) }" EXACT>
			<MvIF EXPR = "{ RelatedProducts.d.EOF }">
				<MvASSIGN NAME = "l.found" VALUE = 1>
				<MvWHILESTOP>
			</MvIF>

			<MvASSIGN NAME = "l.newoffset" VALUE = "{ l.newoffset + 1 }">
			<MvSKIP NAME = "Products" ROWS = 1>
		</MvWHILE>
	</MvIF>

	<MvIF EXPR = "{ l.found }">
		<MvFUNCTIONRETURN VALUE = "{ l.newoffset }">
	<MvELSE>
		<MvFUNCTIONRETURN VALUE = 0>
	</MvIF>

</MvFUNCTION>

<MvFUNCTION NAME = "RelatedProduct_FindOffset_Assigned" PARAMETERS = "prod_id, offset, search" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvASSIGN NAME = "l.newoffset" VALUE = "{ l.offset + 1 }">

	<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.db_store_prod_open" VALUE = "{ _DB_Store_Open_Products() }">
	<MvDO FILE = "{ g.Module_Feature_RPD_DB }" NAME = "l.db_store_rep_open" VALUE = "{ _DB_Store_Open_RelatedProduct() }">

	<MvIF EXPR = "{ l.db_store_prod_open AND l.db_store_rep_open }">
		<MvPRIMARY NAME = "Products" INDEX = "{ g._DB_Store_Directory $ 'prd_id.mvx' }">
		<MvPRIMARY NAME = "RelatedProducts" INDEX = "{ g._DB_Store_Directory $ 'relprodp.mvx' }">

		<MvDO FILE = "{ Module_Library_DB }" NAME = "l.filter" VALUE = "{ _Product_Filter( l.search ) }">
		<MvFILTER NAME = "Products" FILTER = "l.filter" FILTER_TYPE = "variable">

		<MvFIND NAME = "RelatedProducts" VALUE = "{ l.prod_id $ ':' }">
		<MvSKIP NAME = "RelatedProducts" ROWS = "{ l.offset }">

		<MvIF EXPR = "{ ( NOT RelateProducts.d.EOF ) AND ( RelatedProducts.d.product_id EQ l.prod_id ) }">
			<MvFIND NAME = "Products" VALUE = "{ RelatedProducts.d.relprod_id }" EXACT>
			<MvIF EXPR = "{ NOT Products.d.EOF }">
				<MvASSIGN NAME = "l.found" VALUE = 1>
				<MvASSIGN NAME = "l.newoffset" VALUE = "{ l.newoffset + 1 }">
			</MvIF>
		</MvIF>
	</MvIF>

	<MvIF EXPR = "{ l.found }">
		<MvFUNCTIONRETURN VALUE = "{ l.newoffset }">
	<MvELSE>
		<MvFUNCTIONRETURN VALUE = 0>
	</MvIF>
</MvFUNCTION>
