<?xml version="1.0" encoding="utf-8"?>
<ManualTopic ID="/baanerp/tt/EnterpriseStudio/ERPLN_homepages/hpa_create_functions_for_homepages" xml:lang="en" UserLevel="Expert">
	<Header>
		<Title xmlns:HTML="http://www.w3.org/TR/REC-html40">To create functions for ERP LN homepages</Title>
		<Keyword ContextSensitive="No"><Level1>Homepages</Level1>
			<Level2>functions</Level2>
		</Keyword>
		<Keyword ContextSensitive="No"><Level1>Homepages</Level1>
			<Level2>development</Level2>
		</Keyword>
		<Keyword ContextSensitive="No"><Level1>homepages</Level1>
			<Level2>WebTop</Level2>
		</Keyword>
		<Keyword ContextSensitive="No"><Level1>WebTop</Level1>
			<Level2>homepages</Level2>
		</Keyword>
	</Header>
	<GeneralSection><SectionTitle>Introduction</SectionTitle>
		<Paragraph class="Default">When you create a homepage, you must create functions on the ERP LN server, which contain the logic to display the homepage's workload items, alerts, and so on.</Paragraph>
		<ProcedureList><ListIntro>To create a homepage function, complete the following steps:</ListIntro>
			<ListItem>Log on to the ERP LN server.</ListItem>
			<ListItem>Start the <GUIRef href="/baanerp/tt/adv/ttadv2530m000" role="session">Program Scripts / Libraries (ttadv2530m000)</GUIRef> session.</ListItem>
			<ListItem>Either create a library and start the editor, or edit an existing library.</ListItem>
			<ListItem>Add the function syntax to the library.</ListItem>
			<ListItem>Save and compile the library.</ListItem>
		</ProcedureList>
		<Paragraph class="Default">You can now link the function to a homepage. For details, refer to <Link href="/baanerp/tt/EnterpriseStudio/ERPLN_homepages/hpa_create_homepages" role="manual">To create ERP LN homepages</Link>.</Paragraph>
	</GeneralSection>
	<GeneralSection><SectionTitle>Homepage function types</SectionTitle>
		<List><ListIntro>For descriptions and examples of the following homepage function types, see the following section:</ListIntro>
			<ListItem>A function to display workload items.</ListItem>
			<ListItem>A function to display alerts.</ListItem>
			<ListItem>A count function.</ListItem>
			<ListItem>A function to start a session.</ListItem>
			<ListItem>A report item function.</ListItem>
		</List>
		<GeneralSection><SectionTitle>Workload items function</SectionTitle>
			<GeneralSection><SectionTitle>Interface</SectionTitle>
				<CodeBlock space-and-orientation="indented-estimated">function extern long &lt;workloadFunction&gt;(long i.node)</CodeBlock>
				<Paragraph class="Default">i.node has the following content:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">&lt;CompanyInfo&gt;
		&lt;compnr&gt; &lt;/compnr&gt;
		&lt;logcompnr&gt; &lt;/logcompnr&gt;
		&lt;fincompnr&gt; &lt;/fincompnr&gt;
	&lt;/CompanyInfo&gt;
</CodeBlock>
				<Paragraph class="Default">Always returns an XML node:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">&lt;WorkloadItems&gt;
	&lt;Item&gt;
		&lt;id&gt; &lt;/id&gt;
		&lt;label&gt; &lt;/label&gt;	Label in personalize dialog
		[&lt;type&gt; &lt;/type&gt;]	Long (could be extended in the future when there are requirements for it). If not specified, not possible to filter
		[&lt;unit&gt; &lt;/unit&gt;]	Only used for filter
		&lt;countFunction&gt; &lt;/countFunction&gt;
		&lt;sessionStartFunction&gt; &lt;/sessionStartFunction&gt;
		[&lt;supportCount&gt; &lt;/supportCount&gt;]	default = false
		[&lt;supportAmount&gt; &lt;/supportAmount&gt;]	default = false
		[&lt;additionalInfo&gt; &lt;/additionalInfo&gt;]	xml node which is send back to the backend for the count and start function to prevent additional reads.
	&lt;/Item&gt;
	. . .
