<#--
   ******************************************************
   *
   *                       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/>
<@protected.initListProtectedAssociatedAttributes/>
<@protected.initListInternalIdentifiers/>
<@protected.initListProtectedComponents/>
<@protected.initHasMethodAlternativeImplementation/>
<@common.initListComponentImplementations/>
<#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"
	|* 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
	
	#define	ANCHOR_MARKER		"XXXXXX_ANCHOR_"
<#assign SelectionList=[]>
<#assign ListNumber = 0>

<@source.performance_point description="Start"/>
	boolean	bl.keep.child.transaction
<#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-->
<#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 Special Implementation attributes -->
<#assign SpecialSelectionList=[]>
<#list protected.listProtectedComponents() as c>
	<#list c.componentImplementation.component.idref.attribute as a>
		<#if a.isSpecialImplNeeded && !a.isHidden>
			<#assign inSelectionList=false>
			<#list SelectionList as sl>
				<#if sl.component==c.componentName && sl.attribute==a.name>
					<#assign inSelectionList=true>
					<#break>
				</#if>					
			</#list>
			<#if !inSelectionList>
				<#assign SpecialSelectionList=SpecialSelectionList + [{
					"component":c.componentName,
					"attribute":a.name,
					"attributeImplementationName":common.getAttributeName(a)}]>
	boolean ${c.componentName}.${a.name}.select
			</#if>
		</#if>
	</#list>
</#list>
<#if common.queryMethodPresent() && !AFSComponentPresent>

	#define Selection.must.be.filled(...)
^			tlbct.dll1000.Selection.must.be.filled(...)	
</#if>
<#-- 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 -->
<#if Duplicatesfound>

|* Duplicates in model...
	<#list DuplicateComponents as dc>
|* ComponentName : ${dc}
	</#list>
</#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>
<#function isInputAttributeOnly iAttributeName iComponentName iMethodName>
	<#local attributes = public.listPublicAttributes(iMethodName, iComponentName)>
	<#list attributes as a>
		<#if a.attributeName == iAttributeName>
			<#return a.scope == "in">
		</#if>
	</#list>
	<#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>
					<#if !r.component.isHidden>
						<#if public.isPublicSubComponent(iMethodName, iComponent.name, r.component.name)>
							<#assign attributePath=public.getAttributeGroupFromAttribute(iComponent, iAttribute)>
							<#assign parentNode="createGroupNodes(o.Node, \"" + attributePath + "\", \"\")">
	| 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">
				<#if (r.anchorLocation==iLocation || iLocation="both") && r.anchorAttribute?exists && r.anchorAttribute.idref.name == iAttribute.name>
					<#if !r.component.isHidden>
						<#if public.isPublicSubComponent(iMethodName, iComponent.name, r.component.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>
	| 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 userArea=false>
	<#assign addUserArea=false>
	<#assign level=level+1>
	<#if !attrList?contains(":"+iattr.name+":")>
		<#if level==1>
			<#list comp.component.idref.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 aIsSet=false>
		<#list public.listPublicOutputAttributes(methodName, compName) as a1>
			<#if a1.attributeName == iattr.name>
				<#assign a=a1>
				<#assign aIsSet=true>
				<#assign takeIntoAccount=true>
				<#assign defaultVal=a1.defaultVal>
				<#break>
			</#if>
		</#list>
		<#if (iattr.type=="group" || iattr.type == "complex") && !iattr.isSpecialImplNeeded>
			<#assign takeIntoAccount=true>
		</#if>
		<#if userArea && (iattr.name == "UserArea" || iattr.name?ends_with("_UserArea"))>
			<#assign addUserArea=true>
		</#if>
		<#if !takeIntoAccount && !addUserArea>
	|* Attribute ${iattr.name} not in protected output
			<#-- The anchors for this attribute need to be considered nevertheless -->
			<@generate_attribute_anchors iLocation="both" iMethodName=methodName iComponent=comp.component.idref iAttribute=iattr/>
		</#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.component.idref iAttribute=iattr/>
		<#if iattr.type=="group" && iattr.isSpecialImplNeeded>
	|* Special Implementation for ${compName}.${iattr.name}
			<#assign attributeImplementation=common.getAttributeImplementation(comp, iattr.name)>
			<#if attributeImplementation!="">
				<#assign a={
					"componentName":compName,
					"attributeName":attributeImplementation.attribute.idref.name,
					"attributeImplementation":attributeImplementation,
					"path":public.getAttributeGroupFromAttribute(comp.component.idref,attributeImplementation.attribute.idref),
					"alias":public.getAttributeAlias(comp.component.idref,attributeImplementation.attribute.idref),
					"attributeRelationship":attributeImplementation.attribute.idref.attributeRelationship}
				>
			<#else>
	|* No implementation found: nothing generated.
				<#assign takeIntoAccount=false>
			</#if>
			<#assign defaultVal=0>
		<#else>
			<#if !aIsSet>
				<#assign takeIntoAccount=false>
			</#if>
		</#if>
		<#if ((iattr.type!="group" && iattr.type != "qualifier") || (iattr.type=="group" && iattr.isSpecialImplNeeded)) && takeIntoAccount>
		<#-- only attribute -->
			<#assign dimensions=common.getDimensionsForDataType(common.getMandatoryDatatype(a.attributeImplementation))/>
			<#if (dimensions?number != 1)>
				<#if (dimensions?number == 0)>
	string	${a.attributeName}.value(1,1) based
	boolean	${a.attributeName}.valueIsSet(1) based
	long	${a.attributeName}.size
				<#else>
	string	${a.attributeName}.value(1024, ${dimensions})
	boolean	${a.attributeName}.valueIsSet(${dimensions})
				</#if><#--if (dimensions?number == 0)-->
				<#if isQuery>
	if ${a.componentName}.${a.attributeName}.select then
				</#if>
				<#if a.path != "<"+a.alias+">">
${pre_TAB}	g.node = 0
				</#if><#--if a.path != "<"+a.alias+">"-->
${pre_TAB}	RETIFNOK(<@names.SB_DLLCode/>.get.${a.componentName}.${a.attributeName}.Mapper(
				<#if (dimensions?number == 0)>
${pre_TAB}		${a.attributeName}.value, ${a.attributeName}.valueIsSet, ${a.attributeName}.size))
${pre_TAB}	for element = 1 to ${a.attributeName}.size
				<#else>
${pre_TAB}		${a.attributeName}.value, ${a.attributeName}.valueIsSet))
${pre_TAB}	for element = 1 to ${dimensions}
				</#if><#--if (dimensions?number == 0)-->
${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}	|--------------------------------------------------------------
${pre_TAB}		if ${a.attributeName}.valueIsSet(element) then
				<#if a.path != "<"+a.alias+">">
${pre_TAB}			if g.node = 0 then
${pre_TAB}				g.node = createGroupNodes(o.Node, "${a.path}", "${a.alias}")
${pre_TAB}			endif
				</#if><#--if a.path != "<"+a.alias+">"-->
				<#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)
						<#if iattr.type!="group" || !iattr.isSpecialImplNeeded>
							<#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><#--if iattr.type!="group" || !iattr.isSpecialImplNeeded-->
				<#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+">"-->
						<#if iattr.type!="group" || !iattr.isSpecialImplNeeded>
							<#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><#--if iattr.type!="group" || !iattr.isSpecialImplNeeded-->
${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+">"-->
						<#if iattr.type!="group" || !iattr.isSpecialImplNeeded>
							<#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><#--if iattr.type!="group" || !iattr.isSpecialImplNeeded-->
						<#if useNilAttributeForEmptyValues(a.attributeImplementation)>
							<#if methodName == "List" || methodName == "Show">
${pre_TAB}			if not i.suppressNillableAttributes and isspace(${a.attributeName}.value(1,element)) then
							<#else>
${pre_TAB}			if isspace(${a.attributeName}.value(1,element)) then
							</#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 (dimensions?number == 0)>
${pre_TAB}	free.mem(${a.attributeName}.value)
${pre_TAB}	free.mem(${a.attributeName}.valueIsSet)
				</#if><#--if (dimensions?number == 0)-->
				<#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.component.idref, iattr)}", "")
${pre_TAB2}${pre_TAB}		ret = xmlsetAttribute(xmlFindFirst("${public.getAttributeAlias(comp.component.idref, 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.component.idref iAttribute=iattr/>
		<#if !iattr.isSpecialImplNeeded>
			<#list iattr.attributeRelationship as ar>
				<#if ar.attribute.idref.type != "qualifier" && !ar.attribute.idref.isHidden && !isInputAttributeOnly(ar.attribute.idref.name, compName, methodName)>
	|* Reading output for group/attribute ${ar.attribute.value}
<@create_output iattr=ar.attribute.idref comp=comp compName=compName methodName=methodName isQuery=isQuery userArea=userArea/>
				</#if>
				<#if ar.attribute.idref.type != "qualifier" && ar.attribute.idref.isHidden>
					<@create_output_anchors_only iattr=ar.attribute.idref comp=comp.component.idref/>
				</#if>
			</#list>
		</#if><#--if !iattr.isSpecialImplNeeded-->
		<@generate_group_anchors iLocation="after" iMethodName=methodName iComponent=comp.component.idref iAttribute=iattr/>
		<@generate_attribute_anchors iLocation="after" iMethodName=methodName iComponent=comp.component.idref iAttribute=iattr/>
	</#if>
	<#if addUserArea>
	if <@names.ST_DLLCode/>.must.add.${compName}.custom.output() then
		RETIFNOK(${compName}.add.custom.output.if.any(o.node))
	endif
		<#assign userAreaCreated=true>
	</#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+":">
		<@generate_attribute_anchors iLocation="both" iMethodName=methodName iComponent=comp iAttribute=iattr/>
	</#if>
</#macro>

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

	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
<#if object.businessInterfaceDefinition.idref.type!="bod">
	boolean bl.useLocalTime |* flag to indicate whether local time should be used
</#if>
	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
^				if not bl.keep.child.transaction then
^					db.set.child.transaction(0)
^					abort.transaction()
^				endif
^			endif
^			return(bl.result)
^		endif

	#define CONTINUEIFNOK(MTH,RESP,RESU,BODESC,COMPNAME,LCOMP, ...)
^		on case bl.processingScope
^		case BUS_ENT_CMP:
^			if bl.result = 0 then
^				if not bl.skipComponent then
^					RETIFNOK6(RESP, RESU, ...)
^				endif
^			endif
^			break
^		case REQUEST:
^		case BUS_ENT:
^		case NOT_APPLICABLE:
^		default:
^			RETIFNOK6(RESP, RESU, ...)
^			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
^				if not bl.keep.child.transaction then
^					db.set.child.transaction(0)
^					abort.transaction()
^				endif
^			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 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
^		case REQUEST:
^		case BUS_ENT:
^		case NOT_APPLICABLE:
^		default:
^			RETIFNOK_WITH_RETRY(...)
^			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
^				if not bl.keep.child.transaction then
^					db.set.child.transaction(0)
^					abort.transaction()
^				endif
^			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
^			if not bl.keep.child.transaction then
^				db.set.child.transaction(0)
^				abort.transaction()
^			endif
^		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)
}

function convert.xml.to.text(long TNode, ref long TextNumber)
{
static	long	dll.id
static	long	func.id
	long	ret
	long	retval
	
	if func.id = 0 then
		dll.id = load_dll("otlbctdll1000")
		func.id = get_function(dll.id,
				"tlbct.dll1000.xmlimage.convert.xml.to.text")
	endif
	if func.id = 0 then
		ret = tlbct.dll1000.xmlimage.convert.xml.to.text(TNode, TextNumber)
	else
		ret = exec_function(dll.id, func.id, retval, TNode, TextNumber, true)
	endif
}

<#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-->
}

</#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>
		<#assign datatype=common.getDatatype(a)>
		<#if a.attribute?exists && a.attribute.idref.datatype?exists && a.attribute.idref.datatype.idref?exists &&
				a.attribute.idref.datatype.idref.primitiveDatatype == "boolean">
			<#assign primitiveDatatype="boolean">
		<#else>
			<#assign primitiveDatatype=datatype.primitiveDatatype>
		</#if>

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

	i = 0
				<#if dimensions?number == 0>
	domain	${common.getDatatypeName(datatype)}	l.${common.getAttributeName(a)}(1) based
				<#else>
	domain	${common.getDatatypeName(datatype)}	l.${common.getAttributeName(a)}(${dimensions})		
				</#if>
	RETIFNOK(<@names.ST_DLLCode/>.get.${c.componentName}.${common.getAttributeName(a)}(
							l.${common.getAttributeName(a)},
				<#if datatype.dimensions?number == 0>
							o.valueIsSet, o.size))
				<#else>
							o.valueIsSet))
				</#if>
			<#else>
	domain	${common.getDatatypeName(datatype)}	l.${common.getAttributeName(a)}
	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> 
					<#if datatype.dimensions?number == 0>
			l.${common.getAttributeName(a)}, o.value, o.valueIsSet, o.size))
					<#else>
			l.${common.getAttributeName(a)}, o.value, o.valueIsSet))
					</#if>
				<#else>
			l.${common.getAttributeName(a)}, o.value, o.isSet))
				</#if><#--if array-->
				<#if object.removeLeadingSpaces?exists && object.removeLeadingSpaces &&
					!common.hasEnumerations(datatype) && !common.isTextDatatype(datatype) &&
					(primitiveDatatype == "string" || primitiveDatatype == "anyURI" || primitiveDatatype == "duration" || primitiveDatatype == "Name")>
					<#if array>
						<#if dimensions?number == 0>
			if o.size > 0 then
				alloc.mem(o.value, 1024, o.size)
				alloc.mem(o.valueIsSet, o.size)
			endif
			for i = 1 to o.size
				o.value(1,i) = trim$(o.value(1,i))
						<#else>
			for i = 1 to ${dimensions}
				o.value(1,i) = trim$(o.value(1,i))
						</#if>
			endfor
					<#else>
			o.value = trim$(o.value)
					</#if><#--if array-->
				</#if>
			<#else>
				<#if array> 
					<#if dimensions?number == 0>
	if o.size > 0 then
		alloc.mem(o.value, 1024, o.size)
		alloc.mem(o.valueIsSet, o.size)
	endif
	for i = 1 to o.size
					<#else>
	for i = 1 to ${dimensions}
					</#if>
					<#assign arrayPartValue = "(1,i)">
					<#if primitiveDatatype = "string" && !common.isTextDatatype(datatype) && !common.hasEnumerations(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
						iConversionHookPresent=(a.conversionSetHookExpression?exists && a.conversionSetHookExpression?has_content)/>
	endfor
				<#else>
					<@public.convertFromDomain iComponentName=c.componentName iAttributeName=common.getAttributeName(a) iDatatype=datatype
						iPrimitiveDatatype=primitiveDatatype iConversionHookPresent=(a.conversionSetHookExpression?exists && a.conversionSetHookExpression?has_content)/>
				</#if><#--if array-->
			</#if>
	return(0)
}

		</#if><#--if a.attribute?exists-->
