<#--
   ******************************************************
   *
   *                       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
 --> 
<#import "common.source.ftl" as source/>
<#import "common.names.ftl" as names/>
<#import "common.defs.ftl" as common/>
<@common.initListAllPublicAttributes/>
<#import "public.sb.common.ftl" as public/>
<#import "protected.st.common.ftl" as protected/>
<@source.startsource/>
<@source.idents iIsPublic=true/>
<@public.initListPublicAttributes/>
<@public.initDuplicatesList/>
<@protected.initListProtectedAttributes/>
<#--#perf.sn-->
<@protected.initListProtectedAssociatedAttributes/>
<@protected.initListInternalIdentifiers/>
<@protected.initListProtectedComponents/>
<@protected.initHasMethodAlternativeImplementation/>
<@common.initListComponentImplementations/>
<#--#perf.en-->
<#assign AFSComponentPresent=false>
<#list protected.listProtectedComponents() as c>
	<#if protected.isFunctionServerComponent(c.componentImplementation)>
		<#assign AFSComponentPresent=true>
		<#break>
	</#if>
</#list>
<#assign publicSubComponentsStructure = public.createPublicSubComponentsStructure()>

	|* General defines
	#define XmlNode	 long
	|* Defines for List and Show
	#define SELECTION	 	"Selection"
	#define SEL_ATTR	 	"selectionAttribute"
<#--#unused.so--
	#define PROT_FILT	 	"ProtectedFiltering"
	#define LOGIC_EXPR	 	"LogicalExpression"
	#define LOGIC_OPER	 	"logicalOperator"
	#define ATTR_NAME	 	"attributeName"
	#define COMP_OPER		"comparisonOperator"
	#define INST_VAL	 	"instanceValue"
	#define EMPTY_VAL	 	"emptyValue"
<#--#unused.eo-->
	|* Defines for ProcessingScope
	#define NOT_APPLICABLE	"not_applicable"
	#define FUTURE			"future_use"
	#define REQUEST			"request"
	#define BUS_ENT		 	"business_entity"
	#define BUS_ENT_CMP	 	"business_entity_component"
	
	#define TOP_DOWN		1
	#define BOTTOM_UP		2
	#define	BATCH			3
	
<#--#unused.so--
	#define	MAX.CONDITION.LEVEL	10
<#--#unused.eo-->
	#define	ANCHOR_MARKER		"XXXXXX_ANCHOR_"
<#assign SelectionList=[]>
<#assign ListNumber = 0>

<@source.performance_point description="Start"/>
<#if common.queryMethodPresent() && !AFSComponentPresent>
	<#list public.listAllPublicAttributes() as a>
			<#assign ListNumber = ListNumber + 1>
			<#assign SelectionList=SelectionList + [{
				"ID":ListNumber,
				"component":a.componentName,
				"componentPublicName":a.componentPublicName,
				"attribute":a.attributeName,
				"qualifier":a.attributeType == "qualifier"}]>
	boolean ${a.componentName}.${a.attributeName}.select
	</#list><#--list public.listAllPublicAttributes() as a-->

	#define Selection.must.be.filled(...)
^			tlbct.dll1000.Selection.must.be.filled(...)	
<#else>
	<#if common.methodPresent("PublishEvent")>
		<#list protected.listProtectedComponents() as c>
			<#list public.listPublicAttributes("PublishEvent") as a>
				<#if c.componentName == a.componentName & common.getIsIdentifier(a.attributeImplementation)>
					<#if a.attributeType != "qualifier">
						<#assign ListNumber = ListNumber + 1>
						<#assign SelectionList=SelectionList + [{
							"ID":ListNumber,
							"component":a.componentName,
							"componentPublicName":a.componentPublicName,
							"attribute":a.attributeName,
							"qualifier":false}]>
	boolean ${a.componentName}.${a.attributeName}.select
					</#if>
				</#if><#--c.componentName == a.componentName & common.getIsIdentifier(a.attributeImplementation)-->
			</#list><#--public.listPublicAttributes("PublishEvent") as a-->
		</#list><#-- list protected.listProtectedComponents() as c -->
	</#if><#-- common.methodPresent("PublishEvent") -->
</#if><#-- if common.queryMethodPresent()-->
<#-- determine duplicates -->
<#assign DuplicateComponents=[]>
<#assign Components="">
<#assign Duplicatesfound=false>
<#list common.listComponentImplementations() as c>
	<#if Components?contains(c.componentPublicName) && c.componentPublicName != names.businessInterfaceName>
		<#assign DuplicateComponents=DuplicateComponents + [c.componentPublicName]>
		<#assign Duplicatesfound=true>
	<#else>
		<#assign Components = Components + "::" + c.componentPublicName>
	</#if>
</#list>
<#--| Search in .. ${Components}
	|*END -->
<#--#unused.so--
<#assign DuplicatePublicAttributes=[]>
<#list SelectionList as sl>
	<#list SelectionList as sl_check>
		<#if sl.ID != sl_check.ID><#-- Do not check same item -- >
			<#if sl.componentPublicName == sl_check.componentPublicName && sl.attribute == sl_check.attribute>
				<#assign present=false>
				<#list DuplicatePublicAttributes as dpa>
					<#if dpa.component == sl.componentPublicName && dpa.attribute == sl.attribute>
						<#assign present=true>
					</#if>
				</#list>
				<#if !present>
					<#assign DuplicatePublicAttributes=DuplicatePublicAttributes + [{
						"component":sl.componentPublicName,
						"attribute":sl.attribute}]>
				</#if>
			</#if>
		</#if>
	</#list>
</#list>
<#--#unused.eo-->
<#if Duplicatesfound>

|* Duplicates in model...
	<#list DuplicateComponents as dc>
|* ComponentName : ${dc}
	</#list>
<#--#unused.so--
	<#list DuplicatePublicAttributes as dpa>
|* PublicAttributes : ${dpa.component}.${dpa.attribute}
	</#list>
<#--#unused.eo-->
</#if>

<#-- For date/time/dateTime attributes, if the value is empty, an empty tag is
  set. E.g. <deliveryDate/>. However,  this is not a valid value according to
  the data type as defined in the WSDL/XSD. For that reason the WSDL generator
  is updated to indicate that date/time/dateTime attributes are nillable. And
  in the XML we must include 'xsi:nil="true"' for empty elements. This way they
  can be handled properly through client proxies as generated from  the WSDL.
  We do not need this for other data types, because for strings an empty
  string is allowed, for numeric values a '0' is allowed and for 'optional'
  enumerates the empty value is listed as an enumerate value in the BI data
  type. -->
<#function useNilAttributeForEmptyValues iAttributeImplementation>
	<#if object.businessInterfaceDefinition.idref.type!="bod">
		<#if iAttributeImplementation.attribute?exists>
			<#assign primitiveDatatype=common.getDatatype(iAttributeImplementation).primitiveDatatype>
			<#if primitiveDatatype == "date" || primitiveDatatype == "time" || primitiveDatatype == "dateTime">
				<#return true>
			</#if>
		</#if>
	</#if>
	<#return false>
</#function>

<@source.performance_point description="Start 2"/>
<#macro generate_component_anchors iMethodName iLocation iComponent>
	<#list iComponent.relationship as r>
		<#if r.type=="aggregation">
			<#if r.anchorLocation==iLocation && !r.anchorAttribute?exists && !r.anchorGroup?exists>
				<#if !r.component.isHidden>
					<#if public.isPublicSubComponent(iMethodName, iComponent.name, r.component.name)>
	| Anchor: ${iLocation} component ${iComponent.name}
	RETIFNOK4(xmlNewNode(ANCHOR_MARKER & "${r.component.name}", XML_ELEMENT, o.Node))
					<#else>
	| Anchor: ${iLocation} component ${iComponent.name} not generated:
	| ${r.component.name} is not a public subcomponent for method ${iMethodName}
					</#if>
				<#else>
	| Anchor: ${iLocation} component ${iComponent.name} not generated: ${r.component.name} is hidden
				</#if>
			</#if>
		</#if>
	</#list>
</#macro>
<#macro generate_group_anchors iLocation iMethodName iComponent iAttribute>
	<#if iAttribute.type!="qualifier">
		<#list iComponent.relationship as r>
			<#if r.type=="aggregation">
				<#if r.anchorLocation==iLocation && r.anchorGroup?exists && r.anchorGroup.idref.name == iAttribute.name>
<#--#perf.so--
					<#assign attributePath=public.getAttributeGroupFromAttribute(iComponent, iAttribute)>
					<#assign parentNode="createGroupNodes(o.Node, \"" + attributePath + "\", \"\")">
<#--#perf.eo-->
					<#if !r.component.isHidden>
						<#if public.isPublicSubComponent(iMethodName, iComponent.name, r.component.name)>
<#--#perf.sn-->
							<#assign attributePath=public.getAttributeGroupFromAttribute(iComponent, iAttribute)>
							<#assign parentNode="createGroupNodes(o.Node, \"" + attributePath + "\", \"\")">
<#--#perf.en-->
	| Anchor: ${iLocation} attribute group ${iAttribute.name}
	RETIFNOK4(xmlNewNode(ANCHOR_MARKER & "${r.component.name}", XML_ELEMENT, ${parentNode}))
						<#else>
	| Anchor: ${iLocation} attribute ${iAttribute.name} not generated:
	| ${r.component.name} is not a public subcomponent for method ${iMethodName}
						</#if>
					<#else>
	| Anchor: ${iLocation} attribute ${iAttribute.name} not generated: ${r.component.name} is hidden
					</#if>
				</#if>
			</#if>
		</#list>
	</#if>
</#macro>
<#macro generate_attribute_anchors iLocation iMethodName iComponent iAttribute>
	<#if iAttribute.type!="qualifier">
		<#list iComponent.relationship as r>
			<#if r.type=="aggregation">
<#--#perf.so--
				<#if r.anchorLocation==iLocation && r.anchorAttribute?exists && r.anchorAttribute.idref.name == iAttribute.name>
					<#assign attributePath=public.getAttributeGroupFromAttribute(iComponent, iAttribute)>
					<#assign attributeAlias=public.getAttributeAlias(iComponent, iAttribute)>
					<#if attributePath == "<"+attributeAlias+">">
						<#assign parentNode="o.Node">
					<#else>
						<#assign parentNode="createGroupNodes(o.Node, \"" + attributePath + "\", \"" + attributeAlias + "\")">
					</#if>
<#--#perf.eo-->
<#--#perf.sn-->
				<#if (r.anchorLocation==iLocation || iLocation="both") && r.anchorAttribute?exists && r.anchorAttribute.idref.name == iAttribute.name>
<#--#perf.en-->
					<#if !r.component.isHidden>
						<#if public.isPublicSubComponent(iMethodName, iComponent.name, r.component.name)>
<#--#perf.sn-->
							<#assign attributePath=public.getAttributeGroupFromAttribute(iComponent, iAttribute)>
							<#assign attributeAlias=public.getAttributeAlias(iComponent, iAttribute)>
							<#if attributePath == "<"+attributeAlias+">">
								<#assign parentNode="o.Node">
							<#else>
								<#assign parentNode="createGroupNodes(o.Node, \"" + attributePath + "\", \"" + attributeAlias + "\")">
							</#if>
<#--#perf.en-->
<#--#perf.note: changed iLocation by r.anchorLocation below -->
	| Anchor: ${r.anchorLocation} attribute ${iAttribute.name}
	RETIFNOK4(xmlNewNode(ANCHOR_MARKER & "${r.component.name}", XML_ELEMENT, ${parentNode}))
						<#else>
	| Anchor: ${r.anchorLocation} attribute ${iAttribute.name} not generated:
	| ${r.component.name} is not a public subcomponent for method ${iMethodName}
						</#if>
					<#else>
	| Anchor: ${r.anchorLocation} attribute ${iAttribute.name} not generated: ${r.component.name} is hidden
					</#if>
				</#if>
			</#if>
		</#list>
	</#if>
</#macro>
<#macro create_output iattr comp compName methodName isQuery>
	<#assign level=level+1>
	<#if !attrList?contains(":"+iattr.name+":")>
		<#if level==1>
			<#list comp.attribute as attr_check>
				<#list attr_check.attributeRelationship as ar>
					<#if ar.attribute.idref.id == iattr.id>
						<#assign level=level-1>
						<#return>
					</#if>
				</#list>
			</#list>
		</#if>
		<#--Check if attribute should be handled in output -->
		<#assign attrList=attrList+":"+iattr.name+":">
		<#if isQuery>
			<#assign pre_TAB="	">
		<#else>
			<#assign pre_TAB="">
		</#if>
		<#assign takeIntoAccount=false>
		<#if isQuery>
			<#list SelectionList as sl>
				<#if sl.component==compName && sl.attribute==iattr.name>
					<#assign takeIntoAccount=true>
					<#break>
				</#if>
			</#list>
		</#if>
		<#assign attr_set=false>
		<#list public.listPublicOutputAttributes(methodName, compName) as a1>
			<#if a1.attributeName == iattr.name>
				<#assign a=a1>
				<#assign attr_set=true>
				<#assign takeIntoAccount=true>
				<#assign defaultVal=a1.defaultVal>
				<#break>
			</#if>
		</#list>
		<#if iattr.type=="group" || iattr.type == "complex">
			<#assign takeIntoAccount=true>
		</#if>
			<#if !takeIntoAccount>
	|* Attribute ${iattr.name} not in protected output
				<#-- The anchors for this attribute need to be considered nevertheless -->
<#--#perf.so--
				<@generate_attribute_anchors iLocation="before" iMethodName=methodName iComponent=comp iAttribute=iattr/>
				<@generate_attribute_anchors iLocation="after" iMethodName=methodName iComponent=comp iAttribute=iattr/>
<#--#perf.eo-->
<#--#perf.sn-->
				<@generate_attribute_anchors iLocation="both" iMethodName=methodName iComponent=comp iAttribute=iattr/>
<#--#perf.en-->
			</#if>
	<#else>
		<#--Already handled before-->
	|* Attribute ${iattr.name} handled before.
		<#assign takeIntoAccount=false>
	</#if>
	<#if takeIntoAccount>
		<@generate_attribute_anchors iLocation="before" iMethodName=methodName iComponent=comp iAttribute=iattr/>
		<#if iattr.type!="group" && iattr.type != "qualifier">
		<#-- only attribute -->
			<#assign dimensions=common.getDimensionsForDataType(common.getMandatoryDatatype(a.attributeImplementation))/>
			<#if (dimensions?number > 1)>
	string	${a.attributeName}.value(1024, ${dimensions})
	boolean	${a.attributeName}.valueIsSet(${dimensions})
				<#if isQuery>
	if ${a.componentName}.${a.attributeName}.select then
				</#if>
				<#if a.path != "<"+a.alias+">">
${pre_TAB}	g.node = createGroupNodes(o.Node, "${a.path}", "${a.alias}")
				</#if><#--if a.path != "<"+a.alias+">"-->
<#--#repeat.sn-->
${pre_TAB}	RETIFNOK(<@names.SB_DLLCode/>.get.${a.componentName}.${a.attributeName}.Mapper(
${pre_TAB}		${a.attributeName}.value, ${a.attributeName}.valueIsSet))
<#--#repeat.en-->
${pre_TAB}	for element = 1 to ${dimensions}
${pre_TAB}	|--------------------------------------------------------------
${pre_TAB}	| Response repeatable fields:
						<#if object.businessInterfaceDefinition.idref.type=="bod">
${pre_TAB}	|   <attributeNAME>[VALUE]</attributeNAME>
						<#else>
${pre_TAB}	|   <attributeNAME sequence="[ELEMENT]">[VALUE]</attributeNAME>
						</#if><#--if object.businessInterfaceDefinition.idref.type=="bod"-->
${pre_TAB}	| 
${pre_TAB}	| ALL elements are displayed
${pre_TAB}	|--------------------------------------------------------------
<#--#repeat.so--
${pre_TAB}		RETIFNOK(<@names.SB_DLLCode/>.get.${a.componentName}.${a.attributeName}.Mapper(element,
${pre_TAB}			${a.attributeName}.value, ${a.attributeName}.valueIsSet))
<#--#repeat.eo-->
${pre_TAB}		if ${a.attributeName}.valueIsSet(element) then
				<#if common.isTextDatatype(common.getDatatypeFromAttributeImplementation(a.attributeImplementation))>
						<#if a.path != "<"+a.alias+">">
${pre_TAB}			NEW.NODE("${a.alias}", g.Node, text.Node)
						<#else>
${pre_TAB}			NEW.NODE("${a.alias}", createGroupNodes(o.Node, "${a.path}", "${a.alias}"), text.Node)
						</#if><#--if a.path != "<"+a.alias+">"-->
${pre_TAB}			ret = tlbct.dll1000.xmlimage.convert.text.to.xml(
${pre_TAB}				lval(strip$(${a.attributeName}.value(1,element))),
${pre_TAB}				"${a.alias}", " ", text.Node)
						<#list a.attributeRelationship as ar>
							<#if ar.name=="sequence" && ar.attribute.idref.type=="qualifier">
${pre_TAB}			ret = xmlsetAttribute(bl.xml.result, "sequence" , element)
							</#if><#--if ar.name=="sequence" && ar.attribute.idref.type=="qualifier"-->
						</#list><#--list a.attributeRelationship as ar-->
				<#else>
					<#if common.isAnyType(a.attributeImplementation)>
${pre_TAB}			if lval(strip$(${a.attributeName}.value(1,element))) <> 0 then
						<#if a.path != "<"+a.alias+">">
${pre_TAB}				RETIFNOK4(xmlAppendToChilds(g.node, lval(strip$(${a.attributeName}.value(1,element)))))
						<#else>
${pre_TAB}				RETIFNOK4(xmlAppendToChilds(o.node, lval(strip$(${a.attributeName}.value(1,element)))))
						</#if><#--if a.path != "<"+a.alias+">"-->
						<#list a.attributeRelationship as ar>
							<#if ar.name=="sequence" && ar.attribute.idref.type=="qualifier">
${pre_TAB}				ret = xmlsetAttribute(bl.xml.result, "sequence" , element)
							</#if><#--if ar.name=="sequence" && ar.attribute.idref.type=="qualifier"-->
						</#list><#--list a.attributeRelationship as ar-->
${pre_TAB}			endif
					<#else>
						<#if a.path != "<"+a.alias+">">
${pre_TAB}			RETIFNOK4(xmlNewDataElement("${a.alias}", strip$(${a.attributeName}.value(1,element)), g.node))
						<#else>
${pre_TAB}			RETIFNOK4(xmlNewDataElement("${a.alias}", strip$(${a.attributeName}.value(1,element)), o.node))
						</#if><#--if a.path != "<"+a.alias+">"-->
						<#list a.attributeRelationship as ar>
							<#if ar.name=="sequence" && ar.attribute.idref.type=="qualifier">
${pre_TAB}			ret = xmlsetAttribute(bl.xml.result, "sequence" , element)
							</#if><#--if ar.name=="sequence" && ar.attribute.idref.type=="qualifier"-->
						</#list><#--list a.attributeRelationship as ar-->
						<#if useNilAttributeForEmptyValues(a.attributeImplementation)>
							<#if methodName == "List" || methodName == "Show">
<#--#fix.so--
${pre_TAB}			if not i.suppressNillableAttributes and isspace(value(1,element)) then
<#--#fix.eo-->
<#--#fix.sn-->
${pre_TAB}			if not i.suppressNillableAttributes and isspace(${a.attributeName}.value(1,element)) then
<#--#fix.en-->
							<#else>
<#--#fix.so--
${pre_TAB}			if isspace(value(1,element)) then
<#--#fix.eo-->
<#--#fix.sn-->
${pre_TAB}			if isspace(${a.attributeName}.value(1,element)) then
<#--#fix.en-->
							</#if>
${pre_TAB}				ret = xmlSetAttribute(bl.xml.result, "xsi:nil" , "true")
${pre_TAB}			endif
						</#if>
					</#if>
				</#if><#--if common.isTextDatatype(common.getDatatypeFromAttributeImplementation(a.attributeImplementation))-->
${pre_TAB}		endif
${pre_TAB}	endfor
				<#if isQuery>
	endif
				</#if>
				<#assign underAttribute=false>
			<#else>
				<#assign underAttribute=true>
				<#if isQuery>
	if ${a.componentName}.${a.attributeName}.select then
				</#if>
${pre_TAB}	RETIFNOK(<@names.SB_DLLCode/>.get.${a.componentName}.${a.attributeName}.Mapper(value, value.isSet))
				<#if !common.isTextDatatype(common.getDatatypeFromAttributeImplementation(a.attributeImplementation))>
					<#if a.methodArgument?exists>
						<#if a.defaultVal.present>
${pre_TAB}	if not value.isSet then
${pre_TAB}		|* Default value
${pre_TAB}		value = ${a.defaultVal.value}
${pre_TAB}		value.isSet = true
${pre_TAB}	endif
						</#if>
					</#if>
					<#if common.isAnyType(a.attributeImplementation)>