&lt;/WorkloadItems&gt;</CodeBlock>
			</GeneralSection>
			<ExampleSection><SectionTitle>
                                       Example
                                    </SectionTitle>
				<CodeBlock space-and-orientation="indented-estimated">function extern long get.dashboard.workload.items(long i.node)
{
	long	items
	items = xmlNewNode("WorkloadItems")
	
	&lt; Add the Items &gt;
	
	return(items)
}
</CodeBlock>
				<Paragraph class="Default">The items node could look like the following:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">&lt;WorkloadItems&gt;
	&lt;Item&gt;
		&lt;id&gt;wl_1&lt;/id&gt;
		&lt;label&gt;Open Orders&lt;/label&gt;
		&lt;countFunction&gt;get.open.orders.count&lt;/countFunction&gt;
		&lt;sessionStartFunction&gt;start.open.orders&lt;/sessionStartFunction&gt;
		&lt;supportCount&gt;true&lt;/supportCount&gt;
		&lt;supportAmount&gt;false&lt;/supportAmount&gt;
		&lt;additionalInfo&gt;
			&lt;buyer&gt;76300&lt;/buyer&gt;
		&lt;/additionalInfo&gt;
	&lt;/Item&gt;
	&lt;Item&gt;
		&lt;id&gt;wl_2&lt;/id&gt;
		&lt;label&gt;Created Orders greater than&lt;/label&gt;
		&lt;type&gt;long&lt;/type&gt;
		&lt;unit&gt;Eur&lt;/unit&gt;
		&lt;countFunction&gt;get.create.orders.count&lt;/countFunction&gt;
		&lt;sessionStartFunction&gt;start.create.orders&lt;/sessionStartFunction&gt;
		&lt;supportCount&gt;true&lt;/supportCount&gt;
		&lt;additionalInfo&gt;
			&lt;buyer&gt;76300&lt;/buyer&gt;
		&lt;/additionalInfo&gt;
	&lt;/Item&gt;
&lt;/WorkloadItems&gt;</CodeBlock>
			</ExampleSection>
		</GeneralSection>
		<GeneralSection><SectionTitle>Alerts function</SectionTitle>
			<GeneralSection><SectionTitle>Interface</SectionTitle>
				<CodeBlock space-and-orientation="indented-estimated">function extern long &lt;alertFunction&gt;(long i.node)

	
</CodeBlock>
				<Paragraph class="Default">i.node has the following content:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">&lt;CompanyInfo&gt;
		&lt;compnr&gt; &lt;/compnr&gt;
		&lt;logcompnr&gt; &lt;/logcompnr&gt;
		&lt;fincompnr&gt; &lt;/fincompnr&gt;
	&lt;/CompanyInfo&gt;</CodeBlock>
				<Paragraph class="Default">Always returns an XML node:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">&lt;Alerts&gt;
	&lt;Item&gt;
		&lt;id&gt; &lt;/id&gt;
		&lt;label&gt; &lt;/label&gt;	Label in personalize dialog
		[&lt;type&gt; &lt;/type&gt;]	Long (could be extended in the future when there are requirements for it). If not specified, not possible to filter
		[&lt;unit&gt; &lt;/unit&gt;]	Only used for filter
		&lt;countFunction&gt; &lt;/countFunction&gt;
		&lt;sessionStartFunction&gt; &lt;/sessionStartFunction&gt;
		[&lt;supportCount&gt; &lt;/supportCount&gt;]	default = false
		[&lt;supportAmount&gt; &lt;/supportAmount&gt;]	default = false
		[&lt;additionalInfo&gt; &lt;/additionalInfo&gt;]	xml node which is send back to the backend for the count and start function to prevent additional reads.
	&lt;/Item&gt;
	. . .
&lt;/Alerts&gt;</CodeBlock>
			</GeneralSection>
			<ExampleSection><SectionTitle>
                                       Example
                                    </SectionTitle>
				<CodeBlock space-and-orientation="indented-estimated">function extern long get.dashboard.alerts(long i.node)
{
	long	items
	items = xmlNewNode("Alerts")
	
	&lt; Add the Items &gt;
	
	return(items)
}
</CodeBlock>
				<Paragraph class="Default">The items node could look like the following:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">&lt;Alerts&gt;
	&lt;Item&gt;
		&lt;id&gt;al_1&lt;/id&gt;
		&lt;label&gt;Open Orders&lt;/label&gt;
		&lt;countFunction&gt;get.open.orders.count&lt;/countFunction&gt;
		&lt;sessionStartFunction&gt;start.open.orders&lt;/sessionStartFunction&gt;
		&lt;supportCount&gt;true&lt;/supportCount&gt;
		&lt;supportAmount&gt;false&lt;/supportAmount&gt;
	&lt;/Item&gt;
	&lt;Item&gt;
		&lt;id&gt;al_2&lt;/id&gt;
		&lt;label&gt;Late Orders&lt;/label&gt;
		&lt;type&gt;long&lt;/type&gt;
		&lt;unit&gt;days late&lt;/unit&gt;
		&lt;countFunction&gt;get.late.orders.count&lt;/countFunction&gt;
		&lt;sessionStartFunction&gt;start.late.orders&lt;/sessionStartFunction&gt;
		&lt;supportCount&gt;true&lt;/supportCount&gt;
		&lt;imageLarge&gt;td/ipu/bipuoutbox.gif&lt;/imageLarge&gt;
		&lt;imageSmall&gt;td/ipu/bipuoutbox_s.gif&lt;/imageSmall&gt;
	&lt;/Item&gt;
