<#--
   ******************************************************
   *
   *                       NOTICE
   *
   *  THIS SOFTWARE IS THE PROPERTY OF AND CONTAINS
   *  CONFIDENTIAL INFORMATION OF INFOR, AND SHALL NOT BE
   *  COPIED, USED, NOR DISCLOSED WITHOUT EXPRESS WRITTEN
   *  AUTHORIZATION.  ALTHOUGH PUBLICATION IS NOT
   *  INTENDED, IN THE EVENT OF PUBLICATION, THE
   *  FOLLOWING NOTICE IS APPLICABLE:
   *
   *  Copyright © 2009 Infor. All rights reserved.
   *  The word and design marks set forth herein are
   *  trademarks and/or registered trademarks of Infor
   *  and/or related affiliates and subsidiaries.
   *  All rights reserved. All other trademarks listed
   *  herein are the property of their respective owners.
   *  www.infor.com.
   *
   ******************************************************
 -->
<#--
     Generate the public layer implementation file
     - object is an instance of BusinessInterfaceImplementation
 -->
<@common.checkCancel/>
<@source.query_statuses/>
#define RETIFNOK2_LIST_NEW(...)
^               bl.result = ...
^               if bl.result <> 0 then
^                       handle.messages(o.responseArgument,
^					o.resultArgument,
^					true)
^                       bl.ret = xmlDelete(o.ResponseArgument)
^                       o.ResponseArgument = 0
^                       return(bl.result)
^               endif

#define	RETIFNOK5_LIST(...)
^		bl.result = ...
^		if bl.result <> 0 then
^			return(bl.result)
^		endif

<#function attributeImplementedInQuery1 iComponent iAttribute>
	<#list SelectionList as sl>
		<#if sl.component==iComponent && sl.attribute == iAttribute>
			<#return true>
		</#if>
	</#list>

	<#return false>
</#function>

<#macro selecting_attributes iattr comp compName>
	<#assign level=level+1>
	<#if attributeImplementedInQuery1(compName, iattr.name) || iattr.isSpecialImplNeeded>
		<#assign attr_ok=true>
	<#else>
		<#assign attr_ok=false>
	</#if>
	<#if level==1>
		<#assign groupSel=public.getAttributeGroupForSelection(comp, iattr)>
		<#assign attrPath=iattr.name?replace("_", ".")>
		<#if iattr.type=="group" || iattr.type=="complex" >
		<#-- Only ..* -->
			<#assign star=".*">
		<#else>
			<#assign star="">
		</#if>
		<#if attr_ok || iattr.type=="group" || iattr.type=="complex">
			<#assign case_for_attr=true>
	case "${iattr.name}${star}":|*attr(${iattr.type})
			<#if groupSel != iattr.name>
	case "${groupSel}${star}":|*group(${iattr.type})
			</#if>
			<#if attrPath != iattr.name && attrPath != groupSel>
	case "${attrPath}${star}":|*attr_path(${iattr.type})
			</#if>
		</#if>
		<#assign attrList="">
	</#if>
	<#if !attrList?contains(":"+iattr.name+":")>
		<#assign attrList=attrList+":"+iattr.name+":">
	<#if iattr.type!="group" || iattr.isSpecialImplNeeded>
		<#if attr_ok>
		${compName}.${iattr.name}.select = true |* LVL:${level}
			<#if iattr.type == "qualifier" && iattr.parentAttribute?exists && 
			     !attrList?contains(":"+iattr.parentAttribute.value+":") && attributeImplementedInQuery1(compName, iattr.parentAttribute.value)>
				<#assign attrList=attrList+":"+iattr.name+":">
		${compName}.${iattr.parentAttribute.value}.select = true  |* Parentattribute
			</#if>
			<#if level==1>
				<#list parentIdentifiers as pi>
		${pi.component}.${pi.attribute}.select = true  |* Parent Identifier ${compName}
				</#list>
			</#if>
		</#if>
	</#if>
	<#list iattr.attributeRelationship as ar>
		<#if !ar.attribute.idref.isHidden>
<@selecting_attributes iattr=ar.attribute.idref comp=comp compName=compName/>
		</#if>
	</#list>
	</#if>
	<#assign level=level-1>
</#macro>

<@source.performance_point description="InitSelection"/>
function void InitSelection(boolean i.settrue)
{
	FunctionUsage
	EndFunctionUsage

<#list public.listAllPublicAttributes() as a>
	${a.componentName}.${a.attributeName}.select = i.settrue
</#list><#--list public.listAllPublicAttributes() as a-->
<#list SpecialSelectionList as ssl>
	${ssl.component}.${ssl.attribute}.select = i.settrue
</#list><#--list SpecialSelectionList as ssl-->
}

<@source.performance_point description="SetSelectionVariable_new1"/>
function long SetSelectionVariable_new1(const string SelecVar)
{
	long	end_pos_comp
	boolean	correct_selection

	correct_selection = false
	|* Strip component.
	end_pos_comp = pos(SelecVar, ".")

	<#-- make duplicate array -->
	<#assign dupl_comp="">
	<#assign dupl_comp_done="">
	<#list DuplicateComponents as dc>
		<#assign dupl_comp=dupl_comp+":"+dc+":">
	</#list>
	if end_pos_comp > 0 then
		on case SelecVar(1;end_pos_comp-1)
	<#list common.listComponentImplementations("", iobject) as c>
		<#-- Check for duplicate components -->
		<#if dupl_comp?contains(":"+c.componentPublicName+":")> 
			<#if !dupl_comp_done?contains(":"+c.componentPublicName+":")>
		  		<#assign dupl_comp_done=dupl_comp_done+":"+c.componentPublicName+":">
		case "${c.componentPublicName}":
		   	  	<#list common.listComponentImplementations("", iobject) as d1>
		     		<#if c.componentPublicName == d1.componentPublicName>
		    SetSelectionVariable_New1_${d1.componentName}(
				SelecVar(end_pos_comp+1), correct_selection)
		     		</#if>
		     	</#list>
			break
		     </#if>
		<#else>
		case "${c.componentPublicName}":
			SetSelectionVariable_New1_${c.componentName}(
				SelecVar(end_pos_comp+1), correct_selection)
			break
		</#if>
	</#list>
		endcase
	else
		if SelecVar = "*" then
			InitSelection(true)
			correct_selection = true
		endif
	endif
	
	if not correct_selection then
			dal.set.error.message("tlbctsb0042", SelecVar)
			|* No valid selectionAttributes received
			|* (unknown selectionAttribute received "%1$s").
			return(DALHOOKERROR)
	endif
	return (0)
}
	<#list common.listComponentImplementations("", iobject) as c>

<@source.performance_point description="SetSelectionVariable_new1_"+c.componentName/>
function SetSelectionVariable_New1_${c.componentName}(const string SelecVar,
			ref boolean	o.correct_selection)
{
	<#assign first=true>
	<#list common.listComponentImplementations(c.componentName, iobject) as d>
		<#if first>
	long	end_pos_comp

	|* Strip component.
	
	end_pos_comp = pos(SelecVar, ".")
	if end_pos_comp > 0 then
		on case (SelecVar(1;end_pos_comp-1))
			<#assign first=false>
		</#if>
		case "${d.componentPublicName}":
			SetSelectionVariable_New1_${d.componentName}(
				SelecVar(end_pos_comp+1), o.correct_selection)
			return
	</#list>
	<#if !first>
		endcase
	endif
	</#if>
	
	on case (SelecVar)
	case "*": |* ${c.componentName}.*
		<#list SelectionList as sl>
			<#if c.componentName == sl.component>
		${sl.component}.${sl.attribute}.select = true
			</#if>
		</#list>
		<#list SpecialSelectionList as ssl>
			<#if c.componentName == ssl.component>
		${ssl.component}.${ssl.attribute}.select = true
			</#if>
		</#list>
		<#list public.listAllParentIndentifiers(c.componentName) as i>
		${i.parentComponentName}.${i.attributeName}.select = true  |* Parent Identifier ${c.componentName}
		</#list>
		o.correct_selection = true
		break
		<#assign parentIdentifiers=[]>
		<#list public.listAllParentIndentifiers(c.componentName) as i>
			<#assign parentIdentifiers=parentIdentifiers + [{
				"component":i.parentComponentName,
				"attribute":i.attributeName}]>
		</#list>
		<#-- build a list with relations for associations -->
		<#assign attribute_associations=[]>
		<#list public.listAllPublicAttributes() as at>
			<#if at.componentName == c.componentName && at.attributeImplementation.type == "association">
				<#list protected.listProtectedAssociatedAttributes(at.componentImplementation) as aa>
					<#if aa.fromAttributeImplementation == at.attributeImplementation>
						<#list common.listRelationshipDetails(aa.fromComponentImplementation,aa.relationshipImplementation) as rd>
							<#if attributeImplementedInQuery1(aa.fromComponentName, rd.fromAttributeName)>
								<#assign attribute_associations=attribute_associations + [{
									"attribute":at.attributeName,
									"related_component":aa.fromComponentName,
									"related_attribute":rd.fromAttributeName}]>
							</#if>
						</#list>
					</#if>
				</#list>
			</#if>
		</#list>
	<#assign level=0>
	<#list c.componentImplementation.component.idref.attribute as attr>
		<#if !attr.isHidden>
			<#assign case_for_attr=false>
<@selecting_attributes iattr=attr comp=c.componentImplementation.component.idref compName=c.componentName/>
			<#if case_for_attr>
				<#list attribute_associations as aa>
					<#if attr.name == aa.attribute>
		${aa.related_component}.${aa.related_attribute}.select = true  |* Related Identifier
					</#if>
				</#list>
		o.correct_selection = true
		break
			</#if>
		</#if>
	</#list>
	endcase	
}
	</#list>

<@source.performance_point description="SetSelection_new1"/>
function long SetSelection_new1(xmlNode SelectionNode)
{
	long	ret
	xmlNode	AttributeNode
	string	SelectionAttribute(256)
	boolean	postfilter
	xmlnode filteredAttributes
	xmlnode	filter.attribute

	AttributeNode = xmlGetFirstChild(SelectionNode)
	while AttributeNode <> 0
		ret = xmlGetData(AttributeNode, SelectionAttribute)
		RETIFNOK(SetSelectionVariable_new1(strip$(SelectionAttribute)))
		AttributeNode = xmlGetRightSibling(AttributeNode)
	endwhile
	
	|* Set selected for postfilter attributes
	RETIFNOK(<@names.ST_DLLCode/>.get.postfilter(postfilter))
	if postfilter then
		RETIFNOK(<@names.ST_DLLCode/>.get.filteredAttributes(
					filteredAttributes))
		filter.attribute = xmlGetFirstChild(filteredAttributes)
		while filter.attribute <> 0
			on case xmlData$(filter.attribute)
		<#list public.listAllPublicAttributes() as a>
			case "${a.componentName}.${common.getAttributeName(a.attributeImplementation)}":
				${a.componentName}.${a.attributeName}.select = true
				break
		</#list>
		<#list SpecialSelectionList as ssl>
			case "${ssl.component}.${ssl.attributeImplementationName}":
				${ssl.component}.${ssl.attribute}.select = true
				break
		</#list>
			default:			
				break
			endcase
			filter.attribute = xmlGetRightSibling(filter.attribute)
		endwhile
	endif

	return(0)
}

<#list object.methodImplementation as methodImplementation>
	<#assign methodName=common.getNameFromMethodImplementation(methodImplementation)>
	<#if (methodName=="Show" || methodName=="List") &&
	     protected.hasMethodAlternativeImplementation(methodName)=="">
		<#if methodName!="Show" >
<@source.performance_point description="set.paging"/>
function boolean set.paging(
		long	i.iteratorID,
		boolean	i.has.page.tag,
	const	string	i.value,
		boolean	i.is.iterating,
		boolean	i.first.has.been.fetched,
	ref	boolean	io.cont.iteration,
	ref	boolean	io.do.query)
{
	<@names.ST_DLLCode/>.init.paging()
	<@names.ST_DLLCode/>.set.save.first.record(not i.first.has.been.fetched)
	io.do.query=true
	
	if not i.has.page.tag  then
			return(false)
	endif

	on case tolower$(trim$(i.value))
	case "first":
		<@names.ST_DLLCode/>.finalize.${names.businessInterfaceName}.List()
		<@names.ST_DLLCode/>.init.paging()
		<@names.ST_DLLCode/>.set.pageup(false)
		io.cont.iteration=false
		break
	case "last":
		<@names.ST_DLLCode/>.finalize.${names.businessInterfaceName}.List()
		<@names.ST_DLLCode/>.init.paging()
		<@names.ST_DLLCode/>.set.pageup(true)
		io.cont.iteration=false
		break
	case "up":
		if not <@names.ST_DLLCode/>.is.pageup() then
			<@names.ST_DLLCode/>.finalize.${names.businessInterfaceName}.List()
			<@names.ST_DLLCode/>.set.pageup(true)
			if i.is.iterating then
				<@names.ST_DLLCode/>.set.switch.direction(true)
			endif
			<@names.ST_DLLCode/>.set.save.first.record(true)
			io.cont.iteration=false
		endif
		break
	case "down":
		if <@names.ST_DLLCode/>.is.pageup() then
			<@names.ST_DLLCode/>.finalize.${names.businessInterfaceName}.List()
			<@names.ST_DLLCode/>.set.pageup(false)
			<@names.ST_DLLCode/>.set.switch.direction(true)
			<@names.ST_DLLCode/>.set.save.first.record(true)
			io.cont.iteration=false
		endif
		break
	case "clear":
		<@names.ST_DLLCode/>.finalize.${names.businessInterfaceName}.List()
		<@names.ST_DLLCode/>.set.pageup(false)
		io.do.query=false
		break
	default:
		<@names.ST_DLLCode/>.finalize.${names.businessInterfaceName}.List()
		io.do.query=false
		dal.set.error.message(sprintf$("@Error, paging command not supported: %s",trim$(i.value)))
		return(DALHOOKERROR)
		break
	endcase
	return(false)
}

<@source.performance_point description="check.iteratorID_new"/>
function long check.iteratorID_new(long i.iteratorID, boolean	i.reset)
{
	static	long	ProtectedIteratorID

	if i.reset then
		ProtectedIteratorID = 0
		return(0)
	endif
	
	if i.iteratorID <> 0 then
		if ProtectedIteratorID = 0 then
			dal.set.error.message("tlbctsb0017", i.iteratorID)
			|* iteratorID %1$d is not known. No iterator is present
			return(DALHOOKERROR)
		endif

		|* An iterator request for a none existing process: so error
		if i.iteratorID <> pid then
			dal.set.error.message("tlbctsb0016", i.iteratorID)
			|* iteratorID %1$d is not known.
			return(DALHOOKERROR)
		endif
	endif

	ProtectedIteratorID = pid
	
	return(0)
}

		</#if><#--if methodName!="Show"-->
<@source.performance_point description=methodName+"_new"/>
function long <@names.SB_DLLCode/>.${methodName}_new(
					const xmlnode i.RequestArgument,
		<#if object.businessInterfaceDefinition.idref.type!="bod">
					    boolean i.suppressNillableAttributes,
		</#if>
					ref xmlnode o.ResponseArgument,
					ref xmlnode o.ResultArgument)
{
	xmlNode	Response${names.businessInterfaceName}Node
	boolean	doFetch
	boolean	${names.businessInterfaceName}_cancel
	long	bl.retval
		<#if methodName!="Show">
	boolean	iterator_active
		</#if>
	long	duml

	duml = 0
	bl.current.method = "${methodName}"
	bl.processingScope = REQUEST
		<#if methodName!="Show">
	iterator_active = false
		</#if>
		
	RETIFNOK2(createResponseObject(o.ResponseArgument, "${methodName}"))
	RETIFNOK2(createResultObject(o.ResultArgument))
	RETIFNOK2(selectResponseNode(o.ResponseArgument, Response${names.businessInterfaceName}Node))

	make.xmlArguments.global(i.RequestArgument,
				 o.ResponseArgument,
				 o.ResultArgument)


	doFetch = true
	bl.result = Handle.Request.${methodName}.${names.businessInterfaceName}_new(i.RequestArgument, 
		<#if object.businessInterfaceDefinition.idref.type!="bod">
				i.suppressNillableAttributes,
		</#if>
				o.ResponseArgument, o.ResultArgument,
				Response${names.businessInterfaceName}Node, <#if methodName!="Show">iterator_active, </#if>${names.businessInterfaceName}_cancel)

	bl.retval = bl.result
	if bl.result <> 0 then
		|* Add used query to response.
		add.executed.queries.to.response.${methodName}.${names.businessInterfaceName}(o.resultArgument, true)
		handle.messages(o.responseArgument,
		o.resultArgument,
		true)
        bl.ret = xmlDelete(o.ResponseArgument)
        o.ResponseArgument = 0
	else
	 	if log.query then
			|* Add used query to response.
			add.executed.queries.to.response.${methodName}.${names.businessInterfaceName}(o.ResponseArgument, false)
		endif
		handle.messages(o.ResponseArgument,
			o.ResultArgument, false) |* put mess in response
	endif
		<#if methodName!="Show">
	if not iterator_active then
		</#if>
		<#list public.listPublicComponents(methodName) as c>
		RETIFNOK2_LIST_NEW(<@names.ST_DLLCode/>.finalize.${c.componentName}.${methodName}())
		</#list>
		<#if methodName!="Show">
		duml = check.iteratorID_new(0, true)
		</#if>
		
		RETIFNOK2_LIST_NEW(<@names.ST_DLLCode/>.finalize.request.${methodName}())
		<#if methodName!="Show">
	endif
		</#if>

	return(bl.retval)
}

		<#list public.listPublicComponents(methodName) as c>
<@source.performance_point description="add.executed.queries.to.response"/>
function add.executed.queries.to.response.${methodName}.${c.componentName}(xmlnode	io.response,
					boolean		i.error)
{
	xmlnode	log.node
	xmlnode mess.node
	xmlnode	curr.node
	long	i, ret
	xmlnode	bnode
	string hookname(128)
			<#if c.componentName == names.businessInterfaceName>
	string filterExpression(1024)
	boolean	postFilter
	xmlnode	filter
			</#if>

	if <@names.ST_DLLCode/>.return.query.status.${c.componentName}() = QUERY.INACTIVE then
		return
	endif
			<#if c.componentName == names.businessInterfaceName>
	if i.error then
		| we cannot assume that the result is not empty or has no message details
		if xmlGetFirstChild(io.response) = 0 then
			mess.node = io.response
		else
			log.node = xmlFindFirstMatch("<>.<MessageDetails>", io.response)
			if log.node = 0 then
				log.node = xmlNewNode("MessageDetails", XML_ELEMENT, io.response)
			endif
		endif
	else
		log.node = xmlFindFirstMatch("<>.<InformationArea>", io.response)
		if log.node = 0 then
			log.node = xmlNewNode("InformationArea", XML_ELEMENT, io.response)
		endif
		mess.node = xmlNewNode("Message", XML_ELEMENT, log.node)
		ret = xmlSetAttribute(mess.node, "ID", "ID000001")
	endif

	curr.node = xmlNewDataElement("messageCode", "QueryLog", mess.node)
	curr.node = xmlNewDataElement("messageType", "Information", mess.node)
	curr.node = xmlNewDataElement("messageText", "Executed Queries for method ${methodName}.",
				mess.node)
	curr.node = xmlNewDataElement("messageSource","SQL Query",
				mess.node)
	mess.node = xmlNewNode("MessageReference", XML_ELEMENT, mess.node)
	curr.node = xmlNewDataElement("messageReferenceType", "logEntry", mess.node)
	curr.node = xmlNewNode("messageReferenceInfo", XML_ELEMENT, mess.node)
			<#-- Show table Aliases -->
	for i = 1 to <@names.ST_DLLCode/>.retrieve.table_alias.count()
		if i = 1 then
			mess.node = xmlNewNode("Table_Aliases",XML_ELEMENT, curr.node)
		endif
		bnode = xmlNewDataElement("t" & str$(i),
			strip$(<@names.ST_DLLCode/>.retrieve.table_alias(i)), mess.node)
	endfor
	mess.node = xmlNewNode("ComponentFilterHook", XML_ELEMENT, curr.node)
				<#list protected.listProtectedComponents() as pc>
					<#if pc.componentImplementation.componentFilterHookExpression?exists && pc.componentImplementation.componentFilterHookExpression?has_content>
	bnode = xmlNewDataElement("${pc.componentName}", <@names.ST_DLLCode/>.retrieve.component.filter.hook.${pc.componentName}(), mess.node)
					</#if>
				</#list>
	mess.node = xmlNewNode("Filter", XML_ELEMENT, curr.node)
	ret = <@names.ST_DLLCode/>.get.filter.expression(filterExpression)
	bnode = xmlNewDataElement("Expression", filterExpression, mess.node)
	mess.node = xmlNewNode("PostFilter", XML_ELEMENT, curr.node)
	ret = <@names.ST_DLLCode/>.get.postfilter(postfilter)
	if postfilter then
		|* for postfiltering the original filter is used
		ret = <@names.ST_DLLCode/>.get.filter(filter)
		ret = xmlDuplicateAndAppendToChilds(mess.node, filter)
	endif
	ret = xmlSetAttribute(mess.node, "postfiltering", postfilter?"true":"false")
			<#else>
	curr.node = io.response
			</#if>

	log.node = xmlNewNode("${c.componentName}",XML_ELEMENT, curr.node)

	if <@names.ST_DLLCode/>.query.on.hook.${c.componentName}.${methodName}(hookname) then
	mess.node = xmlNewDataElement("HOOK", 
		"Query is executed in hook " & strip$(hookname), log.node)
	else
	|* Read and Add query.
	mess.node = xmlNewDataElement("select", 
		<@names.ST_DLLCode/>.retrieve.select.clause.${c.componentName}(), log.node)
	mess.node = xmlNewDataElement("from", 
		<@names.ST_DLLCode/>.retrieve.from.clause.${c.componentName}(), log.node)
	mess.node = xmlNewDataElement("where", 
		<@names.ST_DLLCode/>.retrieve.where.clause.${c.componentName}(), log.node)
	mess.node = xmlNewDataElement("orderby", 
		<@names.ST_DLLCode/>.retrieve.orderby.clause.${c.componentName}(), log.node)
	for i = 1 to <@names.ST_DLLCode/>.retrieve.selectbind.count.${c.componentName}()
		if i = 1 then
			mess.node = xmlNewNode("selectbind",XML_ELEMENT, log.node)
		endif
		bnode = xmlNewDataElement("_" & str$(i),
			strip$(<@names.ST_DLLCode/>.retrieve.selectbind.clause.${c.componentName}(i)), mess.node)
	endfor
	for i = 1 to <@names.ST_DLLCode/>.retrieve.wherebind.count.${c.componentName}()
		if i = 1 then
			mess.node = xmlNewNode("wherebind",XML_ELEMENT, log.node)
		endif
		bnode = xmlNewDataElement("_"& str$(i),
			strip$(<@names.ST_DLLCode/>.retrieve.wherebind.clause.${c.componentName}(i)), mess.node)
	endfor
	endif
	if <@names.ST_DLLCode/>.return.query.status.${c.componentName}() = QUERY.ERROR then
		ret = xmlsetAttribute(log.node, "Error_status", "Error")
		return
	endif
	ret = xmlsetAttribute(log.node, "fetches", <@names.ST_DLLCode/>.retrieve.fetch.count.${c.componentName}())
	
	|* Add sub components.
			<#assign listOfPublicSubComponents = public.listPublicSubComponents(methodName, c.componentName)>
			<#list listOfPublicSubComponents as s>
	add.executed.queries.to.response.${methodName}.${s.componentName}(log.node, i.error)
			</#list><#--list listOfPublicSubComponents as s-->
}

<@source.performance_point description="Handle.Request."+methodName+"."+c.componentName+"_new"/>
function long Handle.Request.${methodName}.${c.componentName}_new(
			const		xmlNode	i.Request${c.componentName}Node,
			<#if object.businessInterfaceDefinition.idref.type!="bod">
					boolean	i.suppressNillableAttributes,
			</#if>
			ref			xmlNode	io_${methodName}.ResponseArgument, 
			ref			xmlNode	io_${methodName}.ResultArgument,
			<#if c.componentName == names.businessInterfaceName>
			const		xmlNode	i.Response${names.businessInterfaceName}Node,
				<#if methodName!="Show">
			ref			boolean	o.iter_act,
				</#if><#--if methodName!="Show"-->
			<#else><#--if c.componentName == names.businessInterfaceName-->
			const		xmlNode	i.Response${c.parentComponentName}Node,
			</#if><#--if c.componentName == names.businessInterfaceName-->		
			ref		boolean	o.cancel)
{
	long	ret
	boolean	fetching
	xmlNode	Response.${c.componentName}Node
	boolean	selection.present
			<#if c.componentName == names.businessInterfaceName>
	xmlnode	ControlAreaNode
				<#if c.componentName == names.businessInterfaceName && methodName!="Show">
	long	iteratorID
	static	long iteratorFetchSize
	boolean	do.query
	xmlnode ControlArea
				</#if><#--if c.componentName == names.businessInterfaceName && methodName!="Show"-->
	long	fetch.count
				<#if c.componentName == names.businessInterfaceName && methodName!="Show">
	long	max.number.objects, max.batch.count
	static	long	total.object.count
	static	xmlnode	hold.last.fetched.object
	boolean	cont.iteration
				</#if><#--if c.componentName == names.businessInterfaceName && methodName!="Show"-->
	boolean sortingExpressionSet
	boolean	TagFound
	string  Value(1024)
	xmlnode	filter
	boolean	postfilter
	xmlnode	metaDataForFilter
	boolean	postfilter.valid
			</#if><#--if c.componentName == names.businessInterfaceName-->

			<#if c.componentName != names.businessInterfaceName || methodName=="Show">
	ret = 0
			</#if><#--if c.componentName != names.businessInterfaceName || methodName=="Show"-->
	bl.result = 0
	Response.${c.componentName}Node = 0

			<#if c.componentName == names.businessInterfaceName>
	ControlAreaNode = xmlFindFirst("ControlArea", i.Request${c.componentName}Node)
			</#if><#--if c.componentName == names.businessInterfaceName-->
			<#if c.componentName == names.businessInterfaceName && methodName!="Show" >
	|* Get maxNumberOfObjects from the ControlAreaNode Node
	RETIFNOK5_LIST(getValue(ControlAreaNode, 
			"ControlArea.maxNumberOfObjects",
			"<ControlArea>.<maxNumberOfObjects>",
			false, Value, TagFound))
	max.number.objects = lval(Value)
	max.batch.count = max.number.objects
	
	|* Get iteratorID from the ControlAreaNode Node
	RETIFNOK5_LIST(getValue(ControlAreaNode, 
			"ControlArea.iteratorID",
			"<ControlArea>.<iteratorID>",
			false, Value, TagFound))
	iteratorID  = lval(Value)
	RETIFNOK5_LIST(check.iteratorID_new(iteratorID, false))
	
	|* Get iteratorFetchSize from the ControlAreaNode Node
	RETIFNOK5_LIST(getValue(ControlAreaNode, 
			"ControlArea.iteratorFetchSize",
			"<ControlArea>.<iteratorFetchSize>",
			false, Value, TagFound))
	if TagFound then
		iteratorFetchSize = max(1, lval(Value))
	endif

	cont.iteration = false
	if iteratorFetchSize <> 0 then
		if IteratorID <> 0 then
			|* Busy with iteration
			cont.iteration = true
		else
	 		iteratorID = pid
			total.object.count = 0
		endif
		max.batch.count = iteratorFetchSize
	else
		|* No iteration.
		total.object.count = 0
	endif

	|* Get pagingValue from the ControlAreaNode Node
	RETIFNOK5_LIST(getValue(ControlAreaNode,
			"ControlArea.paging",
			"<ControlArea>.<paging>",
			false, Value, TagFound))			
	RETIFNOK5_LIST(set.paging(iteratorID, TagFound, Value,
			total.object.count <> 0,
			hold.last.fetched.object <> 0,
			cont.iteration,do.query))
	if do.query then
			</#if><#--if c.componentName == names.businessInterfaceName && methodName!="Show" -->
			<#if c.componentName == names.businessInterfaceName && methodName!="Show" >
	if not cont.iteration then
			</#if><#--if c.componentName == names.businessInterfaceName && methodName!="Show" -->
			<#if c.componentName == names.businessInterfaceName>
	if <@names.ST_DLLCode/>.return.query.status.${c.componentName}() <> QUERY.FETCH then
		RETIFNOK5_LIST(<@names.ST_DLLCode/>.initialize.request.${methodName}())

				<#if methodName!="Show">
		if iteratorFetchSize = 0 then
				</#if><#--if methodName!="Show"-->
		|* Get sortingExpression from the ControlAreaNode Node
		RETIFNOK5_LIST(getValue(ControlAreaNode, 
				"ControlArea.sortingExpression",
				"<ControlArea>.<sortingExpression>",
				false, Value, TagFound))
		if Tagfound then
			if not isspace(Value) then
				dal.set.error.message("tlbctsb0050")
				|* No valid sortingExpression received
				|* (a non-empty sortingExpression is not supported).
				return(DALHOOKERROR)					
			endif
			sortingExpressionSet = true
		else
			sortingExpressionSet = false
		endif
				<#if methodName!="Show">
		else
			|* Iteration is started or active: sortingExpression is not supported
			sortingExpressionSet = false
		endif
				</#if><#--if methodName!="Show"-->
		
		|* Set sortingExpression to protected layer
		RETIFNOK5_LIST(<@names.ST_DLLCode/>.set.sorting.expression(sortingExpressionSet))

		|* Set filter to protected layer and determine postfiltering
		filter = xmlFindFirst("Filter", ControlAreaNode)
		RETIFNOK5_LIST(<@names.ST_DLLCode/>.set.request.filter(filter))

		|* Get list of components with parent components
		RETIFNOK5_LIST(<@names.ST_DLLCode/>.get.postfilter(postfilter))								
		if postfilter then	
			metaDataForFilter = ${methodName}.getMetaDataForFilter()
		endif
	endif

			</#if><#--if c.componentName == names.businessInterfaceName-->
	CONTINUEIFNOK(${methodName},
			io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
			"${names.businessInterfaceName}", "${c.componentName}", false,
			${methodName}.handle.input.${c.componentName}_new(i.Request${c.componentName}Node,
			io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
			selection.present))
	if not selection.present then	|* No valid selection attributes found
		return(0)
	endif
	if <@names.ST_DLLCode/>.return.query.status.${c.componentName}() <> QUERY.END then
			<#if c.componentName == names.businessInterfaceName && methodName == "List">
		RETIFNOK5_LIST(<@names.ST_DLLCode/>.initialize.${c.componentName}.${methodName}(max.batch.count<>0))
			<#else>
		RETIFNOK5_LIST(<@names.ST_DLLCode/>.initialize.${c.componentName}.${methodName}())
			</#if>
	endif

	CONTINUEIFNOK(${methodName},
			io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
			"${names.businessInterfaceName}", "${c.componentName}", false,
			<@names.ST_DLLCode/>.initialize.set.${c.componentName}.${methodName}())
			<#if c.componentName == names.businessInterfaceName && methodName!="Show" >
	endif
			</#if><#--if c.componentName == names.businessInterfaceName && methodName!="Show" -->
	fetching = true
			<#if c.componentName == names.businessInterfaceName>
	fetch.count = 0
				<#if methodName != "Show">
	if cont.iteration then
		if hold.last.fetched.object <> 0 then
			ret = xmlAppendToChilds(i.Response${names.businessInterfaceName}Node, hold.last.fetched.object)
			fetch.count = 1
			total.object.count = total.object.count + 1
			<@names.ST_DLLCode/>.copy.next.first.record.${c.componentName}()
		endif
	else
		ret = xmlDelete(hold.last.fetched.object)
	endif
	hold.last.fetched.object = 0
				</#if><#--if methodName != "Show"-->
			</#if><#--if c.componentName == names.businessInterfaceName-->
			<#if c.componentName == names.businessInterfaceName && methodName!="Show" >
	while fetching and (fetch.count <= max.batch.count or max.batch.count = 0) and
		  (total.object.count < max.number.objects or max.number.objects = 0)
			<#else><#--if c.componentName == names.businessInterfaceName && methodName!="Show" -->
	while fetching
			</#if><#--if c.componentName == names.businessInterfaceName && methodName!="Show" -->
		RETIFNOK5_LIST(
			<@names.ST_DLLCode/>.before.execute.${c.componentName}.${methodName}(o.cancel))
		if o.cancel then
			return(0)
		endif

		RETIFNOK5_LIST(
			<@names.ST_DLLCode/>.execute.${c.componentName}.${methodName}())

		on case <@names.ST_DLLCode/>.return.query.status.${c.componentName}()
		case QUERY.FETCH:
			RETIFNOK5_LIST(
			<#if c.componentName == names.businessInterfaceName>
				${methodName}.handle.output.${c.componentName}_new(0,
			<#else><#--if c.componentName == names.businessInterfaceName-->
				${methodName}.handle.output.${c.componentName}_new(i.Response${c.parentComponentName}Node,
			</#if><#--if c.componentName == names.businessInterfaceName-->
			<#if object.businessInterfaceDefinition.idref.type!="bod" && (methodName == "List" || methodName == "Show")>
				i.suppressNillableAttributes,
			</#if>
				Response.${c.componentName}Node))
			<#if (methodName == "Show" || methodName == "List") && c.componentName != names.businessInterfaceName>
			if not ${c.componentName}.response.is.valid(i.Request${c.componentName}Node,
				Response.${c.componentName}Node)
			then
				ret = xmlDelete(Response.${c.componentName}Node)
				Response.${c.componentName}Node = 0
			endif
			</#if><#--if (methodName == "Show" || methodName == "List") && c.componentName != names.businessInterfaceName-->
	
			<#assign notInitialized = true>
			<#list public.listPublicSubComponents(methodName, c.componentName) as s>
				<#if notInitialized>
			long	tmp.node
			long	positionNode
			tmp.node = xmlNewNode("TempNode")
					<#assign notInitialized = false>
				</#if>
			RETIFNOK5_LIST(Handle.Request.${methodName}.${s.componentName}_new(
				i.Request${c.componentName}Node,
				<#if object.businessInterfaceDefinition.idref.type!="bod" && (methodName == "List" || methodName == "Show")>
				i.suppressNillableAttributes,
				</#if>
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				tmp.node,
				o.cancel))
				<@public.generateAnchorReplacement iComponentName=c.componentName iSubComponentName=s.componentName iIndent=false/>
			</#list><#--public.listPublicSubComponents(c.componentName) as s-->
			<#if !notInitialized>
			ret = xmlDelete(tmp.node)
			</#if>
			<#if c.componentName == names.businessInterfaceName>

			RETIFNOK5_LIST(tlbct.dll1000.ApplyPostFilter(
				postfilter,
				filter,
				metaDataForFilter,
				i.Response${names.businessInterfaceName}Node,
				Response.${c.componentName}Node,
				postfilter.valid))
			</#if><#--if c.componentName == names.businessInterfaceName-->
			<#list c.componentImplementation.component.idref.relationship as r>
				<#if r.type == "aggregation" && (r.multiplicity == "oneToOne" || r.multiplicity == "oneToMany")>
			if xmlFindFirstMatch("-<>.<${r.component.name}>", Response.${c.componentName}Node) = 0 then
				| No ${r.component.name} instances in ${r.multiplicity} relationship: remove node
				ret = xmlDelete(Response.${c.componentName}Node)
				Response.${c.componentName}Node = 0
			endif
				</#if><#--if r.type == "aggregation" && (r.multiplicity == "oneToOne" || r.multiplicity == "oneToMany")-->
			</#list><#--list c.componentImplementation.component.idref.relationship as r-->
			<#if c.componentName == names.businessInterfaceName && methodName != "Show">
			if fetch.count = max.batch.count and max.batch.count > 0 and
			   Response.${c.componentName}Node <> 0
			then
				| fetch was for next iterator call: store object for next call
				hold.last.fetched.object = xmlUnlink(Response.${c.componentName}Node)
				<@names.ST_DLLCode/>.save.next.first.record.${names.businessInterfaceName}()
			endif
			</#if><#--if c.componentName == names.businessInterfaceName && methodName != "Show"-->
			break
		case QUERY.END:
			fetching = false
			break
		case QUERY.ERROR:
				return (bl.result)
		default:
			|* Should not come here.
			fetching = false
			break
		endcase

		RETIFNOK5_LIST(
			<@names.ST_DLLCode/>.after.execute.${c.componentName}.${methodName}())
		<#if c.componentName == names.businessInterfaceName>
			<#if methodName!="Show" >
		if fetching and postfilter.valid and Response.${c.componentName}Node <> 0 then
			fetch.count = fetch.count + 1
			total.object.count = total.object.count + 1
			if <@names.ST_DLLCode/>.is.pageup() and fetch.count > 1 and
			   hold.last.fetched.object = 0
			then
				xmlInsertInChilds(i.Response${names.businessInterfaceName}Node, Response.${c.componentName}Node)
			endif
		endif
			<#else><#--if methodName!="Show" -->
		if fetching and Response.${c.componentName}Node <> 0 then
			fetch.count = fetch.count + 1
		endif
		fetching = false
			</#if><#--if methodName!="Show" -->
		</#if><#--if c.componentName == names.businessInterfaceName-->
	endwhile
	
		<#if c.componentName == names.businessInterfaceName>
			<#if methodName!="Show" >
	if total.object.count = 0 then
		dal.set.warning.message("tlbctsb0006")
		|* No objects found.
	endif

	if iteratorID <> 0 and fetch.count > max.batch.count then
		|* Create ListResponse > ControlArea

		NEW.NODE("ControlArea", 0, ControlArea)
		|* Create the iteratorID element
		ret = xmlRewriteDataElement(ControlArea, "iteratorID",
								 pid)
		|* Insert ControlArea as first child element in the Response
		ret = xmlInsertInChilds(io_${methodName}.responseArgument, ControlArea)
		o.iter_act = true
	else
		o.iter_act = false
			<#else><#--if methodName!="Show" -->
		if fetch.count = 0 then
			| No objects lefts!
			dal.set.error.message("tlbctsb0026")
			|* Object not found.
			return(DALHOOKERROR)
		endif
			</#if><#--if methodName!="Show" -->
		</#if><#--if c.componentName == names.businessInterfaceName-->
		CONTINUEIFNOK(${methodName},
			io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
			"${names.businessInterfaceName}", "${c.componentName}", false,
			<@names.ST_DLLCode/>.finalize.set.${c.componentName}.${methodName}())
		<#if c.componentName == names.businessInterfaceName && methodName!="Show" >
	endif
	endif |do.query
		</#if><#--if c.componentName == names.businessInterfaceName && methodName!="Show" -->
			
	return(0)
}

<@source.performance_point description=methodName+".handle.input."+c.componentName+"_new"/>
function long ${methodName}.handle.input.${c.componentName}_new(
		const xmlNode 	i.Node,
		ref	  xmlNode	o.ResponseArgument,
		ref	  xmlNode	o.resultArgument,
		ref	  boolean	o.selected)
{
	string	value(1024)
	boolean	value.isSet
	boolean tagfound
		<#if c.componentName==names.businessInterfaceName>
	xmlnode BuildNode
	xmlnode FilterNode
	xmlnode	SelectionNode
	xmlnode ControlAreaNode
		</#if><#--if c.componentName==names.businessInterfaceName-->
	xmlNode	l.node
	long	retl
		<#assign AttributeList=[]>
		<#if c.componentName!=names.businessInterfaceName>
			<#list common.listRelationshipDetails(c.parentComponentImplementation, c.relationshipImplementation) as rd>
				<#assign datatype=common.getDatatype(rd.fromAttributeImplementation)>
				<#assign AttributeList=AttributeList+[{
					"componentImplementation":rd.toComponentImplementation, 
					"componentName":rd.toComponentName,
					"attributeImplementation":rd.toAttributeImplementation,
					"attributeName":rd.toAttributeName
					}]>
				<#assign dimensions = common.getDimensionsForDataType(common.getDatatype(rd.fromAttributeImplementation))>
				<#if dimensions?number == 1>
	domain	${common.getDatatypeName(datatype)} ${rd.fromComponentName}.${rd.fromAttributeName}.value
				<#else>
					<#if dimensions?number == 0>
	domain	${common.getDatatypeName(datatype)} ${rd.fromComponentName}.${rd.fromAttributeName}.value(1) based
	boolean ${rd.fromComponentName}.${rd.fromAttributeName}.valueIsSet(1) based
	long	${rd.fromComponentName}.${rd.fromAttributeName}.size
					<#else>
	domain	${common.getDatatypeName(datatype)} ${rd.fromComponentName}.${rd.fromAttributeName}.value(${dimensions?number})
	boolean	${rd.fromComponentName}.${rd.fromAttributeName}.valueIsSet(${dimensions?number})
					</#if>
				</#if>
			</#list><#--list common.listRelationshipDetails(c.parentComponentImplementation, c.relationshipImplementation) as rd-->
		</#if><#-- c.componentName!=names.businessInterfaceName-->

	l.node = 0
	value = ""
	value.isSet = false
	tagfound = false
	retl = 0

		<#assign elementDeclared=false>
		<#if methodName == "Show" && c.componentName==names.businessInterfaceName>
			<#list public.listPublicInputAttributes(methodName) as a>
				<#if a.componentName == c.componentName>
				<#assign AttributeList=AttributeList+[{
					"componentImplementation":a.componentImplementation, 
					"componentName":a.componentName,
					"attributeImplementation":a.attributeImplementation, 
					"attributeName":a.attributeName 
					}]>
					<#if a.attributeImplementation.datatype?exists && a.attributeImplementation.datatype.idref.dimensions?exists &&
						a.attributeImplementation.datatype.idref.dimensions != "1">
						<#if a.attributeImplementation.datatype.idref.dimensions == "0">
	string	${a.attributeName}.arr(1,1) based
	boolean	${a.attributeName}.arr.set(1) based
						<#else>
	string	${a.attributeName}.arr(1024, ${a.attributeImplementation.datatype.idref.dimensions})
	boolean	${a.attributeName}.arr.set(${a.attributeImplementation.datatype.idref.dimensions})
						</#if>
						<#if !elementDeclared>
	long	element
							<#assign elementDeclared=true>
						</#if>
	l.node = xmlFindFirstMatch("<>.<DataArea>.<${a.componentName}>.${a.path}", i.Node)
	if l.node <> 0 then
		element = 0
		repeat
			element = element + 1
						<#if a.attributeImplementation.datatype.idref.dimensions == "0">
			alloc.mem(${a.attributeName}.arr, 1024, element)
			alloc.mem(${a.attributeName}.arr.set, element)
						</#if>
						<#if common.isAnyType(a.attributeImplementation)>
			${a.attributeName}.arr(1,element) = str$(l.node)
						<#else>
			${a.attributeName}.arr(1,element) = xmlData$(l.node)
						</#if>
			${a.attributeName}.arr.set(element) = true
			l.node = xmlGetRightSibling(l.node)
			if xmlName$(l.node) <> "${a.attributeName}" then
				l.node = 0
			endif
		until l.node = 0
						<#if a.attributeImplementation.datatype.idref.dimensions == "0">
		RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${a.attributeName}.Mapper(${a.attributeName}.arr, ${a.attributeName}.arr.set, element))
						<#else>
		RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${a.attributeName}.Mapper(${a.attributeName}.arr, ${a.attributeName}.arr.set))
						</#if>
						<#if a.componentName==names.businessInterfaceName && a.isMandatory>
	else
		dal.set.error.message("tlbctsb0001", "${a.componentName}.${a.selectionPath}")
		|* Public attribute %1$s is mandatory.
		return(DALHOOKERROR)
						</#if><#--if a.componentName==names.businessInterfaceName && a.isMandatory-->
	endif
					<#else><#--if a.attributeImplementation.datatype.idref.dimensions?exists && a.attributeImplementation.datatype.idref.dimensions != "1"-->
				<#if common.isAnyType(a.attributeImplementation)>
	value = str$(xmlFindFirstMatch("<>.<DataArea>.<${a.componentName}>.${a.path}", i.Node))
	if value <> "0" then
		RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${a.attributeName}.Mapper(value))
					<#if a.componentName==names.businessInterfaceName && a.isMandatory>
	else
		dal.set.error.message("tlbctsb0001", "${a.componentName}.${a.selectionPath}")
		|* Public attribute %1$s is mandatory.
		return(DALHOOKERROR)
					</#if><#--if a.componentName==names.businessInterfaceName && a.isMandatory-->
	endif
				<#else><#--if common.isAnyType(a.attributeImplementation)-->
	RETIFNOK(getValue(i.node, 
		"${a.componentName}.${a.selectionPath}",
		"<>.<DataArea>.${public.getPublicComponentSearchPath(a.componentName)}.${a.path}",
					<#if a.componentName==names.businessInterfaceName && a.isMandatory>
		TRUE,
					<#else><#--if a.componentName==names.businessInterfaceName && a.isMandatory-->
		FALSE,
					</#if><#--if a.componentName==names.businessInterfaceName && a.isMandatory-->
		value, tagfound))
	if tagfound then
		RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${a.attributeName}.Mapper(value))
	endif
				</#if><#--if common.isAnyType(a.attributeImplementation)-->
					</#if><#--if a.attributeImplementation.datatype.idref.dimensions?exists && a.attributeImplementation.datatype.idref.dimensions != "1"-->
				</#if><#--if a.componentName == c.componentName-->
			</#list><#--list public.listPublicInputAttributes(methodName) as a-->
		</#if><#--if methodName == "Show" && c.componentName==names.businessInterfaceName-->
		<#if c.componentName=names.businessInterfaceName>

	|* Which attributes have been selected.
	ControlAreaNode = xmlFindFirst("ControlArea", i.Node)
	BuildNode = xmlFindFirst("Selection", ControlAreaNode)
	if BuildNode <> 0 then
		|* Avoid modification of Request XML
		BuildNode = xmlDuplicate(BuildNode)
	endif
	FilterNode = xmlFindFirst("Filter", ControlAreaNode)
	if must.build.selection.node(BuildNode) then
		build.selectionnode.for.public.attributes(BuildNode)
	endif
	InitSelection(false)
	RETIFNOK2_LIST(SetSelection_new1(BuildNode))
	retl = xmlDelete(BuildNode)
		</#if><#--if c.componentName=names.businessInterfaceName-->
		<#list public.listPublicAttributes(methodName, c.componentName) as a>
			<#assign found=false>
			<#list c.componentImplementation.attributeImplementation as ai>
					<#if common.getAttributeName(ai)==a.attributeName>
						<#assign found=true>
						<#break>
					</#if>
			</#list>
			<#if found>
	if ${a.componentName}.${a.attributeName}.select then
		<@names.ST_DLLCode/>.select.${a.componentName}.${a.attributeName}()
	endif
			</#if>
		</#list><#--list public.listPublicAttributes(methodName, c.componentName) as a-->
		<#list SpecialSelectionList as ssl>
			<#if c.componentName == ssl.component>
				<#assign found=false>
				<#list c.componentImplementation.attributeImplementation as ai>
						<#if common.getAttributeName(ai)==ssl.attribute>
							<#assign found=true>
							<#break>
						</#if>
				</#list>
				<#if found>
	if ${ssl.component}.${ssl.attribute}.select then
		<@names.ST_DLLCode/>.select.${ssl.component}.${ssl.attribute}()
	endif
				</#if>
			</#if><#--if c.componentName == ssl.component-->
		</#list><#--list SpecialSelectionList as ssl-->
	
		<#assign tmp_list=[]>
		<#list AttributeList as at>
			<#list protected.listAttributesUsingAttribute(methodName, at.componentImplementation, at.attributeName, false)?reverse as p1>
				<#assign found=false>
				<#list tmp_list as l>
					<#if l.attributeName==p1.attributeName>
						<#assign found=true>
						<#break>
					</#if>
				</#list>
				<#if !found>
					<#assign tmp_list=[p1]+tmp_list>
				</#if>
			</#list>
		</#list><#--list AttributeList as at-->
		<#list tmp_list as p>
		<#assign dimensions=common.getDimensionsForDataType(common.getMandatoryDatatype(p.attributeImplementation))/>
		<#if dimensions?number != 1>
	long	${p.attributeName}.counter
	domain ${common.getDatatypeFromAttributeImplementation(p.attributeImplementation).nativeDatatype}	set.${p.attributeName}(${dimensions})
	boolean	set.${p.attributeName}isSet(${dimensions})
			<#if dimensions?number == 0>
	for ${p.attributeName}.counter = 1 to bl.${p.componentName}.${p.attributeName}.size
			<#else>
	for ${p.attributeName}.counter = 1 to ${dimensions}
			</#if>
		set.${p.attributeName}(${p.attributeName}.counter) = ${protected.getBaanDataInitializers(p.attributeImplementation)}
		set.${p.attributeName}isSet(${p.attributeName}.counter) = false
	endfor
	retl = <@names.ST_DLLCode/>.set.${p.componentName}.${p.attributeName}(set.${p.attributeName}, set.${p.attributeName}isSet)
		<#else>
	domain ${common.getDatatypeFromAttributeImplementation(p.attributeImplementation).nativeDatatype} set.${p.attributeName}
	set.${p.attributeName} = ${protected.getBaanDataInitializers(p.attributeImplementation)}
	retl = <@names.ST_DLLCode/>.set.${p.componentName}.${(p.attributeName)}(set.${p.attributeName})
		</#if><#--if dimensions?number != 1-->
		</#list>

	o.selected = false
		<#list public.listPublicAttributes(methodName, c.componentName) as a>
		or ${a.componentName}.${a.attributeName}.select
		</#list><#--list public.listPublicAttributes(methodName, c.componentName) as a-->
		<#list SpecialSelectionList as ssl>
			<#if c.componentName == ssl.component>
		or ${ssl.component}.${ssl.attribute}.select
			</#if><#--if c.componentName == ssl.component-->
		</#list><#--list SpecialSelectionList as ssl-->

	if not o.selected then
		return(0)
	endif

		<#if c.componentName!=names.businessInterfaceName>
			<#list common.listRelationshipDetails(c.parentComponentImplementation, c.relationshipImplementation) as rd>
				<#assign dimensions = common.getDimensionsForDataType(common.getDatatype(rd.fromAttributeImplementation))>
				<#if dimensions?number == 1>
	RETIFNOK(<@names.ST_DLLCode/>.get.${rd.fromComponentName}.${rd.fromAttributeName}(
			${rd.fromComponentName}.${rd.fromAttributeName}.value))
	RETIFNOK(<@names.ST_DLLCode/>.set.${rd.toComponentName}.${rd.toAttributeName}(
			${rd.fromComponentName}.${rd.fromAttributeName}.value))
				<#else>
					<#if dimensions?number == 0>
	RETIFNOK(<@names.ST_DLLCode/>.get.${rd.fromComponentName}.${rd.fromAttributeName}(
			${rd.fromComponentName}.${rd.fromAttributeName}.value,
			${rd.fromComponentName}.${rd.fromAttributeName}.valueIsSet,
			${rd.fromComponentName}.${rd.fromAttributeName}.size))
	RETIFNOK(<@names.ST_DLLCode/>.set.${rd.toComponentName}.${rd.toAttributeName}(
			${rd.fromComponentName}.${rd.fromAttributeName}.value,
			${rd.fromComponentName}.${rd.fromAttributeName}.valueIsSet,
			${rd.fromComponentName}.${rd.fromAttributeName}.size))
					<#else>
	RETIFNOK(<@names.ST_DLLCode/>.get.${rd.fromComponentName}.${rd.fromAttributeName}(
			${rd.fromComponentName}.${rd.fromAttributeName}.value,
			${rd.fromComponentName}.${rd.fromAttributeName}.valueIsSet))
	RETIFNOK(<@names.ST_DLLCode/>.set.${rd.toComponentName}.${rd.toAttributeName}(
			${rd.fromComponentName}.${rd.fromAttributeName}.value,
			${rd.fromComponentName}.${rd.fromAttributeName}.valueIsSet))
					</#if>
				</#if>
	<@names.ST_DLLCode/>.select.${rd.toComponentName}.${rd.toAttributeName}()
			</#list><#--list common.listRelationshipDetails(c.parentComponentImplementation, c.relationshipImplementation) as rd-->
		</#if><#-- c.componentName!=names.businessInterfaceName-->
		<#list public.listIdentifiers(methodName, c.componentName) as a>
	${a.componentName}.${a.attributeName}.select = true
	<@names.ST_DLLCode/>.select.${a.componentName}.${a.attributeName}()
		</#list><#--list public.listPublicAttributes(methodName, c.componentName) as a-->
		<#list protected.listInternalIdentifiers(c.componentName) as pi>
	<@names.ST_DLLCode/>.select.${pi.componentName}.${pi.attributeName}()
		</#list>
		
		<#-- add identifiers -->