${pre_TAB}	if value.isSet and lval(strip$(value)) <> 0 then
${pre_TAB}		g.node = createGroupNodes(o.Node, "${a.path}", "${a.alias}")
${pre_TAB}		ret = xmlDelete(xmlFindFirstMatch("<>.${a.path}", o.Node))
${pre_TAB}		RETIFNOK4(xmlAppendToChilds(g.node, lval(strip$(value))))
					<#else>
${pre_TAB}	if value.isSet then
${pre_TAB}		RETIFNOK4(xmlRewriteDataElement(createGroupNodes(o.Node, "${a.path}", 
${pre_TAB}			"${a.alias}"), "${a.alias}", strip$(value)))
						<#if useNilAttributeForEmptyValues(a.attributeImplementation)>
							<#if methodName == "List" || methodName == "Show">
${pre_TAB}		if not i.suppressNillableAttributes and isspace(value) then
							<#else>
${pre_TAB}		if isspace(value) then
							</#if>
${pre_TAB}			ret = xmlSetAttribute(xmlFindFirst("${a.alias}", bl.xml.result),
${pre_TAB}					"xsi:nil" , "true")
${pre_TAB}		endif
						</#if>
					</#if>
				<#else><#--if !common.isTextDatatype(common.getDatatypeFromAttributeImplementation(a.attributeImplementation))-->
${pre_TAB}	if value.isSet then
${pre_TAB}		NEW.NODE("${a.alias}", createGroupNodes(o.Node, "${a.path}", "${a.alias}"), text.Node)
${pre_TAB}		ret = tlbct.dll1000.xmlimage.convert.text.to.xml(lval(value),
${pre_TAB}					"${a.alias}", " ", text.Node)
				</#if><#-- if common.isTextDatatype(common.getDatatypeFromAttributeImplementation(a.attributeImplementation)) -->
			</#if>
			<#assign pre_TAB2="	">
		<#else>
			<#assign underAttribute=false>
			<#assign pre_TAB2="">
			<#if iattr.type == "qualifier">
				<#if isQuery>
	if ${a.componentName}.${a.attributeName}.select then
				</#if>
${pre_TAB}	RETIFNOK(<@names.SB_DLLCode/>.get.${a.componentName}.${a.attributeName}.Mapper(value, value.isSet))
				<#if defaultVal.present>
${pre_TAB}	if not value.isSet then
${pre_TAB}		|* Default value
${pre_TAB}		value = ${defaultVal.value}
${pre_TAB}		value.isSet = true
${pre_TAB}	endif
				</#if>
${pre_TAB}	if value.isSet then
${pre_TAB}		ret = xmlsetAttribute(o.Node, "${iattr.name}", strip$(value))
${pre_TAB}	endif
				<#if isQuery>
	endif
				</#if>
			</#if>
		</#if>
		<#list iattr.attributeRelationship as ar>
			<#if ar.attribute.idref.type == "qualifier">
				<#assign validqualifier=false>
				<#list public.listPublicOutputAttributes(methodName, compName) as qa>
					<#if ar.attribute.idref.name == qa.attributeName>
						<#assign validqualifier=true>
						<#assign defaultVal=qa.defaultVal>
						<#break>
					</#if><#--ar.attribute.idref.name == qa.attributeName-->
				</#list><#--public.listPublicOutputAttributes(methodName, c.componentName) as qa-->
				<#if validqualifier>
	|* Qualifier
	<#assign attrList=attrList+"::"+ar.attribute.idref.name>
					<#if isQuery>
${pre_TAB2}	if ${compName}.${ar.attribute.idref.name}.select then
					</#if>
${pre_TAB2}${pre_TAB}	RETIFNOK(<@names.SB_DLLCode/>.get.${compName}.${ar.attribute.idref.name}.Mapper(value, value.isSet))
					<#if defaultVal.present>
${pre_TAB2}${pre_TAB}	if not value.isSet then
${pre_TAB2}${pre_TAB}		|* Default value
${pre_TAB2}${pre_TAB}		value = ${defaultVal.value}
${pre_TAB2}${pre_TAB}		value.isSet = true
${pre_TAB2}${pre_TAB}	endif
					</#if>
${pre_TAB2}${pre_TAB}	if value.isSet then
					<#if iattr.type=="group">
${pre_TAB2}${pre_TAB}		bl.xml.result = createGroupNodes(o.Node, "${public.getAttributeGroupFromAttribute(comp, iattr)}", "")
${pre_TAB2}${pre_TAB}		ret = xmlsetAttribute(xmlFindFirst("${public.getAttributeAlias(comp, iattr)}", bl.xml.result), "${ar.name}", strip$(value))
					<#else>
${pre_TAB2}${pre_TAB}		ret = xmlsetAttribute(xmlFindFirstMatch("<>.${a.path}", o.Node), "${ar.name}", strip$(value))
					</#if>
${pre_TAB2}${pre_TAB}	endif
					<#if isQuery>
${pre_TAB2}	endif
					</#if>
				</#if><#--validqualifier-->	
			</#if><#--if ar.attribute.idref.type == "qualifier"-->
		</#list>
		<#if underAttribute>
${pre_TAB}	endif
			<#if isQuery>
	endif
			</#if>
		</#if>
		<@generate_group_anchors iLocation="before" iMethodName=methodName iComponent=comp iAttribute=iattr/>
		<#list iattr.attributeRelationship as ar>
			<#if ar.attribute.idref.type != "qualifier" && !ar.attribute.idref.isHidden>
	|* Reading output for group/attribute ${ar.attribute.value}
<@create_output iattr=ar.attribute.idref comp=comp compName=compName methodName=methodName isQuery=isQuery/>
			</#if>
			<#if ar.attribute.idref.type != "qualifier" && ar.attribute.idref.isHidden>
				<@create_output_anchors_only iattr=ar.attribute.idref comp=comp/>
			</#if>
		</#list>
		<@generate_group_anchors iLocation="after" iMethodName=methodName iComponent=comp iAttribute=iattr/>
		<@generate_attribute_anchors iLocation="after" iMethodName=methodName iComponent=comp iAttribute=iattr/>
	</#if>
	<#assign level=level-1>
</#macro>
<#macro create_output_anchors_only iattr comp>
	<#-- do not create output, but generate anchors -->
	<#if !attrList?contains(":"+iattr.name+":")>
		<#assign attrList=attrList+":"+iattr.name+":">
<#--#perf.so--
		<@generate_attribute_anchors iLocation="before" iMethodName=methodName iComponent=comp iAttribute=iattr/>
		<@generate_attribute_anchors iLocation="after" iMethodName=methodName iComponent=comp iAttribute=iattr/>
<#--#perf.eo-->
<#--#perf.sn-->
		<@generate_attribute_anchors iLocation="both" iMethodName=methodName iComponent=comp iAttribute=iattr/>
<#--#perf.en-->
	</#if>
</#macro>

<#assign elementDeclared=false>
<#if common.queryMethodPresent() && !AFSComponentPresent>

<#--#unused.so--
	long	bl.AttrProtected.datatype
	string	bl.AttrProtected.map(${common.CompAttrLen()})
	string	bl.AttrProtected.domain(14)
	xmlNode	bl.attr.node
	long	bl.date
	string	instanceValue(99)
	string	booleanOperator(3, MAX.CONDITION.LEVEL)
	string	pnExpression(1024)
	string	comparisonOperator(2)
	string	attribute(1) based
	long	structure
	long	level
	long	expression
<#--#unused.eo-->
	boolean	log.query
</#if><#-- if common.queryMethodPresent() -->
	long	element
<#assign elementDeclared=true>
	long	messageCnt

	long	bl.result
	xmlNode bl.xml.result
	long	bl.ret
	xmlNode	bl.RequestArgument
	xmlNode	bl.ResponseArgument
	xmlNode	bl.ResultArgument
	string	bl.processingScope(26)	|* transaction granularity
					|* for Create, Change and Delete &
					|* Specific methods
	boolean	bl.skipComponent	|* flag to indicate whether or not
					|* the remainder of the business
					|* object should be processed
	string	bl.current.method(${common.MethodLen()})	|* Used for component selection
 	#include <bic_tt>
	#include <bic_dam>
	#include <bic_text>
	
	|Defines for functions in the tlbctdll1000 library
	#define RewriteDataElementAsNode(...)
^			tlbct.dll1000.xmlRewriteDataElementAsNode(...)
	#define createGroupNodes(...)
^			tlbct.dll1000.createGroupNodes(...)
	#define getSubNode(...)
^			tlbct.dll1000.getSubNode(...)
	#define getValue(...)
^			tlbct.dll1000.getValue(...)
	#define getAttributeValue(...)
^			tlbct.dll1000.getAttributeValue(...)
	#define createResponseObject(...)
^			tlbct.dll1000.createResponseObject(...)
	#define createResponseObject.WithoutDataArea(...)
^			tlbct.dll1000.createResponseObject.WithoutDataArea(...)
	#define createResultObject(...)
^			tlbct.dll1000.createResultObject(...)
^			messageCnt = 1
	#define createCompNode(...)
^			tlbct.dll1000.createCompNode(...)
	#define selectObjectNode(...)
^			tlbct.dll1000.selectObjectNode(...)
	#define selectResponseNode(...)
^			tlbct.dll1000.selectResponseNode(...)
	#define handle.messages(...)
^			tlbct.dll1000.handle.messages(...)
	#define handle.transactionScope(...)
^			tlbct.dll1000.handle.transactionScope(bl.result, bl.processingScope, bl.skipComponent,...)
	#define loXMLtoBaan(...)
^			tlbct.dll1000.loXMLtoBaan(...)

	#define RETIFNOK(...)
^		bl.result = ...
^		if bl.result <> 0 then
^			if bl.processingScope = BUS_ENT
^			   or bl.processingScope = BUS_ENT_CMP
^			then
^				db.set.child.transaction(0)
^				abort.transaction()
^			endif
^			return(bl.result)
^		endif

	#define CONTINUEIFNOK(MTH,RESP,RESU,BODESC,COMPNAME,LCOMP, ...)
^		on case bl.processingScope
^		case REQUEST:
^		case BUS_ENT:
^			RETIFNOK6(RESP, RESU, ...)
^			break
^		case BUS_ENT_CMP:
^			if bl.result = 0 then
^				if not bl.skipComponent then
^					RETIFNOK6(RESP, RESU, ...)
^				endif
^			endif
^			break
^		endcase

	#define SET_RETRY_POINT_BUS_ENT()
^		if bl.processingScope = BUS_ENT then
^			db.retry.point()
^		endif
	#define SET_RETRY_POINT_BUS_ENT_CMP()
^		if bl.processingScope = BUS_ENT_CMP then
^			db.retry.point()
^		endif

	#define CLEAR_RESPONSE_BUS_ENT_RESPONSE_IN_RETRY(BODESC)
^		if bl.processingScope = BUS_ENT and db.retry.hit() > 0 and 
^		   Response##BODESC##node <> 0 then
^			bl.ret = xmlDelete(Response##BODESC##node)
^			Response##BODESC##node = 0
^		endif

	#define COMMIT_BUS_ENT()
^		if bl.processingScope = BUS_ENT then
^			commit.transaction()
^		endif

	#define COMMIT_BUS_ENT_CMP()
^		if bl.processingScope = BUS_ENT_CMP then
^			commit.transaction()
^		endif

	#define RETIFNOK_WITH_RETRY(...)
^		if bl.processingScope = BUS_ENT_CMP then
^			db.retry.point()
^		endif
^		bl.result = ...
^		if bl.result <> 0 then
^			if bl.processingScope = BUS_ENT
^			   or bl.processingScope = BUS_ENT_CMP
^			then
^				db.set.child.transaction(0)
^				abort.transaction()
^			endif
^			return(bl.result)
^		else
^			if bl.processingScope = BUS_ENT_CMP then
^				commit.transaction()
^			endif
^		endif

	#define	RETIFNOK5_WITH_RETRY(MTH, RESP, RESU, BODESC, COMPNAME, LCOMP, ...)
^		if not bl.skipComponent then
^			bl.result = ...
^			handle.transactionScope(##LCOMP##,
^						##RESP##,
^						##RESU##,
^						"##MTH##",
^						##BODESC##,
^						##COMPNAME##)
^
^			if not ##LCOMP## then
^				if bl.result <> 0 and
^					bl.processingScope = REQUEST then
^					bl.ret =
^					<@names.ST_DLLCode/>.finalize.##MTH##(
^								bl.result)
^					return(bl.result)
^				endif
^			else
^				if bl.result <> 0 and
^					bl.processingScope = REQUEST then
^					return(bl.result)
^				endif
^			endif
^		endif

	#define CONTINUEIFNOK_WITH_RETRY(MTH,RESP,RESU,BODESC,COMPNAME,LCOMP, ...)
^		on case bl.processingScope
^		case REQUEST:
^		case BUS_ENT:
^			RETIFNOK_WITH_RETRY(...)
^			break
^		case BUS_ENT_CMP:
^			if bl.result = 0 then
^				if not bl.skipComponent then
^					RETIFNOK5_WITH_RETRY(MTH,
^						RESP,
^						RESU,
^						BODESC,
^						COMPNAME,
^						LCOMP,
^						...)
^				endif
^			endif
^			break
^		endcase

	#define RETIFNOK2(...)
^		bl.result = ...
^ 		if bl.result <> 0 then
^			handle.messages(o.responseArgument,
^				o.resultArgument, set.in.result(true))
^			bl.ret = xmlDelete(o.ResponseArgument)
^			o.ResponseArgument = 0
^			bl.ResponseArgument = 0
^			if bl.processingScope = BUS_ENT
^				   or bl.processingScope = BUS_ENT_CMP then
^				db.set.child.transaction(0)
^				abort.transaction()
^			endif
^			return(bl.result)
^		endif

	#define RETIFNOK2_LIST(...)
^               bl.result = ...
^               if bl.result <> 0 then
^                       handle.messages(o.responseArgument,
^							o.resultArgument, set.in.result(true))
^                       bl.ret = xmlDelete(o.ResponseArgument)
^                       o.ResponseArgument = 0
^						bl.ResponseArgument = 0
^                       bl.ret = xmlDelete(SelectionNode)
^                       return(bl.result)
^               endif

	#define RETIFNOK4(...)
^               bl.xml.result = ...
^               if bl.xml.result = 0 then
^			tlbct.dll1000.set.and.log.xml.error(__FILE__, __LINE__)
^			return(DALHOOKERROR)
^               endif

	#define	RETIFNOK5(MTH, RESP, RESU, BODESC, COMPNAME, LCOMP, ...)
^		bl.result = ...
^		handle.transactionScope(##LCOMP##,
^					##RESP##,
^					##RESU##,
^					"##MTH##",
^					##BODESC##,
^					##COMPNAME##)
^
^			if not ##LCOMP## then
^			if bl.result <> 0 and
^				bl.processingScope = REQUEST
^			then
^				bl.ret =
^				<@names.ST_DLLCode/>.finalize.##MTH##(
^							bl.result)
^				return(bl.result)
^			endif
^		else
^			if bl.result <> 0 and
^				bl.processingScope = REQUEST
^			then
^				return(bl.result)
^			endif
^		endif

	#define	RETIFNOK6(RESP, RESU, ...)
^	bl.result = ...
^	if bl.result <> 0 then
^		handle.messages(##RESP##,
^			##RESU##,
^			set.in.result(true))
^		if bl.processingScope = BUS_ENT
^		   or bl.processingScope = BUS_ENT_CMP then
^			db.set.child.transaction(0)
^			abort.transaction()
^		endif
^		return(bl.result)
^	endif

	#define NEW.NODE(i.NAME, i.PARENTNODE, o.NODE)
^		RETIFNOK4(xmlNewNode(i.NAME, XML_ELEMENT, i.PARENTNODE) )
^		o.NODE = bl.xml.result

<#if common.queryMethodPresent() || common.methodPresent("PublishEvent") >
	#define ASSIGNVAL(COMP,ATTRB,ALIAS)
^               if ##COMP##.##ATTRB##.select then
^                       RETIFNOK(<@names.SB_DLLCode/>.get.##COMP##.##ATTRB##.Mapper(value, value.isSet))
^						if value.isSet then
^                    	   	RETIFNOK4(xmlNewDataElement("##ALIAS##", strip$(value),
^							g.Node))
^						endif
^               endif
</#if> <#-- if common.queryMethodPresent() -->

	#define CHECK_TOOLS_VERSION(response, result)
^	| The Business Studio version used to generate this business object
^	| requires Enterprise Server 8.4.2 or higher or Enterprise Server
^	| 8.3 or 8.4 with solution 236710.
^	| For that reason this define is used at the start of each method.
^	if not <@names.ST_DLLCode/>.is.business.studio.supported() then
^		dal.set.error.message("@To use this business object, use Enterprise Server 8.4.2 or higher or install solution 236710")
^		response = 0
^		result = xmlNewNode("Result")
^		handle.messages(response, result, true) | add messages to result
^		return(DALHOOKERROR)
^	endif
<#-- Explanation on CHECK_TOOLS_VERSION:
	At generation time a check is done, so Business Studio 8.4 does not generate
	a runtime on a system having Enterprise Server 8.3. However, generated business
	objects can be deployed on another system having another Enterprise Server.
	For example, Maintenance on FP3 is done using Enterprise Server 8.4.2, so
	generation of standard business objects from Business Studio into FP3 will work.
	A customer may still be on Enterprise Server 8.3, causing a dynamic link failure
	at runtime. To avoid this, the CHECK_TOOLS_VERSION() is used at the start of
	every method. Performance overhead is not significant.
	The Tools TIV number for ES 8.4.2 is 1400.
	Note: it is an application responsibility to make sure that FP3 business objects
	maintained in Integration Studio are not replaced by an implementation generated
	from Business Studio, because such an implementation will not work for all
	customers!
	If the user does not have Enterprise Server 8.4.2 or later, a check is done if
	the business studio functionality is supported nevertheless.
-->

	#define CHECK_TOOLS_VERSION_PUB_EVENT(response, result)
^	| If Enterprise Server 8.3 or lower is used, the SubscribeEvent method
^	| will fail. So the PublishEvent method can immediately return 0
^	| (= OK), to avoid fatal errors when invoking non-existing tl code.
^	if not <@names.ST_DLLCode/>.is.business.studio.supported() then
^		result = 0
^		response = xmlNewNode("PublishEventResponse")
^		return(0) | OK
^	endif

	#define MESSAGE_EXISTS(mess.code)
^	pos(form.text$(mess.code), mess.code) = 0

	#pragma used	dll otlbctdll1000
	#pragma used	dll <@names.ST_Object/>

|**************************** Internal Functions ******************************

function void make.xmlArguments.global( const xmlNode i.RequestArgument,
					const xmlNode i.ResponseArgument,
					const xmlNode i.ResultArgument)
{
	bl.RequestArgument  = i.RequestArgument
	bl.ResponseArgument = i.ResponseArgument
	bl.ResultArgument   = i.ResultArgument
	|* Make request, response, result available in protected layer
	<@names.ST_DLLCode/>.set.xmlArguments(i.RequestArgument,
		i.ResponseArgument, i.ResultArgument)
}

function boolean set.in.result(boolean i.inResult)
{
	on case bl.processingScope
	case BUS_ENT:
	case BUS_ENT_CMP:
		|* errors must be put into response.
		return (false)
	endcase
	return (i.inResult)
}

function long Handle.retrying.component(string	i.method(${common.CompLen()}),	
					string	i.bde(${common.CompLen()}),
					string	i.component(${common.CompLen()}),
					ref xmlNode o.ResponseArgument,
					ref xmlNode o.ResultArgument)
{
	if db.retry.hit() then
		abort.transaction()
	endif
	if db.retry.hit() > db.max.retry() - 2 then	|%To be saver
		if MESSAGE_EXISTS("tlbcts0082") then
			dal.set.error.message("tlbcts0082", db.max.retry(), strip$(i.method), strip$(i.component))
			|* Max number of retries (%1$d) reached in method %2$s in Component %3$s
		else
			dal.set.error.message("@Max number of retries ("&
				str$(db.max.retry()) & ") reached in method " &
				strip$(i.method) & " in Component " &
				strip$(i.component))
		endif
		bl.result = DALHOOKERROR
		handle.transactionScope(true,
			o.ResponseArgument, o.ResultArgument,
			i.method, i.bde, i.component)
		return (DALHOOKERROR)
	endif
	return (0)
}

<#if common.queryMethodPresent() && !AFSComponentPresent>
<@source.performance_point description="build.selectionnode.for.public.attributes"/>
|**************************** Selection Handling ******************************

function build.selectionnode.for.public.attributes(ref xmlNode io.node)
{
	xmlNode	sel.node

	if io.node = 0 then
		io.node = xmlNewNode(SELECTION)
	endif

<#list public.listAllPublicComponents() as c>
	<#if !public.hasDuplicateComponent(c.componentName, "${c.componentPublicName}")>
	sel.node = xmlNewDataElement(SEL_ATTR,
		"${c.componentPublicName}.*" , io.node)
	</#if>	
</#list><#--list public.listAllPublicComponents() as c-->
}

<#--#unused.so--
|******************************* Filter Handling ******************************

	string	gl.expr.name(${common.CompAttrLen()})
	string	gl.in.name(${common.CompAttrLen()})
	
<@source.performance_point description="handle.conditional.expression"/>
function long handle.conditional.expression()
{
	if level = MAX.CONDITION.LEVEL then
		return (0)
	endif
	level = level + 1

	|* First Read Boolean Operator
	expression = xmlGetFirstChild(structure)
	
	booleanOperator(1, level) = ""
	bl.ret = xmlGetName(expression, gl.expr.name)
	if strip$(gl.expr.name) <> LOGIC_OPER then
		bl.ret = xmlGetName(structure, gl.in.name)
		dal.set.error.message("tlbctsb0037", LOGIC_OPER, strip$(gl.expr.name), strip$(gl.in.name))
		|* Filter Expression not correct: %1$s expected, %2$d received in %3$s.
		return (DALHOOKERROR)
	endif
	bl.ret = xmlGetData(expression, booleanOperator(1, level))
	if isspace(booleanOperator(1, level)) then
		level = level - 1
		return (0)
	endif

	pnExpression = pnExpression & "("

	|* Then Read Expression Arguments
	expression = xmlGetFirstChild(structure)
	if xmlAllocName(attribute, expression) <> 0
	then
		alloc.mem(attribute, 1)
	endif
	if attribute = LOGIC_OPER then
		expression = xmlGetRightSibling(expression)
	endif
	while expression <> 0
		if xmlAllocName(attribute, expression) <> 0
		then
			alloc.mem(attribute, 1)
		endif
		if attribute = LOGIC_EXPR then
			structure = expression
			|* Recursion !!!
			RETIFNOK(handle.conditional.expression())
			|* Recursion !!!
			expression = structure
			structure = xmlGetParent(expression)
		else
			RETIFNOK(handle.filter.attribute())
		endif
		expression = xmlGetRightSibling(expression)
		if xmlAllocName(attribute, expression) <> 0
		then
			alloc.mem(attribute, 1)
		endif
		if attribute = LOGIC_OPER then
			expression = xmlGetRightSibling(expression)
		endif
		if expression <> 0 then
			pnExpression = pnExpression & " " &
				strip$(booleanOperator(1, level)) & " "
		endif
	endwhile
	pnExpression = pnExpression & ")"
	level = level - 1
	return(0)
}

function long handle.filter.attribute()
{
	long	ret
	string	name(1) based
	boolean	emptyValue
	long	assoc.node
	
	assoc.node = 0
	comparisonOperator = ""
	instanceValue      = ""
	emptyValue 	   = false
	if xmlAllocDataElement(name, expression, ATTR_NAME) <> 0
	then	
		alloc.mem(name, 1)
		name = ""
	endif
	ret = xmlGetDataElement(expression, COMP_OPER,
		comparisonOperator)
	ret = xmlGetDataElement(expression, INST_VAL,
		instanceValue)

	if ret = 0 then	|* check for empty value
		ret = xmlGetDataElement(expression, EMPTY_VAL,
			instanceValue)
		if ret <> 0 then
			emptyValue = true
		endif
	endif

	if isspace(name) or
	   not set.AttributeData(name, assoc.node) then
		dal.set.error.message("tlbctsb0023", name)
		|* No valid filterAttributes received.
		|* (filterAttribute received "%1$s")
		return (DALHOOKERROR)
	endif	
	if tlbct.dll1000.column.is.array(bl.AttrProtected.map) then
		dal.set.error.message("tlbctsb0041", name)
		|* Attribute '%1$s' is repeatable; cannot be used in filter.
		return (DALHOOKERROR)	
	endif		
	if isspace(comparisonOperator) then
		dal.set.error.message("tlbctsb0024", name)
		|* FilterOperator received for Attribute "%1$s" is empty.
		return (DALHOOKERROR)
	endif
	if isspace(instanceValue) and not emptyValue then
		dal.set.error.message("tlbctsb0025", name)
		|* InstanceValue received for Attribute "%1$s" is empty.
		return (DALHOOKERROR)
	endif

	pnExpression = pnExpression & strip$(bl.AttrProtected.map) &
		loXMLtoBaan(comparisonOperator)

	if emptyValue then
	on case bl.AttrProtected.datatype
	case DB.STRING:
		pnExpression = pnExpression & """"""
		break
	case DB.ENUM:
		pnExpression = pnExpression & "empty"
		break
	case DB.TIME:
	case DB.DATE:
		pnExpression = pnExpression & "0"
		break
	default:
		pnExpression = pnExpression & "0"
		break
	endcase
	else
	on case bl.AttrProtected.datatype
	case DB.STRING:
		if instanceValue = """""" then
			pnExpression = pnExpression & """"""
		else
			pnExpression = pnExpression &
					quoted.string(instanceValue)
		endif
		break
	case DB.ENUM:
		pnExpression = pnExpression &
				bl.AttrProtected.domain & "." & instanceValue
		break
	case DB.TIME:
		ret = tlbct.dll1000.string.to.utc(instanceValue, bl.date)
		pnExpression = pnExpression & str$(bl.date)
		break
	case DB.DATE:
		ret = tlbct.dll1000.string.to.date(instanceValue, bl.date)
		pnExpression = pnExpression & str$(bl.date)
		break
	default:
		pnExpression = pnExpression & instanceValue
		break
	endcase
	endif
	return (0)
}

<@source.performance_point description="set.ComponentAttributeData"/>
function boolean set.ComponentAttributeData(const string iPublicAttribute)
{
	<#-- Note:
		This generated function uses in public.sb.common 
		the function hasDuplicateSelectionPath. 
		When changing the case structure of this function
		always implement these changes also in the
		hasDuplicateSelectionPath function.
		-- >
	<@public.resetDuplicatesList/>
	<@public.setDuplicatesList iDuplicatesList=public.generateDuplicatesSelectionPath()/>
	on case	trim$(iPublicAttribute)
	<#list public.listAllPublicAttributes() as a>
		<@public.insertCase iComponent=a iSubSelection=".${a.selectionPath}"/>
		<#if public.caseFound>
			<#assign ProtMapping=a.attributeName>		
			<#if a.attributeImplementation.type=="column">
				<#assign ProtMapping=a.attributeImplementation.componentImplementationTable.idref.table.idref.name + "." + a.attributeImplementation.column.idref.name>
			</#if><#--if a.attributeImplementation.type=="table" || a.attributeImplementation.type=="form"-- >
		add.Protected.Attr(	
			"${ProtMapping}",
			${common.get_BaanDatatype_from_XMLSchemaDatatype(common.getDatatypeFromAttributeImplementation(a.attributeImplementation))},
			"${common.getDatatypeName(common.getDatatypeFromAttributeImplementation(a.attributeImplementation))}",
			"${a.attributeName}",
			"${a.attributeName}",
			"${a.componentName}",
			<#if a.attributeImplementation.type=="association">
				<#assign relationshipImplementation=a.attributeImplementation.association.idref>
				<#if relationshipImplementation.toComponentImplementation?exists>
					<#if relationshipImplementation.relationship?has_content>
			"${relationshipImplementation.toBusinessInterfaceImplementation.idref.implementationIdentifier}.${common.getComponentName(relationshipImplementation.toComponentImplementation.idref)}." & 
			str$(<@names.ST_DLLCode/>.convert.relation.ID("${relationshipImplementation.relationship.idref.name}")))
					<#else>
			"${relationshipImplementation.toBusinessInterfaceImplementation.idref.implementationIdentifier}.${common.getComponentName(relationshipImplementation.toComponentImplementation.idref)}." & 
			str$(<@names.ST_DLLCode/>.convert.relation.ID("${relationshipImplementation.name}")))
					</#if>
				<#else><#--if relationshipImplementation.toComponentImplementation?exists-- >
					<#if relationshipImplementation.relationship?has_content>
			"${relationshipImplementation.toBusinessInterfaceImplementation.idref.implementationIdentifier}.${relationshipImplementation.toBusinessInterfaceImplementation.idref.name}." &
			str$(<@names.ST_DLLCode/>.convert.relation.ID("${relationshipImplementation.relationship.idref.name}")))
					<#else>
			"${relationshipImplementation.toBusinessInterfaceImplementation.idref.implementationIdentifier}.${relationshipImplementation.toBusinessInterfaceImplementation.idref.name}." &
			str$(<@names.ST_DLLCode/>.convert.relation.ID("${relationshipImplementation.name}")))
					</#if>
				</#if><#--if relationshipImplementation.toComponentImplementation?exists-- >
			<#else><#--if a.attributeImplementation.type=="association"-- >
			"")
			</#if><#--if a.attributeImplementation.type=="association"-- >
		return(true)
		</#if>	
	</#list><#--list public.listAllPublicAttributes() as a-- >

	default:
		add.Protected.Attr("", 0, "", iPublicAttribute, "", "", "")
		return(false)
	endcase
}

<@source.performance_point description="set.AttributeData"/>
function boolean set.AttributeData(
	const	string	iPublicAttribute,
	ref	long	io.associations)
{
	<#-- Note:
		This generated function uses in public.sb.common 
		the function generateDuplicatesSetAttributeData. When
		changing the case structure of this function
		always implement these changes also in the
		generateDuplicatesSetAttributeData function.
		
		The large case statement has been split in subfunctions to
		avoid a too-large-to-compile function being generated.
		-- >
	boolean	result

	result = true

	on case	trim$(iPublicAttribute)
	case "*":
		return(set.AttributeData1())
		<@public.resetDuplicatesList/>
		<@public.setDuplicatesList iDuplicatesList=public.generateDuplicatesSetAttributeData()/>
		<#list common.listComponentImplementations() as c>
			<#assign listOfAllPublicAttributes=public.listAllPublicAttributes(c.componentName)>
			<@public.insertCase iComponent=c iSubSelection=".*"/>
			<#if public.caseFound>
				<#list listOfAllPublicAttributes as a>
		result = set.ComponentAttributeData("${public.getPublicPath(a.componentName)}.${a.selectionPath}") and result
				</#list><#--list public.listAllPublicAttributes(c.componentName) as a-- >
		return (result)
			</#if>
			<#list listOfAllPublicAttributes as a>
				<#assign qualifier=false>
				<#list a.attributeRelationship as ar>
					<#if ar.attribute.idref.type == "qualifier" && !ar.attribute.idref.isHidden>				
						<#if public.isValidQualifier(ar.attribute.idref.name)>
							<#assign qualifier=true>
							<@public.insertCase iComponent=c iSubSelection=".${a.selectionPath}.${ar.attribute.idref.name}"/>
							<#if public.caseFound>
		result = set.ComponentAttributeData("${public.getPublicPath(a.componentName)}.${a.selectionPath}") and result
		result = set.ComponentAttributeData("${public.getPublicPath(a.componentName)}.${ar.attribute.idref.name}") and result
		return (result)
							</#if>
						</#if><#--validqualifier-- >
					</#if><#--ar.attribute.idref.type == "qualifier" && !ar.attribute.idref.isHidden-- >					
				</#list><#--a.attributeRelationship as ar-- >
				<#if qualifier>
					<@public.insertCase iComponent=c iSubSelection=".${a.selectionPath}.*"/>
					<#if public.caseFound>
		result = set.ComponentAttributeData("${public.getPublicPath(a.componentName)}.${a.selectionPath}") and result
						<#list a.attributeRelationship as ar>
							<#if !ar.attribute.idref.isHidden && public.isValidQualifier(ar.attribute.idref.name)>
		result = set.ComponentAttributeData("${public.getPublicPath(a.componentName)}.${ar.attribute.idref.name}") and result
							</#if><#--validqualifier-- >
						</#list><#--a.attributeRelationship as ar- ->
		return(result)
					</#if>
				</#if><#--qualifier-- >
			</#list><#--list listOfAllPublicAttributes as a-- >
		</#list><#--list common.listComponentImplementations() as c-- >
	default:
		return(set.AttributeData2(iPublicAttribute, io.associations))
	endcase
}

<@source.performance_point description="set.AttributeData1"/>
function boolean set.AttributeData1()
{
	boolean	result

	result = true
		<#list public.listAllPublicAttributes() as a>
	result = set.ComponentAttributeData("${public.getPublicPath(a.componentName)}.${a.selectionPath}") and result
		</#list><#--list public.listAllPublicAttributes() as a-- >
	return (result)
}

<@source.performance_point description="set.AttributeData2"/>
function boolean set.AttributeData2(
	const	string	iPublicAttribute,
	ref	long	io.associations)
{
	boolean	result

	result = true

	on case	trim$(iPublicAttribute)
		<#list public.listAllPublicComponents() as c>
			<#list public.listPublicAttributeGroups(c.componentImplementation.component.idref) as g>
				<@public.insertCase iComponent=c iSubSelection=".${g.selectionPath}.*"/>
				<#if public.caseFound>
					<#list public.listAllPublicAttributes(c.componentName) as a>
						<#if a.path?contains("<"+g.groupName+">")>
		result = set.ComponentAttributeData("${public.getPublicPath(a.componentName)}.${a.selectionPath}") and result
						</#if><#-- if a.path?contains("<"+g.groupName+">")-- >
					</#list><#--list public.listAllPublicAttributes(c.componentName) as a-- >
		return (result)
				</#if>
			</#list><#-- list public.listPublicAttributeGroups(c.componentImplementation.component.idref) as g -- >
		</#list><#--list public.listAllPublicComponents() as c-- >
		<#if public.getDuplicatesList()?size!=0>
			<#list public.getDuplicatesList() as d>
				<#if d.selection == d.component+".*">
	case "${d.selection}":
					<#list common.listComponentImplementations() as c>
						<#if c.componentPublicName == d.component>
							<#list public.listAllPublicAttributes(c.componentName) as a>
		result = set.ComponentAttributeData("${public.getPublicPath(a.componentName)}.${a.selectionPath}") and result
							</#list>
						</#if>
					</#list>
		return (result)
				</#if>
			</#list>
			<#list public.getDuplicatesList() as d>
				<#if d.selection != d.component+".*">
	case "${d.selection}": |* ${d.component} ++ ${d.path}
				</#if>
			</#list>
		dal.set.error.message("tlbctsb0038", trim$(iPublicAttribute))
		|* No valid selectionAttributes received.
		|* (duplicate selectionAttribute received "%1$s")
		return(DALHOOKERROR)
		</#if>
	default:
		return(set.AttributeData3(iPublicAttribute, io.associations))
	endcase
}

<@source.performance_point description="set.AttributeData3"/>
function boolean set.AttributeData3(
	const	string	iPublicAttribute,
	ref	long	io.associations)
{
	boolean	result
	string	assoc.attr(300)
	long	dot.pos

	result = true
	dot.pos = 0
	assoc.attr = ""

	if io.associations <> 0 then
		<#list protected.listProtectedComponents() as c>
			<#list c.componentImplementation.relationshipImplementation as ri>
				<#if ri.relationship?has_content>
					 <#if ri.relationship.idref.type=="association">
	    if tlbct.dll1000.starts.with(trim$(iPublicAttribute), "${c.componentPublicName}.${ri.relationship.idref.name}", assoc.attr) then
		dot.pos = pos(assoc.attr, ".")
		if dot.pos > 1 then
			assoc.attr = strip$(assoc.attr(dot.pos+1))
		endif
		result = tlbct.dll1000.add.association.to.association.tree(
				"${ri.relationship.idref.name}",
				"${c.componentPublicName}",
				"${ri.relationship.idref.toBusinessInterface.value}",
						<#if !ri.toComponentImplementation?has_content || ri.toBusinessInterfaceImplementation.value==ri.toComponentImplementation.value>
				"",
						<#else>
				"${ri.toComponentImplementation.value}",
						</#if>
				assoc.attr,
				io.associations)
						<#list public.listAllIdentifiers(c.componentName) as pi>
		result = set.ComponentAttributeData("${pi.componentPublicName}.${pi.attributeName}") and result
						</#list><#--list public.listAllIdentifiers(c.componentName) as pi-- >
		return(result)
	    endif
		    		</#if><#--ri.relationship.idref.type=="association"-- >
		    	<#else>
	    if tlbct.dll1000.starts.with(trim$(iPublicAttribute), "${c.componentPublicName}.${ri.name}", assoc.attr) then
		dot.pos = pos(assoc.attr, ".")
		if dot.pos > 1 then
			assoc.attr = strip$(assoc.attr(dot.pos+1))
		endif
		result = tlbct.dll1000.add.association.to.association.tree(
				"${ri.name}",
				"${c.componentPublicName}",						
				"${ri.toBusinessInterfaceImplementation.value}",
					<#if ri.toBusinessInterfaceImplementation.value==ri.toComponentImplementation.value>
				"",
					<#else>
				"${ri.toComponentImplementation.value}",
					</#if>
				assoc.attr,
				io.associations)
		return(result)
	    endif			
				</#if><#--if ri.relationship?has_content-- >
			</#list>
		</#list>
	endif
	return (set.ComponentAttributeData(trim$(iPublicAttribute)))
}
<#--#unused.eo-->
</#if><#--if common.queryMethodPresent()-->
<@source.performance_point description="create.association.show.request"/>

function extern void <@names.SB_DLLCode/>.getset.xmlArguments(
					ref xmlNode o.RequestArgument,
					ref xmlNode o.ResponseArgument,
					ref xmlNode o.ResultArgument)
{
	DllUsage
		This function gives other parts of the BOL the possibility
		to read/update data from the XML objects from the public layer
	EndDllUsage

	o.RequestArgument  = bl.RequestArgument
	o.ResponseArgument = bl.ResponseArgument
	o.ResultArgument   = bl.ResultArgument
}

<@source.performance_point description="Mappers"/>
|******************************* Mapper Methods *******************************
<#list common.listComponentImplementations() as c>
	<#list c.componentImplementation.attributeImplementation as a>
		<#if a.attribute?exists>
			<#assign datatype=common.getDatatype(a)>
			<#if a.attribute.idref.datatype.idref?exists && a.attribute.idref.datatype.idref.primitiveDatatype == "boolean" >
				<#assign primitiveDatatype="boolean">
			<#else>
				<#assign primitiveDatatype=datatype.primitiveDatatype>
			</#if>

function long <@names.SB_DLLCode/>.get.${c.componentName}.${common.getAttributeName(a)}.Mapper(
			<#assign array=false>
			<#if datatype.dimensions?exists>
				<#assign array=true>
<#--#repeat.so--
	long		i.element,
<#--#repeat.eo-->
	ref	string	o.value(,), 
	ref boolean o.valueIsSet())
			<#else>		
	ref	string	o.value,
	ref	boolean	o.isSet)	
			</#if><#--if datatype.dimensions?exists-->
{
			<#if array>
				<#assign dimensions = datatype.dimensions>
<#--#repeat.sn-->
	long	i

	i = 0
<#--#repeat.en-->
	domain	${common.getDatatypeName(datatype)}	l.${common.getAttributeName(a)}(${dimensions})		
			<#else>
	domain	${common.getDatatypeName(datatype)}	l.${common.getAttributeName(a)}
			</#if><#--array-->
			<#if array> 
	RETIFNOK(<@names.ST_DLLCode/>.get.${c.componentName}.${common.getAttributeName(a)}(
							l.${common.getAttributeName(a)},
							o.valueIsSet))
			<#else>
	RETIFNOK(<@names.ST_DLLCode/>.get.${c.componentName}.${common.getAttributeName(a)}(
							l.${common.getAttributeName(a)}))
	o.isSet = <@names.ST_DLLCode/>.is.set.${c.componentName}.${common.getAttributeName(a)}()
			</#if><#--if array-->
			<#if a.conversionGetHookExpression?exists && a.conversionGetHookExpression?has_content>
	|* Conversion Get Hook
	RETIFNOK(<@names.ST_DLLCode/>.Hook.ConversionGet.${c.componentName}.${common.getAttributeName(a)}(
				<#if array> 
			l.${common.getAttributeName(a)}, o.value, o.valueIsSet))
				<#else>
			l.${common.getAttributeName(a)}, o.value, o.isSet))
				</#if><#--if array-->
<#--#trim.sn-->
				<#if object.removeLeadingSpaces?exists && object.removeLeadingSpaces &&
					!common.hasEnumerations(datatype) && !common.isTextDatatype(datatype) &&
					(primitiveDatatype == "string" || primitiveDatatype == "anyURI" || primitiveDatatype == "duration" || primitiveDatatype == "Name")>
					<#if array>
			for i = 1 to ${dimensions}
				o.value(1,i) = trim$(o.value(1,i))
			endfor
					<#else>
			o.value = trim$(o.value)
					</#if><#--if array-->
				</#if>
<#--#trim.en-->
			<#else>
				<#if array> 
