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

EML- READ Entity using partial key fields

Jaison_John
Discoverer
3,279

Hi Experts,


I have a requirement to read the BO entity using partial key. I have 3 key fields in the BO and want to read the data using only the first two key fields. When I pass only two fields to the READ statement it is not fetching any value. The third key is a numeric type and it will be defaulted as "0" when no data is passed. Is there any way to overcome this issue?

The pseudo code is below. Any help would be appreciated!

 

READ ENTITY IN LOCAL MODE <Root_entity>

ALL FIELDS WITH VALUE #( ( %key-field1 = value1

%key-field2 = value2

"%key-field3 = <No value is passed here> -- This is an integer type

) )

RESULT DATA(lt_result)

FAILED DATA(lt_failed).

 

 

View Entire Topic
RicardoLadeiro
Product and Topic Expert
Product and Topic Expert
0 Likes

That may not be possible on the BO beh. implementation.

I had a situation where a validation would require a similar logic, but it turned out that I needed to improve the data model, creating a relationship between a root and a child entity in order to achieve my goal. Something that worth considering in some cases.

Jaison_John
Discoverer
0 Likes

Hello Ricardo,

Thanks for the heads up. I am using the direct SELECT on the root entity to achieve the goal now. Not sure if it is a best practice in case of RAP developments.

Regards,
Jaison.

RicardoLadeiro
Product and Topic Expert
Product and Topic Expert
0 Likes

Hey.

Well, EML does not support SELECT statements.

If you want to stick to the EML language, you might need to do the following:
1. Create a Root entity with key1, key2
2. Create a Child entity with key1, key2, key3
3. Use READ ENTITIES to read the root entity with the full key (key1, key2) with an association to the Child entries.

This way you'll be able to fetch all the child result data "using the child entity partial key".

This approach might have some benefits if you are making use of Draft features. Handling draft features with SELECT statements will become a challenge.