Show TOC Start of Content Area

Procedure documentation Defining Business Object Associations  Locate the document in its SAP Library structure

Use

You can create associations between business objects. Association of business object nodes is a way to specify model-level dependency between two business object nodes. At runtime this is  implemented as a relation between the master tables of the two business objects nodes. The association gives you a way to retrieve related business object node instances of a particular business object node. Once you model an association in Composite Application Explorer and generate the code, there is a set of methods (set(), get(), add() and remove()) available in the business object nodes service interface to manage this association at runtime. Another way to use association is to model findBy operations that involve attributes of the associated business object nodes.

Procedure

...

       1.      Open the Associations tab page of the business object editor for which you want to create an association.

       2.      In the Available Business Object Nodes tree, select the business object node you want to associate.

Choose This graphic is explained in the accompanying text with the quick info text Add Association.

       3.      Optional: You can enable permission propagation for the association you have created. To do that, select it and set thePropagate Permission parameter to true in the Properties view.

       4.       Make the association bi-directional or unidirectional. To do that, enable or disable the Bi-Directional indicator on the Association tab page.

       unidirectional –  the association has a target and a source business object node.

       bi-directional – association has two sides. This way you allow the navigation, management, and usage of query operations for this association from both sides of the associated business objects.

Note

You can change the values of the Name and Cardinality fields for the target business object node on its Associations tab page.

CAF automatically creates associations for both source and target business object nodes in the Composite Application Explorer view.

       5.      Choose the type of your association. You have the following options regarding the type of the association:

       Child-parent associations between business objects.

If the parent business object node is deleted, the child business object node is deleted as well. To create a parent-child association, in the Composite Application Explorer, click the node of the business object and choose New BO Node. Choose the newly created business object node and choose This graphic is explained in the accompanying text with the quick info text Add Association.

       Cross-business object associations.

This way, if you delete the source business object, the target business object node of the association is not deleted. To create a cross-business object node association, choose a business object node with a different root node and choose This graphic is explained in the accompanying text with the quick info text Add Association.

       Internal business object node associations.

Result

The business object node has as a new association.

To remove an association, select it and choose This graphic is explained in the accompanying text with the quick info text Delete Association.

Example

You may have a business object node named Department that has an association to another business object node Employee. Then you can set the cardinality to be NONE_TO_MANY (that implies a collection) and you can get all the employees that currently work in a particular department. Three tables are generated at runtime – two for business object nodes and one table for the multiple association between them.

End of Content Area