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:
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:
- 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.
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
- Define the ABAP/4 Program: - Source code Write the ABAP/4 program that includes the logic needed for your function.
- 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.
- 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:
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.