
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.
Having completed all preceding parts of SAP S/4HANA Extensibility Tutorial.
1. Open Custom Business Objects application
2. Switch to the Custom Code List view
3. Start Creation process of a Code List by clicking the "New" action.
4. Maintain following information for the new code list.
5. Execute action "Save and Publish"
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.
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.
* set release status initially IF bonusplan-releasestatus IS INITIAL. bonusplan-releasestatus = '1'. ENDIF.
5. Publish the logic
6. Go back
Before Save Event
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
* decide about save rejection IF bonusplan-releasestatus EQ '2'. SELECT SINGLE ( releasestatus ) FROM yy1_bonusplan INTO @DATA(releasestatus_db) WHERE id = @bonusplan-id. IF releasestatus_db NE '2'. IF bonusplan-isconsistent EQ abap_true. valid = abap_true. message = 'Bonus Plan released successfully.'. ELSE. valid = abap_false. message = 'Bonus Plan is inconsistent and cannot be released. Set it back to "Not Released" and solve inconsistencies first.'. ENDIF. ELSE. valid = abap_false. message = 'Bonus Plan was already released before. Changes are forbidden and saving is not possible.'. ENDIF. RETURN. ELSE. valid = abap_true. ENDIF. * consistency check START * same code as in Tutorial Part II following
5. Publish the logic
1. Open the Bonus Plan application
2. Open the Bonus Plan, created in Part I tutorial
3. Execute the “Edit” action to start editing.
4. Delete the Target Amount value.
5. Save the Bonus Plan. Save succeeds, but brings Warning due to missing Target Amount.
6. Enter Edit mode again.
7. Choose Release Status "Released".
8. Save the Bonus Plan. Save fails due to release status change while having the inconsistency of a missing target amount.
9. Enter Target Amount 1000 again.
10. Save the Bonus Plan. Save succeeds.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
7 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |