Part III: Custom Code List (Bonus Plan)

So far, we created a custom business object “Bonus Plan” with simple data structure, initialization and check logic and application UI. This business object is there to save employee specific rules for bonus entitlement.

Task: Create your Custom Code List to be used in your custom Business Object

Example: A code list for release status shall be used in Bonus Plan to reflect if a Bonus Plan is still under work or ready for use.

Prerequisites

Step 1: Creating the Custom Code List

3. Start Creation process of a Code List by clicking the “New” action.

4. Maintain following information for the new code list.

Name: “Release Status”

Maximum Code Length: 1

First new Code Value: Code: 1, Description: “Not Released”

Second new Code Value: Code: 2, Description: “Released”

5. Execute action “Save and Publish”

Step 2: Enhancing Bonus Plan structure

To make use of this new code list, you first have to add it to the structure of the Bonus Plan Business Object.

1. Go back in Custom Business Objects application and switch to Custom Business Objects view.

2. Open “Bonus Plan”.

3. Press “Edit Draft” action.

4. “Go to Fields and Logic”.

5. Click the “New” field action.

6. Name the new field “Release Status”.

7. Switch its Type to “Code List”.

8. In the Code List field start typing yy1_releasestatus until the value help offers the right name to choose easily.

9. Go back inside the application and publish the Bonus Plan definition.

Step 3: Enhancing Bonus Plan logic

After having added it to the Business Object structure, also the business logic has to deal with it.
In the After Modification Event we want to find out if end user just set the bonus plan to “Released” and ensure that bonus plan’s consistency allows to leave this end user change.

After Modification Event

1. In Custom Business Object application view on Bonus Plan “Go to Fields and Logic”.

2. Open After Modification Event in Determination Logic.

3. Create a Draft implementation.

4. Implement following functionality:General:Set ReleaseStatus to “1” (Not Released) if still initial.

1. In Custom Business Object application view on Bonus Plan “Go to Fields and Logic”.

2. Open Before Save Event in Validation Logic.

3. Create a Draft implementation.

4. Implement following functionality:
Save rejection shall no longer be dependent on consistency but on release status.Hint: Exporting parameter valid must be set to true for save and to false for save rejection

A consistent bonus plan which just shall get released, can be saved.

An inconsistent bonus plan which just shall get released, shall be set to “Not Released” by end user again and made consistent first.Hint: The release status from before current changes can be read from database

Changing and therefore saving an already released bonus plan is not allowed.

A bonus plan in status “Not Released” can be saved, but first consistency error shall be given back as information.Hint: Exporting parameter message gets automatically an information only if save is not rejected. (valid = abap_true)