&lt;/Alerts&gt;</CodeBlock>
			</ExampleSection>
		</GeneralSection>
		<GeneralSection><SectionTitle>Count function</SectionTitle>
			<GeneralSection><SectionTitle>Interface</SectionTitle>
				<CodeBlock space-and-orientation="indented-estimated">function extern void &lt;countFunction &gt;(long i.node)
</CodeBlock>
				<Paragraph class="Default">i.node has the following content:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">&lt;Item&gt;
		&lt;id&gt; &lt;/id&gt;
		&lt;compnr&gt; &lt;/compnr&gt;
		&lt;logcompnr&gt; &lt;/logcompnr&gt;
		&lt;fincompnr&gt; &lt;/fincompnr&gt;
		[&lt;amount&gt; &lt;amount&gt;]			If a type is defined
		[&lt;additionalInfo&gt; &lt;/additionalInfo&gt;]
	&lt;/Item&gt;</CodeBlock>
				<Paragraph class="Default">Return always an XML node:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">&lt;Item&gt;
	&lt;id&gt; &lt;/id&gt;
	&lt;description&gt; &lt;/description&gt;
	[&lt;count&gt;&lt;count&gt;]
	[&lt;amount&gt;&lt;amount&gt;]
	[&lt;amountDescription&gt;&lt;amountDescription&gt;]
&lt;/Item&gt;</CodeBlock>
			</GeneralSection>
			<ExampleSection><SectionTitle>
                                       Example
                                    </SectionTitle>
				<CodeBlock space-and-orientation="indented-estimated">function extern long get.create.orders.count(long i.node)
{
	string	id(5)
	long	amount
	long	infoNode

	id = xmlDataElement$(i.node, "id", 0)
	amount = xmlDataElement$(i.node, "amount", 0)
	infoNode = xmlFindFirst("additionalInfo", i.node)
	
	select . . . 
	. . .
	return(node)
}
</CodeBlock>
				<Paragraph class="Default">The node could look like the following:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">&lt;Item&gt;
		&lt;id&gt;wl_2&lt;/id&gt;
		&lt;description&gt;Orders greater than 100.000 Eur&lt;/description&gt;
		&lt;count&gt;5&lt;count&gt;
&lt;/Item&gt;</CodeBlock>
			</ExampleSection>
		</GeneralSection>
		<GeneralSection><SectionTitle>Function to start a session</SectionTitle>
			<GeneralSection><SectionTitle>Interface</SectionTitle>
				<CodeBlock space-and-orientation="indented-estimated">function extern void &lt;sessionStartFunction&gt;(long i.node)</CodeBlock>
				<Paragraph class="Default">i.node has the following content:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">
	&lt;Item&gt;
		&lt;id&gt; &lt;/id&gt;
		&lt;compnr&gt; &lt;/compnr&gt;
		&lt;logcompnr&gt; &lt;/logcompnr&gt;
		&lt;fincompnr&gt; &lt;/fincompnr&gt;
		[&lt;amount&gt; &lt;amount&gt;]			If a type is defined
		[&lt;additionalInfo&gt; &lt;/additionalInfo&gt;]
	&lt;/Item&gt;
