cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to access individual fields from sdsdk response

0 Kudos

Hi Experts,

I followed the blog: https://blogs.sap.com/2018/04/30/deep-dive-10-with-sap-s4hana-cloud-sdk-generating-java-vdm-for-s4ha...

I am able to generate the vdm & access the response as string as well, but my use case is to create a join between 2 different services by comparing 1 common key in both the services, below is my code & respective output:

final List<SamplSrv> result1 = new GetAllSamplSrvCommands(service).execute();        	
for(SamplSrv var1: result1) {
        jsonResult += "is empty: " + var1.getCustomFields().isEmpty() + " \n ";
        jsonResult += "get custom fields: " + var1.getCustomFields() + " \n ";
        jsonResult += "hash code: " + var1.hashCode() + " \n ";
        jsonResult += "erp context: " + var1.getErpConfigContext() + " \n ";
        jsonResult += "string value of var1: " + new Gson().toJson(var1) + " \n ";
        break;
}

0 Kudos

Hi ekaterina.gavrilova your help is much appreciated

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member186608
Active Participant
0 Kudos

Can you upload your metadata file so that we can reproduce the issue?

former_member186608
Active Participant
0 Kudos

Hi Armoghan,

can you pls point out which problem you are facing?

Thanks

Marco

0 Kudos

Hi Marco,
thanks for responding, I am getting the values as String but not as fields in the result list (refer to the code & screen I shared in my post).
Problem is that I need to access individual fields from the result, is there any way for doing that?

former_member186608
Active Participant
0 Kudos

Hi Armoghan,

I guess you may use the respective getter methods on your reference named "var1".

Have you tried this?

Marco

0 Kudos

Hi Marco,
Apologies, I am unable to follow which getter you are referring to.
I did try using var1.PRCTR (a field name), but all I get as output is: com.sap.cloud.s4hana.examples.vdm.namespaces.zsbscustlinescds.field.CustomerLineItemsField@5339dda3
Following is the screen of all the getters I get in suggestion, I hope it will help you guide me in the right direction: