G/L Account line item grouping

Following the SAP Best Practice approach regarding the setup of GL accounts ins SAP ERP and SAP S/4HANA any account allows a detailed reporting on line item level.

We can select any available field to sort or group accounts. So far all seems to be set and further discussion is needed on the question how to group line items. And indeed, as long as there is a common field the selected items shall be sorted everything is fine.

However, things are getting more complex when crossing the border of a company code and processes are not 100% alike, since in company code the grouping criteria may for an account may be the customer number whereas in another it may be the customer order.

In reporting this can be handled by executing certain reports multiple times. In automatic clearing things are different since the clearing rule setup seems to be show stopper:

Additional%20Rules%20for%20Automatic%20Clearing

Customizing: Additional Rules for Automatic Clearing

At first sight this seems to be no-brainer: we just unter BUKRS as Criterion 1 and the job is done… Taking a closer look at the underlying table TF123 shows that this idea is never going to fly, since none of the five criteria are part of the table key:

Table%20definition%20TF123

Definition of table TF123

So what we need is a different approach. And taking a closer look to table TF123 requires us to rephrase the question. So instead of asking:

  • How can we group G/L accounts specific to certain company codes?

the question must be rephrased to

  • Which common field allows as to have company code specific information automatically recorded on line item level?

To answer this question we must have closer look on the account maintenance, especially to the tab “Control Data”:

G/L%20Account%20Maintenance%3A%20Control%20Data

G/L Account Maintenance: Control Data

The relevant entry is the highlighted “Sort key”. Looking back to the early days of SAP like R/2 this information was really relevant for sorting since sorting was limited to certain fields of which one was the assignment. But this is history. Looking at SAP S/4HANA the functionality to take over certain field values and field names still exist, whereas sorting is no longer limited to any field.

So one can think that since sorting functionality is no longer required the same applies to the “Sort key”. Actually the “Sort key” is tightly connected to the field ZUONR. The functionality in a nutshell is, it copies a value from one filed or a combination of fields into another one.

Example:

In each line item where the account from the screenshot above is used in company code 0001 the value of the “Settlement period” is copied over into the field ZUONR.

Since the “Sort key” is assigned on company code level all what there is to do, is to answer the initial question:

  • How can we group G/L accounts specific to certain company codes?

and after that assign in each company code the correct sort key to these company codes.

In standard there already exists some pre-defined “Sort keys”:

Sort%20key

Sort key

If you can’t find what you are looking for you may define a key that you like. The only restriction is that it must be a field in one of the database tables BKPF, BSEG, BSEC, or BSED.

Definition%3A%20Sort%20key

Definition: T-Code SH02 – Determine Standard Sorting for Line Items

Another restriction is that the result cannot be longer than 18 characters. But despite of this limitation we are free to transfer any value on line item level (combination) we want just out-of-the-box without having to develop anything.

Assume you want to clear items in company code referring to the document number and in another one based on the reference document number. In this case you would assign this very general ledger account for the first company code to sort key 002 and for the last one to 009:

Sort%20Key%20002%20-%20Document%20Number%20/%20Fisc%20Year

Sort Key 002 – Document Number / Fisc Year

Sort%20Key%20009%20-%20Reference%20Document%20Number

Sort Key 009 – Reference Document Number

Remember how the default customizing regarding Chart of Accounts INT looks like:

Customizing%3A%20Additional%20Rule%20for%20Automatic%20Clearing

Customizing: Additional Rule for Automatic Clearing

In order for an automatic clearing of such an account to work, it must have an entry in this table. Regarding Chart of Accounts INT this setup would work for the general ledger accounts 113101, 113102 and 131511. In all other cases we still would get the according information into our line item, however, automatic clearing would not consider this information.

If you want certain accounts to get considered differently by the automatic clearing, the sort key in combination with the assignment do provide a sophisticated solution. The only limitation is that the basic setup is part of customizing and based on the Chart of Accounts.

This means for the business to take the full capacity of automatic clearing an accounting manual is required that considers the dependency between

  • Chart Of Account
  • Account Number
  • Sort Key.