<#--#repeat.so--
					<@public.convertFromDomain iComponentName=c.componentName iAttributeName=common.getAttributeName(a) iDatatype=datatype iPrimitiveDatatype=primitiveDatatype iDimensions=dimensions/>
<#--#repeat.eo-->
<#--#repeat.sn-->
	for i = 1 to ${dimensions}
					<#assign arrayPartValue = "(1,i)">
					<#if primitiveDatatype = "string" && !common.isTextDatatype(datatype)>
		 				<#assign arrayPart = "(1,i)">			
					<#else>
						<#assign arrayPart = "(i)">
					</#if>
					<@public.convertFromDomain iComponentName=c.componentName iAttributeName=common.getAttributeName(a) iDatatype=datatype iPrimitiveDatatype=primitiveDatatype iArrayPart=arrayPart iArrayPartValue=arrayPartValue/>
	endfor
<#--#repeat.en-->
				<#else>
					<@public.convertFromDomain iComponentName=c.componentName iAttributeName=common.getAttributeName(a) iDatatype=datatype iPrimitiveDatatype=primitiveDatatype/>
				</#if><#--if array-->
			</#if>
	return(0)
}

<#if !common.getIsReadOnly(a)>
function long <@names.SB_DLLCode/>.set.${c.componentName}.${common.getAttributeName(a)}.Mapper(			
	<#assign array=false>
	<#if datatype.dimensions?exists>
		<#assign array=true>
	ref string	i.value(,), ref boolean i.valueIsSet())		
	<#else>
	const	string	i.value)				
	</#if><#--if datatype.dimensions?exists-->	
{
	<#if array>
		<#assign dimensions = datatype.dimensions>
	string	temp.value(1024, ${dimensions}) mb
	domain	${common.getDatatypeName(datatype)}	l.${common.getAttributeName(a)}(${dimensions})

	temp.value(1,1) = ""
	<#else>
	string	temp.value(1024) mb
	domain	${common.getDatatypeName(datatype)}	l.${common.getAttributeName(a)}
	boolean	isSet
	
	isSet = true
	temp.value = ""
	</#if><#--array-->
	<#if a.conversionSetHookExpression?exists && a.conversionSetHookExpression?has_content>
	|* Conversion Set Hook
	RETIFNOK(<@names.ST_DLLCode/>.Hook.ConversionSet.${c.componentName}.${common.getAttributeName(a)}(
		<#if array>
		i.value, l.${common.getAttributeName(a)}, i.valueIsSet))
		<#else>
		i.value, l.${common.getAttributeName(a)}, isSet))
		</#if><#--if array-->
	<#else>
		<#if array> 
	long	i
			<#assign arrayPartValue = "(1,i)">
			<#if primitiveDatatype = "string" && !common.isTextDatatype(datatype)>
 				<#assign arrayPart = "(1,i)">			
			<#else>
				<#assign arrayPart = "(i)">
			</#if><#--if primitiveDatatype = "string" && !common.isTextDatatype(datatype)-->
	for i = 1 to ${dimensions}
		if i.valueIsSet(i) then		
			<@public.convertToDomain iComponentName=c.componentName iAttributeName=common.getAttributeName(a) iDatatype=datatype iPrimitiveDatatype=primitiveDatatype iArrayPart=arrayPart iArrayPartValue=arrayPartValue/>
		<#else>
			<#assign arrayPart = "">
			<#assign arrayPartValue = "">
			<@public.convertToDomain iComponentName=c.componentName iAttributeName=common.getAttributeName(a) iDatatype=datatype iPrimitiveDatatype=primitiveDatatype/>
		</#if><#--if array-->
		<#if primitiveDatatype == "boolean" >
			|* Do special check.
			if strip$(tolower$(i.value${arrayPartValue})) <> "true" and
			   strip$(tolower$(i.value${arrayPartValue})) <> "false"
			then
				dal.set.error.message("tlbcts0071",	
					"${c.componentName}.${common.getAttributeName(a)}",	
					strip$(i.value${arrayPartValue}))
				return(DALHOOKERROR)
			endif
		<#else>
			<#if !common.isTextDatatype(datatype)>
				<#if !common.hasEnumerations(datatype) &&
					  (datatype.primitiveDatatype == "string" || datatype.primitiveDatatype == "anyURI" || datatype.primitiveDatatype == "duration" || datatype.primitiveDatatype == "Name")>
					<#-- temp.value is assigned in public.convertToDomain (public.sb.common), so we must use that one. -->
					<#if array>
	RETIFNOK(tlbct.dll1000.domain.check.value(strip$(temp.value${arrayPart}),
					<#else>
	RETIFNOK(tlbct.dll1000.domain.check.value(temp.value,
					</#if>
		"${common.getDatatypeName(datatype)}", "${common.getDatatypeName(datatype)}", "${common.getAttributeName(a)}"))
	l.${common.getAttributeName(a)}${arrayPart} = temp.value${arrayPart}
					<#-- Alignment is done after assigning to the right variable, 
					     because when right-aligning the string length must be correct.
					     Note that tlbct.dll1000.domain.check.value() does NOT check the alignment. -->
	retv = tt.align.according.domain(l.${common.getAttributeName(a)}${arrayPart}, l.${common.getAttributeName(a)}${arrayPart}, "${common.getDatatypeName(datatype)}")
				<#else>
					<#if array>
	RETIFNOK(tlbct.dll1000.domain.check.value(strip$(i.value${arrayPartValue}),
					<#else>
	RETIFNOK(tlbct.dll1000.domain.check.value(i.value,
					</#if>
		"${common.getDatatypeName(datatype)}", "${common.getDatatypeName(datatype)}", "${common.getAttributeName(a)}"))
				</#if>
			</#if>
		</#if>
		<#if array> 
		endif
	endfor
		</#if><#--if array-->	
	</#if>
	<#if array>
	RETIFNOK(<@names.ST_DLLCode/>.set.${c.componentName}.${common.getAttributeName(a)}(
			l.${common.getAttributeName(a)}, i.valueIsSet))
	<#else>
	RETIFNOK(<@names.ST_DLLCode/>.set.${c.componentName}.${common.getAttributeName(a)}(
			l.${common.getAttributeName(a)}))
	</#if><#--if array-->	
	return(0)
}
				</#if><#--if !common.getIsReadOnly(a)-->

			</#if><#--if a.attributeImplementation.attribute?exists-->
		</#list><#--list c.attributeImplementation as a-->
</#list><#--list common.listComponentImplementations() as c-->

<@source.performance_point description="GetBusinessInterfaceType"/>
|******************************* Public Methods *******************************

<#--namespace.sn-->
function extern string <@names.SB_DLLCode/>.GetSchemaVersion()
{
       DllUsage
              This method returns the BID Schema Version or an empty string
              if the schema version is unknown.
       EndDllUsage

<#if object.businessInterfaceDefinition.idref.bidSchemaVersion?exists>
       return("${object.businessInterfaceDefinition.idref.bidSchemaVersion}")
<#else>
       return("")
</#if>

}
<#--namespace.en-->

function extern string <@names.SB_DLLCode/>.GetBusinessInterfaceType()
{
       DllUsage
              This method returns the type of the Business Interface as a
              lowercase string or an empty string if the type is unknown.
              For example, it can be used to check if the Business Object
              is a BOD.
       EndDllUsage
 
<#if object.businessInterfaceDefinition.idref.type?exists>
       return("${object.businessInterfaceDefinition.idref.type}")
<#else>
       return("")
</#if>
}

<#if object.businessInterfaceDefinition.idref.type=="bod">
function extern long <@names.SB_DLLCode/>.GetPublishableEventActions()
{
	DllUsage
	Desc:	Returns a list of all publishable actions
	Return: XML structure containing all publishable verbs
	EndDllUsage

	return(<@names.ST_DLLCode/>.GetPublishableEventActions())
}

</#if><#--if object.businessInterfaceDefinition.idref.type=="bod"-->
<#list object.methodImplementation as methodImplementation>
	<#assign methodName=common.getNameFromMethodImplementation(methodImplementation)>
	<#if methodName!="List" && methodName!="Show" && methodName!="SupportsProcessingScope" && 
	     methodName!="SupportsReferentialIntegrity" && methodName!="SubscribeEvent" && 
	     methodName!="UnSubscribeEvent" && methodName!="PublishEvent" && methodName!="OnEvent" &&
	     methodName!="SubscribeList" &&
	     methodImplementation.processingOrder != "batch" &&
	     protected.hasMethodAlternativeImplementation(methodName)=="">
function extern long <@names.SB_DLLCode/>.${methodName}(
					const xmlNode i.RequestArgument,
					ref xmlNode o.ResponseArgument,
					ref xmlNode o.ResultArgument)
{
	DllUsage
	<#if (methodName=="CreateRef" || methodName=="DeleteRef")>
		This method will handle one Business Object as
	<#else>
		This method will handle one or more Business Objects as	
	</#if>
		requested in the XML Request message. Output information and
		warnings will be placed in the XML response message.
		Errors are put in the XML result message.
	EndDllUsage

	<#if (methodName=="CreateRef" || methodName=="DeleteRef")>
	boolean	TagFound
		<#if (methodName=="CreateRef")>
	long	ret
		</#if><#--if (methodName=="CreateRef")-->
	string	referenceID(40)
	xmlnode ControlAreaNode
	</#if><#--if (methodName=="CreateRef" || methodName=="DeleteRef")-->
	boolean	correct.objects.found
	xmlNode	Request${names.businessInterfaceName}Node
	<#if public.hasPublicOutputArguments(methodName)>
	xmlNode	Response${names.businessInterfaceName}Node
		<#if public.hasPublicOutputDataArguments(methodName)>
	xmlNode	ResponseDataNode
		</#if>
	</#if>
	<#if object.businessInterfaceDefinition.idref.type!="bod">
	long	duml
	</#if>

	CHECK_TOOLS_VERSION(o.ResponseArgument, o.ResultArgument)
	
	<#if (methodName=="CreateRef" || methodName=="DeleteRef")>
	TagFound = false
	</#if>
	<#if public.hasPublicOutputArguments(methodName)>
		<#if public.hasPublicOutputDataArguments(methodName)>
	RETIFNOK2(createResponseObject(o.ResponseArgument, "${methodName}"))
		<#else>
	RETIFNOK2(createResponseObject.WithoutDataArea(o.ResponseArgument,
							"${methodName}"))
		</#if>
	<#else>
	RETIFNOK2(createResponseObject.WithoutDataArea(o.ResponseArgument,
							"${methodName}"))
	</#if>
	RETIFNOK2(createResultObject(o.ResultArgument))

	RETIFNOK2(selectObjectNode(i.RequestArgument, Request${names.businessInterfaceName}Node))
	<#if public.hasPublicOutputDataArguments(methodName)>
	RETIFNOK2(selectResponseNode(o.ResponseArgument, ResponseDataNode))
	</#if>
	make.xmlArguments.global(i.RequestArgument,
				 o.ResponseArgument,
				 o.ResultArgument)

	RETIFNOK2(tlbct.dll1000.get.processingScope(
			"${methodName}",
			i.RequestArgument,
			bl.processingScope)) |* sets the bl.transactionScope
	if bl.processingScope = BUS_ENT or bl.processingScope = BUS_ENT_CMP
	then
		db.set.child.transaction(1)
	endif

	if bl.processingScope = FUTURE then
		if get.bshell.tiv() >= 1012 then
			bl.ret = db.get.child.transaction()
			if bl.ret <> 1 then
				dal.set.error.message("tlbctsb0028")
				| processingScope with value 'not_applicable'
				| needs a running transaction
				handle.messages(o.ResponseArgument,
					o.ResultArgument, set.in.result(true)) |* handle errors
				return (DALHOOKERROR)
			endif
		endif
	endif

	<#if (methodName=="DeleteRef")>
	ReferenceID = ""
	ControlAreaNode = xmlFindFirst("ControlArea", i.RequestArgument)
	if ControlAreaNode <> 0	then
		RETIFNOK2(getValue(ControlAreaNode, 
					"ControlArea.referenceID", 
					"<ControlArea>.<referenceID>", 
					false, referenceID, TagFound))
	endif
	if isspace(referenceID)
	then
		dal.set.error.message("tlbctsb0020")
		|* No ReferenceID specified
		handle.messages(o.ResponseArgument,
				o.ResultArgument, set.in.result(true)) |* handle errors
		return (DALHOOKERROR)
	else
		<@names.ST_DLLCode/>.set.refkey(referenceID)
	endif
	</#if><#--if (methodName=="DeleteRef")-->
	<#if (methodName=="CreateRef")>
	referenceID = ""
	<@names.ST_DLLCode/>.set.refkey(referenceID)
	</#if><#--if (methodName=="CreateRef")-->
	correct.objects.found = false
	while ( Request${names.businessInterfaceName}Node <> 0 )
		bl.skipComponent = false|* all components must be processed
		SET_RETRY_POINT_BUS_ENT()<#--RETRY-->
	<#if public.hasPublicOutputDataArguments(methodName)>
		CLEAR_RESPONSE_BUS_ENT_RESPONSE_IN_RETRY(${names.businessInterfaceName})<#--RETRY-->
		if bl.processingScope = BUS_ENT then
			bl.result = Handle.retrying.component(
				"${methodName}",
				"${names.businessInterfaceName}",
				"${names.businessInterfaceName}",
				o.ResponseArgument, 
				o.ResultArgument)
		endif
		RETIFNOK2(createCompNode(ResponseDataNode, "${names.businessInterfaceName}",
			Response${names.businessInterfaceName}Node))
	</#if><#--if public.hasPublicOutputDataArguments(methodName)-->

	<#if !public.hasPublicOutputArguments(methodName)>
		if not bl.skipComponent then
		    RETIFNOK5(${methodName}, 
			o.ResponseArgument, o.ResultArgument, 
			"${names.businessInterfaceName}", "${names.businessInterfaceName}",false,
			Handle.Request.${methodName}.${names.businessInterfaceName}(Request${names.businessInterfaceName}Node,
			o.ResponseArgument, 
			o.ResultArgument,
				${public.processingOrder(methodImplementation)}))
		endif
	<#else><#--if !public.hasPublicOutputArguments(methodName)-->
		if not bl.skipComponent then
		    RETIFNOK5(${methodName}, 
			o.ResponseArgument, o.ResultArgument,
			"${names.businessInterfaceName}", "${names.businessInterfaceName}",false,
			Handle.Request.${methodName}.${names.businessInterfaceName}(Request${names.businessInterfaceName}Node, 
			Response${names.businessInterfaceName}Node,
			o.ResponseArgument, o.ResultArgument,
			${public.processingOrder(methodImplementation)}))
		endif
	</#if><#--if !public.hasPublicOutputArguments(methodName)-->
		if not bl.skipComponent then
			SET_RETRY_POINT_BUS_ENT_CMP()
		    RETIFNOK5(${methodName},
			o.ResponseArgument, o.ResultArgument,
			"${names.businessInterfaceName}", "${names.businessInterfaceName}", true,
			<@names.ST_DLLCode/>.finalize.${methodName}())
		endif
	<#if public.hasPublicOutputArguments(methodName)>
		|* Check if BO is empty or that the BO can be skipped.
		|* If so, remove BO node
		if bl.skipComponent or
		   xmlGetFirstChild(Response${names.businessInterfaceName}Node) = 0
		then
			bl.ret = xmlDelete(Response${names.businessInterfaceName}Node)
			Response${names.businessInterfaceName}Node = 0
		endif
	</#if><#--if public.hasPublicOutputArguments(methodName)-->
		if bl.processingScope = BUS_ENT and not bl.skipComponent then
			correct.objects.found = true
		endif
		Request${names.businessInterfaceName}Node = xmlGetRightSibling(Request${names.businessInterfaceName}Node)
	endwhile
	<#if (methodName=="CreateRef")>
	|* Add the referenceID in Response
	RETIFNOK(<@names.ST_DLLCode/>.get.refKey(referenceID))
	if not isspace(referenceID) then
		NEW.NODE("ControlArea", 0, ControlAreaNode)
		ret = xmlRewriteDataElement(ControlAreaNode, "referenceID",	referenceID)
		ret = xmlInsertInChilds(o.ResponseArgument, ControlAreaNode)
	endif
	</#if>
<#--#returnfix.so--
	if bl.processingScope = BUS_ENT and not correct.objects.found then
		| move messages from Response to Result
		handle.messages(o.ResponseArgument,
			o.ResultArgument, true) |* put mess in result
	else
		handle.messages(o.ResponseArgument,
			o.ResultArgument, false) |* put mess in response
	endif
<#--#returnfix.eo-->
	if bl.processingScope = BUS_ENT or bl.processingScope = BUS_ENT_CMP
	then
		db.set.child.transaction(0)
		abort.transaction()
	endif
<#--#returnfix.sn-->
	if bl.processingScope = BUS_ENT and not correct.objects.found then
		| move messages from Response to Result
		handle.messages(o.ResponseArgument,
			o.ResultArgument, true) |* put mess in result
		return(DALHOOKERROR)
	else
		handle.messages(o.ResponseArgument,
			o.ResultArgument, false) |* put mess in response
<#--#returnfix.en-->
	<#if object.businessInterfaceDefinition.idref.type!="bod">
		| Set namespace to allow nillable attributes
		duml = xmlSetAttribute(o.ResponseArgument, "xmlns:xsi" ,
					"http://www.w3.org/2001/XMLSchema-instance")
	</#if>
<#--#CRM-00000-01607.sn-->
	<@names.ST_DLLCode/>.finalize.${methodName}()
<#--#CRM-00000-01607.en-->
		return(0)
<#--#returnfix.sn-->
	endif
<#--#returnfix.en-->
}

<#if (methodName=="CreateRef" || methodName=="DeleteRef")>
<#--TODO RequestAttrUnderBO: Solution: Always do it??-->
function long NextNodeIsSame.${methodName}(const string  i.component,
			     const xmlNode    i.CurrNode,
			     ref   boolean o.is.equal)
{
	FunctionUsage
		This function checks if the next node is equal to the current
		node. No next node present is interpretted as 'True'.
		Another issue is that the current node can have childeren that
		have children of their own. in that case the function returns
		'False'
	EndFunctionUsage

	xmlNode    Node

	o.is.equal = true
	|* Check if next node is present and the same type
	Node = xmlGetRightSibling(i.CurrNode)
	RETIFNOK(NextNodeIsEqual.${methodName}(i.component, Node, o.is.equal))
	if not o.is.equal then
		return(0)
	endif

	|* Check if current node has children that have childeren
	Node = xmlGetLastChild(i.CurrNode)
	RETIFNOK(NextNodeIsEqual.${methodName}(i.component, Node, o.is.equal))
	return(0)
}

function long NextNodeIsEqual.${methodName}(const string  i.component(),
			      const xmlNode    i.Node,
			      ref   boolean o.is.equal)
{
	string  NextNodeName(256)

	if i.Node <> 0 then
		NextNodeName = ""
		RETIFNOK4(xmlGetName(i.Node, NextNodeName))
		on case i.component
	<#list public.listPublicComponents(methodName) as c>		
		case "${c.componentName}":
			on case NextNodeName
			<#assign listOfPublicSubComponents = public.listPublicSubComponentsFromStructure(publicSubComponentsStructure, methodName, c.componentName)>
			<#list listOfPublicSubComponents as d>
			case "${d.componentName}":
				o.is.equal = false
				break
			</#list> <#--#list listPublicSubComponents as d -->
			default:
				break
			endcase
			break
	</#list><#-- list public.listPublicComponents(methodName) as c -->		
		default:
			break
		endcase
	endif
	return(0)
}
</#if><#--if (methodName=="CreateRef" || methodName=="DeleteRef")-->

<#if methodName=="DeleteRef" || methodName=="Delete">
<#assign methodComponents=protected.listProtectedComponents()/>
<#else>
<#assign methodComponents=public.listPublicComponents(methodName)/>
</#if><#--if methodName=="DeleteRef" || (object.businessInterfaceDefinition.idref.type=="bod" && methodName=="Delete")-->
<#assign generateCheckActionTypeConsistency=false>
<#list methodComponents as c>
<#--#cust.sn-->
	<#assign componentHasCustomerDataLocation=public.hasCustomerDataLocation(c.componentImplementation.component.idref)>
<#--#cust.en-->
	<#assign methodExists=false>
	<#list c.componentImplementation.methodImplementation as mi>
		<#if mi.name == methodName>
			<#assign methodExists=true>
		</#if>
	</#list><#--list c.componentImplementation.methodImplementation as mi-->
	<#if methodExists>
		<#assign listOfPublicSubComponents = public.listPublicSubComponentsFromStructure(publicSubComponentsStructure, methodName, c.componentName)>
		<#if methodName=="Change">
	string	bl.${c.componentName}.actionType(25)
		</#if><#--if methodName=="Change"-->
		
function long Handle.Request.${methodName}.${c.componentName}(
		<#if !public.hasPublicOutputArguments(methodName)>
			ref	xmlNode	io.${c.componentName}Node,
		<#else><#--if !public.hasPublicOutputArguments(methodName)-->
			ref	xmlNode	io.${c.componentName}Node,
			<#if c.componentName == names.businessInterfaceName>
			const	xmlNode	i.Response${names.businessInterfaceName}Node,
			<#else><#--if c.componentName == names.businessInterfaceName-->
			const	xmlNode	i.Response${c.parentComponentName}Node,
			</#if><#--if c.componentName == names.businessInterfaceName-->
		</#if><#--if !public.hasPublicOutputArguments(methodName)-->
		<#if c.componentName != names.businessInterfaceName>
		ref		boolean	o.cancel,
		</#if><#--if c.componentName == names.businessInterfaceName-->
		ref		xmlNode	io_${methodName}.ResponseArgument, 
		ref		xmlNode	io_${methodName}.ResultArgument,
				long	i.processingOrder)
{
	long	ret
	long	tmp.node
	long	positionNode
	long	duml
	xmlNode	sv.${c.componentName}Node
	xmlNode	Lower.${c.componentName}Node
		<#if c.componentName == names.businessInterfaceName>
	boolean	o.cancel
		</#if><#--if c.componentName == names.businessInterfaceName-->
	boolean	${c.componentName}.cancel
		<#list listOfPublicSubComponents as s>
	boolean	${s.componentName}.cancel
		</#list><#--listOfPublicSubComponents as s-->
		<#if c.componentName != names.businessInterfaceName>
	string	Request.Name(256)
		</#if><#--if c.componentName != names.businessInterfaceName-->
		<#if public.hasPublicOutputArguments(methodName) || methodName=="Delete">
	xmlNode	Response.${c.componentName}Node
		</#if><#--if public.hasPublicOutputArguments(methodName)-->
		<#if (methodName=="CreateRef" || methodName=="DeleteRef")>
	boolean	is.equal
		</#if><#--if (methodName=="CreateRef" || methodName=="DeleteRef")-->

	duml = 0
	ret = 0
	tmp.node = 0
	positionNode = 0
	sv.${c.componentName}Node = 0
	Lower.${c.componentName}Node = 0
		<#if c.componentName == names.businessInterfaceName>
	o.cancel = false
		</#if><#--if c.componentName == names.businessInterfaceName-->
	${c.componentName}.cancel = false
		<#list listOfPublicSubComponents as s>
	${s.componentName}.cancel = false
		</#list><#--listOfPublicSubComponents as s-->

		<#if c.componentName != names.businessInterfaceName>
	|* Check if this is the correct component??
	if io.${c.componentName}Node <> 0 then
		RETIFNOK4(xmlGetName(io.${c.componentName}Node, Request.Name))
	endif
	while io.${c.componentName}Node <> 0 and
	      Request.Name = "${c.componentPublicName}"
    	</#if><#--if c.componentName != names.businessInterfaceName-->
		bl.result = 0
		<#if public.hasPublicOutputArguments(methodName)>
		Response.${c.componentName}Node = 0
		</#if><#--if public.hasPublicOutputArguments(methodName)-->
		sv.${c.componentName}Node = io.${c.componentName}Node
		SET_RETRY_POINT_BUS_ENT_CMP()
		if bl.processingScope = BUS_ENT_CMP then
			bl.result = Handle.retrying.component(
				"${methodName}",
				"${names.businessInterfaceName}",
				"${c.componentName}",
				io_${methodName}.ResponseArgument,
				io_${methodName}.ResultArgument)
			if db.retry.hit() then
				io.${c.componentName}Node = sv.${c.componentName}Node
			endif
		endif
		<@names.ST_DLLCode/>.${c.componentName}.initialize()
		<#if public.hasPublicInputDataArgumentsByComponent(methodName, c.componentName)>
		CONTINUEIFNOK(${methodName},
			io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
			"${names.businessInterfaceName}", "${c.componentName}", false,
			${methodName}.handle.input.${c.componentName}(io.${c.componentName}Node))

<#--For any method but not change. -->
			<#if methodName!="Change" >
		CONTINUEIFNOK_WITH_RETRY(${methodName},
			io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
			"${names.businessInterfaceName}", "${c.componentName}", false,
			<@names.ST_DLLCode/>.before.execute.${c.componentName}.${methodName}(${c.componentName}.cancel))
		if ${c.componentName}.cancel then
			if i.processingOrder = BOTTOM_UP then
				o.cancel = true
			endif
			return(0)
		endif
			</#if><#--if methodName!="Change"-->
			<#if methodName == "Delete">
				<#if common.bdeHasMoreThanOneComponent()>
		|* Build 'new' request node.
		CONTINUEIFNOK(${methodName},
			io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
			"${names.businessInterfaceName}", "${c.componentName}", false,
			Build.requestNode.for.Delete.${c.componentName}(io.${c.componentName}Node, tmp.node))
				<#else>
		tmp.node = xmlDuplicate(io.${c.componentName}Node)
				</#if><#--if common.bdeHasMoreThanOneComponent-->
		if tmp.node <> 0 then
		|* Call the 'Change' method.
		duml = createResponseObject(Response.${c.componentName}Node, "Change")
		CONTINUEIFNOK(Change,
			io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
			"${names.businessInterfaceName}", "${c.componentName}", false,
			Handle.Request.Change.${c.componentName}(
				<#if !public.hasPublicOutputArguments("Change")>
		  	tmp.node,
				<#else><#--if !public.hasPublicOutputArguments(methodName)-->
		  	tmp.node, Response.${c.componentName}Node,
				</#if><#--if !public.hasPublicOutputArguments(methodName)-->
				<#-- no cancel here when Change is called as 'root' -->
				<#if c.componentName != names.businessInterfaceName>	
			${c.componentName}.cancel,
				</#if>
			io_${methodName}.ResponseArgument, 
			io_${methodName}.ResultArgument,
			TOP_DOWN))
		|* Clean up response from 'Change'.
		ret = xmlDelete(Response.${c.componentName}Node)
		ret = xmlDelete(tmp.node)
			</#if><#--if methodName == "Delete"-->
			<#if methodName=="Change">
		ret = xmlGetAttribute(io.${c.componentName}Node, "actionType",
			bl.${c.componentName}.actionType)
		if ret = 0 then
			bl.${c.componentName}.actionType  = "change"
		endif
		bl.${c.componentName}.actionType = strip$(shiftl$(bl.${c.componentName}.actionType))
				<#if common.getAttributeImplementationActionType(methodImplementation, c.componentImplementation) != "">
<#-- A user can explicitly model the actionType using a subset of the standard 
	action types. In that case a check is generated into the public layer for 
	ERP LN: if one of the five standard action types (create, change, delete, 
	createOrChange or unchanged) is disabled for the Change method, then an error
	is raised at runtime if the Change request includes the disabled action type. -->
		CONTINUEIFNOK(${methodName},
			io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
			"${names.businessInterfaceName}", "${c.componentName}", false,
			check.actionType.${c.componentName}(bl.${c.componentName}.actionType))

				</#if>
				<#if c.componentName != names.businessInterfaceName>
		CONTINUEIFNOK(${methodName},
			io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
			"${names.businessInterfaceName}", "${c.componentName}", false,
			check.actionType.consistency(bl.${c.parentComponentName}.actionType,
			bl.${c.componentName}.actionType))
					<#assign generateCheckActionTypeConsistency=true>
				</#if><#--if c.componentName != names.businessInterfaceName-->
		on case bl.${c.componentName}.actionType
		case "change":
<#--Always call before here... method is change because in action type part. -->
			CONTINUEIFNOK_WITH_RETRY(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				"${names.businessInterfaceName}", "${c.componentName}", false,
				<@names.ST_DLLCode/>.before.execute.${c.componentName}.${methodName}(${c.componentName}.cancel))
			if ${c.componentName}.cancel then
				if i.processingOrder = BOTTOM_UP then
					o.cancel = true
				endif
				return(0)
			endif

<#--Always call before here... method is change because in action type part.--> 
			CONTINUEIFNOK_WITH_RETRY(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				"${names.businessInterfaceName}", "${c.componentName}", false,
<#--#cust.sn-->
				<#if componentHasCustomerDataLocation>
				execute.${c.componentName}.${methodName}(io.${c.componentName}Node))
				<#else>
<#--#cust.en-->
				<@names.ST_DLLCode/>.execute.${c.componentName}.${methodName}())
<#--#cust.sn-->
				</#if>
<#--#cust.en-->
			break
		case "create":
				<#if c.componentName != names.businessInterfaceName>
				<#if !common.methodPresent("Create", c.componentImplementation)>
					${logger.error(object,"Method Create is not implemented for component ${c.componentName}.")}
				</#if><#--#if common.methodPresent("Create", c.componentImplementation)-->
			CONTINUEIFNOK_WITH_RETRY(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				"${names.businessInterfaceName}", "${c.componentName}", false,
				<@names.ST_DLLCode/>.before.execute.${c.componentName}.Create(${c.componentName}.cancel))
			if ${c.componentName}.cancel then
				return(0)
			endif
			CONTINUEIFNOK_WITH_RETRY(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				"${names.businessInterfaceName}", "${c.componentName}", false,
<#--#cust.sn-->
				<#if componentHasCustomerDataLocation>
				execute.${c.componentName}.Create(io.${c.componentName}Node))
				<#else>
<#--#cust.en-->
				<@names.ST_DLLCode/>.execute.${c.componentName}.Create())
<#--#cust.sn-->
				</#if>
<#--#cust.en-->
			break 
				<#else><#--if c.componentName != names.businessInterfaceName-->
			dal.set.error.message("tlbctsb0005")
			|* Method 'Create' not allowed on top level of Business Object.
			return(DALHOOKERROR)
				</#if><#--if c.componentName != names.businessInterfaceName-->	
		case "createOrChange":	
		<#if c.componentName != names.businessInterfaceName>
				<#if !common.methodPresent("Create", c.componentImplementation)>
					${logger.error(object,"Method Create is not implemented for component ${c.componentName}.")}
				</#if><#--#if common.methodPresent("Create", c.componentImplementation)-->
			if <@names.ST_DLLCode/>.execute.${c.componentName}.Read.Only() = 0 then
				CONTINUEIFNOK_WITH_RETRY(${methodName},
					io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
					"${names.businessInterfaceName}", "${c.componentName}", false,
					<@names.ST_DLLCode/>.before.execute.${c.componentName}.${methodName}(${c.componentName}.cancel))
				if ${c.componentName}.cancel then
					if i.processingOrder = BOTTOM_UP then
						o.cancel = true
					endif
					return(0)
				endif
				CONTINUEIFNOK_WITH_RETRY(${methodName},
					io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
					"${names.businessInterfaceName}", "${c.componentName}", false,
<#--#cust.sn-->
				<#if componentHasCustomerDataLocation && (methodName=="Create" || methodName=="Change")>
					execute.${c.componentName}.${methodName}(io.${c.componentName}Node))
				<#else>
<#--#cust.en-->
					<@names.ST_DLLCode/>.execute.${c.componentName}.${methodName}())
<#--#cust.sn-->
				</#if><#--if methodName=="Create" || methodName=="Change"-->
<#--#cust.en-->
			else
				CONTINUEIFNOK_WITH_RETRY(${methodName},
					io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
					"${names.businessInterfaceName}", "${c.componentName}", false,
					<@names.ST_DLLCode/>.before.execute.${c.componentName}.Create(${c.componentName}.cancel))
				if ${c.componentName}.cancel then
					return(0)
				endif
				CONTINUEIFNOK_WITH_RETRY(${methodName},
					io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
					"${names.businessInterfaceName}", "${c.componentName}", false,
<#--#cust.sn-->
				<#if componentHasCustomerDataLocation>
					execute.${c.componentName}.Create(io.${c.componentName}Node))
				<#else>
<#--#cust.en-->
					<@names.ST_DLLCode/>.execute.${c.componentName}.Create())
