Configuring Object Dependencies

Objective

After completing this lesson, you will be able to configure advanced settings for object dependencies.

Object Dependencies Review

After you've created object dependencies for classification, you can customize them so that they work exactly the way you wanted, by:

  • Creating reference characteristics
  • Defining a processing sequence
  • Linking variant tables
  • Defining variant functions

Before we dive into these tasks, here's a quick refresher of information to keep in mind.

Note

If you've completed Unit 1: Creating and Testing Object Dependencies, you may skip this concept. If not, the following review may provide a useful memory refresher for the material you'll learn in this unit.

The following image shows the types of object dependencies that you can create.

Types of Object Dependencies

Object dependencies work:

  • During classification, for characteristics (values) and classes
  • Not during selection
  • In Variant Configuration, for characteristics (values)

In Variant Configuration, another type of object dependency is available: Constraints.

Object dependencies can be global or local:

  • Global object dependencies are created and maintained centrally using a separate function in the Variant Configuration menu. They're created using a name and can be used multiple times.
  • Local object dependencies are created specifically for a class, characteristic, or characteristic value. They receive a number internally and can't be used more than once.

Reference Characteristics and Syntax Elements for CHAR Characteristics

How Reference Characteristics Support Classification

You can combine characteristics with the master data field information in the SAP system to enable object searches. To do this, you'll work with reference characteristics.

The following video introduces the concept of reference characteristics.

In classification, reference characteristics link custom characteristics to standard master data fields (such as Material, Customer, or Vendor fields). Using the links, you can use the data in these fields to create reports, search for objects--or to set up object dependencies to set the values of other, non reference characteristics.

The following flowchart shows an example. The process begins by creating the characteristic MARA_WRKST, for the basic material field in a material. Reference characteristics display information that can be used for object searches and assist in the valuation of other characteristics via object dependencies.

A flowchart illustrating the concept of a reference characteristic in a classification system.

By using the table link to retrieve information directly from the object master, you can avoid inconsistencies when managing your classifications.

Syntax for CHAR Characteristics

A CHAR characteristic is used when the value of the characteristic is alphanumeric. It's one of the most common types due to its flexibility and ability to represent a wide range of information types, from text descriptions to coded values.

For CHAR characteristics, only three operators are available:

  1. Concatenate (||)- This element joins two strings and truncates the result if it exceeds 30 characters. Here's an example:

    $self.CHAR1 = 'Hello' || 'Classification' || 'HelloClassification'

    This assignment would assign to CHAR1 the value of Hello, appended to Classification and HelloClassification. Because the resulting string, HelloClassificationHelloClassification is longer than 30 characters, the value would be truncated to HelloClassificationHelloClassi

  2. Lowercase (LC) - This element converts all characters in a string to lowercase. So the following example:

    Code Snippet
    1
    $self.CHAR1 = LC( 'HelloClassification')

    Would assign to CHAR1 the value helloclassification

  3. Uppercase (UC) - This element converts all characters in a string to uppercase. So the following example:

    Code Snippet
    1
    $self.CHAR1 = UC( 'HelloClassification')

    Would assign to CHAR1 the value HELLOCLASSIFICATION

The following video shows these three operators as they appear in SAP.

Note

In Advanced Variant Configuration more operators are available. Classification, however, uses variant functions to perform the roles of those operators. We'll explore variant functions later in this lesson.

Functions and Operators

In principle, all usual functions and operators from mathematics can be used for numeric characteristics.

For string characteristics, we have three operators. In Advanced Variant Configuration more operators exist. In classifications we can use more functionality via variant functions.

How to Create Reference Characteristics

As you may recall, you can use reference characteristics to read information from a database table to use for a search.

You can also use the same information in object dependencies to assign values to other characteristics.

For example, the basic material is read from the MARA-WRKST field.

First, it's written directly to another characteristic.

With this syntax:

Code Snippet
1
$self.CMD00 = MARA_WRKST_00

Then, using syntax elements in object dependencies, the information is converted to lowercase letters, to uppercase letters to longer strings.

With this syntax:

Code Snippet
1
$self.CMD00 = LC(MARA_WRKST_00) || '-' || UC(MARA_WRKST_00) || '--------'

The following video demonstrates the creation of a reference characteristic for use in an object dependency.

Mass Change of Material Master and Classification and Object Dependencies

