cancel
Showing results for 
Search instead for 
Did you mean: 

RAP service consumption model - OData $expand issue

I am trying to fetch the data from the remote API.

I have an issue with reading the associated entity set, the problem is that the API returns the correct data structure

there is a nested table from the related entity in the object retrieved by the framework, but there is an issue with

calling get_business_data method.

The existing logic works perfectly fine for a flat structure of entity - while I am not using expand_node

How can I fix it?

Thanks in advance for your help

Below the code

" Query implementation

DATA:

read_list_response TYPE REF TO /iwbep/if_cp_response_read_lst,

materials TYPE STANDARD TABLE OF zae_ps_pet_materialsset.

DATA(client_proxy) = zcl_ps_pet_material_proxy=>get_client_proxy( ).

DATA(read_request) = client_proxy->create_resource_for_entity_set( 'MATERIALSET' )->create_request_for_read( ).

DATA(expand_node_root) = read_request->create_expand_node( ).

DATA(expand_node) = expand_node_root->add_expand( '_CLASSIFICATION' ).

expand_node->add_expand( '_CLASS_CSTICS' ).

read_request->set_expand( expand_node_root ).

read_list_response = read_request->execute( ). " read_list_response cointains _classifcation structure - screenshot below

read_list_response->get_business_data( IMPORTING et_business_data = materials ). " Error - Field _CLASSIFICATION not found in the data container of entity type ET_CCED138628261B822C847A33FBF.

@OData.entitySet.name: 'MaterialSet'

@OData.entityType.name: 'Material'

define root abstract entity ZAE_PS_PET_MATERIALSSET {

key MaterialNumber : abap.char( 18 ) ;

@Odata.property.valueControl: 'OldMaterialNumber_vc'

OldMaterialNumber : abap.char( 18 ) ;

OldMaterialNumber_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'CreatedOnDate_vc'

CreatedOnDate : RAP_CP_ODATA_V2_EDM_DATETIME ;

CreatedOnDate_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'CreatedByUser_vc'

CreatedByUser : abap.char( 12 ) ;

CreatedByUser_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'LastChangedOnDate_vc'

LastChangedOnDate : RAP_CP_ODATA_V2_EDM_DATETIME ;

LastChangedOnDate_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'ChangedByUser_vc'

ChangedByUser : abap.char( 12 ) ;

ChangedByUser_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'ManufacturerPartNumber_vc'

ManufacturerPartNumber : abap.char( 40 ) ;

ManufacturerPartNumber_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'BaseUnitOfMeasure_vc'

BaseUnitOfMeasure : abap.char( 3 ) ;

BaseUnitOfMeasure_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'MaterialGroup_vc'

MaterialGroup : abap.char( 9 ) ;

MaterialGroup_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'MaterialType_vc'

MaterialType : abap.char( 4 ) ;

MaterialType_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'DeletionFlag_vc'

DeletionFlag : abap_boolean ;

DeletionFlag_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'CrossPlantMaterialStatus_vc'

CrossPlantMaterialStatus : abap.char( 2 ) ;

CrossPlantMaterialStatus_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'PurchaseOrderUnitOfMeasure_vc'

PurchaseOrderUnitOfMeasure : abap.char( 3 ) ;

PurchaseOrderUnitOfMeasure_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'AuthorizationGroup_vc'

AuthorizationGroup : abap.char( 4 ) ;

AuthorizationGroup_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'MaterialText_vc'

MaterialText : abap.char( 40 ) ;

MaterialText_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'GrossWeight_vc'

@Semantics.quantity.unitOfMeasure: 'WeightUnit'

GrossWeight : abap.dec( 13, 3 ) ;

GrossWeight_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'NetWeight_vc'

@Semantics.quantity.unitOfMeasure: 'WeightUnit'

NetWeight : abap.dec( 13, 3 ) ;

NetWeight_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'WeightUnit_vc'

@Semantics.unitOfMeasure: true

WeightUnit : abap.unit( 3 ) ;

WeightUnit_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'Volume_vc'

@Semantics.quantity.unitOfMeasure: 'VolumeUnit'

Volume : abap.dec( 13, 3 ) ;

Volume_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'VolumeUnit_vc'

@Semantics.unitOfMeasure: true

VolumeUnit : abap.unit( 3 ) ;

VolumeUnit_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'Length1_vc'

@OData.property.name: 'Length'

@Semantics.quantity.unitOfMeasure: 'UnitOfDimension'

Length1 : abap.dec( 13, 3 ) ;

Length1_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'Width_vc'

@Semantics.quantity.unitOfMeasure: 'UnitOfDimension'

Width : abap.dec( 13, 3 ) ;

Width_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'Height_vc'

@Semantics.quantity.unitOfMeasure: 'UnitOfDimension'

Height : abap.dec( 13, 3 ) ;

Height_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'UnitOfDimension_vc'

@Semantics.unitOfMeasure: true

UnitOfDimension : abap.unit( 3 ) ;

UnitOfDimension_vc : RAP_CP_ODATA_VALUE_CONTROL ;

ETAG__ETAG : abap.string( 0 ) ;

@OData.property.name: 'to_Classification'

//A dummy on-condition is required for associations in abstract entities

//On-condition is not relevant for runtime

_Classification : association [0..*] to ZAE_PS_PET_CLASSIFICSET on 1 = 1;

}

@OData.entitySet.name: 'ClassificationSet'

@OData.entityType.name: 'Classification'

define root abstract entity ZAE_PS_PET_CLASSIFICSET {

key MaterialNumber : abap.char( 50 ) ;

key ClassNumber : abap.numc( 10 ) ;

@Odata.property.valueControl: 'Class_vc'

Class : abap.char( 18 ) ;

Class_vc : RAP_CP_ODATA_VALUE_CONTROL ;

@Odata.property.valueControl: 'ClassDescription_vc'

ClassDescription : abap.char( 40 ) ;

ClassDescription_vc : RAP_CP_ODATA_VALUE_CONTROL ;

ETAG__ETAG : abap.string( 0 ) ;

@OData.property.name: 'to_Class_Cstics'

//A dummy on-condition is required for associations in abstract entities

//On-condition is not relevant for runtime

_Class_Cstics : association [0..*] to ZAE_PS_PET_ZPSMM_MATERIAL_CSTI on 1 = 1;

}

View Entire Topic
alrikx
Participant
0 Kudos

Dear Kamil,

I've got the same issue here. Have you found a solution for this?

When I debug get_business_data, i can see the data reached the remote system, but i can't find the right datatype to transfer them out.

Best Regards

Alrik