
So far, we have created two applications. One to maintain employee specific Bonus Plans and a second to entitle bonuses for an employee. Until now the Bonus Entitlement is only dependent on the net amount of completed sales orders, but at the Bonus Plan one can already maintain relevant products.
Task: Make use of custom fields.
Example: Custom Fields for Bonus Data at Product are used to calculate an additional product based bonus.
I) Having completed all preceding parts of SAP S/4HANA Extensibility Tutorial.
II) Having Sales Orders in the system for the employee of the bonus plan as creator. The sales Orders where created within the validity period of the bonus plan. Their sum of Net Amount is higher than 3000,- Euros (multiplication product of bonus plan's Target Amount and High Bonus Assignment Factor) and consist of at least one product that is bonus relevant for the employee.
To be able to create Sales Order a user needs Business Catalog SAP_SD_BC_SO_PROC_MC.
To be able to complete Sales Orders a user needs Business Catalog SAP_LE_BC_ODLV_PROC_MC
The enablement of the Bonus fields in the Product UI, doesn't offer a possibility to read their data in Custom Business objects yet. To achieve that, do the following
1. Start the Custom Fields and Logic application by clicking its tile
2. Search for the Bonus Fields and do the following points 3.-8. of Step 3 for each of them
3. Open the details by clicking the field's list item
4. Go to “UIs and Reports”
6. “Enable Usage” for “Product active core entity”
7. Save the change.
8. Publish the field.
This has enhanced a CDS View with the field.
Hint: To see the CDS View name, open table Personalization via the action in the upper right corner
Check the "Data Source" Column and press OK to make that column visible in the table.
Now you can see the CDS View's name "i_product" that you have to use to get the custom field data in logic implementations
All relevant products maintained at a bonus plan shall be considered at bonus calculation.
1. Start the Custom Business Object’s application by clicking its tile
2. Search for the Bonus Entitlement object and open its details by clicking its list item
3. Create a draft version to be able to do changes by executing "Edit Draft" action.
4. Go to Fields and Logic of the its one node.
5. Create following field
Product Bonus Amount | Amount |
8. Go back and publish.
1. "Go to Fields and Logic"
2. Enter the After Modification Event Logic
3. Implement following additional functionality:
Bonus Calculation:
" calculate product bonus DATA: relevantproducts TYPE TABLE OF yy1_relevantproduct_bonusplan. DATA: products_s TYPE string. DATA: productbonus TYPE i. DATA: products TYPE TABLE OF i_product. DATA: product LIKE LINE OF products. SELECT * FROM yy1_relevantproduct_bonusplan INTO TABLE @relevantproducts WHERE sap_parent_uuid EQ @bonusplan-sap_uuid. LOOP AT relevantproducts INTO DATA(relevant_product). " get net amount for product SELECT * FROM i_product INTO @product WHERE i_product~product = @relevant_product-productid. ENDSELECT. CONCATENATE products_s product-product INTO products_s SEPARATED BY ','. IF product-yy1_bonuspercentage1_prd GT 0. SELECT FROM i_salesorderitemcube( p_exchangeratetype = 'M', p_displaycurrency = @bonusplan-targetamount_c ) FIELDS SUM( netamountindisplaycurrency ) WHERE createdbyuser = @bonusplan-employeeid AND overallsdprocessstatus = 'C' AND creationdate BETWEEN @bonusplan-validitystartdate AND @bonusplan-validityenddate AND creationdate BETWEEN @product-yy1_bonusvalid1tystart_prd AND @product-yy1_bonusvalidityend1_prd AND material = @relevant_product-productid INTO @bonusentitlement-productbonusamount_v. " if net amount for product greater 0, calculate its bonus IF bonusentitlement-productbonusamount_v GT 0. bonusentitlement-productbonusamount_v = bonusentitlement-productbonusamount_v * product-yy1_bonuspercentage1_prd / 100. productbonus = productbonus + bonusentitlement-productbonusamount_v. ENDIF. ENDIF. ENDLOOP. bonusentitlement-productbonusamount_v = productbonus. bonusentitlement-productbonusamount_c = bonusplan-targetamount_c. " calculate total bonus bonusentitlement-totalbonusamount_v = bonusentitlement-lowbonusamount_v + bonusentitlement-highbonusamount_v + bonusentitlement-productbonusamount_v. bonusentitlement-totalbonusamount_c = bonusplan-targetamount_c. " write bonus plan information into description DATA(employee_s) = CONV string( bonusplan-employeename ). DATA(target_s) = CONV string( bonusplan-targetamount_v ). DATA(lowf_s) = CONV string( bonusplan-lowbonusassignmentfactor ). DATA(lowp_s) = CONV string( bonusplan-lowbonuspercentage_v ). DATA(highf_s) = CONV string( bonusplan-highbonusassignmentfactor ). DATA(highp_s) = CONV string( bonusplan-highbonuspercentage_v ). CONCATENATE 'Bonus Run for Plan: ' bonusentitlement-bonusplanid ' of Employee: ' employee_s ' with Target Amount: ' target_s ', Low Factor: ' lowf_s ', Low Percentage: ' lowp_s ', High Factor: ' highf_s ', High Percentage: ' highp_s ', Products: ' products_s INTO bonusentitlement-description SEPARATED BY space.
4. Publish the logic.
1. Open the Bonus Entitlement application.
2. Create an object.
3. Enter following data
Bonus Plan | 2 |
4. Save the Bonus Entitlement. All Data of the Entitlement will get filled, including the product based bonus.
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 | |
6 | |
5 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |