cancel
Showing results for 
Search instead for 
Did you mean: 

Custom CDS Views remove Access Protection Fields

former_member306668
Participant
0 Kudos

Hi;

I like to to build a custom CDS View (as OData) that returns the project team for Customer and Internal projects. The closest view I found is I_ResourceAssignmentPlanItem, which works fine except that it returns to many duplicated entries. We are only interested in the EngagementProject itself and the EmployeeInternalID.

However the field PlanLineItemUUID is automatically added due the Access Protection. When making the OData call it returns a lot of duplicated entries, which we need to filter out every time.

Is there a way to have a custom cds view to return only unique values, and to somehow avoid the PlanLineItemUUID field being included.

Unfortunately I haven't fund any other view that can be used to return the project team.

Thanks

Thomas

Accepted Solutions (1)

Accepted Solutions (1)

MartyMcCormick
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Thomas

This CDS view has the hours per resource so the PlanLineItemUUID is the key (so the Project and InternalID are duplicated but other fields like hours aren't duplicated). The CDS views are using OData 2.0 so $apply groupby is not an option either.

What's the use case? Is it possible you can use the API for commercial project management and get back a list of all projects with the associated staffing?

https://api.sap.com/api/_CPD_SC_EXTERNAL_SERVICES_SRV/resource

Thanks,

Marty

former_member306668
Participant
0 Kudos

marty.mccormick

Thanks for the response. We are building a time sheet application in SCP and need to be able to display a list of projects where a logged on user is part of the project team. Hence for any given employee we need to retrieve the list of projects for them.

We had a look at the API but haven't been able to call it in the a way that we pass in the StaffedEmployee and then simply return project id and project name for of their projects.

Regards

Thomas

MartyMcCormick
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Thomas

I see and I am facing same issue.

However, although not ideal, maybe you possible approach is to call the API as such: https://my######-api.s4hana.ondemand.com/sap/opu/odata/CPD/SC_EXTERNAL_SERVICES_SRV/StaffingDataSet?... eq '50000920'

This will return all projects for which the user is assigned with duplicates. However, you will get json back in your app and since you are developing an app maybe you could iterate this set to generate unique list of values for your table?

Thanks,

Marty

MartyMcCormick
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Thomas

I just tested the following and I think it will work. I created a CDS view from I_EngagementProject. Then I associated the I_ResourceAssignmentPlan item on the General tab. I linked them on the engagement ID.

Then for fields, EngagementProject, EngagementProjectName, EmploymentInternalID will show the assigned resources. You can query based on EmplyomentInternalID to get a list of Projects & ProjectNames ror the user and then use the aforementioned logic I mentioned yesterday in your app to filter out duplicate entries.

sap/opu/odata/sap/YY1_ENGAGEMENTPROJECT_CDS/YY1_EngagementProject?$filter=EmploymentInternalID eq '50000780'&$select=EngagementProject,EngagementProjectName

TESTJOB1

TEST Job for Domestic Customer 17100001

Thanks,

Marty

former_member306668
Participant
0 Kudos

marty.mccormick The issue with this call is that it only returns the ProjectID, not very useful for the user. WPName would be an option but not for us, We will have several work packages for the project, but the resources will only be assigned to one. Ideally the call should return the ProjectSet based on a filter from the StaffingDataSet.

Another option could replicating between S/4HANA Cloud and an SCP Hana DB.

Thanks

Thomas

former_member306668
Participant
0 Kudos

marty.mccormick

Thanks this works fine except for the duplication obviously so we just need to eliminate the duplicate entries in the code.

We have also added work package information to the view. We have the requirement that we an employee can enter time against all work packages of the project and we only want to assign them to one work package.

Regards

Thomas

Answers (0)