Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CDS question

Former Member
0 Likes
1,493

I created a CDS view myself, and read the data from the source view, and published the created CDS view as a service to access. The result of the visit is: <?xml version="1.0" encoding="utf-8"?> <app:service xml:lang="en" xml:base="https://my300052-api.saps4hanacloud.cn/sap/opu/odata/sap/YY1_I_PURCHASEORDERAPI01_CDS/" xmlns:app="http://www. W3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/ Metadata" xmlns:sap="http://www.sap.com/Protocols/SAPData"> <app:workspace> <atom:title type="text">Data</atom:title> <app:collection sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:content-version="1" href="YY1_I_PurchaseOrderAPI01"> <atom:title type="text">YY1_I_PurchaseOrderAPI01</atom:title> <sap:member-title>YY1_I_PurchaseOrderAPI01Type</sap:member-title> </app:collection> </app:workspace> <atom:link rel="self" href="https://my300052-api.saps4hanacloud.cn/sap/opu/odata/sap/YY1_I_PURCHASEORDERAPI01_CDS/"/> <atom:link rel="latest-version" href="https://my300052-api.saps4hanacloud.cn/sap/opu/odata/sap/YY1_I_PURCHASEORDERAPI01_CDS/"/> </app:service>

5 REPLIES 5
Read only

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Likes
1,095

I am not sure what your question exactly is but I assume you are wondering how to access the data. And I also assume that you are trying to do this using the self service tools in S/4HANA.

The XML code snippet you posted looks like an excerpt of the service document of the OData Service that you have created by publishing the CDS view YY1_I_PURCHASEORDERAPI01. But it doesn't look complete. I assume you tried out the following URL

https://<my hostname>/sap/opu/odata/sap/YY1_I_PURCHASEORDERAPI01_CDS/

---------

Caution:
Please edit your question and replace the real hostname "my#####-api.saps4hanacloud.##" by a placeholder such as "<my hostname>" since your S/4HANA Cloud system is accessible via the Internet.

-----------

A complete service document that can be for example retrieved using the following URL

https://sapes5.sapdevcenter.com/sap/opu/odata/sap/EPM_REF_APPS_PO_APV_SRV/

from the ES5 demo System (see my blog "New SAP Gateway Demo System available" ) should look like follows

<?xml version="1.0" encoding="UTF-8"?>
<app:service xml:lang="de" xmlns:sap="http://www.sap.com/Protocols/SAPData" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xml:base="https://sapes5.sapdevcenter.com/sap/opu/odata/sap/EPM_REF_APPS_PO_APV_SRV/">
<app:workspace>
<atom:title type="text">Data</atom:title>
<app:collection sap:content-version="1" sap:updatable="false" sap:creatable="false" sap:deletable="false" href="PurchaseOrders">
<atom:title type="text">PurchaseOrders</atom:title>
<sap:member-title>PurchaseOrder</sap:member-title>
</app:collection>
<app:collection sap:content-version="1" sap:updatable="false" sap:creatable="false" sap:deletable="false" sap:pageable="false" href="PurchaseOrderItems">
<atom:title type="text">PurchaseOrderItems</atom:title>
<sap:member-title>PurchaseOrderItem</sap:member-title>
</app:collection>
<app:collection sap:content-version="1" sap:updatable="false" sap:creatable="false" sap:deletable="false" sap:pageable="false" sap:addressable="false" href="Suppliers">
<atom:title type="text">Suppliers</atom:title>
<sap:member-title>Supplier</sap:member-title>
</app:collection>
</app:workspace>
<atom:link href="https://sapes5.sapdevcenter.com/sap/opu/odata/sap/EPM_REF_APPS_PO_APV_SRV/" rel="self"/>
<atom:link href="https://sapes5.sapdevcenter.com/sap/opu/odata/sap/EPM_REF_APPS_PO_APV_SRV/" rel="latest-version"/>
</app:service>

Here you will find within the XML tag

<app:workspace>

one or more relative links

href="<Name of the Entity Set>" (here for example href="PurchaseOrders")

that will point to the entity sets published by your OData service.

Since it is a relative link you have to add it to the base service URL you have used to retrieve the service document.

So the URL you would be looking for in the above mentioned Service from ES5 is the following (<Base URL> + <Relative link found in the service document>)


https://sapes5.sapdevcenter.com/sap/opu/odata/sap/EPM_REF_APPS_PO_APV_SRV/PurchaseOrders

But I would also at at least the query Option $top=3 if you test your service to limit the number of entries.

So the URL to test would read as follows:

https://sapes5.sapdevcenter.com/sap/opu/odata/sap/EPM_REF_APPS_PO_APV_SRV/PurchaseOrders

?$top=3

ceterum censeo RAP esse utendam
Read only

0 Likes
1,095

As you said, I am now calling these APIs to create a purchase order. When I use this address: https://<my hostname>/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/A_PurchaseOrder, when I use the post request to call, I get an error: The requested service is not supported by entity ~A_PURCHASEORDER

Read only

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Likes
1,095

Than it sounds as if you have not implemented the creation of purchase orders in your service.

But you have to be more specific what environment you are working in order to be able to provide a meaningful answer.

I saw your Name also raising comments to questions in the C4C area.

So please provide more details about your environment.

  • C4C?
  • S/4HANA Cloud Key user Tools ?
  • On Premise SAP Gateway (since your Service URL Ends with a _SRV which would indicate that you are using the Service Builder.

Regards,

Andre

ceterum censeo RAP esse utendam
Read only

0 Likes
1,095

I am currently serving SAP S/4 Hana Cloud. I can't create a purchase order now. The relative API for the purchase order is: <app:workspace> <atom:title type="text">Data</atom:title> <app:collection sap:content-version="1" href="A_PurchaseOrder"> <atom:title type="text">A_PurchaseOrder</atom:title> <sap:member-title>A_PurchaseOrderType</sap:member-title> </app:collection> <app:collection sap:content-version="1" href="A_PurchaseOrderItem"> <atom:title type="text">A_PurchaseOrderItem</atom:title> <sap:member-title>A_PurchaseOrderItemType</sap:member-title> </app:collection> <app:collection sap:content-version="1" href="A_PurchaseOrderScheduleLine"> <atom:title type="text">A_PurchaseOrderScheduleLine</atom:title> <sap:member-title>A_PurchaseOrderScheduleLineType</sap:member-title> </app:collection> <app:collection sap:content-version="1" href="A_PurOrdAccountAssignment"> <atom:title type="text">A_PurOrdAccountAssignment</atom:title> <sap:member-title>A_PurOrdAccountAssignmentType</sap:member-title> </app:collection> <app:collection sap:content-version="1" href="A_PurOrdPricingElement"> <atom:title type="text">A_PurOrdPricingElement</atom:title> <sap:member-title>A_PurOrdPricingElementType</sap:member-title> </app:collection> </app:workspace> I don't know why this is not about system configuration, because I am using a communication scenario provided by SAP S/4 Hana Cloud. The scene number is 0053. It may be that the CDS view in this communication scenario is not equipped with ODATA service.

Read only

0 Likes
1,095

hello, I think I need your help