cancel
Showing results for 
Search instead for 
Did you mean: 

How to call the data query in SAP BTP Android wizard generated code

dillibabubottu
Explorer
0 Kudos

Dear Experts,

I generated the offline code using SAP BTP SDK wizard from android studio, Now i want to call the multiple collections in one screen for example :  Products  and Typesets in single screen, I tried using data query but it is not working , can any one explain how to call the data quey using data service in wizard generated code .

 

Thanks, 

Delli

dillibabubottu
Explorer
0 Kudos

Hi Bruce,

It looks like the generated DataService proxy class is named "SFGW_ALL_Entities" in your project, right?

Yes data service calss name is SFGW_ALL_Entities

Here i am facing the issue while getting the instance for SFGW_ALL_Entities , i am getting SFGW_ALL_Entities unable to resolve the class .

I am not getting how to solve this , can you guide me how to do this 

Thanks,

Delli 

Accepted Solutions (0)

Answers (1)

Answers (1)

bruce_qin
Advisor
Advisor
0 Kudos

Hello Delli,

Could you please show the specify errors you got? And what is the version of the SDK that you were using?
There is a "WizardAppReadme.md" file in the generated application for you to get started with the DataService and DataQuery.

Normally in the application generated by the assistant, you can get the DataService in OfflineWorkerUtil object.
You can check the generated source for how this DataService was initialized.

Once you get the DataService instance, you then can use DataService.executeQuery API to query the date you want.
https://help.sap.com/doc/f53c64b93e5140918d676b927a3cd65b/Cloud/en-US/docs-en/reference/android/java...

Thanks,
Bruce

dillibabubottu
Explorer
0 Kudos

Hi Bruce ,

Thanks for the reply.

In OfflineWorkerUtil class i am able to see the Data Service , but i am not able to access that Dataservice in another class . Please find the below code snippet in OfflineworkerUtil 

 * OData service for interacting with local OData Provider
*/
private static SFGW_ALL_Entities sFGW_ALL_Entities;

@NonNull
public static SFGW_ALL_Entities getSFGW_ALL_Entities() {
if (sFGW_ALL_Entities == null) {
throw new NullPointerException("sFGW_ALL_Entities was not initialized.");
}
return sFGW_ALL_Entities;
}

Kindly guide me how to access this in another class

Thanks ,
Delli
bruce_qin
Advisor
Advisor
0 Kudos

Hello Deli,
You may want to go through the tutorial fist,
https://developers.sap.com/tutorials/cp-sdk-android-wizard-app-offline.html.
It is not possible to understand what is the the code snippet your shared means without the sample project.
Could you please share more details?

Thanks,
Bruce

bruce_qin
Advisor
Advisor
0 Kudos

It looks like the generated DataService proxy class is named "SFGW_ALL_Entities" in your project, right?
The source code of SFGW_ALL_Entities is automatically generated after you make the build. You can find all the available APIs in that SFGW_ALL_Entities class(usually under the app/build/generated/source folder).
With that SFGW_ALL_Entities object instance you can make any odata query on the local db to suit your needs, thanks.

dillibabubottu
Explorer
0 Kudos

Hi Bruce ,

Thanks for your reply ,

It looks like the generated DataService proxy class is named "SFGW_ALL_Entities" in your project, right? : Yes , SFGW_ALL_Entities is the proxy class 
When i am trying to create the instance , it is giving me the error  like unable to access the SFGW_ALL_Entities,

Can you guide me how to access the Data service class in another class

 

Thanks ,

Delli