<#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>
		<#if datatype.dimensions?number == 0>
	ref string	i.value(,), ref boolean i.valueIsSet(), long i.size)		
		<#else>
	ref string	i.value(,), ref boolean i.valueIsSet())		
		</#if>
	<#else>
	const	string	i.value)				
	</#if><#--if datatype.dimensions?exists-->	
{
	<#assign tempValueNeeded=false>
	<#if !(a.conversionSetHookExpression?exists && a.conversionSetHookExpression?has_content) && primitiveDatatype != "boolean" && !common.isTextDatatype(datatype) &&
		!common.hasEnumerations(datatype) && (datatype.primitiveDatatype == "string" || datatype.primitiveDatatype == "anyURI" || datatype.primitiveDatatype == "duration" || datatype.primitiveDatatype == "Name")>
		<#assign tempValueNeeded=true>
	</#if>
	<#if array>
		<#assign dimensions = datatype.dimensions>
		<#if tempValueNeeded>
			<#if dimensions?number == 0>
	string	temp.value(1,1) mb based
	if i.size > 0 then
		alloc.mem(temp.value, 1024, i.size)
	endif
			<#else>
	string	temp.value(1024, ${dimensions}) mb
			</#if>
		</#if>
		<#if dimensions?number == 0>
	domain	${common.getDatatypeName(datatype)}	l.${common.getAttributeName(a)}(1) based
	if i.size > 0 then
		alloc.mem(l.${common.getAttributeName(a)}, i.size)
	endif
		<#else>
	domain	${common.getDatatypeName(datatype)}	l.${common.getAttributeName(a)}(${dimensions})
		</#if>
	<#else>
		<#if tempValueNeeded>
	string	temp.value(1024) mb
		</#if>
	domain	${common.getDatatypeName(datatype)}	l.${common.getAttributeName(a)}
	</#if><#--array-->

	<#if a.conversionSetHookExpression?exists && a.conversionSetHookExpression?has_content>
	boolean	isSet
	
	isSet = true
	|* Conversion Set Hook
	RETIFNOK(<@names.ST_DLLCode/>.Hook.ConversionSet.${c.componentName}.${common.getAttributeName(a)}(
		<#if array>
			<#if dimensions?number == 0>
		i.value, l.${common.getAttributeName(a)}, i.valueIsSet, i.size))
			<#else>
		i.value, l.${common.getAttributeName(a)}, i.valueIsSet))
			</#if>
		<#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) && !common.hasEnumerations(datatype)>
 				<#assign arrayPart = "(1,i)">			
			<#else>
				<#assign arrayPart = "(i)">
			</#if><#--if primitiveDatatype = "string" && !common.isTextDatatype(datatype)-->
			<#if dimensions?number == 0>
	for i = 1 to i.size
			<#else>
	for i = 1 to ${dimensions}
			</#if>
		if i.valueIsSet(i) then		
			<@public.convertToDomain iComponentName=c.componentName iAttributeName=common.getAttributeName(a) iDatatype=datatype iPrimitiveDatatype=primitiveDatatype
				iArrayPart=arrayPart iArrayPartValue=arrayPartValue iConversionHookPresent=(a.conversionGetHookExpression?exists && a.conversionGetHookExpression?has_content)/>
		<#else>
			<#assign arrayPart = "">
			<#assign arrayPartValue = "">
			<@public.convertToDomain iComponentName=c.componentName iAttributeName=common.getAttributeName(a) iDatatype=datatype iPrimitiveDatatype=primitiveDatatype
				iConversionHookPresent=(a.conversionGetHookExpression?exists && a.conversionGetHookExpression?has_content)/>
		</#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)}(
		<#if dimensions?number == 0>
			l.${common.getAttributeName(a)}, i.valueIsSet, i.size))
		<#else>
			l.${common.getAttributeName(a)}, i.valueIsSet))
		</#if>
	<#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)-->
		</#list><#--list c.attributeImplementation as a-->
</#list><#--list common.listComponentImplementations() as c-->

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

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>

}

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")-->
	<#if (methodName=="Create" || methodName=="Change" || methodName=="Delete")>
	boolean	TagFound
	xmlnode ControlAreaNode
	string  Value(5)
	</#if>
	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)

	<#if object.businessInterfaceDefinition.idref.type!="bod" && (methodName=="Create" || methodName=="Change" || methodName=="Delete")>
	ControlAreaNode = xmlFindFirst("ControlArea", i.RequestArgument)
	RETIFNOK(getAttributeValue(ControlAreaNode, 
				"ControlArea.LocalTime",
				"<ControlArea>",
				"LocalTime", false, Value, TagFound))
	if tolower$(strip$(Value)) = "true" then
		bl.useLocalTime = true
	else
		bl.useLocalTime = false
	endif
	</#if>
	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>
	if bl.processingScope = BUS_ENT or bl.processingScope = BUS_ENT_CMP
	then
		if not bl.keep.child.transaction then
			db.set.child.transaction(0)
			abort.transaction()
		endif
	endif
	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
	<#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>
	<@names.ST_DLLCode/>.finalize.${methodName}()
		return(0)
	endif
}

<#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>
	<#assign componentHasCustomerDataLocation=public.hasCustomerDataLocation(c.componentImplementation.component.idref)>
	<#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}(
			const	xmlNode	i.${c.componentName}Node,
		<#if public.hasPublicOutputArguments(methodName)>
			<#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)
		<#if c.componentName != names.businessInterfaceName>
{
	boolean	cancel
	boolean	cancelleds
	boolean	noncancelleds
	long	retl
	xmlNode	${c.componentName}Node
	xmlNode	Loop.${c.componentName}Node
	
	o.cancel = false
	cancelleds = false
	noncancelleds = false
	
	Loop.${c.componentName}Node = i.${c.componentName}Node
	while Loop.${c.componentName}Node <> 0
		|* Check if this is the correct component
		${c.componentName}Node = xmlFindFirst("${c.componentPublicName}", Loop.${c.componentName}Node)
		if ${c.componentName}Node <> 0 then
			retl = Handle.Request.${methodName}.${c.componentName}_sub(
						${c.componentName}Node,
			<#if public.hasPublicOutputArguments(methodName)>
						i.Response${c.parentComponentName}Node,
			</#if><#--if public.hasPublicOutputArguments(methodName)-->
						cancel,
						io_${methodName}.ResponseArgument, 
						io_${methodName}.ResultArgument,
						i.processingOrder)
			if retl <> 0 then
				return(retl)
			endif
			if cancel then
				cancelleds = true
			else
				noncancelleds = true
			endif
		endif
		Loop.${c.componentName}Node = xmlGetRightSibling(Loop.${c.componentName}Node)
	endwhile
	
	|* Only set cancel flag if there were components and all components were cancelled
	o.cancel = cancelleds and not noncancelleds
	return(0)
}			

