Skip to Content
Nov 03, 2020 at 01:57 PM

normal approval process after BADIforApprovalCustomResponsibilityDetermination


Hi Experts,

I have developed a code to add the managers of the employees/cost center managers as approvers of project baseline if they have planned hours in a project. I achieved that using the BADI: BADIforApprovalCustomResponsibilityDetermination

But when the project have no employees or non of the employees have any hours the the baseline approval will be pending with no approvers and will need to be assigned an approver manually from the Business Task management. Is there anyway to skip the custom approval process if the conditions didn't met?

My code is as follow:

Add your SAP Business ByDesign scripting language implementation for:
Enhancement Option: BADIforApprovalCustomResponsibilityDetermination
Script file signature
Parameter: InputData of type BADIforApprovalCustomResponsibilityDetermination
Returns: CustomApprovalCategoryEmployeeResponsibles
  - To use code completion, press CTRL+J.
import AP.FO.Task.Global;
import AP.Common.GDT;
import AP.ProjectManagement.Global;
import ABSL;
var result : CustomApprovalCategoryEmployeeResponsibles;
var baselineUUID : DataType::UUID;
//Get the baseline
baselineUUID.content = Library::UUID.ParseFromString(InputData.KeyFieldValue.content.ToString());
var baseline : ProjectBaseline=ProjectBaseline.Retrieve(baselineUUID);
var projectID = baseline.BaseProjectID;
//Get the prject associated with this baseline
var QueryProject = Project.QueryByCreationIdentity;
var SelectionParams = QueryProject.CreateSelectionParams();
SelectionParams.Add(QueryProject.ProjectID.content, "I", "EQ", projectID.content);
var projects = QueryProject.Execute(SelectionParams);
if (projects.Count() != 0)
var project = projects.GetFirst();
var participants = project.Participant;
foreach (var p in participants)

var lt : CustomApprovalCategoryEmployeeResponsibles.EmployeeResponsibles;
var zeroWorkingHours : Quantity;
zeroWorkingHours.content = 0;
zeroWorkingHours.unitCode = p.TotalPlannedWorkQuantity.unitCode;
var manager : DataType::UUID;
// If the employee has planned working hours, then the cost center manager needs to be an approver.
if (p.TotalPlannedWorkQuantity.GreaterThan(zeroWorkingHours))
//Get the current cost center manager.
if (p.Employee.IsSet())
{//check for direct manager.
if (p.Employee.Position.CurrentResponsibleManager.GetFirst().IsSet())
if (p.Employee.Position.CurrentResponsibleManager.GetFirst().ResponsibleManagingEmployee.IsSet())
if (!p.Employee.Position.CurrentResponsibleManager.GetFirst().ResponsibleManagingEmployee.UUID.IsInitial())
manager = p.Employee.Position.CurrentResponsibleManager.GetFirst().ResponsibleManagingEmployee.UUID;
//check for the higher cost center manager
else if (p.Employee.Position.CurrentSuperordinateCostCentre.GetFirst().IsSet())
if (p.Employee.Position.CurrentSuperordinateCostCentre.GetFirst().ResponsibleManager.GetFirst().IsSet())
if (!p.Employee.Position.CurrentSuperordinateCostCentre.GetFirst().ResponsibleManager.GetFirst().ResponsibleManagingEmployeeUUID.IsInitial())
manager = p.Employee.Position.CurrentSuperordinateCostCentre.GetFirst().ResponsibleManager.GetFirst().ResponsibleManagingEmployeeUUID;

//if manager found add the manger to the approvers.
if (!manager.IsInitial())
lt.content = manager.content;
return result;

So what if result didn't have any thing?