Skip to Content
Author's profile photo Former Member

Sort Key Functionalities

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.

Assigned tags

      32 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      its very helpfull ... 

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Debarun!

      Author's profile photo Sankar AK
      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

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Most welcome SKA!

      Author's profile photo Cecil D'Souza
      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?.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Cecil,

      Please use the transaction code OB16 to access the details of Sort Keys.

      Thanks and regards,

      Ajit

      Author's profile photo Cecil D'Souza
      Cecil D'Souza

      Thank you very much Ajit for your timely help. It's great to get professional help and guidance like this. What a system this internet has created.

      Author's profile photo Ranu Eugene
      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

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Eugene

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Former Member
      Former Member

      Very useful …thank you

      Author's profile photo Lakshmi Sama
      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

      Author's profile photo narin kamuni
      narin kamuni

      Very well documented... Very useful document... Thanks for the efforts.

      Regards,

      Narin Kamuni

      Author's profile photo Arvind Pereira
      Arvind Pereira

      Hello Arjit,

      Very helpful, Very useful, very clear.

      Thanks

      Arvind

      Author's profile photo Former Member
      Former Member

      Arjit,

      Very helpful !

      Author's profile photo pulak samantaray
      pulak samantaray

      thanks ajit,

      nice document

      regards

      pulak

      Author's profile photo Former Member
      Former Member

      beautiful explanation!! thanks for sharing your knowledge πŸ™‚

      Author's profile photo Former Member
      Former Member

      Very Very Helpful

      Thanks

      Regards

      KIran

      Author's profile photo Former Member
      Former Member

      Thanks for sharing a great document sir !!!

      Author's profile photo Kiran MMD
      Kiran MMD

      Thank you very much for the detailed explanation regarding Sort key. Its self explanatory and really helpful.

      Author's profile photo Former Member
      Former Member

      Its very good notes.

      Author's profile photo CA. Prasad Atmakuri
      CA. Prasad Atmakuri

      Hi Ajith

      Thanks for sharing nice document

      Regards

      Prasad

      Author's profile photo Former Member
      Former Member

      Hi Ajith,

      Thanks a lot for sharing.

      It is very useful info.

      Regards,

      GSR

      Author's profile photo Prakash Sutar
      Prakash Sutar

      Hi Ajit,

      Very useful information and nicely presented.

      Thanks,

      Prakash

      Author's profile photo Manasi kulkarni Phatak
      Manasi kulkarni Phatak

      Very useful Info..

      Author's profile photo Selvakumar Natarajan
      Selvakumar Natarajan

      very very useful info.. the area often user fail to do the appropriate sort key... thank u for your efforts..

      Author's profile photo Former Member
      Former Member

      Hi Ajit,

      Nice document. beautiful explanation.

      Regards

      Karthi

      Author's profile photo Hoysala SAP
      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.

      Author's profile photo Vishwanath Gamanagatti
      Vishwanath Gamanagatti

      Its very informative and very well documented. Thanks for taking affects and Β sharing with us.

      Author's profile photo Former Member
      Former Member

       

      Well explained

      Author's profile photo Former Member
      Former Member

      thanks for sharing!

      Author's profile photo Shashikant Gaekwad
      Shashikant Gaekwad

      Thoroughly explained sort key. good document for begginers. thank you so much...