function long Handle.Request.${methodName}.${c.componentName}_sub(
			const	xmlNode	i.${c.componentName}Node,
			<#if public.hasPublicOutputArguments(methodName)>
			const	xmlNode	i.Response${c.parentComponentName}Node,
			</#if><#--if public.hasPublicOutputArguments(methodName)-->
		ref		boolean	o.cancel,
		ref		xmlNode	io_${methodName}.ResponseArgument, 
		ref		xmlNode	io_${methodName}.ResultArgument,
				long	i.processingOrder)
		</#if><#--if c.componentName != names.businessInterfaceName-->
{
	long	ret
	long	tmp.node
	long	positionNode
	long	duml
	xmlNode	${c.componentName}Node
	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" && !common.isBatchMethod("Change", c.componentImplementation))>
	xmlNode	Response.${c.componentName}Node
		</#if><#--if public.hasPublicOutputArguments(methodName) || (methodName=="Delete" && !common.isBatchMethod("Change", c.componentImplementation))-->
		<#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
	${c.componentName}Node = i.${c.componentName}Node
	${c.componentName}.cancel = false
		<#list listOfPublicSubComponents as s>
	${s.componentName}.cancel = false
		</#list><#--listOfPublicSubComponents as s-->

		bl.result = 0
		<#if public.hasPublicOutputArguments(methodName)>
		Response.${c.componentName}Node = 0
		</#if><#--if public.hasPublicOutputArguments(methodName)-->
		sv.${c.componentName}Node = ${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
				${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}(${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() && !common.isBatchMethod("Change", c.componentImplementation)>
		|* Build 'new' request node.
		CONTINUEIFNOK(${methodName},
			io_${methodName}.ResponseArgument, io_${methodName}.ResultArgument,
			"${names.businessInterfaceName}", "${c.componentName}", false,
			Build.requestNode.for.Delete.${c.componentName}(${c.componentName}Node, tmp.node))
		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,
			i.processingOrder))
		|* Clean up response from 'Change'.
		ret = xmlDelete(Response.${c.componentName}Node)
		ret = xmlDelete(tmp.node)
				<#else>
		if ${c.componentName}Node <> 0 then
				</#if><#--if common.bdeHasMoreThanOneComponent() && !common.isBatchMethod("Change", c.componentImplementation)-->
			</#if><#--if methodName == "Delete"-->
			<#if methodName=="Change">
		ret = xmlGetAttribute(${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,
				<#if componentHasCustomerDataLocation>
				execute.${c.componentName}.${methodName}(${c.componentName}Node))
				<#else>
				<@names.ST_DLLCode/>.execute.${c.componentName}.${methodName}())
				</#if>
			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,
				<#if componentHasCustomerDataLocation>
				execute.${c.componentName}.Create(${c.componentName}Node))
				<#else>
				<@names.ST_DLLCode/>.execute.${c.componentName}.Create())
				</#if>
			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,
				<#if componentHasCustomerDataLocation && (methodName=="Create" || methodName=="Change")>
					execute.${c.componentName}.${methodName}(${c.componentName}Node))
				<#else>
					<@names.ST_DLLCode/>.execute.${c.componentName}.${methodName}())
				</#if><#--if methodName=="Create" || methodName=="Change"-->
			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,
				<#if componentHasCustomerDataLocation>
					execute.${c.componentName}.Create(${c.componentName}Node))
				<#else>
					<@names.ST_DLLCode/>.execute.${c.componentName}.Create())
				</#if>
			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,
				<#if componentHasCustomerDataLocation && (methodName=="Create" || methodName=="Change")>
					execute.${c.componentName}.${methodName}(${c.componentName}Node))
				<#else>
					<@names.ST_DLLCode/>.execute.${c.componentName}.${methodName}())
				</#if><#--if methodName=="Create" || methodName=="Change"-->
			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)>
			    Lower.${c.componentName}Node = xmlFindFirst("${s.componentName}", sv.${c.componentName}Node)
			    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>
				Lower.${c.componentName}Node = xmlFindFirst("${s.componentName}", sv.${c.componentName}Node)
			    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>
		${c.componentName}Node = xmlGetRightSibling(${c.componentName}Node)
			</#if><#--if c.componentName != names.businessInterfaceName-->
		</#if><#-- if public.hasPublicInputDataArgumentsByComponent(methodName, c.componentName)-->
		<#if methodName != "Delete">
		if i.processingOrder = BOTTOM_UP then
			<#if public.hasPublicOutputDataArgumentsByComponent(methodName, c.componentName)>
				<#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 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
			    Lower.${c.componentName}Node = xmlFindFirst("${s.componentName}", sv.${c.componentName}Node)
			    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
			    Lower.${c.componentName}Node = xmlFindFirst("${s.componentName}", sv.${c.componentName}Node)
			    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/>
				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
		<#else><#--if methodName != "Delete"-->
			<#if public.hasPublicOutputDataArgumentsByComponent(methodName, c.componentName)>
		if i.processingOrder = BOTTOM_UP then
			|* 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))
				<#list listOfPublicSubComponents as s>
			
			| Remove placeholder for component ${s.componentName}
			positionNode = xmlFindFirst(ANCHOR_MARKER & "${s.componentName}",
					Response.${c.componentName}Node)
			ret = xmlDelete(positionNode)
				</#list>
		endif
			</#if><#--if public.hasPublicOutputDataArgumentsByComponent(methodName, c.componentName)-->
		</#if><#--if methodName != "Delete"-->

		<#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,
				<#if componentHasCustomerDataLocation && (methodName=="Create")>
			execute.${c.componentName}.${methodName}(sv.${c.componentName}Node))
			| ${c.componentName}Node refers to next node (maybe 0), so don't use that here
				<#else>
			<@names.ST_DLLCode/>.execute.${c.componentName}.${methodName}())
				</#if><#--if methodName=="Create"-->
				<#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 c.componentName == names.businessInterfaceName>
		COMMIT_BUS_ENT_CMP()
		</#if><#--if c.componentName == names.businessInterfaceName-->

		<#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>
			    Lower.${c.componentName}Node = xmlFindFirst("${s.componentName}", sv.${c.componentName}Node)
			    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>
			    Lower.${c.componentName}Node = xmlFindFirst("${s.componentName}", sv.${c.componentName}Node)
			    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>
		COMMIT_BUS_ENT_CMP()
		</#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)
<#--#Note: must not include identifiers only but all mandatories.
Every attribute that is mandatory input for Change must be an output attribute for the Show method. -->

			<#list public.listPublicComponents("Change", actual_object) as cs>
				<#list public.listPublicAttributes("Change", cs.componentName, iobject) as a>
					<#if a.isMandatory>
	ret = xmlNewDataElement("selectionAttribute", "${a.componentPublicName}.${a.selectionPath}", SelectionNode)
					</#if>
				</#list>
			</#list><#--list public.listPublicComponents("Change", actual_object) 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
			if not bl.keep.child.transaction then
				db.set.child.transaction(0)
			endif
		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)-->
	long	i

	TNode = 0
	i = 0
	<#-- Build AttributeList: contains all attributes in right order.
		The attributes with Used Attributes are at the end, the used attributes
		must be earlier in the list, because they have to be set first. -->
	<#assign AttributeList=[]>
	<#assign AttributeList1=[]>
	<#assign RelatedAttributeNameList=[]>
	<#assign count=0>
	<#list public.listPublicInputAttributes(methodName, c.componentName) as a>
		<#if a.attributeImplementationRelationship?exists && a.attributeImplementationRelationship?has_content>
			<#assign AttributeList1=AttributeList1+[a]>
			<#assign count=count+1>
		<#else>
			<#assign AttributeList=AttributeList+[a]>
		</#if>
	</#list>
	<#list 1..count as x>
		<#if AttributeList1?has_content>
			<#assign AttributeList2=[]>
			<#list AttributeList1 as a>
				<#assign found=false>
				<#list a.attributeImplementationRelationship as air>
					<#assign relatedAttributeName = common.getAttributeName(air.attributeImplementation.idref)>
					<#if !found>
						<#list AttributeList1 as b>
							<#if b.attributeName==relatedAttributeName>
								<#assign found=true>
								<#break>
							</#if>
						</#list>
					</#if>
					<#if !protected.containedIn(relatedAttributeName, RelatedAttributeNameList)>
						<#assign RelatedAttributeNameList = RelatedAttributeNameList+[relatedAttributeName]>
					</#if>
				</#list>
				<#if found>
					<#assign AttributeList2=AttributeList2+[a]>
				<#else>
					<#assign AttributeList=AttributeList+[a]>
				</#if>
			</#list>
			<#assign AttributeList1=AttributeList2>
		</#if>
	</#list>
	<#-- Now: AttributeList contains all attributes, sorted. -->
	<#-- Protected Attributes -->
	<#list c.componentImplementation.methodImplementation as methodImplementation>
		<#if common.getNameFromMethodImplementation(methodImplementation)==methodName>
			<#list methodImplementation.methodArgumentImplementation as mai>
				<#if mai.attributeImplementation?exists && (mai.scope=="in" || mai.scope=="inout") &&
				!common.getIsReadOnly(mai.attributeImplementation.idref)>
					<#assign found=false>
					<#list AttributeList as a>
						<#if a.attributeName==mai.attributeImplementation.idref.name>
							<#assign found=true>
							<#break>
						</#if>
					</#list>
					<#if !found>
						<#assign componentName=common.getComponentNameFromAttributeImplementation(mai.attributeImplementation.idref)>
						<#assign attributeName=mai.attributeImplementation.idref.name>
	|* Protected Attribute ${componentName}.${attributeName}
						<#if mai.attributeImplementation.idref.attributeImplementationRelationship?exists && mai.attributeImplementation.idref.attributeImplementationRelationship?has_content>
						<#-- Check if the protected attribute has public attributes as used attributes. In that case, the attribute must not be set
							(it will be set later during setting derived attributes). -->
							<#list mai.attributeImplementation.idref.attributeImplementationRelationship as air>
								<#assign relatedAttribute=common.getAttributeName(air.attributeImplementation.idref)>
								<#list AttributeList as a>
									<#if !found && a.attributeName==relatedAttribute>
										<#assign found=true>
	|* Default value not set: has used attribute ${relatedAttribute} that has to be set.
										<#break>
									</#if>
								</#list>
							</#list>
						</#if>
						</#if>
					<#if !found>
						<#assign defaultVal=protected.getDefaultValueFromMethodArgumentImplementation(mai)>
						<#assign dimensions=common.getDimensionsForDataType(common.getMandatoryDatatype(mai.attributeImplementation.idref))>
						<#if dimensions?number != 1>
							<#if dimensions?number == 0>
	string	tmp.array.${attributeName}(1,1) based
	boolean	tmp.arrayIsSet.${attributeName}(1) based
	RETIFNOK(<@names.SB_DLLCode/>.set.${componentName}.${attributeName}.Mapper(tmp.array.${attributeName}, tmp.arrayIsSet.${attributeName}, 0))
							<#else>
	string	tmp.array.${attributeName}(1024, ${dimensions})
	boolean	tmp.arrayIsSet.${attributeName}(${dimensions})
	for i = 1 to ${dimensions}
		tmp.array.${attributeName}(1,i) = ""
		tmp.arrayIsSet.${attributeName}(i) = false
	endfor
	RETIFNOK(<@names.SB_DLLCode/>.set.${componentName}.${attributeName}.Mapper(tmp.array.${attributeName}, tmp.arrayIsSet.${attributeName}))
							</#if>
						<#else>
							<#assign datatype=common.getDatatypeFromMethodArgumentImplementation(mai)>
							<#if defaultVal.present>
								<#if defaultVal.value?starts_with("\"")>
									<#if common.get_BaanDatatype_from_XMLSchemaDatatype(datatype)=="DB.ENUM">
	RETIFNOK(<@names.SB_DLLCode/>.set.${componentName}.${attributeName}.Mapper(${defaultVal.value[datatype.nativeDatatype?length+2..defaultVal.value?length-1]}))
									<#else>
	RETIFNOK(<@names.SB_DLLCode/>.set.${componentName}.${attributeName}.Mapper(${defaultVal.value}))
									</#if>
								<#else>
									<#if common.get_BaanDatatype_from_XMLSchemaDatatype(datatype)=="DB.ENUM">
											<#assign defaultValue=defaultVal.value[datatype.nativeDatatype?length+1..defaultVal.value?length-1]>
	RETIFNOK(<@names.SB_DLLCode/>.set.${componentName}.${attributeName}.Mapper("${defaultVal.value[datatype.nativeDatatype?length+1..defaultVal.value?length-1]}"))
									<#else>
	RETIFNOK(<@names.SB_DLLCode/>.set.${componentName}.${attributeName}.Mapper("${defaultVal.value}"))
									</#if>
								</#if>
							<#else>
								<#if protected.containedIn(attributeName, RelatedAttributeNameList)>
									<#if common.get_BaanDatatype_from_XMLSchemaDatatype(datatype)=="DB.STRING">
	RETIFNOK(<@names.SB_DLLCode/>.set.${componentName}.${attributeName}.Mapper(""))
									<#else>
	RETIFNOK(<@names.SB_DLLCode/>.set.${componentName}.${attributeName}.Mapper("${protected.getBaanDataInitializers(mai.attributeImplementation.idref)}"))
									</#if>
								<#else>
	|* Default value not set: not specified on Method Argument Implementation 
								</#if> 
							</#if>
						</#if>
					</#if>
				</#if>
			</#list>	
		</#if>
	</#list>
	<#if c.componentName!=names.businessInterfaceName>
	<#list common.listRelationshipDetails(c.parentComponentImplementation, c.relationshipImplementation) as rd>
		<#assign datatype=common.getDatatype(rd.fromAttributeImplementation)>
		<#assign dimensions = common.getDimensionsForDataType(datatype)>
		<#if dimensions?number == 1>
	domain ${common.getDatatypeName(datatype)} ${rd.fromComponentName}.${rd.fromAttributeName}.value
	RETIFNOK(<@names.ST_DLLCode/>.get.${rd.fromComponentName}.${rd.fromAttributeName}(
			${rd.fromComponentName}.${rd.fromAttributeName}.value))
	RETIFNOK(<@names.ST_DLLCode/>.set.${rd.toComponentName}.${rd.toAttributeName}(
			${rd.fromComponentName}.${rd.fromAttributeName}.value))
		<#else>
			<#if dimensions?number == 0>
	domain ${common.getDatatypeName(datatype)} ${rd.fromComponentName}.${rd.fromAttributeName}.value(1) based
	boolean	${rd.fromComponentName}.${rd.fromAttributeName}.valueIsSet(1) based
	long	${rd.fromComponentName}.${rd.fromAttributeName}.size
	RETIFNOK(<@names.ST_DLLCode/>.get.${rd.fromComponentName}.${rd.fromAttributeName}(
			${rd.fromComponentName}.${rd.fromAttributeName}.value,
			${rd.fromComponentName}.${rd.fromAttributeName}.valueIsSet,
			${rd.fromComponentName}.${rd.fromAttributeName}.size))
	RETIFNOK(<@names.ST_DLLCode/>.set.${rd.toComponentName}.${rd.toAttributeName}(
			${rd.fromComponentName}.${rd.fromAttributeName}.value,
			${rd.fromComponentName}.${rd.fromAttributeName}.valueIsSet,
			${rd.fromComponentName}.${rd.fromAttributeName}.size))
			<#else>
	domain ${common.getDatatypeName(datatype)} ${rd.fromComponentName}.${rd.fromAttributeName}.value(${dimensions?number})
	boolean	${rd.fromComponentName}.${rd.fromAttributeName}.valueIsSet(${dimensions?number})
	RETIFNOK(<@names.ST_DLLCode/>.get.${rd.fromComponentName}.${rd.fromAttributeName}(
			${rd.fromComponentName}.${rd.fromAttributeName}.value,
			${rd.fromComponentName}.${rd.fromAttributeName}.valueIsSet))
	RETIFNOK(<@names.ST_DLLCode/>.set.${rd.toComponentName}.${rd.toAttributeName}(
			${rd.fromComponentName}.${rd.fromAttributeName}.value,
			${rd.fromComponentName}.${rd.fromAttributeName}.valueIsSet))
			</#if>
		</#if>
	</#list><#--list common.listRelationshipDetails(c.parentComponentImplementation, c.relationshipImplementation) as rd-->
	</#if><#-- c.componentName!=names.businessInterfaceName-->
	
<#-- Processing of qualifiers linked to attribute group-->
	<#assign QualifierList = []>
	<#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
						<#assign QualifierList=QualifierList+[ar.attribute.idref.name]>
					</#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 AttributeList as a>
		<#if a.attributeImplementation.type!="association">			
			<#if !common.isTextDatatype(common.getDatatypeFromAttributeImplementation(a.attributeImplementation))>		
				<#if a.attributeType!="qualifier">
					<#if common.getMandatoryDatatype(a.attributeImplementation).dimensions?exists>
	RETIFNOK(${methodName}.input.${a.componentName}.${a.attributeName}(i.Node))
					<#else>	
						<#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
										<#assign QualifierList=QualifierList+[ar.attribute.idref.name]>
									</#if>
								</#if>
							</#if><#--ar.attribute.idref.type == "qualifier"-->
						</#list><#--a.attributeRelationship as ar-->
	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>
						<#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.componentName}.${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		
					<#if methodName=="Change">
						<#assign mappedToTable=false>
						<#list protected.listTables() as t>
							<#if protected.isMappedToTable(c.componentImplementation, a.attributeImplementation, t.tableName)>
								<#assign mappedToTable=true>
							</#if>
						</#list>
						<#if mappedToTable>
		RETIFNOK(<@names.ST_DLLCode/>.read.text.${a.componentName}.${a.attributeName}())
						</#if>
		RETIFNOK(<@names.SB_DLLCode/>.get.${a.componentName}.${a.attributeName}.Mapper(value, tagfound))
		if tagfound then
			TextNumber = lval(value)
		else
			TextNumber = 0
		endif
					<#else>
		TextNumber = 0
					</#if>
		SET_RETRY_POINT_BUS_ENT_CMP()<#--RETRY-->
		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-->
<#-- Processing of qualifiers not linked to attribute group-->
	<#list AttributeList as a>
		<#if a.attributeImplementation.type!="association">			
			<#if !common.isTextDatatype(common.getDatatypeFromAttributeImplementation(a.attributeImplementation))>		
				<#if a.attributeType=="qualifier" && !protected.containedIn(a.attributeName, QualifierList) && !common.getIsReadOnly(a.attributeImplementation)>
	RETIFNOK(getAttributeValue(i.Node,
					<#-- The qualifier attribute name must be stripped from the attribute path and attribute selection path -->
					<#assign thePos = a.selectionPath?last_index_of(".")>
					<#if thePos < 0>
		"${c.componentPublicName}",
		"<${c.componentPublicName}>", "${public.getAttributeAlias(c.componentImplementation.component.idref, a.attributeImplementation)}", ${a.isMandatory?string("TRUE","FALSE")}, value, tagfound))
					<#else>
						<#assign selectionPath = a.selectionPath[0..thePos-1]>
						<#assign thePos = a.path?last_index_of(".")>
						<#assign path = a.path[0..thePos-1]>
		"${c.componentPublicName}.${selectionPath}",
		"<${c.componentPublicName}>.${path}", "${public.getAttributeAlias(c.componentImplementation.component.idref, a.attributeImplementation)}", ${a.isMandatory?string("TRUE","FALSE")}, value, tagfound))
					</#if><#--if a.selectionPath == ""-->
	if tagfound then
		RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${a.attributeName}.Mapper(value))
	endif
				</#if><#--a.attributeType=="qualifier" && !protected.containedIn(a.attributeName, QualifierList)-->
			</#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 dimensions=common.getDimensionsForDataType(common.getMandatoryDatatype(a.attributeImplementation))/>
			<#if dimensions?number != 1>