<#--#cust.sn-->
				</#if>
<#--#cust.en-->
			endif
		<#else>
			if <@names.ST_DLLCode/>.execute.${c.componentName}.Read.Only() = 0 then
				CONTINUEIFNOK_WITH_RETRY(${methodName},
					io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
					"${names.businessInterfaceName}", "${c.componentName}", false,
					<@names.ST_DLLCode/>.before.execute.${c.componentName}.${methodName}(${c.componentName}.cancel))
				if ${c.componentName}.cancel then
					if i.processingOrder = BOTTOM_UP then
						o.cancel = true
					endif
					return(0)
				endif
				CONTINUEIFNOK_WITH_RETRY(${methodName},
					io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
					"${names.businessInterfaceName}", "${c.componentName}", false,
<#--#cust.sn-->
				<#if componentHasCustomerDataLocation && (methodName=="Create" || methodName=="Change")>
					execute.${c.componentName}.${methodName}(io.${c.componentName}Node))
				<#else>
<#--#cust.en-->
					<@names.ST_DLLCode/>.execute.${c.componentName}.${methodName}())
<#--#cust.sn-->
				</#if><#--if methodName=="Create" || methodName=="Change"-->
<#--#cust.en-->
			else
				dal.set.error.message("tlbctsb0005")
				|* Method 'Create' not allowed on top level of Business Object.
				return(DALHOOKERROR)
			endif
		</#if><#--if c.componentName != names.businessInterfaceName-->
			break		
		case "delete":
				<#if c.componentName != names.businessInterfaceName>
					<#if !common.methodPresent("Delete", c.componentImplementation)>
						${logger.error(object,"Method Delete is not implemented for component ${c.componentName}.")}
					</#if><#--#if common.methodPresent("Delete", c.componentImplementation)-->
			CONTINUEIFNOK_WITH_RETRY(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				"${names.businessInterfaceName}", "${c.componentName}", false,
				<@names.ST_DLLCode/>.before.execute.${c.componentName}.Delete(${c.componentName}.cancel))
			if ${c.componentName}.cancel then
				o.cancel = true
				return (0)
			endif
					<#if (listOfPublicSubComponents?size!=0)>
			Lower.${c.componentName}Node = xmlGetFirstChild(sv.${c.componentName}Node)
			CONTINUEIFNOK(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				"${names.businessInterfaceName}", "${c.componentName}", false,
				Move.Node.To.Component.Under.${c.componentName}(
				Lower.${c.componentName}Node))
					</#if><#--if (listOfPublicSubComponents?size!=0)-->
					<#list listOfPublicSubComponents as s>
			if not bl.skipComponent then
						<#if !public.hasPublicOutputArguments(methodName)>
			    RETIFNOK5(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				 "${names.businessInterfaceName}", "${s.componentName}", false,
				Handle.Request.${methodName}.${s.componentName}(
				  	Lower.${c.componentName}Node,
					${s.componentName}.cancel,
					io_${methodName}.ResponseArgument, 
					io_${methodName}.ResultArgument,
					BOTTOM_UP))
						<#else><#--if !public.hasPublicOutputArguments(methodName)-->
							<#assign notInitialized = true>
							<#list listOfPublicSubComponents as s>
								<#if notInitialized>
				tmp.node = xmlNewNode("TempNode")
									<#assign notInitialized = false>
								</#if>
			    RETIFNOK5(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				 "${names.businessInterfaceName}", "${s.componentName}", false,
				Handle.Request.${methodName}.${s.componentName}(
				  	Lower.${c.componentName}Node,
					tmp.node,
					${s.componentName}.cancel,
					io_${methodName}.ResponseArgument, 
					io_${methodName}.ResultArgument,
					BOTTOM_UP))
								<@public.generateAnchorReplacement iComponentName=c.componentName iSubComponentName=s.componentName/>
							</#list><#--list listOfPublicSubComponents as s-->
							<#if !notInitialized>
				ret = xmlDelete(tmp.node)
							</#if>
						</#if><#--if !public.hasPublicOutputArguments(methodName)-->
				if ${s.componentName}.cancel then
					o.cancel = true
				endif
			endif
					</#list><#--listOfPublicSubComponents?reverse as s-->
			if o.cancel then
				return (0)
			else
				CONTINUEIFNOK_WITH_RETRY(${methodName},
					io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
					"${names.businessInterfaceName}", "${c.componentName}", false,
					<@names.ST_DLLCode/>.execute.${c.componentName}.Delete())
			endif
			break
				<#else><#--if c.componentName != names.businessInterfaceName-->
			dal.set.error.message("tlbctsb0004")
			|* Method 'Delete' not allowed on top level of Business Object.
			return(DALHOOKERROR)
				</#if><#--if c.componentName != names.businessInterfaceName-->
		case "unchanged":
			CONTINUEIFNOK_WITH_RETRY(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				"${names.businessInterfaceName}", "${c.componentName}", false,
				<@names.ST_DLLCode/>.execute.${c.componentName}.Read())
			break
		default:
			| invalid action type
				<#if c.componentName != names.businessInterfaceName>
	 			dal.set.error.message("tlbctsb0022", bl.${c.componentName}.actionType,
					"${c.componentName}")
			|* Method Change: invalid action type (%1$s) on component
			|* (%2$s) of Business Object
				<#else><#--if c.componentName != names.businessInterfaceName-->
				dal.set.error.message("tlbctsb0021", bl.${names.businessInterfaceName}.actionType)
			|* Method Change: invalid action type  (%1$s) on
			|* top level of Business Object
				</#if><#--if c.componentName != names.businessInterfaceName-->
			return(DALHOOKERROR)
		endcase
			</#if><#--if methodName=="Change"-->
			<#if c.componentName != names.businessInterfaceName>
		io.${c.componentName}Node = xmlGetRightSibling(io.${c.componentName}Node)
			</#if><#--if c.componentName != names.businessInterfaceName-->
		</#if> <#-- if public.hasPublicInputDataArgumentsByComponent(methodName, c.componentName)-->
		if i.processingOrder = BOTTOM_UP then
			<#if public.hasPublicOutputDataArgumentsByComponent(methodName, c.componentName)>
				<#if methodName != "Delete">
					<#if methodName == "Change">
			if bl.${c.componentName}.actionType <> "delete" then
					</#if>
				|* Set the correct response tree (fill with empty data), this will be overwritten afterwards..
				CONTINUEIFNOK(${methodName},
					io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
					"${names.businessInterfaceName}", "${c.componentName}", false,
					<#if c.componentName == names.businessInterfaceName>
					${methodName}.handle.output.${c.componentName}(i.Response${names.businessInterfaceName}Node,
					<#else><#--if c.componentName == names.businessInterfaceName-->
					${methodName}.handle.output.${c.componentName}(i.Response${c.parentComponentName}Node,
					</#if><#--if c.componentName == names.businessInterfaceName-->
					Response.${c.componentName}Node))
					<#if methodName == "Change">
			endif
					</#if><#-- if methodName == "Change" -->
				</#if> <#--if methodName != "delete"-->
			</#if><#--if public.hasPublicOutputDataArgumentsByComponent(methodName, c.componentName)-->
			<#if (listOfPublicSubComponents?size!=0)>
			Lower.${c.componentName}Node = xmlGetFirstChild(sv.${c.componentName}Node)
			CONTINUEIFNOK(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				"${names.businessInterfaceName}", "${c.componentName}", false,
				Move.Node.To.Component.Under.${c.componentName}(
				Lower.${c.componentName}Node))
			</#if><#--if (listOfPublicSubComponents?size!=0)-->
			<#if !public.hasPublicOutputArguments(methodName)>
				<#list listOfPublicSubComponents as s>
			if not bl.skipComponent then
			    RETIFNOK5(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				 "${names.businessInterfaceName}", "${s.componentName}", false,
				Handle.Request.${methodName}.${s.componentName}(
				  	Lower.${c.componentName}Node,
					${s.componentName}.cancel,
					io_${methodName}.ResponseArgument, 
					io_${methodName}.ResultArgument,
					${public.processingOrder(methodImplementation)}))
				if ${s.componentName}.cancel then
					o.cancel = true
				endif
			endif
				</#list><#--listOfPublicSubComponents as s-->
			<#else><#--if !public.hasPublicOutputArguments(methodName)-->
				<#assign notInitialized = true>
				<#list listOfPublicSubComponents?reverse as s>
					<#if notInitialized>
				tmp.node = xmlNewNode("TempNode")
						<#assign notInitialized = false>
					</#if>
			if not bl.skipComponent then
			    RETIFNOK5(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				 "${names.businessInterfaceName}", "${s.componentName}", false,
				Handle.Request.${methodName}.${s.componentName}(
				  	Lower.${c.componentName}Node,
					tmp.node,
					${s.componentName}.cancel,
					io_${methodName}.ResponseArgument, 
					io_${methodName}.ResultArgument,
					${public.processingOrder(methodImplementation)}))
					<@public.generateAnchorReplacement iComponentName=c.componentName iSubComponentName=s.componentName/>
				if ${s.componentName}.cancel then
					o.cancel = true
				endif
			endif
				</#list><#--listOfPublicSubComponents?reverse as s-->
				<#if !notInitialized>
			ret = xmlDelete(tmp.node)
				</#if>
			</#if><#--if !public.hasPublicOutputArguments(methodName)-->
			if o.cancel then
				return (0)
			endif
		endif

		<#if (methodName=="CreateRef" || methodName=="DeleteRef")>
		CONTINUEIFNOK(${methodName},
			io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
			"${names.businessInterfaceName}", "${c.componentName}", false,
			NextNodeIsSame.${methodName}("${c.componentName}",
			sv.${c.componentName}Node, is.equal))
		if is.equal then
			CONTINUEIFNOK_WITH_RETRY(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				"${names.businessInterfaceName}", "${c.componentName}", false,
				<@names.ST_DLLCode/>.execute.${c.componentName}.${methodName}())
		endif
		<#else><#--if (methodName=="CreateRef" || methodName=="DeleteRef")-->
			<#if methodName!="Change">
		CONTINUEIFNOK_WITH_RETRY(${methodName},
			io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
			"${names.businessInterfaceName}", "${c.componentName}", false,
<#--#cust.sn-->
				<#if componentHasCustomerDataLocation && (methodName=="Create")>
			execute.${c.componentName}.${methodName}(sv.${c.componentName}Node))
			| io.${c.componentName}Node refers to next node (maybe 0), so don't use that here
				<#else>
<#--#cust.en-->
			<@names.ST_DLLCode/>.execute.${c.componentName}.${methodName}())
<#--#cust.sn-->
				</#if><#--if methodName=="Create"-->
<#--#cust.en-->
				<#if methodName == "Delete" && public.hasPublicInputDataArgumentsByComponent(methodName, c.componentName)>
		endif
				</#if>
			</#if><#--if methodName!="Change"-->
		</#if><#--if (methodName=="CreateRef" || methodName=="DeleteRef")-->
		<#if public.hasPublicOutputDataArgumentsByComponent(methodName, c.componentName)>
			<#if methodName != "Delete">
				<#if methodName == "Change">
		if bl.${c.componentName}.actionType <> "delete" then
				</#if><#-- if methodName == "Change" -->
			CONTINUEIFNOK(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				"${names.businessInterfaceName}", "${c.componentName}", false,
				<#if c.componentName == names.businessInterfaceName>
				${methodName}.handle.output.${c.componentName}(i.Response${names.businessInterfaceName}Node,
				<#else><#--if c.componentName == names.businessInterfaceName-->
				${methodName}.handle.output.${c.componentName}(i.Response${c.parentComponentName}Node,
				</#if><#--if c.componentName == names.businessInterfaceName-->
				Response.${c.componentName}Node))
				<#if methodName == "Change">
		endif
				</#if><#-- if methodName == "Change"-->
			</#if><#--if methodName != "Delete"-->
		</#if><#---<#if public.hasPublicOutputDataArgumentsByComponent(methodName, c.componentName)-->

		<#if methodName == "Change">
		if bl.${c.componentName}.actionType <> "delete" then 
		</#if>
		if i.processingOrder = TOP_DOWN then
			<#if (listOfPublicSubComponents?size!=0)>
			Lower.${c.componentName}Node = xmlGetFirstChild(sv.${c.componentName}Node)
			CONTINUEIFNOK(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				"${names.businessInterfaceName}", "${c.componentName}", false,
				Move.Node.To.Component.Under.${c.componentName}(
				Lower.${c.componentName}Node))
			</#if><#--if (listOfPublicSubComponents?size!=0)-->
			if not bl.skipComponent then
				<#if !public.hasPublicOutputArguments(methodName)>
					<#list listOfPublicSubComponents as s>
			    RETIFNOK5(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				 "${names.businessInterfaceName}", "${s.componentName}", false,
				Handle.Request.${methodName}.${s.componentName}(
				  	Lower.${c.componentName}Node,
					${s.componentName}.cancel,
					io_${methodName}.ResponseArgument, 
					io_${methodName}.ResultArgument,
					${public.processingOrder(methodImplementation)}))
					</#list><#--list listOfPublicSubComponents as s-->
				<#else><#--if !public.hasPublicOutputArguments(methodName)-->
					<#assign notInitialized = true>
					<#list listOfPublicSubComponents as s>
						<#if notInitialized>
				tmp.node = xmlNewNode("TempNode")
							<#assign notInitialized = false>
						</#if>
			    RETIFNOK5(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				 "${names.businessInterfaceName}", "${s.componentName}", false,
				Handle.Request.${methodName}.${s.componentName}(
				  	Lower.${c.componentName}Node,
					tmp.node,
					${s.componentName}.cancel,
					io_${methodName}.ResponseArgument, 
					io_${methodName}.ResultArgument,
					${public.processingOrder(methodImplementation)}))
						<@public.generateAnchorReplacement iComponentName=c.componentName iSubComponentName=s.componentName/>
					</#list><#--list listOfPublicSubComponents as s-->
					<#if !notInitialized>
				ret = xmlDelete(tmp.node)
					</#if>
				</#if><#--if !public.hasPublicOutputArguments(methodName)-->
			endif
		endif
		<#if methodName == "Change">
		endif 
			<#if c.componentName != names.businessInterfaceName>
		on case bl.${c.componentName}.actionType
		case "create":
			if not bl.skipComponent then
			    CONTINUEIFNOK_WITH_RETRY(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				"${names.businessInterfaceName}", "${c.componentName}", false,
			<@names.ST_DLLCode/>.after.execute.${c.componentName}.Create())
			endif
			break
		<#if methodName=="Change" && c.componentName != names.businessInterfaceName>
		case "change":
			if not bl.skipComponent then
			    CONTINUEIFNOK_WITH_RETRY(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				"${names.businessInterfaceName}", "${c.componentName}", false,
				<@names.ST_DLLCode/>.after.execute.${c.componentName}.${methodName}())
			endif
			break
		</#if><#--if methodName=="Change" && c.componentName != names.businessInterfaceName-->
		case "delete":
			if not bl.skipComponent then
			    CONTINUEIFNOK_WITH_RETRY(${methodName},
				io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
				"${names.businessInterfaceName}", "${c.componentName}", false,
				<@names.ST_DLLCode/>.after.execute.${c.componentName}.Delete())
			endif
			break
		endcase
			</#if><#--if c.componentName != names.businessInterfaceName-->
		</#if><#--if methodName=="Change"-->

		<#if methodName!="Change" || c.componentName == names.businessInterfaceName>
		if not bl.skipComponent then
		    CONTINUEIFNOK_WITH_RETRY(${methodName},
			io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
			"${names.businessInterfaceName}", "${c.componentName}", false,
			<@names.ST_DLLCode/>.after.execute.${c.componentName}.${methodName}())
		endif
		</#if><#--if methodName!="Change" || c.componentName == names.businessInterfaceName-->
			
		<#if c.componentName != names.businessInterfaceName>
		if io.${c.componentName}Node <> 0 then
			RETIFNOK4(xmlGetName(io.${c.componentName}Node, Request.Name))
		endif
	endwhile
		</#if><#--if c.componentName != names.businessInterfaceName-->
	return(0)
}
	</#if><#--if methodExists-->

	<#-- Function is only being used for multi component BDEs -->
	<#if methodName=="Delete" && common.bdeHasMoreThanOneComponent()>
		<#if public.hasPublicInputDataArgumentsByComponent(methodName, c.componentName)>
	<#-- generate this function for each component due to component specific coding sections -->
function long Build.requestNode.for.Delete.${c.componentName}(
			ref xmlnode i.${c.componentName}Node,
			ref xmlnode o.${c.componentName}Node)
{
	xmlnode	RequestNode, ControlNode, SelectionNode, DataArea, selattr, CNode
	xmlnode ResponseNode, sv.Result
	xmlnode sv.Request, sv.Response
	xmlnode ResultNode
	long	ret
	string	Data(20)

			<#assign actual_object=object>
			<#list object.businessInterfaceDefinition.idref.method as method>
				<#if method.name=="Show">
					<#list protected.listProtectedComponents() as c>
						<#if c.componentName == names.businessInterfaceName>
							<#list c.componentImplementation.methodImplementation as cm>
								<#if cm.name=="Show" &&
							     cm.alternativeBusinessInterfaceImplementation?exists>
									<#assign actual_object=cm.alternativeBusinessInterfaceImplementation.idref>
									<#break>
								</#if>
							</#list>
						</#if>
					</#list>
				</#if>
			</#list>
	
	RequestNode = xmlNewNode("ShowRequest",XML_ELEMENT, 0)
	ControlNode = xmlNewNode("ControlArea", XML_ELEMENT, RequestNode)
	SelectionNode = xmlNewNode("Selection", XML_ELEMENT, ControlNode)
			<#list public.listPublicComponents("Show", actual_object) as cs>
				<#list public.listIdentifiers("Show", cs.componentName, actual_object) as a>
					<#if a.componentName == cs.componentName>
	ret = xmlNewDataElement("selectionAttribute", "${a.componentPublicName}.${a.selectionPath}", SelectionNode)
					</#if>
				</#list><#--list public.listIdentifiers("Show", cs.componentName) as a-->
			</#list><#--list public.listPublicComponents("Show") as cs-->
	DataArea = xmlNewNode("DataArea", XML_ELEMENT, RequestNode)
	ret = xmlDuplicateAndAppendToChilds(DataArea, i.${c.componentName}Node)

	ResponseNode = 0
	ResultNode = 0
	sv.Result = bl.resultArgument
	sv.Request = bl.requestArgument
	sv.Response = bl.responseArgument
	bl.result = <@names.SB_DLLCode/>.Show(RequestNode,
					ResponseNode, ResultNode)
	if bl.result <> 0 then
		if bl.processingScope = BUS_ENT
		   or bl.processingScope = BUS_ENT_CMP
		then
			db.set.child.transaction(0)
		endif
			ret = xmlInsertInChilds(sv.Result, xmlGetFirstChild(ResultNode), xmlGetLastChild(ResultNode))
			ret = xmlDelete(RequestNode)
			ret = xmlDelete(ResponseNode)
			ret = xmlDelete(ResultNode)
			return(bl.result)
	endif
	
	ret = xmlDelete(RequestNode)
	|* Convert Response Node.
	o.${c.componentName}Node = xmlDuplicate(xmlGetFirstChild(xmlGetFirstChild(ResponseNode)))
	ret = xmlDelete(ResponseNode)
	ret = xmlDelete(ResultNode)
	|* Set action types...
	bl.resultArgument = sv.Result
	bl.requestArgument = sv.Request
	bl.responseArgument = sv.Response
	ret = xmlSetAttribute(o.${c.componentName}Node, "actionType", "unchanged")
	
			<@public.resetListPublicAttributes/>
			<#list public.listPublicComponents("Show", actual_object) as cs>
				<#if cs.componentName != names.businessInterfaceName>
	selattr = xmlFindNodes(o.${c.componentName}Node, "${cs.componentPublicName}",0)
	CNode = xmlGetFirstChild(selattr)
	while CNode <> 0
		Data = ""
		ret = xmlGetData(CNode, Data)
		ret = xmlSetAttribute(lval(Data), "actionType", "delete")
		CNode = xmlGetRightSibling(CNode)
	endwhile
				</#if>
			</#list><#--list public.listPublicComponents("Show") as cs-->
	return (0)
}

		</#if><#--if public.hasPublicInputDataArgumentsByComponent(methodName, c.componentName)-->
	</#if><#--if methodName=="Delete" && common.bdeHasMoreThanOneComponent-->
	<#if public.hasPublicInputDataArgumentsByComponent(methodName, c.componentName)>
<@source.performance_point description=methodName+".handle.input."+c.componentName/>
function long ${methodName}.handle.input.${c.componentName}(
		const xmlNode i.Node)
{
	string	value(1024)
	boolean tagfound
	xmlNode	TNode
	<#if public.hasPublicInputTextArgumentsByComponent(methodName, c.componentName)>
	long	TextNumber
	long	ret
	</#if><#--if hasPublicInputTextArgumentsByComponent(methodName, c.componentName)-->	
	<#assign AttributeList=[]>

	TNode = 0
	<#if c.componentName!=names.businessInterfaceName>
	<#list common.listRelationshipDetails(c.parentComponentImplementation, c.relationshipImplementation) as rd>
		<#assign datatype=common.getDatatype(rd.fromAttributeImplementation)>
	domain ${common.getDatatypeName(datatype)} ${rd.fromComponentName}.${rd.fromAttributeName}.value
	RETIFNOK(<@names.ST_DLLCode/>.get.${rd.fromComponentName}.${rd.fromAttributeName}(
			${rd.fromComponentName}.${rd.fromAttributeName}.value))
		<#assign AttributeList=AttributeList+[{
			"componentImplementation":rd.toComponentImplementation, 
			"componentName":rd.toComponentName,
			"attributeImplementation":rd.toAttributeImplementation,
			"attributeName":rd.toAttributeName
		}]>
	RETIFNOK(<@names.ST_DLLCode/>.set.${rd.toComponentName}.${rd.toAttributeName}(
			${rd.fromComponentName}.${rd.fromAttributeName}.value))
	</#list><#--list common.listRelationshipDetails(c.parentComponentImplementation, c.relationshipImplementation) as rd-->
	</#if><#-- c.componentName!=names.businessInterfaceName-->
	
<#-- Processing of qualifiers linked to attribute group-->
	<#list public.listPublicAttributeGroups(c.componentImplementation.component.idref) as ag>
		<#if ag.attributeIdref.type == "group">
			<#list ag.attributeIdref.attributeRelationship as ar>
				<#if ar.attribute.idref.type == "qualifier">
					<#assign validQualifier=false>
					<#list public.listPublicInputAttributes(methodName, c.componentName) as qa>
						<#if ar.attribute.idref.name==qa.attributeName>
							<#assign validQualifier=true>
							<#break>
						</#if>
					</#list>
					<#if validQualifier>
	RETIFNOK(getAttributeValue(i.Node, 
		"${c.componentName}.${ag.selectionPath}",
		"<${c.componentName}>.${ag.path}", "${public.getAttributeAlias(c.componentImplementation.component.idref, ar)}", ${ag.attributeIdref.isMandatory?string("TRUE","FALSE")}, value, tagfound))
	if tagfound then
		RETIFNOK(<@names.SB_DLLCode/>.set.${c.componentName}.${ar.attribute.idref.name}.Mapper(value))
	endif
					</#if>
				</#if><#--ar.attribute.idref.type == "qualifier"-->
			</#list><#--a.attributeRelationship as ar-->
		</#if><#--ag.attributeIdref.type == "group"-->
	</#list><#--public.listPublicAttributeGroups(c.componentImplementation.component.idref) as ag-->	
	<#list public.listPublicInputAttributes(methodName, c.componentName) as a>
		<#if a.attributeImplementation.type!="association">			
			<#assign AttributeList=AttributeList+[{
				"componentImplementation":a.componentImplementation, 
				"componentName":a.componentName,
				"attributeImplementation":a.attributeImplementation,
				"attributeName":a.attributeName,
				"attributeRelationship":a.attributeRelationship,
				"attributeType":a.attributeType
			}]>
			<#if !common.isTextDatatype(common.getDatatypeFromAttributeImplementation(a.attributeImplementation))>		
				<#if a.attributeType!="qualifier">
					<#if common.getMandatoryDatatype(a.attributeImplementation).dimensions?exists>
	RETIFNOK(${methodName}.input.${a.attributeName}(i.Node))
					<#else>	
	RETIFNOK(getValue(i.Node,
			"${c.componentPublicName}.${a.selectionPath}",   
			"<${c.componentPublicName}>.${a.path}", ${a.isMandatory?string("TRUE","FALSE")}, value, tagfound))
	if tagfound then
						<#if common.isAnyType(a.attributeImplementation)>
		TNode = GETSUBNODE(i.Node, "<${c.componentPublicName}>.${a.path}")
		if TNode <> 0 then
			| AnyType maps onto a XML
			RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${a.attributeName}.Mapper(str$(TNode)))
		endif
						<#else>
		RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${a.attributeName}.Mapper(value))
						</#if>
						<#list a.attributeRelationship as ar>
							<#if ar.attribute.idref.type == "qualifier">
								<#assign validQualifier=false>
								<#list public.listPublicInputAttributes(methodName, c.componentName) as qa>
									<#if ar.attribute.idref.name==qa.attributeName>
										<#assign validQualifier=true>
										<#break>
									</#if>
								</#list>
								<#if validQualifier>
									<#if !common.getIsReadOnly(ar.attribute.idref)>
			RETIFNOK(getAttributeValue(i.Node,
				"${c.componentPublicName}.${a.selectionPath}",
				"<${c.componentPublicName}>.${a.path}", "${public.getAttributeAlias(c.componentImplementation.component.idref, ar)}", ${ar.attribute.idref.isMandatory?string("TRUE","FALSE")}, value, tagfound))
			if tagfound then
				RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${ar.attribute.idref.name}.Mapper(value))
			endif
									</#if>
								</#if>
							</#if><#--ar.attribute.idref.type == "qualifier"-->
						</#list><#--a.attributeRelationship as ar-->
						<#if methodName=="Create">
							<#if a.defaultVal.present>
	else
		|* Default value
		|CHECK1
		<#if a.defaultVal.value?starts_with("\"")>
			RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${a.attributeName}.Mapper(${a.defaultVal.value}))
		<#else>
			RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${a.attributeName}.Mapper("${a.defaultVal.value}"))
		</#if>
							</#if>
						</#if>
	endif			
					</#if>	
				</#if><#--a.attributeType!="qualifier"-->				
			<#else><#-- if!common.isTextDatatype(common.getDatatypeFromAttributeImplementation(a.attributeImplementation))-->
				<#if common.getMandatoryDatatype(a.attributeImplementation).dimensions?exists>
	RETIFNOK(${methodName}.input.${a.attributeName}(i.Node))
				<#else>
	RETIFNOK(getValue(i.Node,
			"${c.componentPublicName}.${a.selectionPath}",   
			"<${c.componentPublicName}>.${a.path}", ${a.isMandatory?string("TRUE","FALSE")}, value, tagfound))
	if tagfound then
		TNode = GETSUBNODE(i.Node, "<${c.componentPublicName}>.${a.path}")
		if TNode <> 0 then
				<#if common.isAnyType(a.attributeImplementation)>
		| AnyType maps onto a XML
		RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${a.attributeName}.Mapper(TNode))
				<#else>
		| maps onto a TEXT. So convert to TEXT		
		SET_RETRY_POINT_BUS_ENT_CMP()<#--RETRY-->
		ret = tlbct.dll1000.xmlimage.convert.xml.to.text(TNode, TextNumber)
		COMMIT_BUS_ENT_CMP()<#--RETRY-->
		RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${a.attributeName}.Mapper(str$(TextNumber)))
				</#if>
		endif
	endif
				</#if>
			</#if><#-- if common.isTextDatatype(common.getDatatypeFromAttributeImplementation(a.attributeImplementation)) -->
		</#if><#--if attributeImplementation.type!="association"-->
	</#list><#--list public.listPublicInputAttributes(methodName, c.componentName) as a-->
	return(0)
}
	
	</#if> <#-- if public.hasPublicInputDataArgumentsByComponent(methodName, c.componentName) -->
<#if public.hasPublicInputDataArgumentsByComponent(methodName, c.componentName)>
	<#list public.listPublicInputAttributes(methodName, c.componentName) as a>
		<#if a.attributeImplementation.type!="association">			
			<#assign AttributeList=AttributeList+[{
				"componentImplementation":a.componentImplementation, 
				"componentName":a.componentName,
				"attributeImplementation":a.attributeImplementation, 
				"attributeName":a.attributeName,
				"attributeRelationship":a.attributeRelationship,
				"attributeType":a.attributeType
			}]>
			<#assign dimensions=common.getDimensionsForDataType(common.getMandatoryDatatype(a.attributeImplementation))/>
			<#if (dimensions?number > 1)>
function long ${methodName}.input.${a.attributeName}(const xmlNode i.Node)
{
|---------------------------------------------------------------
| Usage repeatable fields
| - Specify sequence YES:
|   <attributeNAME sequence="[ELEMENT]">[VALUE]</attributeNAME>
| - Specify sequence NO (include ALL elements):
|   <attributeNAME>[VALUE]</attributeNAME>|
| Mix NOT allowed.
|--------------------------------------------------------------- 
	boolean	meth1.selected
	boolean	meth2.selected
	long	xml1, xml2, xml3, ret
	long	counter, element
	<#assign datatype = common.get_BaanDatatype_from_XMLSchemaDatatype(common.getDatatype(a.attributeImplementation))>
	<#if datatype != "DB.TEXT" && !common.isAnyType(a.attributeImplementation)>
	string	value(1024), Data(20)
	<#else>
	string	Data(20)
	</#if>
	string	tmp.array(1024, ${dimensions})
	boolean	tmp.arrayIsSet(${dimensions})
	long	i
	<#if datatype == "DB.TEXT">
	long	TextNumber
	</#if>

	for i = 1 to ${dimensions}
	<#switch datatype>
	  	<#case "DB.LONG">
	  	<#case "DB.DATE">
	  	<#case "DB.TIME">
	  	<#case "DB.TEXT">
		tmp.array(1, i) = "0"
			<#break>	  	
	  	<#case "DB.DOUBLE">
		tmp.array(1, i) = "0.0"
			<#break>	  	
	  	<#case "DB.STRING">
		tmp.array(1, i) = ""
			<#break>	  	
	  	<#case "DB.ENUM">
		tmp.array(1, i) = "empty"
			<#break>	  	
	</#switch>
		tmp.arrayIsSet(i) = false
	endfor	
	
	counter = 0			
	element = 0
	meth1.selected = false
	meth2.selected = false		

	xml1 = xmlFindMatch("<${c.componentPublicName}>.${a.path}", i.Node)
	xml2 = xmlGetFirstChild(xml1)
	while xml2 <> 0
		Data = ""
		ret = xmlGetData(xml2, Data)
		xml3 = lval(Data)
		Data = ""
		ret = xmlGetAttribute(xml3, "sequence", Data)
		if isspace(Data) then
			element = element + 1
			meth1.selected = true
		else
			element = lval(Data)
			meth2.selected = true
		endif
		counter = counter + 1
		if meth1.selected and meth2.selected then
			dal.set.error.message("tlbctsb0040", "${a.componentName}.${a.attributeName}")
			|* Repeatable attribute '%1$s' contains a mixed up approach of defining the different elements.
			return(DALHOOKERROR)
		endif
		if element <= 0 or 
		   element > ${dimensions?number} or 
		   counter > ${dimensions?number} then
			ret = xmldelete(xml1)
			xml1 = 0
			xml2 = 0
			xml3 = 0
			dal.set.error.message("tlbctsb0039", "${a.componentName}.${a.attributeName}")
			|* For repeatable attribute '%1$s' the number of element(s) is not according to the datatype.
			return(DALHOOKERROR)
		endif

		<#if datatype != "DB.TEXT">
			<#if common.isAnyType(a.attributeImplementation)>
		| AnyType maps onto a XML
		tmp.array(1, element) = str$(xml3)
		tmp.arrayIsSet(element) = true
			<#else>
		ret = xmlGetData(xml3, value)
		if ret <> 0 then
			tmp.array(1, element) = value
			tmp.arrayIsSet(element) = true
		endif
			</#if>
		<#else>
		| maps onto a TEXT. So convert to TEXT		
		SET_RETRY_POINT_BUS_ENT_CMP()<#--RETRY-->
		ret = tlbct.dll1000.xmlimage.convert.xml.to.text(xml3, TextNumber)
		COMMIT_BUS_ENT_CMP()<#--RETRY-->
		tmp.array(1, element) = str$(TextNumber)
		tmp.arrayIsSet(element) = true
		</#if>
		xml2 = xmlGetRightSibling(xml2)
	endwhile
	RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${a.attributeName}.Mapper(tmp.array, tmp.arrayIsSet))
	ret = xmldelete(xml1)
	xml1 = 0
	xml2 = 0
	xml3 = 0

	return (0)
}

		</#if><#--a.attributeImplementation.datatype.idref.dimensions?exists--> 
		</#if><#--if a.attributeImplementation.type!="association"-->	
	</#list><#--#list public.listPublicInputAttributes(methodName, c.componentName) as a-->	
</#if><#-- if public.hasPublicInputDataArgumentsByComponent(methodName, c.componentName) -->
	<#if public.hasPublicOutputDataArgumentsByComponent(methodName, c.componentName)>

<@source.performance_point description=methodName+".handle.output."+c.componentName/>
function long ${methodName}.handle.output.${c.componentName}(
		const	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

		<#assign hasTextNode = public.hasPublicOutputTextArgumentsByComponent(methodName, c.componentName)>
		<#if hasTextNode>
	xmlnode	text.Node
		</#if><#--if hasTextNode-->

	ret = 0
	<#-- used in macro create_output -->
	g.node = 0
		<#if hasTextNode>
	text.Node = 0
		</#if><#--if hasTextNode-->
		<#if c.componentName == names.businessInterfaceName>
	o.Node = i.Node
		<#else><#--if c.componentName == names.businessInterfaceName-->
	if o.Node = 0 then
		NEW.NODE("${c.componentPublicName}", i.Node, o.Node)
	endif
		</#if><#--if c.componentName == names.businessInterfaceName-->

	<#assign attrList="">
	<#assign level=0>
	<#assign attributeCounter = 0>
	<#assign functionCounter = 0>
	<@generate_component_anchors iMethodName=methodName iLocation="before" iComponent=c.componentImplementation.component.idref/>
	<#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>
	<#if object.businessInterfaceDefinition.idref.type!="bod" && (methodName == "List" || methodName == "Show")>
	return( ${methodName}.handle.output.${c.componentName}_${functionCounter}(i.suppressNillableAttributes, o.Node) )
	<#else>
	return( ${methodName}.handle.output.${c.componentName}_${functionCounter}(o.Node) )
	</#if>
}

function long ${methodName}.handle.output.${c.componentName}_${functionCounter}(
	<#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 hasTextNode>
	xmlnode	text.Node
				</#if><#--if hasTextNode-->

	ret = 0
	g.node = 0
				<#if hasTextNode>
	text.Node = 0
				</#if><#--if hasTextNode-->

			</#if><#--if 100 < attributeCounter-->
<@create_output iattr=attr comp=c.componentImplementation.component.idref compName=c.componentName methodName=methodName isQuery=false/>
		</#if>
	</#list>
<#--#cust.sn-->
	<#if componentHasCustomerDataLocation && methodImplementation.processingOrder != "batch" &&
		public.hasCustomerDataLocation(c.componentImplementation.component.idref)>
	RETIFNOK(${c.componentName}.add.custom.output.if.any(o.node))
	</#if>
<#--#cust.en-->

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

	return(0)
}

	</#if><#--if public.hasPublicOutputArguments(methodName)-->
	<#--/#if> <#--if c.componentName!=names.businessInterfaceName-->
</#list><#--list methodComponents as c-->
<#if methodName=="Change">
	<#if generateCheckActionTypeConsistency>