</CodeBlock>
				<Paragraph class="Default">The function does not return anything, but should start a session.</Paragraph>
			</GeneralSection>
			<ExampleSection><SectionTitle>
                                       Example
                                    </SectionTitle>
				<CodeBlock space-and-orientation="indented-estimated">function extern void start.create.orders(long i.node)
{
	string	id(5)
	long amount
	id = xmlDataElement$(i.node, "id", 0)
	amount = xmlDataElement$(i.node, "amount", 0)

	. . .
	start.session(., .,  ., .)
}
</CodeBlock>
				<Paragraph class="Default">The node could look like the following:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">
	&lt;Item&gt;
		&lt;id&gt;wl_2&lt;/id&gt;
		&lt;amount&gt;100000&lt;/amount&gt;
	&lt;/Item&gt;</CodeBlock>
			</ExampleSection>
		</GeneralSection>
		<GeneralSection><SectionTitle>Report item function</SectionTitle>
			<GeneralSection><SectionTitle>Interface</SectionTitle>
				<CodeBlock space-and-orientation="indented-estimated">function extern long &lt;reportFunction&gt;(long i.node)</CodeBlock>
				<Paragraph class="Default">i.node has the following content:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">
	&lt;CompanyInfo&gt;
		&lt;compnr&gt; &lt;/compnr&gt;
		&lt;logcompnr&gt; &lt;/logcompnr&gt;
		&lt;fincompnr&gt; &lt;/fincompnr&gt;
	&lt;/CompanyInfo&gt;
</CodeBlock>
				<Paragraph class="Default">Always returns an XML node:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">&lt;Report&gt;
	&lt;design&gt; &lt;/design&gt;	Name of the report design
	[&lt;parameterSession&gt; &lt;/parameterSession&gt;]	Session to start to change the parameters by the end user
	[&lt;parameter 
		[name=’. . .’] 	Attribute ‘name’ specifies the name of the parameter.
	 &gt; &lt;/parameter&gt;]*	The value of each parameter should be specified. 
&lt;/Report&gt;</CodeBlock>
			</GeneralSection>
			<ExampleSection><SectionTitle>
                                       Example
                                    </SectionTitle>
				<CodeBlock space-and-orientation="indented-estimated">function extern long purchased.order.amount.report(long i.node)
{
	long node
	. . .
	return(node)
}

</CodeBlock>
				<Paragraph class="Default">The node could look like the following:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">&lt;Report&gt;
		&lt;design&gt;Purchased Order Amount&lt;/design&gt;
		&lt;parameterSession&gt;gazzzreptest&lt;/parameterSession&gt;
		&lt;parameter name=’Period Table’&gt;MONTH&lt;/parameter&gt;
		&lt;parameter name=’Start Date’&gt;Jan 01, 2006&lt;/parameter&gt;
		&lt;parameter name=’End Date’&gt;Dec 31, 2006&lt;/parameter&gt;
		&lt;parameter name=’Buyer’&gt;jsmith&lt;/parameter&gt;
		&lt;parameter name=’Default Currency’&gt;EUR&lt;/parameter&gt;
	&lt;/Report&gt;

</CodeBlock>
				<Paragraph class="Default">At runtime this node creates the following link to the report:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">

... /run?__report=Report\Purchased Order Amount.rptdesign&amp;Period Table=MONTH&amp;Start Date=Jan 01, 2006&amp;End Date=Dec 31, 2006&amp;Buyer=jsmith&amp;Default Currency=EUR

</CodeBlock>
				<Figure space-and-orientation="indented-estimated"><FigIntro>The user can click the link to display a graph. For an example, see the following figure:</FigIntro>
					<HTML:IMG height="405" width="649" SRC="../images/nt_screen_hpa_create_functions_for_homepages1.gif" path="/enterpriseserver/tools/tt/enterprisestudio/erpln_homepages" btb-count="1" btb-count2="1" btb-image-name="nt_screen_hpa_create_functions_for_homepages1.gif" btb-source-path="C:\SVN\docnl\Technology\EnterpriseServer~8.5\EnterpriseServer" btb-image-path="/enterpriseserver/tools/tt/enterprisestudio/images/nt_screen_hpa_create_functions_for_homepages1.gif" ID="IDAMC0AC" alt="[...]" xmlns:HTML="http://www.w3.org/TR/REC-html40"/></Figure>
				<Paragraph class="Default">When you have defined a parameter session for the report, a <GUIRef href="" role="manual">Parameters</GUIRef> button is displayed. When the user presses the button, the corresponding parameter session starts.</Paragraph>
				<Figure space-and-orientation="indented-estimated"><HTML:IMG height="141" width="456" SRC="../images/nt_screen_hpa_create_functions_for_homepages2.gif" path="/enterpriseserver/tools/tt/enterprisestudio/erpln_homepages" btb-count="1" btb-count2="1" btb-image-name="nt_screen_hpa_create_functions_for_homepages2.gif" btb-source-path="C:\SVN\docnl\Technology\EnterpriseServer~8.5\EnterpriseServer" btb-image-path="/enterpriseserver/tools/tt/enterprisestudio/images/nt_screen_hpa_create_functions_for_homepages2.gif" ID="IDA3C0AC" alt="[...]" xmlns:HTML="http://www.w3.org/TR/REC-html40"/></Figure>
				<Paragraph class="Default">With the session you created, the user can change the parameters.</Paragraph>
				<Paragraph class="Default">The parameter session is an ERP LN session. Therefore, when developing this session, you have all ERP LN programming possibilities such as browsing and so on. In the choice.end.program section you must call the send.parameters.to.report(…) function. This function requires the parameters specified as pairs, with the name of the parameter followed by the value. See the following example:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">choice.end.program:
