cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CAP Java - odataV2 and odataV4 example for generation by mavin plugin

MR3
Explorer
0 Likes
1,486

Hi, im working on a cap java project which uses standard odata v2 like API_PRODUCT_SRV and some own odata services . We are using fiori elements . We detect that the requested "search" function in fiori elements are not functional with OdataV2 . So we decide to change all odata service to v4. The standard service API_PRODUCT_SRV only exists as odata v2 -> when we see v4? Or isnt necessary to swtich to V4? Are existing some real world example where odata v2 AND odata v4 used together. I need examples where odatav2 and odataV4 clients are generated together with maven plugin( odata-generator-maven-plugin /odata-v4-generator-maven-plugin).

The question is not exposing V2 and V4 together. Thats simple done by the adapter.

I will have to generate the client java classes. I do this for the o2 services and also for v4. In V4 i have to override the V4 basepath because the edmx file doesnt contain this. Because im using 3 different o4 services i used 3 excution steps to do this. This is for me kind of strange, so i was looking for real world examples doing this in a better way?

<defaultBasePath>/sap/opu/odata4/sap/z7_dummyservice_o4/srvd/sap/z7_dummyservice/0001/
<defaultBasePath>/sap/opu/odata4/sap/z7_dummyserviceXY_o4/srvd/sap/z7_dummyservice/0001/

Kind Regards

Mario

View Entire Topic
MR3
Explorer
0 Likes

Hi ,

yes i'm aware of the remote service feature and also i used it in the configuration.

I needed some time to figured out the solution which works for me.

1. step in pom.xml create plugin areas for odata-generator-maven-plugin odata-v4-generator-maven-plugin

-> so i can generate Odata V2 and V4.

Override the default paths if need. Important Exclude the edmx files which are not corresponding with the odata generator version.

E.g. -> here is the odata-v4-generator-maven-plugin so exclude all edmx files for OData V2

<configuration>
<defaultBasePath>/sap/opu/odata4/sap</defaultBasePath>
<inputDirectory>${project.basedir}/external</inputDirectory>
<excludes>*_O2.edmx,API_BUSINESS_PARTNER.edmx,API_PRODUCT_SRV.edmx</excludes>

2. Step specify the main suffix path -> i must do this because in the namespace of my OData V4 has some gateway.xy information

-> Also i do a workaround by add "/" as service. This is used to get a final url like this

/sap/opu/odata4/sap/z7test_list_o4/srvd/sap/z7test_list/0001//....

remote.services:

- name: "Z7TEST_LIST_O4"

destination:

name: "s4onprem_local"

suffix: "/sap/opu/odata4/sap/z7test_list_o4/srvd/sap/z7test_list/0001"

service: "/"

type: "odata-v4"