<#list public.listPublicAttributes(methodName, c.componentName) as a>
	<#if a.attributeImplementation.attribute.idref.type == "qualifier" && 
		 !a.attributeImplementation.attribute.idref.parentAttribute?exists>
	${a.componentName}.${a.attributeName}.select = true
	<@names.ST_DLLCode/>.select.${a.componentName}.${a.attributeName}()
	</#if>
</#list>
	return(0)
}

<#if methodName == "Show" && c.componentName != names.businessInterfaceName>
function boolean ${c.componentName}.response.is.valid(long i.request, long i.response)
{
	long	${c.componentName}Node
	boolean	ok

	${c.componentName}Node = xmlFindFirst("${c.componentName}", i.request)
	if ${c.componentName}Node = 0 then
		return(true)
	endif
	
	while ${c.componentName}Node <> 0
		if xmlName$(${c.componentName}Node) = "${c.componentName}" then
			ok = true
		<#list public.listIdentifiers(methodName, c.componentName) as a>
			<#if a.componentName == c.componentName>
			if xmlData$(xmlFindFirstMatch("<${c.componentName}>.${a.path}", i.response)) <>
			   xmlData$(xmlFindFirstMatch("<${c.componentName}>.${a.path}", ${c.componentName}Node))
			then
				ok = false
			endif
			</#if>
		</#list><#--list public.listPublicAttributes(methodName, c.componentName) as a-->
			if ok then
				return(true)
			endif
		endif
		${c.componentName}Node = xmlGetRightSibling(${c.componentName}Node)
	endwhile

	return(false)
}

