<?xml version="1.0" encoding="utf-8"?>
<ManualTopic ID="/baanerp/da/onlinemanual/000010" xml:lang="en">
	<Header>
		<Title xmlns:HTML="http://www.w3.org/TR/REC-html40">To use audits in the exchange module</Title>
		<Keyword ContextSensitive="No"><Level1>Exchange audits</Level1>
		</Keyword>
		<Keyword ContextSensitive="No"><Level1>Audit procedure</Level1>
		</Keyword>
	</Header>
	<GeneralSection><Paragraph class="Default">The <Link href="/baanerp/tt/glossary/glossary#100072" role="glossary">audit server</Link> logs all database actions that change the contents of a table in so-called <Link href="/baanerp/tt/glossary/glossary#100069" role="glossary">audit</Link> files. These audit files can be used by the <GUIRef href="/baanerp/da/xch" role="module">Exchange</GUIRef> module. Audit files are useful in a multisite environment because the databases on all sites must have identical data. They can also be used in data conversions.</Paragraph>
		<Paragraph class="Default">Only the updates in a specific period are exchanged, leading to an improvement in performance. Specify this period in the <GUIRef href="/baanerp/da/xch/daxch0233m000" role="session">Export Data (Non-Regular) (daxch0233m000)</GUIRef>, <GUIRef href="/baanerp/da/xch/daxch0234m000" role="session">Export Data (on a Regular Basis) (daxch0234m000)</GUIRef> sessions. Changes like insert, update and delete are processed and written into the <Link href="/baanerp/da/glossary/glossary#000001" role="glossary">ASCII files</Link>. Actions like drop, clear and create tables are ignored.</Paragraph>
		<Paragraph class="Default">Audit control data is added to the resulting ASCII file, consisting of a batchline-id, transaction-id, sequence-id and an indicator. The control data is added at the beginning of each line and is formatted like other data fields like the enclosing and separator characters.</Paragraph>
		<Paragraph class="Default">An update writes two lines to the ASCII file. One line contains the keyfields and old values of the updated fields. The other line contains the new values of the keyfields and updated fields, even if a keyfield does not change.</Paragraph>
		<Paragraph class="Default">The batchline-id is used for recognition when processing the ASCII files. The transaction- and sequence-id are used to make sure that the transactions are replayed in the same order as on the exporting site. The indicator defines the type of action that is executed on the table. Use the letter I for inserting, the letter D for deleting, U for updating with old values and the letter N for updating with new values.</Paragraph>
		<Paragraph class="Default">Select the <GUIRef href="/baanerp/da/xch/daxch0501m000#daxch001.adon" role="manual">Based on Audit</GUIRef> check box in the <GUIRef href="/baanerp/da/xch/daxch0101s000" role="session">Exchange Schemes (daxch0101s000)</GUIRef> session to enable this functionality.</Paragraph>
		<GeneralSection><SectionTitle>Audit configuration</SectionTitle>
			<List><ListIntro>If you use audit files for data exchange make sure to:</ListIntro>
				<ListItem>Audit all involved export tables by defining an <Link href="/baanerp/tt/glossary/glossary#100237" role="glossary">audit profile</Link>. The audit profile can be generated for an exchange scheme using the <GUIRef href="/baanerp/da/xch/daxch1201m000" role="session">Generate Audit Configuration (daxch1201m000)</GUIRef> session, which is available from the <GUIRef href="" role="menu">Specific</GUIRef> menu of the <GUIRef href="/baanerp/da/xch/daxch0501m000" role="session">Exchange Schemes (daxch0501m000)</GUIRef> session.</ListItem>
				<ListItem>Have enough space in the $BSE_TMP directory because all ASCII files are merged into one file during an import. This file contains the audit control data and is sorted on transaction-id and sequence-id.</ListItem>
			</List>
			<Paragraph class="Default">To be sure that all changes made in the database are audited, a transaction notification is created in the database for each database transaction being audited. The transaction notification is inserted within the user transaction, and used by <GUIRef href="" role="manual">Exchange</GUIRef> to collect the audit data. This way we are always sure that all changes are processed.</Paragraph>
		</GeneralSection>
	</GeneralSection>
	<GeneralSection><SectionTitle>Limitations of the Exchange (XCH) module based on audit</SectionTitle>
		<GeneralSection><SectionTitle>Introduction</SectionTitle>
			<Paragraph class="Default">When exchanging based on audit it is important that the sequence in which the database actions are imported is the same as the sequence in which those database actions were executed on the original database by the end users. the <GUIRef href="/baanerp/da/xch" role="module">Exchange</GUIRef> module based on audit guarantees that the sequence of the transactions and the sequence of the database actions within each transaction are preserved. This is also the case for transactions in which multiple tables are involved.</Paragraph>
		</GeneralSection>
		<GeneralSection><SectionTitle>Restrictions on exchange models</SectionTitle>
			<Paragraph class="Default">The batchline-ids have to be identical on the export and import sites. Do not use conditions for updates that integrate two fields into one field. The audit server only logs keyfields and changed fields, therefore if only one field changes the other value will not be present in the ASCII-field.</Paragraph>
			<Paragraph class="Default">Be careful when using conditions in the import part of exchange models that are used for auditing. They can create unsolvable problems. For example, a condition that integrates two fields into one field cannot be used for updates. The audit server only logs keyfields and changed fields, therefore if only one field has changed, the other value will not be present in the ASCII field.</Paragraph>
		</GeneralSection>
		<GeneralSection><SectionTitle>Export</SectionTitle>
			<List><ListItem>The table and ASCII file definition do not have to match. Table fields that are not attached to an ASCII field are ignored and ASCII fields that are not attached to a table field are left empty.</ListItem>
				<ListItem>The names do not have to match anymore (as in earlier releases), the data maintained in <Link href="/baanerp/da/xch/daxch0132s000" role="session">Field Relations (Export) (daxch0132s000)</Link> session is used to link table fields with ASCII fields.</ListItem>
				<ListItem>Conditions cannot be used.</ListItem>
				<ListItem>Constants cannot be used (at this moment).</ListItem>
			</List>
		</GeneralSection>
		<GeneralSection><SectionTitle>Import</SectionTitle>
			<List><ListItem>The names do not have to match anymore (as in earlier releases), the data maintained in <Link href="/baanerp/da/xch/daxch0122s000" role="session">Field Relations (Import) (daxch0122s000)</Link> session is used to link table fields with ASCII fields.</ListItem>
				<ListItem>For inserts the full functionality is available, like constants, conditions and relations.</ListItem>
				<ListItem>Idem for overwrite (inserting an already existing record), as long as the <GUIRef href="/baanerp/da/xch/daxch0122s000#daxch022.rval" role="manual">Condition</GUIRef> field returns true.</ListItem>
				<ListItem>The same for deletes, but note that only the keyfields are assigned their values (thus conditions, that are attached to non-keyfields, having side-effects, probably won't work correctly).</ListItem>
				<ListItem>Note that relations based on <GUIRef href="/baanerp/da/domains/xch.base#increment" role="option">Increment</GUIRef> are meaningless for deletes.</ListItem>
			</List>
			<List><ListIntro>It is difficult for updates to provide the full functionality:</ListIntro>
				<ListItem>Relations for which the Based on field is defined as Default, Fixed value, or increment are ignored, because they are not useful.</ListItem>
				<ListItem>Relations based on <GUIRef href="/baanerp/da/domains/xch.base#field.value" role="option">Field value</GUIRef> or <GUIRef href="/baanerp/da/domains/xch.base#rel.code" role="option">Conv. table</GUIRef> can be used without any restrictions. But they will only be applied on keyfields (old values) and changed fields (new values).</ListItem>
				<ListItem>As the audit server only logs keyfields and changed fields for an update the other fields are not known. Thus many fields in the ascii file will remain empty. If conditions are used it is not known whether all accessed fields have valid values. If not, the condition should probably not be executed. To provide you with the flexibility of conditions, even in case audit is used, you can guard conditions by the <GUIRef href="/baanerp/da/xch/daxch0122s000#daxch022.uval" role="manual">Condition</GUIRef> field condition. It is assumed that this condition decides whether the condition (at field value level) can return a proper value. For this the function changed (&lt;ascii_file&gt;_&lt;field&gt;) can be used in your condition.</ListItem>
				<ListItem>Note that, by the introduction of parameters by condition, all accessed ASCII fields are known and thus it can be decided whether all ASCII fields have valid values. However this knowledge has not been explored in the current version.</ListItem>
				<ListItem>The old value of the ascii field can be accessed via: not.curr(&lt;ascii_file&gt;_&lt;field&gt;) old.value = &lt;ascii_file&gt;_&lt;field&gt; not.curr(&lt;ascii_file&gt;_&lt;field&gt;) | restore new value! The old value of the tablefield is in the tablefield itself (first the condition is executed, and only on returning the value is assigned to the tablefield.</ListItem>
			</List>
		</GeneralSection>
	</GeneralSection>
	<Note><SectionTitle>
                              Note
                           </SectionTitle>
		<Paragraph class="Default">The auditing does not have to be configured manually. Instead, the required <Link href="/baanerp/tt/glossary/glossary#100237" role="glossary">audit profile</Link> can be generated using the <GUIRef href="/baanerp/da/xch/daxch1201m000" role="session">Generate Audit Configuration (daxch1201m000)</GUIRef> session, which is available from the <GUIRef href="" role="menu">Specific</GUIRef> menu of the <GUIRef href="/baanerp/da/xch/daxch0501m000" role="session">Exchange Schemes (daxch0501m000)</GUIRef> session.</Paragraph>
		<Paragraph class="Default">Regarding the logging of values that have not been changed, the behavior of the audit server can be adapted. By changing the audit profile, the audit server can be forced to log the values for one or more table fields even if they have not been changed in an update action. For more information, refer to <Link href="/baanerp/tt/onlinemanual/100006" role="manual">Audit Configuration Management</Link> Help topic.</Paragraph>
	</Note>
	<RelatedTopics><SectionTitle>
                              Related topics
                           </SectionTitle>
		<RelTopic><Link href="/baanerp/da/onlinemanual/000011" role="manual">To use multiline text in an audit procedure</Link>
		</RelTopic>
		<RelTopic><Link href="/baanerp/tt/onlinemanual/100006" role="manual">Audit Configuration Management</Link>
		</RelTopic>
	</RelatedTopics>
</ManualTopic>