before.choice:
	send.parameters.to.report("Start Date", start.date, "End Date", end.date)
</CodeBlock>
				<Paragraph class="Default">At runtime, this code results in a call to the backend. For example:</Paragraph>
				<CodeBlock space-and-orientation="indented-estimated">&lt;RESPONSE&gt;
   &lt;ARG NAME="callResult"&gt;
       &lt;callResult&gt;
           &lt;SESSION ID="6-2" STATE="CLOSED"&gt;
               &lt;REPORTPARAMETERS&gt;
                   &lt;parameter NAME="Start Date"&gt;Jan 01, 2007&lt;/parameter&gt;
                   &lt;parameter NAME="End Date"&gt;Jan 31, 2007&lt;/parameter&gt;
                   &lt;processinfo&gt;report_0&lt;/processinfo&gt;
               &lt;/REPORTPARAMETERS&gt;
           &lt;/SESSION&gt;
       &lt;/callResult&gt;
   &lt;/ARG&gt;
&lt;/RESPONSE&gt;
</CodeBlock>
				<List><ListIntro>As a result of this call, the homepage does the following:</ListIntro>
					<ListItem>Searches for the correct report and replaces the parameters with the new values. The values are only replaced for the parameters sent to the report. For parameters not sent to the report, the values stay the same.</ListItem>
					<ListItem>Refreshes the pane where the graph is displayed.</ListItem>
				</List>
				<Figure space-and-orientation="indented-estimated"><HTML:IMG height="502" width="694" SRC="../images/nt_screen_hpa_create_functions_for_homepages3.gif" path="/enterpriseserver/tools/tt/enterprisestudio/erpln_homepages" btb-count="1" btb-count2="1" btb-image-name="nt_screen_hpa_create_functions_for_homepages3.gif" btb-source-path="C:\SVN\docnl\Technology\EnterpriseServer~8.5\EnterpriseServer" btb-image-path="/enterpriseserver/tools/tt/enterprisestudio/images/nt_screen_hpa_create_functions_for_homepages3.gif" ID="IDAOD0AC" alt="[...]" xmlns:HTML="http://www.w3.org/TR/REC-html40"/></Figure>
			</ExampleSection>
		</GeneralSection>
	</GeneralSection>
	<RelatedTopics><SectionTitle>
                                 Related topics
                              </SectionTitle>
		<RelTopic><Link href="/baanerp/tt/EnterpriseStudio/ERPLN_homepages/hpa_homepages_introduction" role="manual">Homepages introduction</Link>
		</RelTopic>
		<RelTopic><Link href="/baanerp/tt/EnterpriseStudio/ERPLN_homepages/hpa_homepages_structure" role="manual">Homepage structure</Link>
		</RelTopic>
		<RelTopic><Link href="/baanerp/tt/EnterpriseStudio/ERPLN_homepages/hpa_homepages_delivery" role="manual">Homepages delivery</Link>
		</RelTopic>
		<RelTopic><Link href="/baanerp/tt/EnterpriseStudio/ERPLN_homepages/hpa_predefined_homepages" role="manual">Predefined homepages delivered by Infor</Link>
		</RelTopic>
		<RelTopic><Link href="/baanerp/tt/EnterpriseStudio/ERPLN_homepages/hpa_installation_configuration" role="manual">To install and configure Homepages</Link>
		</RelTopic>
		<RelTopic><Link href="/baanerp/tt/EnterpriseStudio/ERPLN_homepages/hpa_create_homepages" role="manual">To create ERP LN homepages</Link>
		</RelTopic>
	</RelatedTopics>
</ManualTopic>