</#if><#--if methodName == "Show" && c.componentName != names.businessInterfaceName-->
<@source.performance_point description=methodName+".handle.output."+c.componentName+"_new"/>
function long ${methodName}.handle.output.${c.componentName}_new(
				xmlnode	i.Node,
		<#if object.businessInterfaceDefinition.idref.type!="bod" && (methodName == "List" || methodName == "Show")>
				boolean	i.suppressNillableAttributes,
		</#if>
			ref	xmlnode	o.Node)
{
	string	value(1024)
	boolean	value.isSet
	long	ret
	<#-- used in macro create_output -->
	long	g.node
		<#if public.hasPublicOutputTextArgumentsByComponent(methodName, c.componentName)>
	xmlnode	text.Node
		</#if><#--if public.hasPublicOutputTextArgumentsByComponent(methodName, c.componentName) -->

	value = ""
	value.isSet = false
	ret = 0
	<#-- used in macro create_output -->
	g.node = 0
	NEW.NODE("${c.componentPublicName}", i.Node, o.Node)

		<#assign attrList="">
		<#assign level=0>
		<@generate_component_anchors iMethodName=methodName iLocation="before" iComponent=c.componentImplementation.component.idref/>
		<#assign attributeCounter = 0>
		<#assign functionCounter = 0>
		<#if public.hasCustomerDataLocation(c.componentImplementation.component.idref)>
			<#assign createUserArea=true>
		<#else>
			<#assign createUserArea=false>
		</#if>
		<#assign userAreaCreated=false>
		<#list c.componentImplementation.component.idref.attribute as attr>
			<#if !attr.isHidden>
				<#assign attributeCounter = attributeCounter+1>
				<#if 100 < attributeCounter>
					<#assign attributeCounter = 1>
					<#assign functionCounter = functionCounter+1>

	return(${methodName}.handle.output.${c.componentName}_${functionCounter}_new(
					<#if object.businessInterfaceDefinition.idref.type!="bod" && (methodName == "List" || methodName == "Show")>
				i.suppressNillableAttributes,
					</#if>
				o.Node))
}
	