function long 	check.actionType.consistency(
		const	string	i.Parent.actionType,
		const	string	i.Child.actionType)
{
|* ,------------------------------------------------------------------------.
|* | Child          | Parent                                                |
|* |----------------+-------------------------------------------------------|
|* |                | create | createOrChange | change | delete | unchanged |
|* |----------------+--------+----------------+--------+--------+-----------|
|* | create         |   Y    |        Y       |    Y   |    N   |     Y     |
|* | createOrChange |   N    |        Y       |    Y   |    N   |     Y     |
|* | change         |   N    |        N       |    Y   |    N   |     Y     |
|* | delete         |   N    |        N       |    Y   |    Y   |     Y     |
|* | unchanged      |   N    |        N       |    Y   |    N   |     Y     |
|* `------------------------------------------------------------------------'

	if ( i.Parent.actionType = "create" and i.Child.actionType = "create" ) or
	   ( i.Parent.actionType = "createOrChange" and (i.Child.actionType = "create" or i.Child.actionType = "createOrChange") ) or
	     i.Parent.actionType = "change" or
	   ( i.Parent.actionType = "delete" and i.Child.actionType = "delete" ) or
	     i.Parent.actionType = "unchanged" then
		return (0)
	endif
	dal.set.error.message("tlbctsb0008", i.Parent.actionType,
			i.Child.actionType)

	|* Method Change: inconsistent action types (Parent=%1$s; Child=%2$s)

	return (DALHOOKERROR)
}
	</#if><#--if generateCheckActionTypeConsistency-->

	<#list public.listPublicComponents(methodName) as c>
		<#assign attributeImplementation=common.getAttributeImplementationActionType(methodImplementation, c.componentImplementation)/>
		<#if attributeImplementation!="">
function long 	check.actionType.${c.componentName}(
		const	string	i.actionType)
{
			<#assign datatype=common.getDatatype(attributeImplementation)/>
		  	<#if common.hasEnumerations(datatype)>
	on case i.actionType
				<#list datatype.facet as facet>
					<#if common.isStandardActionType(facet.value)>
	case "${facet.value}":
					</#if>
		  		</#list>
		break
	default:	
		dal.set.error.message("tlbctsb0043", "${c.componentName}",
				i.actionType)
		|* Method Change: disabled or non-standard action type used for 
		|* component (Component=%1$s, ActionType=%2$s)
		return (DALHOOKERROR)		
	endcase
			<#else>
	| No enumeration defined for actionType, Ok
			</#if><#-- common.hasEnumerations(datatype) -->

	return(0)
}

		</#if><#-- attribute != "" -->
	</#list><#--list public.listPublicComponents(methodName) as c-->
</#if><#--if methodName=="Change"-->
</#if><#-- if methodName!="List" && methodName!="Show" && methodName!="SupportsProcessingScope" && 
	     methodName!="SupportsReferentialIntegrity" && methodName!="SubscribeEvent" && 
	     methodName!="UnSubscribeEvent" && methodName!="PublishEvent" && methodName!="OnEvent" &&
	     methodName!="SubscribeList" &&
	     methodImplementation.processingOrder != "batch" &&
	     protected.hasMethodAlternativeImplementation(methodName)==""-->
</#list><#--list object.methodImplementation as methodImplementation-->

<#assign ComponentList=[]>
<#list object.methodImplementation as methodImplementation>
	<#assign methodName=common.getNameFromMethodImplementation(methodImplementation)>
	<#if methodName!="List" && methodName!="Show" && methodName!="SupportsProcessingScope" && 
	     methodName!="SupportsReferentialIntegrity" && methodName!="SubscribeEvent" && 
	     methodName!="UnSubscribeEvent" && methodName!="PublishEvent" && 
	     methodName!="OnEvent" &&
	     protected.hasMethodAlternativeImplementation(methodName)=="">
	<#list public.listPublicComponents(methodName) as c>
		<#assign listOfPublicSubComponents = public.listPublicSubComponentsFromStructure(publicSubComponentsStructure, methodName, c.componentName)>
		<#if (listOfPublicSubComponents?size!=0)>
			<#-- Check if component already handled -->
			<#assign compToDo=true>
				<#list ComponentList as cl>
				<#if c.componentName == cl.componentName>
					<#assign compToDo=false>
				</#if>
			</#list>
			<#if compToDo>
					<#assign ComponentList=ComponentList+[{
						"componentName":c.componentName
					}]>
| Global variables to apply recursion in Find.SubNode.${c.componentName}()
long	node.arr.${c.componentName}(50)
long	node.arr.${c.componentName}.elt
long	fsn.${c.componentName}.candidate.node
long	fsn.${c.componentName}.sub.node
string	fsn.${c.componentName}.Node.Name(${common.AttrLen()})

function long Move.Node.To.Component.Under.${c.componentName}(
		ref xmlNode	io.node)
{
	string	Node.Name(${common.AttrLen()})
	long	candidate.node

	candidate.node = io.node
	if candidate.node <> 0 then
		RETIFNOK4(xmlGetName(candidate.node, Node.Name))
	endif
	while candidate.node <> 0
				<#list listOfPublicSubComponents as s>
	      and Node.Name <> "${s.componentPublicName}"
				</#list><#--list listOfPublicSubComponents as s-->
		candidate.node = xmlGetRightSibling(candidate.node)
		if candidate.node <> 0 then
			RETIFNOK4(xmlGetName(candidate.node, Node.Name))
		endif
	endwhile
	if candidate.node = 0 then
		node.arr.${c.componentName}.elt = node.arr.${c.componentName}.elt + 1
		node.arr.${c.componentName}(node.arr.${c.componentName}.elt) = io.node
		candidate.node = Find.SubNode.${c.componentName}()
		node.arr.${c.componentName}.elt = node.arr.${c.componentName}.elt - 1
	endif
	io.node = candidate.node
	return(0)
}

function long Find.SubNode.${c.componentName}()
{
	fsn.${c.componentName}.candidate.node = xmlGetFirstChild(node.arr.${c.componentName}(node.arr.${c.componentName}.elt))
	if fsn.${c.componentName}.candidate.node <> 0 then
		fsn.${c.componentName}.Node.Name = xmlName$(fsn.${c.componentName}.candidate.node)
	endif
	while fsn.${c.componentName}.candidate.node <> 0
			<#list listOfPublicSubComponents as s>
    	  and fsn.${c.componentName}.Node.Name <> "${s.componentPublicName}"
			</#list><#--list listOfPublicSubComponents as s-->
		node.arr.${c.componentName}.elt = node.arr.${c.componentName}.elt + 1
		node.arr.${c.componentName}(node.arr.${c.componentName}.elt) = fsn.${c.componentName}.candidate.node
		fsn.${c.componentName}.sub.node = Find.SubNode.${c.componentName}()
		fsn.${c.componentName}.candidate.node = node.arr.${c.componentName}(node.arr.${c.componentName}.elt)
		node.arr.${c.componentName}.elt = node.arr.${c.componentName}.elt - 1
		if fsn.${c.componentName}.sub.node <> 0 then
			return(fsn.${c.componentName}.sub.node)
		endif
		fsn.${c.componentName}.candidate.node = xmlGetRightSibling(fsn.${c.componentName}.candidate.node)
		if fsn.${c.componentName}.candidate.node <> 0 then
			fsn.${c.componentName}.Node.Name = xmlName$(fsn.${c.componentName}.candidate.node)
		endif
	endwhile
	
	return(fsn.${c.componentName}.candidate.node)
}
			</#if>
	
		</#if><#--if (listOfPublicSubComponents?size!=0)-->
	</#list>
	</#if><#--if methodName!="List" && methodName!="Show" && methodName!="SupportsProcessingScope" && methodName!="SupportsReferentialIntegrity" && methodName!="SubscribeEvent" && methodName!="UnSubscribeEvent" && methodName!="PublishEvent" && methodName!="OnEvent"-->
</#list><#--list public.listPublicComponents(methodName) as c-->
<@source.performance_point description="SupportsReferentialIntegrity"/>

|*************************** External Hidden Methods *******************************
function extern long <@names.SB_DLLCode/>.SupportsReferentialIntegrity(
					const xmlnode i.RequestArgument,
					ref xmlnode o.ResponseArgument,
					ref xmlnode o.ResultArgument)
{
	DllUsage
	The SupportsReferentialIntegrity function returns information about
	whether the BDE supports the CreateRef and DeleteRef methods.
	Note that the request for this method does not contain any elements.
	Therefore it is not required to read the RequestArgument.
	However, to keep this function similar to the other methods, the same
	function interface has been adopted.
	EndDllUsage

	long	ret
	long	ControlArea
	boolean	ReferentialIntegrityIsSupported

	CHECK_TOOLS_VERSION(o.ResponseArgument, o.ResultArgument)
	
	|* The response consist of a ControlArea and a "supported" element which
	|* contains either a false or a true value.
	RETIFNOK2(createResultObject(o.ResultArgument))
	RETIFNOK2(createResponseObject.WithoutDataArea(
			o.ResponseArgument,
			"SupportsReferentialIntegrity"))

	|* Create a ControlArea to hold the "supported" element
	NEW.NODE("ControlArea", o.ResponseArgument, ControlArea)

	|* Determine whether referential integrity is supported by calling the
	|* appropriate protected method.
	ReferentialIntegrityIsSupported =
		<@names.ST_DLLCode/>.supports.referential.integrity()

	|* Store the information in the "supported" element
	ret = xmlRewriteDataElement(ControlArea,
			"supported",
			ReferentialIntegrityIsSupported ? "true" : "false")

	|* When this point is reached, no errosrs have been encountered
	|* and the result can be cleared.
	ret = xmlDelete(o.ResultArgument)
	o.ResultArgument = 0
	return(0)	| All went well
}

<#if common.queryMethodPresent() && !AFSComponentPresent>
|*************************** List/Show Methods *******************************

<#assign addMissingGenerated=false>
<#list object.methodImplementation as methodImplementation>
	<#assign methodName=common.getNameFromMethodImplementation(methodImplementation)>
	<#if (methodName=="Show" || methodName=="List") &&
	     protected.hasMethodAlternativeImplementation(methodName)=="">
function extern long <@names.SB_DLLCode/>.${methodName}(
					const xmlnode i.RequestArgument,
					ref xmlnode o.ResponseArgument,
					ref xmlnode o.ResultArgument)
{
	DllUsage
	<#if methodName=="Show">
		This method will show -a part- one Business Object as
		requested in the XML Request message.
		Data from the requested object and warnings will be placed in
		the XML response message.
		Errors are put in the XML result message.
	<#else><#--if methodName=="Show"-->
		This method will show a list of Business Objects: 0,1 or more as
		requested in the XML Request message.
		Data from the requested objects and warnings will be placed in
		the XML response message.
		Errors are put in the XML result message.
	</#if><#--if methodName=="Show"-->
	EndDllUsage
	xmlnode	ControlAreaNode
	string  Value(1024)
	boolean	TagFound
<#if object.businessInterfaceDefinition.idref.type!="bod">
	boolean	suppressNillableAttributes
</#if>
	long	retval, ret
	long	sv.time, exec.time

	CHECK_TOOLS_VERSION(o.ResponseArgument, o.ResultArgument)
	
	|* redirect to actual List/Show
	|* Get prefetchConsistentSet (as prepared set) from
	|* the ControlAreaNode Node
	|* Select the ControlArea Node
	ControlAreaNode = xmlFindFirst("ControlArea", i.RequestArgument)
	Value = ""
	RETIFNOK(getValue(ControlAreaNode, 
				"ControlArea.LogQuery",
				"<ControlArea>.<LogQuery>",
				false, Value, TagFound))
				
	if tolower$(strip$(Value)) = "true" or strip$(Value) = "1" then
		log.query = true
	else
		log.query = false
	endif
	Value = ""
	<#if object.businessInterfaceDefinition.idref.type!="bod">
	RETIFNOK(getValue(ControlAreaNode, 
				"ControlArea.SuppressNillable",
				"<ControlArea>.<SuppressNillable>",
				false, Value, TagFound))
	if tolower$(strip$(Value)) = "true" then
		suppressNillableAttributes = true
	else
		suppressNillableAttributes = false
	endif
	Value = ""
	</#if>

	sv.time = mtime()
	retval = (<@names.SB_DLLCode/>.${methodName}_new(
				i.RequestArgument,
	<#if object.businessInterfaceDefinition.idref.type!="bod">
				suppressNillableAttributes,
	</#if>
				o.ResponseArgument,
				o.ResultArgument))
	exec.time = mtime() - sv.time
	Value = ""
	RETIFNOK(getValue(ControlAreaNode, 
				"ControlArea.ShowExecuteTime",
				"<ControlArea>.<ShowExecuteTime>",
				false, Value, TagFound))
				
	if tolower$(strip$(Value)) = "true" or strip$(Value) = "1" and o.ResponseArgument <> 0 then
		ret = xmlsetAttribute(o.ResponseArgument, "ExecuteTime", str$(exec.time))
	endif

	<#if object.businessInterfaceDefinition.idref.type!="bod">
	if not suppressNillableAttributes then
		| Set namespace to allow nillable attributes
		ret = xmlSetAttribute(o.ResponseArgument, "xmlns:xsi" ,
					"http://www.w3.org/2001/XMLSchema-instance")
	endif
	</#if>
	return (retval)
}
 
</#if><#--if (methodName=="Show" || methodName=="List")-->
</#list><#--list object.methodImplementation as methodImplementation-->
<#list object.methodImplementation as methodImplementation>
	<#assign methodName=common.getNameFromMethodImplementation(methodImplementation)>
		<#if (methodName=="Show" || methodName=="List") &&
	     protected.hasMethodAlternativeImplementation(methodName)=="">
function xmlNode ${methodName}.getMetaDataForFilter()
{
	xmlNode	FilterMetaData
	xmlNode	componentNode
	xmlNode	attributeNode
	long	duml
	
	FilterMetaData = xmlNewNode("MetaData", XML_ELEMENT)
			<#list public.listPublicComponents(methodName) as c>
		componentNode = xmlNewNode("Component", XML_ELEMENT, FilterMetaData)
		duml = xmlSetAttribute(componentNode, "name", strip$("${c.componentPublicName}"))
		duml = xmlSetAttribute(componentNode, "parent", strip$("${common.getComponentPublicNameFromName(c.parentComponentName)}"))
				<#list public.listPublicAttributes(methodName, c.componentName) as a>
			attributeNode = xmlNewNode("Attribute", XML_ELEMENT, componentNode)
			duml = xmlSetAttribute(attributeNode, "name", strip$("${a.attributeName}"))
			duml = xmlSetAttribute(attributeNode, "nameSearch", strip$("${a.path}"))
			duml = xmlSetAttribute(attributeNode, "datatype", strip$("${common.get_BaanDatatype_from_XMLSchemaDatatype(common.getDatatypeFromAttributeImplementation(a.attributeImplementation))}"))
				</#list><#-- list public.listPublicAttributes(methodName, c.componentName) as a-->
			</#list><#-- list public.listPublicComponents(methodName) as c -->
	return(FilterMetaData)
}
		</#if><#--if (methodName=="Show" || methodName=="List")-->
	</#list><#--list object.methodImplementation as methodImplementation-->

function boolean must.build.selection.node(xmlnode i.selection)
{
<#--prevent generation of obsolete coding-->
	<#assign found=false>
	<#list protected.listProtectedComponents() as c>
		<#list c.componentImplementation.relationshipImplementation as ri>
			<#if !ri.relationship?has_content>
				<#assign found=true>
				<#break>	
			</#if>
		</#list>
		<#if found=true>
			<#break>
		</#if>
	</#list>
	<#if found>
	long	node
	string	dums(1)

	</#if>
	if i.selection = 0 or xmlGetFirstChild(i.selection) = 0 then
		return(true)
	endif

	<#if found>
	node = xmlGetFirstChild(i.selection)
	while node <> 0
		<#list protected.listProtectedComponents() as c>
			<#list c.componentImplementation.relationshipImplementation as ri>
				<#if !ri.relationship?has_content>
		if tlbct.dll1000.starts.with(xmlData$(node), "${c.componentPublicName}.${ri.name}", dums) then
			return(true)
		endif
				</#if><#-- if !ri.relationship?has_content -->	
			</#list>
		</#list>
		node = xmlGetRightSibling(node)
	endwhile

	</#if>
	return(false)
}

<#--#unused.so--
function void add.Protected.Attr(string i.prot.map(${common.CompAttrLen()}),
				 long i.prot.datatype,
				 string i.prot.domain(14),
				 string i.public.attr(${common.CompAttrLen()}),
				 string i.name(${common.AttrLen()}),
				 string i.comp(${common.CompLen()}),
				 string i.origin(65))
{
	xmlNode	PANode
	long	ret

	bl.AttrProtected.map		= i.prot.map
	bl.AttrProtected.datatype	= i.prot.datatype
	if bl.AttrProtected.datatype = DB.MULTIBYTE then
		bl.AttrProtected.datatype = DB.STRING
	endif
	bl.AttrProtected.domain		= i.prot.domain

	if isspace(i.name) then
		return
	endif

	PANode = xmlNewNode("ProtectedAttribute", XML_ELEMENT, bl.attr.node)

	if isspace(i.origin) then
		ret = xmlSetAttribute(PANode, "Name", strip$(i.name))
	else
		ret = xmlSetAttribute(PANode, "Name", strip$(i.public.attr))
	endif
	ret = xmlSetAttribute(PANode, "Component", strip$(i.comp))
	ret = xmlSetAttribute(PANode, "Origin", strip$(i.origin))
	ret = xmlSetAttribute(PANode, "Map", strip$(bl.AttrProtected.map))
}
<#--#unused.eo-->
</#if><#--if common.queryMethodPresent()-->
<#if common.eventMethodPresent() || common.batchMethodPresent() >
<#-- ****************************** Event/Batch Methods******************************** -->
<#include "public.sb.events.ftl" parse=true />
</#if><#-- common.eventMethodPresent() || common.batchMethodPresent() -->

<#-- Alternative method implementation -->
<#list object.methodImplementation as methodImplementation>
	<#assign methodName=common.getNameFromMethodImplementation(methodImplementation)>
	<#assign alt_BDE=protected.hasMethodAlternativeImplementation(methodName)>
	<#if alt_BDE!="">

function extern long <@names.SB_DLLCode/>.${methodName}(
					const xmlNode i.RequestArgument,
					ref xmlNode o.ResponseArgument,
					ref xmlNode o.ResultArgument)
{
	DllUsage
		<#if (methodName=="CreateRef" || methodName=="DeleteRef")>
		This method will handle one Business Object as
		<#else>
		This method will handle one or more Business Objects as	
		</#if>
		requested in the XML Request message. Output information and
		warnings will be placed in the XML response message.
		Errors are put in the XML result message.
	EndDllUsage

	|* Call :  ${alt_BDE}
	string	BODLLName(100)
	string	BODLLMethod(100)
	xmlnode	newRequest, tmpResponse
	long 	BODLL.id, function.id, ret, retValue, retl

	CHECK_TOOLS_VERSION(o.ResponseArgument, o.ResultArgument)
	
	retl = tlbct.dll1000.BORlookup("${alt_BDE}",
			 "${methodName}", BODLLName, BODLLMethod)
	if retl <> 0 then
		| DAL error message is set in tlbct.dll1000.BORlookup
		handle.messages(o.responseArgument, o.resultArgument, set.in.result(true))
	
		ret = xmlDelete(newRequest)
		return(DALHOOKERROR)
	endif
	
	retl = tlbct.dll1000.replace.bde.name("request",
				"${names.businessInterfaceName}", i.RequestArgument,
				"${alt_BDE}", newRequest)
	if retl <> 0 then
		dal.set.error.message("tlbctsb0049", "${alt_BDE}", "${names.businessInterfaceName}", "Request")
		|* Business Object name %1$s cannot be replaced by %2$s in %3$s.
		handle.messages(o.responseArgument, o.resultArgument, set.in.result(true))
		ret = xmlDelete(newRequest)
		return(DALHOOKERROR)
	endif
	bodll.id = load_dll(tolower$(BODLLName), DLL_SILENT_ERR)
	if bodll.id = 0 then
		dal.set.error.message("tlbctsb0044", "${methodName}", "${names.businessInterfaceName}", -1)
		|* Alternative implementation for method %1$s in business object
		|* %2$s cannot be started (error %3$d).
		handle.messages(o.responseArgument, o.resultArgument, set.in.result(true))
		ret = xmlDelete(newRequest)
		return(DALHOOKERROR)
	endif
		
	function.id = get_function(bodll.id, tolower$(BODLLMethod))
	if function.id = 0 then
		dal.set.error.message("tlbctsb0044", "${methodName}", "${names.businessInterfaceName}", -2)
		|* Alternative implementation for method %1$s in business object
		|* %2$s cannot be started (error %3$d).
		handle.messages(o.responseArgument, o.resultArgument, set.in.result(true))
		ret = xmlDelete(newRequest)
		return(DALHOOKERROR)
	endif

	retl = exec_function(bodll.id, function.id, retValue,
					newRequest, tmpResponse, o.ResultArgument)
	if retl < 0 then
		dal.set.error.message("tlbctsb0044", "${methodName}", "${names.businessInterfaceName}", retl)
		|* Alternative implementation for method %1$s in business object
		|* %2$s cannot be started (error %3$d).
		handle.messages(o.responseArgument, o.resultArgument, set.in.result(true))
		ret = xmlDelete(newRequest)
		return(DALHOOKERROR)
	endif
	if retValue <> 0 then
		| o.resultArgument is filled in alternative business object
		o.responseArgument = 0
		ret = xmlDelete(newRequest)
		return(retValue)
	endif

	retl = tlbct.dll1000.replace.bde.name("response", "${alt_BDE}",
				tmpResponse, "${names.businessInterfaceName}",
				o.ResponseArgument)
	if retl <> 0 then
		dal.set.error.message("tlbctsb0049", "${alt_BDE}", "${names.businessInterfaceName}", "Response")
		|* Business Object name %1$s cannot be replaced by %2$s in %3$s.
		handle.messages(o.responseArgument, o.resultArgument, set.in.result(true))
		ret = xmlDelete(newRequest)
		return(DALHOOKERROR)
	endif

	ret = xmlDelete(newRequest)
	ret = xmlDelete(tmpResponse)
	
	return(0)
}
		<#if names.businessInterfaceName==alt_BDE> -->
${logger.error(object,"Alternative Business Interface Implementation has same name as current one '${alt_BDE}' in method ${methodName}.")}
		</#if>
	</#if>
</#list>

<@source.performance_point description="Before Queries"/>
<#if common.queryMethodPresent() && !AFSComponentPresent>
<@source.performance_point description="Before SB_QUERY"/>
<#include "public.sb.query.ftl" parse=true />
<@source.performance_point description="After SB_QUERY"/>
</#if>

function do.not.use.this.function()
{
| The purpose of this function is to avoid compile warnings on unused global
| variables and unused functions.

	long	duml
	string	dums(1)
	string	dumsa(1,1)
	boolean	dumb
	boolean	dumba(1)
	
	if false then
		do.not.use.this.function()
<#if elementDeclared>
		duml = element
		dumb = bl.skipComponent
<#else>
		duml = 0
</#if>
		dums = bl.current.method
		dumb = false
		dumba(1) = false
		dumsa(1,1) = ""
		
		| generate calls to all Mapper functions
<#list common.listComponentImplementations() as c>
	<#list c.componentImplementation.attributeImplementation as a>
		<#if a.attribute?exists>
			<#assign datatype=common.getDatatype(a)>
			<#assign attributeName=common.getAttributeName(a)>
		duml = <@names.SB_DLLCode/>.get.${c.componentName}.${attributeName}.Mapper(
			<#if datatype.dimensions?exists>
<#--#repeat.so--
				duml, dumsa, dumba)
<#--#repeat.eo-->
<#--#repeat.sn-->
				dumsa, dumba)
<#--#repeat.en-->
			<#else>		
				dums, dumb)
			</#if>
			<#if !common.getIsReadOnly(a)>
		duml = <@names.SB_DLLCode/>.set.${c.componentName}.${attributeName}.Mapper(			
				<#if datatype.dimensions?exists>
				dumsa, dumba)
				<#else>
				dums)
				</#if>
			</#if>
		</#if>
	</#list>
</#list>

		| generate calls to other functions which may not be invoked
		make.xmlArguments.global(duml, duml, duml)
		duml = Handle.retrying.component(dums, dums, dums, duml, duml)
	endif
}

<#--#cust.sn-->
<@source.performance_point description="Customizations"/>
<#assign hasAnyCustomization=false>
<#assign hasAnyCustomInput=false>
<#list common.listComponentImplementations() as c>
	<#assign customerDataLocation=public.getCustomerDataLocation(c.componentImplementation.component.idref)>
	<#if customerDataLocation.name!="">
		<#if !hasAnyCustomization>
			<#assign hasAnyCustomization=true>
|******************* customizations: generated part ***************************

		</#if>
		<#assign hasCustomInput=false>
		<#list object.methodImplementation as methodImplementation>
			<#assign methodName=common.getNameFromMethodImplementation(methodImplementation)>
			<#if methodName=="Create" || methodName=="Change">
				<#if public.protectedComponentMethodPresent(c.componentName, methodName, object)>
					<#if protected.hasMethodAlternativeImplementation(methodName)=="" && methodImplementation.processingOrder != "batch">
						<#assign hasCustomInput=true>
						<#assign hasAnyCustomInput=true>
function long execute.${c.componentName}.${methodName}(
	long	i.component.node)
{
	RETIFNOK(<@names.ST_DLLCode/>.execute.${c.componentName}.${methodName}())
	RETIFNOK(${c.componentName}.process.custom.input.if.any(
					i.component.node))
	return(0) | OK
}

					</#if><#--if protected.hasMethodAlternativeImplementation(methodName)==""-->
				</#if><#--if common.protectedComponentMethodPresent(c.componentName, methodName, object)-->
			</#if><#--if methodName=="Create" || methodName=="Change"-->
		</#list><#--list object.methodImplementation as methodImplementation-->
		<#if hasCustomInput>
function long ${c.componentName}.process.custom.input.if.any(
		long		i.component.node)
{
	long	additional.elements.xml
	long	index.value.xml
	long	customer.data.location.node
	long	retl

	retl = get.additional.elements(
			"<@names.CC_Object/>",
			"<@names.CC_DLLCode/>.get.additional.elements",
			"${public.getPublicPath(c.componentName)}",
			additional.elements.xml)
	if additional.elements.xml <> 0 then
		RETIFNOK(<@names.ST_DLLCode/>.get.${c.componentName}._index1(
			index.value.xml))
		customer.data.location.node = xmlFindFirstMatch("<>.${customerDataLocation.searchString}",
						i.component.node)
		if customer.data.location.node <> 0 then
			RETIFNOK(process.custom.input(
					additional.elements.xml,
					index.value.xml,
					customer.data.location.node))
		endif
	endif

	return(0) | OK
}

		</#if><#--if hasCustomInput-->
function long ${c.componentName}.add.custom.output.if.any(
		long		i.component.node)
{
	long	additional.elements.xml
	long	index.value.xml
	long	customer.data.location.node
	long	retl
	boolean	${c.componentName}.${customerDataLocation.name}.select

	retl = get.additional.elements(
			"<@names.CC_Object/>",
			"<@names.CC_DLLCode/>.get.additional.elements",
			"${public.getPublicPath(c.componentName)}",
			additional.elements.xml)
<#--#custfix.sn-->
	if retl = DALHOOKERROR then
		return(DALHOOKERROR)
	endif
<#--#custfix.en-->
	if retl = 0 and additional.elements.xml <> 0 then
		RETIFNOK(<@names.ST_DLLCode/>.get.${c.componentName}._index1(
			index.value.xml))
		customer.data.location.node = xmlFindFirstMatch("<>.${customerDataLocation.searchString}",
						i.component.node)
		if customer.data.location.node = 0 then
			retl = createGroupNodes(i.component.node,
						"${customerDataLocation.searchString}", "")
			customer.data.location.node = xmlFindFirstMatch("<>.${customerDataLocation.searchString}",
							i.component.node)
		endif
		if customer.data.location.node = 0 then
			dal.set.error.message("@No user area (%s-%d)",
					__FILE__, __LINE__)
			return(DALHOOKERROR)
		endif
		RETIFNOK(add.custom.output(
				additional.elements.xml,
				index.value.xml,
				customer.data.location.node))
		if xmlGetFirstChild(customer.data.location.node) = 0 then
			| nothing in ${customerDataLocation.name}: remove that node 
			retl = xmlDelete(customer.data.location.node)
		endif
	endif

	return(0) | OK
}

	</#if><#--if customerDataLocation.name!=""-->
</#list><#--list common.listComponentImplementations() as c-->
<#if hasAnyCustomization>
function long get.additional.elements(
	const	string	i.object,
	const	string	i.function,
	const	string	i.component.name,
	ref	long	o.additional.elements.xml)
{
	long	retl
	long	retvalue
	
	| Call tlbct.dll1000.get.additional.elements dynamically to avoid a fatal
	| error if no recent version of tlbctdll1000 is used.
	retl = exec_dll_function("otlbctdll1000",
					"tlbct.dll1000.get.additional.elements",
					retvalue,
					i.object,
					i.function,
					i.component.name,
					o.additional.elements.xml)
	if retl <> 0 then
		return(retl)
	endif
	return(retvalue)
}

	<#if hasAnyCustomInput>
function long process.custom.input(
		long	i.additional.elements.xml,
		long	i.index.value.xml,
		long	i.customer.data.location.node)
{
	long	retl
	long	retvalue
	
	| Call tlbct.dll1000.process.custom.input dynamically to avoid a fatal
	| error if no recent version of tlbctdll1000 is used.
	retl = exec_dll_function("otlbctdll1000",
					"tlbct.dll1000.process.custom.input",
					retvalue,
					i.additional.elements.xml,
					i.index.value.xml,
					i.customer.data.location.node)
	if retl <> 0 then
		return(retl)
	endif
	return(retvalue)
}

	</#if><#--if hasAnyCustomInput-->
function long add.custom.output(
		long	i.additional.elements.xml,
		long	i.index.value.xml,
		long	i.customer.data.location.node)
{
	long	retl
	long	retvalue
	
	| Call tlbct.dll1000.add.custom.output dynamically to avoid a fatal
	| error if no recent version of tlbctdll1000 is used.
	retl = exec_dll_function("otlbctdll1000",
					"tlbct.dll1000.add.custom.output",
					retvalue,
					i.additional.elements.xml,
					i.index.value.xml,
					i.customer.data.location.node)
	if retl <> 0 then
		return(retl)
	endif
	return(retvalue)
}

#ifdef CUSTOMIZATION_LIBRARY
|##############################################################################
|################### Customization Library part ###############################
|##############################################################################

| Customization library for the ${names.businessInterfaceName} business object.
| You can use this part to copy it to ${names.packageName}${names.moduleName}bl${names.businessObjectID}cc00.
| and use it as a starting point for the customization library construction.
| This code is escaped with #ifdef CUSTOMIZATION_LIBRARY because it is not part
| of this ${names.packageName}${names.moduleName}bl${names.businessObjectID}sb00 library.

|------------------- DO NOT CHANGE THIS PART ----------------------------------

| Template for <@names.CC_DLLCode/> <#if object.name?has_content>(${object.name})</#if>
| Template generation date: ${today?datetime}

#pragma used dll "otlbctinterface"

#define initialize()
^	retl = tlbctinterface.cust.initialize(o.xml)
^	if retl <> 0 then
^		return(retl)
^	endif

#define addTableField(elementName, tableCode, columnName, dataType)
^	retl = tlbctinterface.cust.add.element(o.xml, elementName,
^					tableCode, columnName, dataType)
^	if retl <> 0 then
^		return(retl)
^	endif

#define addCdfField(elementName, tableCode, cdfName, dataType)
^	addTableField(elementName, tableCode, "cdf_" & cdfName, dataType)

| Use addTableField to include data for a table field as defined in the
| data model. This could be a customer-specific table field, or a table
| field that exists in the standard, but is not yet used in the business object.
| Use addCdfField to include data from a customer-defined field in the
| business object. Customer-defined fields are maintained in the
| Customer-Defined Fields (ttadv4194m000.) session.
|
| The parameters to be used are:
| 1. elementName (string): the name that must be used to identify the
|    element in the business object data XML.
| 2. tableCode (string): the code of the table that contains the custom
|    data to be included.
| 3. columnName or cdfName (string): the name of the table column or
|    customer-defined field. Note that customer-defined fields have a
|    prefix ('cdf_') in the table column name; this prefix must NOT be
|    included in the cdfName.
| 4. dataType (string): the data type of the column or customer-defined
|    field.
|    The following data types can be used:
|    - "String"
|    - "Integer"
|    - "Numeric"
|    - "Date"
|    - "Checkbox"
|
| Some examples:
| addTableField("CustomDate", "ppmmm001", "cdat", "Date")
| addCdfField("CustomNote", "ppmmm001", "note", "String")
| addTableField("CustomAmount", "ppmmm001", "camn", "Numeric")
| addCdfField("NumberOfDeviations", "ppmmm001", "cdev", "Integer")
| addTableField("Checked", "ppmmm001", "cchk", "Checkbox")

|------------------- Custom implementation ------------------------------------

function extern long <@names.CC_DLLCode/>.get.additional.elements(
	const	string	i.component.path,
	ref	long	o.xml)
{
	DllUsage
	Desc:	Define the additional elements (columns) for a component.
	Input:	i.component.path - the component path.
	Output:	o.xml - if return value is = 0: an xml structure containing
                        the details on custom fields (if any)
	Return:	0 (OK) or DALHOOKERROR (one or more DAL error
			messages are set)
	EndDllUsage

	long	retl		| return value to be checked

	initialize() | do not remove this line

	on case i.component.path
	
	<#list common.listComponentImplementations() as c>
		<#if public.hasCustomerDataLocation(c.componentImplementation.component.idref) &&
		    (public.protectedComponentMethodPresent(c.componentName, "Create", object) ||
			public.protectedComponentMethodPresent(c.componentName, "Change", object))>
	case "${public.getPublicPath(c.componentName)}":
		| Custom data element for this component is
		| ${public.getPublicPath(c.componentName)}.${public.getCustomerDataLocation(c.componentImplementation.component.idref).name}.
		| Fill in your customized table fields here.
		| You can use data from one of the following table(s):
		<#list c.componentImplementation.componentImplementationTable as componentImplementationTable>
			<#assign table=componentImplementationTable.table.idref/>
			<#if table.type=="table">
		|   ${table.name}
			</#if><#--if table.type=="table"-->
		</#list><#--list c.componentImplementation.componentImplementationTable as componentImplementationTable-->
		| Custom data from the table(s) will only be used when a corresponding row
		| exists in those tables.
		| For example:
		|addTableField("CustomDate", "ppmmm001", "cdat", "Date")
		|addCdfField("SomeHeaderNotes", "ppmmm001", "cstr", "String")

		break

		</#if><#--if public.hasCustomerDataLocation(c.componentImplementation.component.idref) &&
		    (public.protectedComponentMethodPresent(c.componentName, "Create", object) ||
			public.protectedComponentMethodPresent(c.componentName, "Change", object)) -->
	</#list><#--list common.listComponentImplementations() as c-->
	default:
		| Nothing
	endcase

	return(0) | OK
}
#endif | ifdef CUSTOMIZATION_LIBRARY

</#if><#--if hasAnyCustomization-->
<#--#cust.en-->
<@source.performance_point description="Finish"/>
<@source.endsource/>