<?xml version="1.0" encoding="utf-8"?>
<ManualTopic ID="/baanerp/tt/EnterpriseStudio/onlinemanual/dal" xml:lang="en" TopicType="Overview">
	<Header>
		<Title xmlns:HTML="http://www.w3.org/TR/REC-html40">DAL</Title>
		<Keyword ContextSensitive="No"><Level1>
                                    Infor ERP LN Development Tools
                                 </Level1>
			<Level2>DAL</Level2>
		</Keyword>
		<Keyword ContextSensitive="No"><Level1>
                                    Infor ERP LN Development Tools
                                 </Level1>
			<Level2>Data Access Layer</Level2>
		</Keyword>
		<Keyword ContextSensitive="No"><Level1>
                                    Infor ERP LN Development Tools
                                 </Level1>
			<Level2>DAL 1</Level2>
		</Keyword>
		<Keyword ContextSensitive="No"><Level1>
                                    Infor ERP LN Development Tools
                                 </Level1>
			<Level2>DAL 2</Level2>
		</Keyword>
	</Header>
	<GeneralSection><SectionTitle>Data Access Layer (DAL)</SectionTitle>
		<Paragraph class="Default">The Data Access Layer (DAL) allows developers to describe rules about data. A DAL is linked to a table, as opposed to a session. Therefore, anytime the table is accessed, the DAL is used. In this way, different sessions can update a table and the same rules apply in the same way. In addition, integration capabilities use the DAL to insure updates will occur in the same way.</Paragraph>
		<Paragraph class="Default">Data Access Layer (DAL) scripts implement the business rules of the application to ensure the logical integrity of the database. DAL scripts are a Library software component that is aligned with a specific table. These scripts are compiled into objects. When a session performs an action on a table, the DAL for the table is loaded.</Paragraph>
		<Paragraph class="Default">In Infor ERP LN 6.1, two types of Data Access Layer scripts exist: DAL 1 and DAL 2.</Paragraph>
		<GeneralSection><SectionTitle>Business Rules</SectionTitle>
			<Paragraph class="Default">A business rule is a statement that defines or constrains some aspect or operation of the business. It is intended to control or influence the behavior of the business operations. Business rules are logical integrity rules, and differ from database oriented referential integrity rules.</Paragraph>
			<List><ListTitle>Business Rules - example</ListTitle>
				<ListIntro>Business rules in a purchasing system may be:</ListIntro>
				<ListItem>An item can be ordered only from its supplier</ListItem>
				<ListItem>When the gross weight and net weight for an item are the same, there is no packaging</ListItem>
				<ListItem>The supplier provides the arrival date of a purchase order after the order is entered into the system.</ListItem>
				<ListItem>Items cannot be removed if there is stock on-hand</ListItem>
				<ListItem>The item on-order quantity is increased when an order for the item is entered</ListItem>
				<ListItem>The item on-hand quantity is increased and the on-order quantity decreased when an order arrives</ListItem>
			</List>
			<List><ListTitle>Referential Integrity Rules - example</ListTitle>
				<ListIntro>In contrast, integrity rules in a purchasing system may be:</ListIntro>
				<ListItem>An item must exist for it to be ordered</ListItem>
				<ListItem>If an item has a supplier, the supplier must be known to the system</ListItem>
				<ListItem>Items can not be deleted if the item record is used elsewhere in the system</ListItem>
			</List>
			<Paragraph class="Default">Business rules are implemented as hooks. A hook is a pre-defined function name that you create in a Data Access Layer script. The 4GL engine will call this function as it executes user interface and database related actions on the table that the DAL is written for.</Paragraph>
			<Paragraph class="Default">Business rules fall into categories that determine how the business rule is implemented in the DAL.</Paragraph>
			<List><ListIntro>The categories, depending on the type of DAL script, are:</ListIntro>
				<ListItem>Property or Field hooks</ListItem>
				<ListItem>Object Hooks</ListItem>
				<ListItem>Field Dependencies</ListItem>
				<ListItem>Business Methods</ListItem>
			</List>
		</GeneralSection>
	</GeneralSection>
	<GeneralSection ID="dal1"><SectionTitle>DAL 1</SectionTitle>
		<Paragraph class="Default">DAL 1 scripts were introduced in Infor ERP Baan5.0. A DAL 1 script contains database logic (e.g. logical integrity rules), but it usually does not contain <Emphasis>all</Emphasis> business logic for the table it belongs to. Very often business logic is spread across the DAL 1 script and the UI scripts.</Paragraph>
		<List><ListIntro>Most UI scripts still contain business logic. They can contain, for example, logic to:</ListIntro>
			<ListItem>make fields read-only.</ListItem>
			<ListItem>determine which enum constants can be selected in an enumerated field.</ListItem>
			<ListItem>update a field after a change to a related field.</ListItem>
		</List>
		<Paragraph class="Default">Therefore it is very hard to use the DAL 1 scripts for integrations via Infor ERP LN Business Adapter: the business logic in the UI scripts is skipped if another application connects to a Infor ERP LN table. Therefore this logic must be rebuilt in the <Link href="/baanerp/tt/glossary/glossary#100082" role="glossary">BOIs</Link> that provide the connection. If you change the business logic in the UI scripts, you must adapt the corresponding BOIs as well.</Paragraph>
		<List><ListIntro>A DAL 1 script can contain the following types of hooks:</ListIntro>
			<ListItem>Object hooks. These hooks operate on the row or record as a whole unit. Object hooks determine if operations on a row are allowed, and specify additional operations that should be performed based on an operation of the row. Examples of object hooks are: <List><ListItem>Delete the additional employee data in the People package when an employee is deleted.</ListItem>
					<ListItem>When a sales order line is saved, create a history record of the sales order line.</ListItem>
					<ListItem>Update the item inventory when a planned stock transaction is created.</ListItem>
				</List>
			</ListItem>
			<ListItem>Property hooks. These hooks operate at a field level, and are, among other things, used to verify valid values and calculate default values for table fields. Examples of property hooks are: <List><ListItem>Validity check that the Quotation expiration date should be after the Quotation entry date.</ListItem>
					<ListItem>When adding an employee, the language of the company is the default for the employee’s language.</ListItem>
				</List>
			</ListItem>
		</List>
		<Paragraph class="Default">For details on DAL 1 scripts, refer to "Data Access Layer" in the <DocRef>ERP LN 6.1 Programmer's Guide</DocRef>.</Paragraph>
		<GeneralSection><SectionTitle>To create DAL 1 scripts</SectionTitle>
			<Paragraph class="Default">You can create and edit DAL 1 scripts in the <GUIRef href="" role="manual">Program Scripts / Libraries (ttadv2530m000)</GUIRef> session. For DAL 1 scripts, the script type is "DAL".</Paragraph>
		</GeneralSection>
	</GeneralSection>
	<GeneralSection ID="dal2"><SectionTitle>DAL 2</SectionTitle>
		<Paragraph class="Default">DAL 2 scripts are introduced in Infor ERP LN. A DAL 2 script contains <Emphasis>all</Emphasis> business logic (database logic + other logic) related to a particular table. The UI scripts of the sessions operating on the table, only contain UI logic.</Paragraph>
		<Paragraph class="Default">DAL 2 scripts are therefore perfectly suited for integrations via Infor ERP LN Business Adapter. Other applications can connect, through <Link href="/baanerp/tt/glossary/glossary#100032" role="glossary" Update="No">Business Objects</Link>, to Infor ERP LN tables. The business logic in the table's DAL 2 script is executed automatically. So, to build an integration, you don't need to rebuild this business logic in the BOIs that provide the interface.</Paragraph>
		<Paragraph class="Default">Various predefined Business Objects, that can be used for integration purposes, are delivered with Infor ERP LN. DAL 2 scripts are only available for tables that are used in these business objects. For the remaining tables, DAL 1 scripts are available. Refer to the Infor ERP LN Business Adapter documentation for details on business objects and integration technology.</Paragraph>
		<List><ListIntro>In DAL 2 various new hooks are introduced. A DAL 2 script can contain:</ListIntro>
			<ListItem>Object hooks: these hooks are identical to the object hooks in DAL 1 scripts.</ListItem>
			<ListItem>Field hooks. Field hooks contain the business logic for table fields. They can contain, for example, logic to: <List><ListItem>verify valid values on a table field (logical integrity rules).</ListItem>
					<ListItem>make a field read-only. For example: the contact field of the Business Partner is not a required entry, and is a display field in the UI when the Business Partner is created.</ListItem>
					<ListItem>make a field invisible.</ListItem>
					<ListItem>automatically update a field, after a related field was changed. See "Field Dependencies".</ListItem>
					<ListItem>make input on a field mandatory.</ListItem>
					<ListItem>hide a particular enumerated constant from an enum list.</ListItem>
				</List>
			</ListItem>
			<ListItem>Business method hooks. These hooks are used to disable/enable and hide specific <Link href="/baanerp/tt/glossary/glossary#100053" role="glossary">form commands</Link> of type "business method".</ListItem>
		</List>
		<Paragraph class="Default">For details on DAL 2 scripts, refer to "DAL 2 Overview" in the <DocRef>ERP LN 6.1 Programmer's Guide</DocRef>.</Paragraph>
		<GeneralSection><SectionTitle>To create DAL 2 scripts</SectionTitle>
			<Paragraph class="Default">You can create and edit DAL 2 scripts in the <GUIRef href="" role="manual">Program Scripts / Libraries (ttadv2530m000)</GUIRef> session. For DAL 2 scripts, the script type is "DAL (version 2)".</Paragraph>
		</GeneralSection>
	</GeneralSection>
	<GeneralSection><SectionTitle>Field dependencies</SectionTitle>
		<Paragraph class="Default">In DAL 2 scripts, you can define field dependencies that are used to determine default values. Once these field dependencies are defined, dependent fields update themselves when the fields that they depend on are updated. The field updates are defined in the DAL as a field hook.</Paragraph>
		<Paragraph class="Default">Dependencies are also used to update the User Interface. The 4GL Engine uses these field dependencies to disable and enable fields, and to determine enum values.</Paragraph>
		<List><ListIntro>Examples of field dependencies are:</ListIntro>
			<ListItem>The packing field of the Item is yes if the gross weight and net weight of the item are different. A field dependency is defined so that the packing field is updated if the gross or net weight fields change.</ListItem>
			<ListItem>An item without a gross weight cannot have a net weight and packing. A field dependency is defined so that the net weight and packing fields are disabled if the gross weight is zero.</ListItem>
		</List>
	</GeneralSection>
	<GeneralSection><SectionTitle>Business methods</SectionTitle>
		<Paragraph class="Default">Business Methods are operations on a row or set or rows within a table. A business method is a function that performs a task that involves manipulating or checking one or more tables in the database.</Paragraph>
		<Paragraph class="Default">Sessions, object hooks or property hooks from another table’s DAL can call a business method. For more information, refer to the <DocRef>ERP LN 6.1 Programmer's Guide</DocRef>.</Paragraph>
		<List><ListIntro>Examples of business methods are:</ListIntro>
			<ListItem>The sales order line session can remove an order line. The object hook for deleting the sales order line calls a business method to also remove the unpaid commissions.</ListItem>
			<ListItem>In the Purchase Order session, check if it is allowed to change a purchase order header based on the purchase order status and the business partner status.</ListItem>
			<ListItem>If a purchase order issues components, the object hook for the purchase order line calls a business method to issue the components for the purchase order. The business method inserts items of the bill of material into a purchase order components table.</ListItem>
		</List>
	</GeneralSection>
</ManualTopic>
