s4hana-hana-audit-policies
SQL templates for the SAP HANASAP HANASAP’s relational database platform, which stores application data and executes SQL and SQLScript in the database, available on-premise and as the managed service SAP HANA Cloud.sap official, btp audit policies of the database tenant an SAP S/4HANASAP S/4HANASAP's ERP suite, run on-premise or as a private cloud edition, with its business data and processes reached over OData, RFC and the ABAP platform. For the things here it is the system a tool reads from or writes to. The public cloud edition is its own entry. system uses, in four sets from the mandatory default policies to scenario examples.
An SAP S/4HANA system needs HANA audit policies to trace security-relevant changes on its database tenant, and this project ships them as SQL files instead of leaving each customer to write its own. They come in four sets: a mandatory one, identical to the policies the SAP HANA Cockpit Audit Policy Wizard provides and set as the default for new installations of SAP S/4HANA 2021, 2022, 2023 and SAP BW/4HANA 2021 and later; a second for S/4HANA schema access logging, which the README says varies with how the database is used; a third for an extended system changelog and monitoring; and a fourth of examples for specific scenarios that the README says should not be applied without careful consideration. A fifth file exposes part of the audit log through a table function, for a user who should not be granted select on every entry. Applying and adjusting the templates on a tenant stays the administrator's job: the README notes that technical users not handled as the SQL files describe can generate a high number of audit log events, and that a policy fails to be created if the global minimal retention period is higher than the one in the policy.
Facts
Where it sits
Who is behind it
In the atlas: maintains 222@SAP-samplesmaintainerAjinkya PatilContributes to this
In the atlas: contributes to 112@ajinkyapatil8190Bjoern BrencherContributes to this
In the atlas: contributes to 1@bjoernbrenchersapBrian BernardContributes to this
In the atlas: contributes to 64@btbernardJoe GörlichContributes to this
In the atlas: contributes to 1@joegoerlichLea PoletinContributes to this
In the atlas: contributes to 1@leapoletinsapChristianeContributes to this
In the atlas: contributes to 1@saint-j6 contributors
What it declares
Every artifact
- Type
- Practice
- Origin
- By SAP
- Use as
- A reference
Connections
Recording who touched personal or sensitive data, for auditors
SAP's relational database platform, on-premise and in HANA Cloud
SAP's ERP suite, run on-premise or as a private cloud edition, with its business data and processes reached over OData, RFC and the ABAP platform. For the things here it is the system a tool reads from or writes to. The public cloud edition is its own entry.
Download
README
quoted from SAP-samples/s4hana-hana-audit-policies under Apache-2.0, readSAP HANA Audit Policy Templates for SAP S/4HANA
Description
This project provides HANA audit policy templates for the SAP HANA database tenant used by SAP S/4HANA. The HANA audit policy templates for S/4HANA provide a set of policies.
- Mandatory HANA Audit Policies (File: 1_hana_audit_policy_mandatory.sql)
A first set of policies defined as mandatory ensure traceability of security relevant changes. These have the prefix 'SAP'. They are identical to the audit policies provided by "SAP HANA Cockpit Audit Policy Wizard" (starting with SAP HANA Cockpit 2.0 SP13). These policies are set as defaults for HANA database tenant used by S/4HANA for new installations with SAP S/4HANA 2021, 2022, 2023 and SAP BW/4HANA 2021 and later. For conversions and system copies, HANA audit policies are only enabled as defaults in case no other HANA audit policies are existing. - S/4HANA Schema Access Log HANA Audit Policies (File: 2_s4hana_hana_audit_policy_recommended.sql)
The second set of policies define "recommended" policies for S/4 systems. These have the prefix 'SAPS4'. These policies vary with the usage of the SAP HANA DB and cannot be defined identical for all systems. - S/4HANA Optional HANA Audit Policies (File: 3_s4hana_hana_audit_policy_optional.sql)
The third set called “optional” suggests policy definition for extended system changelog and monitoring. These have the prefix 'SAPS4_Opt'. - S/4HANA HANA Audit Policies additional consideration (File: 4_s4hana_hana_audit_policiy_additional.sql)
The fourth called “additional” gives examples for policy definition for specific scenarios. It is not recommended to apply the policies without careful consideration. There is no predefined naming. Adoption cannot be done out of the box. Adjustments depend on the usage of an individual HANA database. - S/4HANA Expose View on Auditlog (File: 5_s4hana_expose_view_on_auditlog.sql) The fifth file contains an example implementation of a table function. It is needed if a part of the HANA audit log should to be exposed to a user without granting select on all audit entries.
Please refer to SAP Note 3016478 for more details and explanations.
Requirements
To use those policies you need SAP S/4HANA.
Download and Installation
Information how to list and adjust HANA audit policies can be found on SAP HANA Platform on the SAP Help Portal.
Known Issues
- If technical users (e.g. ABAP Database user , SAPHANADB, SAPDBCTRL) are not handled as described in the SQL files, a high number of HANA audit log events might be generated.
- If the global minimal retention period limit (INI parameter minimal_retention_period) is higher than the minimum period in a HANA audit policy, creation of the policy will fail.
- Additional comments for every policy are provided. Take them into consideration before activating a policy.
How to obtain support
Create an issue in this repository if you find a bug or have questions about the content.
For additional support, ask a question in SAP Community.
Contributing
When contributing to this repository, please first discuss the changes you wish to make through an issue, email, or any other method with the owners of this repository.
License
Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.
Others providing
Compare all 6 on the Audit logging page →- SAP Audit Log serviceSAP Audit Log serviceIngests compliance audit data from BTP services and applications and keeps it for ninety days by default; retrieval and longer retention are separate services.sap official, btpIngests and retains compliance audit data from BTPfrom BTP/BAIP
- com.sap.cds:cds-feature-auditlog-ngcom.sap.cds:cds-feature-auditlog-ngA CAP Java plugin that sends audit log events to the SAP Audit Log service in the format the Audit Log Event Catalog expects.sap official, capCAP Java plugin sending audit log events to SAP Audit Log servicefrom CAP
- com.sap.cds:cds-feature-auditlog-v2com.sap.cds:cds-feature-auditlog-v2The CAP Java handler that sends the SDK's AuditLog events to the SAP Audit Log service over its API version 2, once a service binding is present.sap official, capCAP Java handler for SAP Audit Log service API version 2from CAP
- com.sap.cds:cds-services-bomcom.sap.cds:cds-services-bomThe Maven bill of materials for CAP Java, pinning every com.sap.cds module in a release, from the API and core runtime to the Spring Boot starters and the CQN engine, to the same version.sap official, capMaven bill of materials pinning CAP Java module versionsfrom CAP
- @cap-js/audit-logging@cap-js/audit-loggingIntegration with the SAP Audit Log service, so operations on personal data are recorded in the form an auditor expects without the application writing the entries.sap official, capCAP integration with the SAP Audit Log servicefrom CAP
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
History in the atlas
- First seen.
For your agent
- Ref
artifact:sap-samples-s4hana-hana-audit-policies- JSON
- /artifacts/sap-samples-s4hana-hana-audit-policies.json
- MCP
- Connecting an agent