Finally, you should check how the object dependencies behave if you change the basic material here or enter it for the first time using the mass change of the material master. The following video demonstrates how to do this.

Processing Sequence of Object Dependencies

To properly set up multiple object dependencies in a classification system, you need to be aware of the sequence in which SAP will process them. The following video introduces this sequence.

Because sequences of dependencies that include multiple procedures involve steps-within-steps, they can become complex. The following example may help to clarify these sequences.

This slide shows the sequence in which object dependencies process procedures. The process starts with Enter, followed by Deletion of all valuations by procedures, Procedure, and Preconditions. It includes steps for setting color values using procedures and preconditions for characteristics and values. The text below details how these are handled.

In the image before this, the sequence begins with the deletion of any previous valuations by procedures, Next, we create four new procedures.

  • $self.COLOR = 'red' is assigned to the class "gearboxes"
  • $self.COLOR = 'blue'is assigned to the characteristic "Number of Gears."
  • $self.COLOR = 'green' is assigned to the characteristic value "5" for the "Number of Gears" characteristic.
  • $self.COLOR = 'yellow' is also assigned to the characteristic value "5" for the "Number of Gears" characteristic.

Now, we have four procedures, each of which specifies a different value for COLOR. What do you think happens to that characteristic when we classify a new object? Here's the sequence:

  1. The value of the "COLOR" characteristic is set to "red" initially, because the procedure =red assigned to the class is processed first.
  2. Next, the sequence moves to the characteristic "Number of Gears."
    • If the number of gears is unassigned, then the sequence ends, and the value of "COLOR" remains "red."
    • If a value is assigned to the number of gears, then the =blue procedure is processed. As a result, the "red" characteristic value for "COLOR" is overwritten and changed to "blue."
  3. Next, the sequence examines characteristic values for "Number of Gears."
    • If the number of gears is anything other than 5, the remaining two processes remain idle, and "COLOR" remains "blue."
    • If the number of gears is 5, then the =green procedure is executed, changing "COLOR" from "blue" to "green."
  4. Finally, the = yellow procedure is executed. Because the "Number of Gears" is still 5, that process changes "COLOR" from "green" to "yellow." Both the = green and = yellow procedures are executed. But because the= yellow procedure is processed last, it "gets the last word" and "wins."

The following demonstration will show the preceding sequence as it appears in SAP.

How to Specify a Processing Sequence

Let’s look at this theory with examples.

Variant Tables

What Are Variant Tables?

As the object dependencies in your system multiply, so does the challenge of managing them. The following video introduces one tool that can simplify this task: variant tables.

Deriving Characteristic Values With Variant Tables

By linking a variant table to a procedure, you can calculate missing values within a classification.

To enable value derivation from variant tables in procedures, you use value assignment alternatives to specify which table fields serve as key fields and which serve as data fields. Key fields are used to extract values for the data fields.

For example, consider a car manufacturer that sells the following types of vehicles:

  • Sport vehicles, which are always green
  • Economy vehicles, which are always blue
  • Comfort vehicles, which are always white

The following table illustrates these value combinations. It can be used in a procedure that uses the Mode characteristic to derive the Color and Characteristic D.

T_S41420_##

ModeColorCharacteristic D
SportGreenHello-s-G
EconomyBlueHello-e-B
ComfortWhiteHello-c-W

The following syntax would assign the procedure:

Key word:

TABLE

Declaration of table name:

T_S41420_##

Declaration of characteristics:

Code Snippet
1234
( CMC## = CMC## , CME## = $self.CME## , CMD## = $self.CMD## )

Characteristics that refer to data fields in the table must be flagged with the variable $SELF to enable value derivation. For example:

Code Snippet
123
Key: CMC## = Mode Derive: CME## = Color Derive: CMD## = Characteristic D

These can also be derived as default values:

Code Snippet
12345
TABLE T_S41420_## ( CMC## = CMC## , CME## ?= $self.CME## , CMD## ?= $self.CMD## )

Linking Variant Tables and Database Tables

You can use variant tables without a link, or you can link a variant table to a database table, so that the content can easily be used in object dependencies. You can either link to an existing database table, or you can create one. Either way, users can maintain content on the database table rather than the variant table.

For example, suppose you have a variant table and want to link it to an existing database table.

First, you'd create the structure of the variant table, including basic data and characteristics. In the basic data, you'd select "Enter Database Table" Then you would link the two using the following dialog.

A user interface with two elements: a check box labeled Link Active on the left, and a button labeled Field Assgmts on the right. The checkbox is currently unchecked.

On the other hand, let's say you want to link your variant table to a newly created database table.

First, create and activate the new database table in the ABAP Workbench. Define field names with suitable data elements for all characteristics used as keys in the variant table. Ensure that these corresponding fields are set as unique keys in the database table.

Next, link the variant table with the new database table, the same way as for an existing one.

Finally, you'd use the Variant Configuration menu to copy the data from the variant table to the database table. The following image shows this interface.

User interface for database operations with options for Insert, Insert and Change, and Insert, Change, and Delete. It also displays a menu under Tools with sections for Table Structure and Table Contents, listing functions such as CU61 - Create, CU62 - Change, CU63 - Display, CU64 - List, CU60 - Maintain, and CU59 - Transfer to Database Table.

How to Create Variant Tables

The video shows how to create variant tables and use these variant tables in object dependencies.

You can link variant tables to database tables. This makes it relatively easy-to-use the content of the database tables in object dependencies. You can simply access the variant table in the object dependencies and still use the content of the database table.

Variant Functions

In Variant Configuration and in classification, you can build your own programs to augment the functions of standard object dependencies. Written in the SAP programming language Advanced Business Application Programming Version 4 (ABAP/4), these programs result in dependencies that can't be mapped well with the standard object dependencies.

The following video illustrates the idea.

Variant functions allow you to enhance an object dependency with specialized logic for calculations or consistency checks. In a variant function, you reference an ABAP function module and pass import and export parameters to it. Within the function module, you can then access and process all relevant data further.

The syntax looks like this:

Key word:

FUNCTION

Declaration of function name:

Z_LABEL_ID

Declaration of characteristics:

Code Snippet
1234
(Chassis = $SELF.CHASSIS, ENGINE = $SELF.ENGINE, COLOR = $SELF.COLOR, LABEL_ID = $ROOT.LABEL_ID)

When you call a user-defined function module, the system no longer controls any potential error situations. The programmer who writes the function module can use all ABAP language elements but bears full responsibility for the code.

The process for defining a variant function for object dependencies is:

  1. Define the ABAP/4 Program - Here define Parameters for Import, Export, Changing, Tables and Exceptions.: Here define Parameters for Import, Export, Changing, Tables and Exceptions required for the function. The following screenshot shows the Function Builder interface that you'll use to do this. Other function modules are similar; only the attributes and the source code are different.A screenshot of the SAP Function Builder displaying the function module LOBM_UBD_PER_CENT in the Import tab. The table shows one parameter named GLOBALS with typing LIKE and associated type CUOV_00. The parameter is marked as passed.
    • Tab: Import

      Parameter Name = GLOBALS

      Associated Type = CUOV_00

    • Tab: Export

      empty

    • Tab: Changing

      empty

    • Tab: Tables

      Parameter Name = QUERY

      Associated Type = CUOV_01

      Parameter Name = MATCH

      Associated Type = CUOV_01

    • Tab: Exceptions

      Exception = FAIL

      Exception = INTERNAL_ERROR

  2. Define the ABAP/4 Program: - Source code Write the ABAP/4 program that includes the logic needed for your function.
  3. Create the Variant Function to Call the ABAP/4 Program: Here define Input and Output Characteristics Develop the variant function that will call and execute the ABAP/4 program. Specify the input and output characteristics required for the function.
  4. Include the Variant Function in an Object Dependency: Integrate the variant function into an object dependency, such as a procedure, using the keyword FUNCTION. Assign these object dependencies to the class, characteristic or characteristic value as needed.

    The syntax looks like this:

    Code Snippet
    123
    function z_t991 (characteristic1_f = charl1_o, characteristic2_f = char2_o, characteristic3_f = $self.char3_o)

The demonstration that follows shows two examples of variant functions.

How to Use Variant Functions

Examples of Variant Functions

Variant functions are the tool for having many more functions available in object dependencies. In this case, you can go beyond the restricted syntax of the object dependency to integrate function modules. This means that you can use all the functions of the SAP ABAP language..

A first variant function can create popups, if a characteristic with description "additional properties" is valuated.

This second variant function can split strings and assign them to characteristics.

In Variant Configuration with Advanced Variant Configuration, this can also be implemented much more easily.

Log in to track your progress & complete quizzes