Skip to Content

Contents of the Document:

This document is an attempt at analyzing the functionality of sort key in SAP.

This document provides a framework for understanding:

  • What is a Sort Key
  • What is the functionality of a sort key
  • What are the uses of Sort Key
  • General process flow for using sort key
  • Example for illustrating the sort key functionality

Sort Keys:

Sort Keys are used to populate the Assignment number field in the line items of customers or vendors or general ledgers.

The content of this Assignment number field can be populated in a customer or vendor or general ledger document when the document is created:

  • either manually
  • or automatically by the system

Whenever a document is created, the Assignment number field in the document line items will be populated automatically, if the requisite sort keys are assigned to the customers or vendors or general ledgers master record.

Use of Sort Key – Benefits of Automatic Population of Assignment Field:

Whenever any standard reports are executed for displaying the line items of customers or vendors or general ledgers, SAP uses the content of the Assignment number field as one of the criteria to sort and display the line items.

What are the contents that can be populated automatically in the Assignment number field:

The Assignment number field of a customer or vendor or general ledger document line item can be populated automatically with the contents of one or more fields which are:

  • Either the data derived from the header of the document
  • Or the data derived from the line item of the document

The only requirement is that the above mentioned data proposed to be populated automatically in the Assignment number field should be available in one of the database tables – BKPF or BSEG or BSEC or BSED.

Can partial contents be populated in the Assignment number field:

The contents of the fields available in the database tables – BKPF or BSEG or BSEC or BSED can be populated automatically in the Assignment number field of the document, either completely or partially.

This can be controlled by mentioning the length of the field to be transferred in the fields – Length and Offset.

Applicability of the Sort Key logic:

The logic defined in the Sort Key is applicable across the client.

General Process Flow Describing Sort Key Functionality:

Sort Key - Process Flow1.png

Illustration of Sort Key Functionality:

Step 1:

SAP Configuration – Define Sort Key:

Description Transaction Code
Determine Standard Sorting for Line Items SPRO/OB16

The standard sort keys provided by SAP can be used to automatically populate the Assignment number field.

But custom sort keys can also be defined if the requirements of the client cannot be met with the standard sort keys available.

For example, if the standard sort key – 002 is assigned to the customer or vendor or general ledger master record, it would populate the Assignment number field of the document with the document number (BELNR) followed by the fiscal year (GJAHR).

Similarly, the standard sort key – 001, would populate the Assignment number field of the document with the posting date.

Sort Key SPRO 1.PNG

Sort Key SPRO 2.PNG

Parameters of standard sort key 002 – Screen Shot:

Sort Key SPRO 3.PNG

Parameters of standard sort key 001 – Screen Shot:

Step 2:

Master Data maintenance – for illustrating Sort Key Functionality:

Assigning Sort Key in the customer master:

Description Transaction Code
Create/change Customer master FD01/FD02/XD01/XD02

In the example, the standard sort key – 001 has been assigned to the customer master.

Customer Master - Assign Sort Key 001.PNG

Assignment of Sort Key in Customer Master Record – Screen Shot:

(Similar assignment can be made in the case of vendor or general ledger master record also)

Step 3:

Transactional data – for illustrating Sort Key Functionality:

Post Invoice against customer:

Description Transaction Code
Enter Customer Invoice FB70/VF01

An invoice is posted against the customer referred above, without entering anything in the Assignment number field.

After the document is saved, if the Assignment number field is checked, it can be seen that the field is automatically populated with the posting date of the document.

In the example below, the sort key assigned in the customer master record is 001 – Posting Date.

Since the posting date of the customer invoice – 7500205569, is 07/20/2012, the Assignment number field in the document is automatically populated with the posting date in the format YYYYMMDD (20120720).

Allocation Field in Invoice.PNG

Automatic population of Assignment Number field in the customer invoice – Screen Shot:

Similarly, for subsequent documents posted, the posting date would automatically get populated in the Assignment number field.

In the example, the posting date of the document 7500208207 is 08/03/2012, and hence the Assignment number field is automatically populated as 20120803.

Similarly, the posting date of the document 7500210765 is 08/17/2012, and hence the Assignment number field is automatically populated as 20120817.

Step 4:

Transactional data – for illustrating Sort Key Functionality:

Customer Line Item Display:

Description Transaction Code
Customer Line Item Display FBL5N

When the transaction code is executed to display the customer line items, it can be observed that the line items are displayed sorted on the basis of the content of the Assignment number field.

Customer Line Item Display.PNG

Customer Line Item Display Report – Screen Shot:

Step 5:

Transactional data – for illustrating Sort Key Functionality:

Modify Assignment number field of the customer invoice:

Description Transaction Code
Change Customer Document Line Item FB02

The Assignment number field of the customer invoice – 7500205569 is modified manually and the content is changed from 20120720 to 20120920

Modified Allocation Field in Invoice.PNG

Modification of Assignment Number field in Customer Invoice – Screen Shot:

Step 6:

Transactional data – for illustrating Sort Key Functionality:

Re-run Customer Line Item Display:

Description Transaction Code
Customer Line Item Display FBL5N

When the transaction code is re-executed to display the customer line items, it can be observed that the line items are displayed sorted on the basis of the content of the modified Assignment number fields.

The customer invoice – 7500205569 which was previously displayed as the first invoice in the report is currently being displayed as the third invoice, because the content of the Assignment number field has been modified.

Modified Customer Line Item Display.PNG

Customer Line Item Display Report after modification of Assignment number field – Screen Shot:

Conclusion:

Based on the above discussion, it can be concluded that:

  • The Assignment number field of a customer or vendor or general ledger document, if not manually populated, will be automatically populated with the data from the header or line item of the document as per the sort key assigned to the customer or vendor of general ledger master record.
  • The content that will be populated in the Assignment number field will be derived from the database tables – BKPF or BSEG or BSEC or BSED.
  • The customer line items are displayed in standard SAP reports after being sorted on the basis of the content of the Assignment number field.
To report this post you need to login first.

30 Comments

You must be Logged on to comment or reply to a post.

  1. Sankar AK

    Hi Ajit kumar,

      Helped me to understand the functionaries of Sort key and also helped me to analyse our client’s issue in this regards. Thanks for this nice document.

    Thanks

    (0) 
  2. Cecil D'Souza

    I am a newbie and I found that it is impossible to get to the sort key screen by entering SPRO and Enter. I then used tcode SM30 and it asks for the table name. Can you please adjust the procedural steps to fill the gap?.

    (0) 
  3. Ranu Eugene

    Hi Ajit,

    Very helpful and self explanatory doc. πŸ™‚

    Very well described by you and it made very clear the use of sort keys in Master Data.

    Nice job done. πŸ™‚

    Keep up the good work. πŸ™‚

    Best of Luck.

    Regards

    Eugene

    (0) 
  4. deepa p

    Hi Ajit,

    Nice doument of sort keys… i guess its really helpful for beginners like me, mainly sharing the knowledge on customization of sort keys is appreciated.

    regards

    Deepa

    (0) 
  5. Lakshmi Sama

    Hello Arjit,

    Very helpful and a good concept. And very well explained. Thanks for sharing the knowledge on a new concept πŸ™‚ and keep sharing

    Regards,

    Lakshmi S

    (0) 
  6. Hoysala SAP

    Thanks a lot, Ajith.

    Can you pls clarify my doubt. We will need to populate #Shipment number in Assignment field and that Shipment number is available in Material document. However, I do not find any Logistic related fields in OB16. Can you pls let me know how can we achieve this requirement.

    Thank you.

    (0) 

Leave a Reply