function long ${methodName}.input.${a.componentName}.${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
	<#if dimensions?number == 0>
	long	element
	<#else>
	long	counter, element
	</#if>
	<#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>
	<#if dimensions?number == 0>
	string	tmp.array(1,1) based
	boolean	tmp.arrayIsSet(1) based
	long	tmp.array.size
	tmp.array.size = 0
	<#else>
	string	tmp.array(1024, ${dimensions})
	boolean	tmp.arrayIsSet(${dimensions})
	</#if>
	long	i
	<#if datatype == "DB.TEXT">
	long	TextNumber
			<#if methodName=="Change">
				<#if dimensions?number == 0>
	string	tmp2.array(1,1) based
	boolean	tmp2.arrayIsSet(1) based
	long	tmp2.array.size
	tmp2.array.size = 0
				<#else>
	string	tmp2.array(1024, ${dimensions})
	boolean	tmp2.arrayIsSet(${dimensions})
				</#if>

	RETIFNOK(<@names.ST_DLLCode/>.read.text.${a.componentName}.${a.attributeName}())
				<#if dimensions?number == 0>
	RETIFNOK(<@names.SB_DLLCode/>.get.${a.componentName}.${a.attributeName}.Mapper(tmp2.array, tmp2.arrayIsSet, tmp2.array.size))
				<#else>
	RETIFNOK(<@names.SB_DLLCode/>.get.${a.componentName}.${a.attributeName}.Mapper(tmp2.array, tmp2.arrayIsSet))
				</#if>
			</#if>
	</#if>

	<#if dimensions?number == 0>
	xml1 = xmlFindMatch("<${c.componentPublicName}>.${a.path}", i.Node)
	tmp.array.size = xmlGetNumChilds(xml1)
	xml2 = xmlGetFirstChild(xml1)
	while xml2 <> 0
		Data = ""
		ret = xmlGetData(xml2, Data)
		xml3 = lval(Data)
		Data = ""
		ret = xmlGetAttribute(xml3, "sequence", Data)
		if not isspace(Data) then
			element = lval(Data)
			if element > tmp.array.size then
				tmp.array.size = element
			endif
		endif
		xml2 = xmlGetRightSibling(xml2)
	endwhile
	if tmp.array.size > 0 then
		alloc.mem(tmp.array, 1024, tmp.array.size)
		alloc.mem(tmp.arrayIsSet, tmp.array.size)
	endif
	for i = 1 to tmp.array.size
	<#else>
	for i = 1 to ${dimensions}
	</#if>
	<#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	
	
	<#if (dimensions?number > 1)>
	counter = 0			
	</#if>
	element = 0
	meth1.selected = false
	meth2.selected = false		

	<#if (dimensions?number > 1)>
	xml1 = xmlFindMatch("<${c.componentPublicName}>.${a.path}", i.Node)
	</#if>
	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
	<#if (dimensions?number > 1)>
		counter = counter + 1
	</#if>
		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 dimensions?number == 0>
		if element <= 0 then
	<#else>
		if element <= 0 or 
		   element > ${dimensions?number} or 
		   counter > ${dimensions?number} then
	</#if>
			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		
			<#if methodName=="Change">
		if tmp2.arrayIsSet(element) then
			TextNumber = lval(tmp2.array(1,element))
		else
			TextNumber = 0
		endif
			<#else>
		TextNumber = 0
			</#if>
		SET_RETRY_POINT_BUS_ENT_CMP()<#--RETRY-->
		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
		<#if dimensions?number == 0>
	RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${a.attributeName}.Mapper(tmp.array, tmp.arrayIsSet, tmp.array.size))
	if tmp.array.size > 0 then
		free.mem(tmp.array)
		free.mem(tmp.arrayIsSet)
	endif
		<#else>
	RETIFNOK(<@names.SB_DLLCode/>.set.${a.componentName}.${a.attributeName}.Mapper(tmp.array, tmp.arrayIsSet))
		</#if>
	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/>
	<#if componentHasCustomerDataLocation && methodImplementation.processingOrder != "batch" &&
		public.hasCustomerDataLocation(c.componentImplementation.component.idref)>
		<#assign createUserArea=true>
	<#else>
		<#assign createUserArea=false>
	</#if>
	<#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 compName=c.componentName methodName=methodName isQuery=false userArea=createUserArea/>
		</#if>
	</#list>

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

	return(0)
}

	</#if><#--if public.hasPublicOutputArguments(methodName)-->
</#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
					}]>
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
	io.node = candidate.node
	return(0)
}

			</#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)
	string	origProcessingScope(26)
	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
	RETIFNOK(getAttributeValue(ControlAreaNode, 
				"ControlArea.LocalTime",
				"<ControlArea>",
				"LocalTime", false, Value, TagFound))
	if tolower$(strip$(Value)) = "true" then
		bl.useLocalTime = true
	else
		bl.useLocalTime = false
	endif
	Value = ""
	</#if>

	origProcessingScope = bl.processingScope
	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
	bl.processingScope = origProcessingScope
	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
	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)}"))
	${c.componentPublicName}.${methodName}.addMetaDataForFilter(componentNode)
			</#list><#-- list public.listPublicComponents(methodName) as c -->
	
	return(FilterMetaData)
}
			<#list public.listPublicComponents(methodName) as c>

function ${c.componentPublicName}.${methodName}.addMetaDataForFilter(xmlNode i.componentNode)
{
	xmlNode	attributeNode
	long	duml
	
				<#list public.listPublicAttributes(methodName, c.componentName) as a>
	attributeNode = xmlNewNode("Attribute", XML_ELEMENT, i.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 -->
		</#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)
}

</#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>
		<#assign datatype=common.getDatatype(a)>
		<#assign attributeName=common.getAttributeName(a)>
		<#if a.attribute?exists>
		duml = <@names.SB_DLLCode/>.get.${c.componentName}.${attributeName}.Mapper(
			<#if datatype.dimensions?exists>
				<#if datatype.dimensions?number == 0>
				dumsa, dumba, duml)
				<#else>
				dumsa, dumba)
				</#if>
			<#else>		
				dums, dumb)
			</#if>
		</#if>
		<#if !common.getIsReadOnly(a)>
		duml = <@names.SB_DLLCode/>.set.${c.componentName}.${attributeName}.Mapper(			
			<#if datatype.dimensions?exists>
				<#if datatype.dimensions?number == 0>
				dumsa, dumba, duml)
				<#else>
				dumsa, dumba)
				</#if>
			<#else>
				dums)
			</#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)
		convert.xml.to.text(duml, duml)
	endif
}

<@source.performance_point description="Customizations"/>
<#assign hasAnyCustomization=false>
<#assign hasAnyCustomInput=false>
<#assign definePrinted=false>
<#assign customizeHelperFunctionsPrinted=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-->
		<#if !customizeHelperFunctionsPrinted>
function boolean are.all.present(long i.additional.elements, long i.customer.data)
{
	long	table.node
	long	element.node
	
	table.node = xmlGetFirstChild(i.additional.elements)
	while table.node <> 0
		element.node = xmlGetFirstChild(table.node)
		while element.node <> 0
			if not is.present(xmlData$(element.node), i.customer.data) then
				return(false)
			endif
			element.node = xmlGetRightSibling(element.node)
		endwhile
		table.node = xmlGetRightSibling(table.node)
	endwhile
	return(true)
}

function boolean is.present(const string i.name, long i.customer.data)
{
	long	name.value.node
	
	name.value.node = xmlGetFirstChild(i.customer.data)
	while name.value.node <> 0
		if xmlAttribute$(xmlGetFirstChild(name.value.node), "name") = i.name then
			return(true)
		endif
		name.value.node = xmlGetRightSibling(name.value.node)
	endwhile
	return(false)
}

			<#assign customizeHelperFunctionsPrinted=true>
		</#if><#--if !customizeHelperFunctionsPrinted-->
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

	retl = get.additional.elements(
			"<@names.CC_Object/>",
			"<@names.CC_DLLCode/>.get.additional.elements",
			"${public.getPublicPath(c.componentName)}",
			additional.elements.xml)
	if retl = DALHOOKERROR then
		return(DALHOOKERROR)
	endif
	if retl = 0 and xmlGetFirstChild(additional.elements.xml) <> 0 then
		customer.data.location.node = xmlFindFirstMatch("<>.${customerDataLocation.searchString}",
						i.component.node)
		if customer.data.location.node <> 0 then
			| check if all additional elements are already present in customer data
			if are.all.present(additional.elements.xml, customer.data.location.node) then
				retl = xmlDelete(additional.elements.xml)
				return(0) | OK
			endif
		endif
		RETIFNOK(<@names.ST_DLLCode/>.get.${c.componentName}._index1(
			index.value.xml))
		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

	retl = xmlDelete(additional.elements.xml)
	retl = xmlDelete(index.value.xml)
	return(0) | OK
}

		<#if !definePrinted>
#define DALERROR_IF(cond, mesg)
^	if cond then
^		dal.set.error.message("@" & mesg)
^		return(DALHOOKERROR)
^	endif

			<#assign definePrinted=true>
		</#if>
| External function to arrange custom output from On Execute Hook
| Note: This function should be invoked dynamically to prevent a dependency cycle
| (sb -> st-> (hook library) -> sb).
function extern long <@names.SB_DLLCode/>.${c.componentName}.add.custom.output.if.any(
	ref	long	io.user.area.node, | node <UserArea> or 0
	...) | attributes in name-value pairs, the name must be the table column
	     | code (e.g. tcibd001.item).
{
	string	table.column.name(18)
	string	dums(1)
	long	additional.elements.xml
	long	index.value.xml
	long	table.node
	long	column.node
	long	retl
	long	duml
	long	typ
	long	i

	retl = get.additional.elements(
			"<@names.CC_Object/>",
			"<@names.CC_DLLCode/>.get.additional.elements",
			"${public.getPublicPath(c.componentName)}",
			additional.elements.xml)
	if retl = DALHOOKERROR then
		return(DALHOOKERROR)
	endif
	if retl = 0 and xmlGetFirstChild(additional.elements.xml) <> 0 then
		if io.user.area.node = 0 then
			io.user.area.node = xmlNewNode("UserArea")
			DALERROR_IF(io.user.area.node = 0, "Cannot create XML node")
		endif
		index.value.xml = xmlNewNode("IndexValues")
		DALERROR_IF(index.value.xml = 0, "Cannot create XML node")
	
		| fill IndexValues based on provided name-value pairs
		for i = 2 to get.argc() step 2
			table.column.name = get.string.arg(i)
			table.node = xmlNewNode("Table", XML_ELEMENT, index.value.xml)
			DALERROR_IF(table.node = 0, "Cannot create XML node")
			retl = xmlSetAttribute(table.node, "name", table.column.name(1;8))
			DALERROR_IF(retl = 0, "Cannot set XML attribute")
			column.node = xmlNewDataElement("Column",
				get.string.arg(i+1), table.node)
			DALERROR_IF(column.node = 0, "Cannot create XML node")
			retl = xmlSetAttribute(column.node, "name", strip$(table.column.name(10)))
			DALERROR_IF(retl = 0, "Cannot set XML attribute")
			retl = rdi.column(table.column.name, dums, duml, duml, duml, typ, duml, dums)
			DALERROR_IF(retl <> 0, "Cannot determine domain for column " & table.column.name)
			if typ = DB.STRING then
				retl = xmlSetAttribute(column.node, "dataType", "DB.STRING")
			else
				retl = xmlSetAttribute(column.node, "dataType", typ)
			endif
			DALERROR_IF(retl = 0, "Cannot set XML attribute")
		endfor

		RETIFNOK(add.custom.output(
				additional.elements.xml,
				index.value.xml,
				io.user.area.node))
		if xmlGetFirstChild(io.user.area.node) = 0 then
			| nothing in ${customerDataLocation.name}: remove that node 
			retl = xmlDelete(io.user.area.node)
			io.user.area.node = 0
		endif
	endif

	retl = xmlDelete(additional.elements.xml)
	retl = xmlDelete(index.value.xml)
	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)

#define addValue(elementName, description, dataType)
^	retl = tlbctinterface.cust.add.value(o.xml, elementName, description, dataType)
^	if retl <> 0 then
^		return(retl)
^	endif

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

| 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.
| Use addValue to include data not based on a table field.
| Use addXml to include a custom defined structure.
|
| The parameters to be used for addTableField and addCdfField 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"
|    - "DateOnly"
|    - "Checkbox"
|
| The parameters to be used for addValue are:
| 1. elementName (string): the name that must be used to identify the
|    element in the business object data XML.
| 2. description (string): the custom data to be included.
| 3. dataType (string): the data type of the column or customer-defined
|    field. See above for the data types that can be used.
|
| The parameter to be used for addXml is:
| 1. xml (long): XML structure to be included; the complete tree is copied to
|    the customization part (UserArea) of the outgoing message.
|
| 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")
| addValue("ItemDescription", "This is the item description", "String")


| Macros to retrieve the list of identifiers for a component
| The argument is an outgoing XML structure 'xml' that can be used as input for
| the macros 'getIdentifierValueFromIdentifierStructure' and
| 'getIdentifierDataTypeFromIdentifierStructure'. Do not forget to discard the
| XML structure using 'removeIdentifierStructure' (or delete the XML directly).

	<#list common.listComponentImplementations() as c>
		<#if public.hasCustomerDataLocation(c.componentImplementation.component.idref)>
#define getTableIdentifiers.${c.componentName}(xml)
^	retl = tlbctinterface.cust.get.component.table.identifiers("<@names.BDE_Code/>", "${c.componentName}", xml)
^	if retl <> 0 then
^		xml = 0
^		return(retl)
^	endif

		</#if><#--if public.hasCustomerDataLocation(c.componentImplementation.component.idref)-->
	</#list><#--list common.listComponentImplementations() as c-->
#define getIdentifierValueFromIdentifierStructure(xml, table, column)
^	tlbctinterface.cust.get.value.from.identifier.structure(xml, table, column)
| This returns the value for identifier table/column as a string.
| It returns an empty string if the identifier is not present.

#define getIdentifierDataTypeFromIdentifierStructure(xml, table, column)
^	tlbctinterface.cust.get.datatype.from.identifier.structure(xml, table, column)
| This returns the datatype for identifier table/column.
| It returns an empty string if the identifier is not present.

#define removeIdentifierStructure(xml)
^	retl = xmlDelete(xml)
^	xml = 0
| This removes a list of identifiers for a component.
| This macro should be invoked afterwards to prevent memory leakage.

|------------------- 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)>
	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)-->
	</#list><#--list common.listComponentImplementations() as c-->
	default:
		| Nothing
	endcase

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

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