function long ${methodName}.handle.output.${c.componentName}_${functionCounter}_new(
					<#if object.businessInterfaceDefinition.idref.type!="bod" && (methodName == "List" || methodName == "Show")>
				boolean	i.suppressNillableAttributes,
					</#if>
			ref	xmlnode	o.Node)
{
	string	value(1024)
	boolean	value.isSet
	long	ret
	<#-- used in macro create_output -->
	long	g.node
					<#if public.hasPublicOutputTextArgumentsByComponent(methodName, c.componentName)>
	xmlnode	text.Node
					</#if><#--if public.hasPublicOutputTextArgumentsByComponent(methodName, c.componentName) -->

	value = ""
	value.isSet = false
	ret = 0
	<#-- used in macro create_output -->
	g.node = 0
				</#if><#--if 100 < attributeCounter-->
<@create_output iattr=attr comp=c.componentImplementation compName=c.componentName methodName=methodName isQuery=true userArea=createUserArea/>
			<#else>
				<@create_output_anchors_only iattr=attr comp=c.componentImplementation.component.idref/>
			</#if>
		</#list>
		<#if createUserArea && !userAreaCreated>
	if <@names.ST_DLLCode/>.must.add.${c.componentName}.custom.output() then
		RETIFNOK(${c.componentName}.add.custom.output.if.any(o.node))
	endif
		</#if>

		<@generate_component_anchors iMethodName=methodName iLocation="after" iComponent=c.componentImplementation.component.idref/>

	return(0)
}

		</#list>
	</#if>
</#list><#-- object.methodImplementation as methodImplementation-->
