cancel
Showing results for 
Search instead for 
Did you mean: 

EML - Read entities: missing fields from consumption view

ChrisTh
Explorer
2,464

Hello experts,


I have a question concerning read entities statement. I was able to reproduce my problem with the ‘Demo Flight Reference Scenario (TX managed)’ on ABAP trial account.

I focused on CDS-Consumption view /DMO/C_TRAVEL_PROCESSOR_M which has some fields of associated views (e.g. AgencyName read from CDS-View /DMO/I_Agency)

The above-mentioned Consumption-View is exposed via Service-Definition /DMO/UI_TRAVEL_Processor_M. The preview of the corresponding Service-Binding gives me the ability to display the attribute AgencyName:

Now I try to read the data of the Consumption-View (better of the corresponding behavior ‘/DMO/C_Travel_Processor_M’) via EML:

READ ENTITIES OF /DMO/C_Travel_Processor_M

ENTITY TravelProcessor

ALL FIELDS WITH VALUE #( ( %pky-TravelID = '00000001' ) ( %pky-TravelID = '00000002' ) )

RESULT DATA(gt_result).

I am quite surprised to find only the exposed attributes of the projected Interface-View ‘/DMO/I_Travel_M’ inside the derived type. The additional field AgencyName is not part of the derived type.

Am I doing something wrong or is my expectation of having the additional fields inside the derived type wrong?

Could someone please shed some light on this problem?

Many thanks in advance.

Best regards

Chris

Accepted Solutions (1)

Accepted Solutions (1)

Ramjee_korada
Active Contributor
0 Kudos

Hello Chris,

As per initial example, I understand it as an association and gave the hint. I verified before answering.
Now I understand that it as a Composition. Here, I see 2 options.

  1. Read the data in steps. See below example

      READ ENTITIES OF zrk_i_pur_req_h
         ENTITY _PRHead
         ALL FIELDS WITH value #( ( objectid = 'PR10000003' ) )
         RESULT DATA(pr_head) FAILED DATA(failed).

      READ ENTITIES OF zrk_i_pur_req_h
         ENTITY _PRHead BY \_PRItem         
         ALL FIELDS WITH value #( ( objectid = 'PR10000003' ) )
         RESULT DATA(pr_item) FAILED failed.

2. Adjust your base view with inner join ( your cardinality is 1..1 ) or Left outer join ( 1..* ) so they can be part of your base view. ( I have not tested this one yet ).

Best wishes,

Ramjee Korada.

ChrisTh
Explorer
0 Kudos

Hello Ramjee Korada,

first I want to apologize. I was completely unaware about the difference between association and composition. Sorry for misleading you.

I just wanted to save some development effort for reading the data so I created a consumption view (and the corresponding behaviour) on top of my interface views. This consumption view comes without own associatoins or compositions.

define root view entity ZCT_C_TEST_MD_T024_FULL
  as projection on zct_i_test_md_t024
{
  key PurchasingDepartment,
      PurchasingDepartmentName,
      _extension.PurchasingDepGroup as PurchasingDepartmentGroup
}
I used this consumption view for my read entity statement:
READ ENTITIES OF zct_c_test_md_t024_full
    ENTITY t024
    ALL FIELDS WITH VALUE #( ( %tky-PurchasingDepartment = '001') ( %tky-PurchasingDepartment = '003' ) ( %tky-PurchasingDepartment = '004' ) )
    RESULT DATA(gt_result).
As I understand from your answer, my assumption was wrong. The attributes accessbile via EML are defined by the interface view and not the consumption view. In that case I will include the associations in my consumption view and read the data using the associaton.Many thanks for your support.

Best regards,

Chris

Answers (3)

Answers (3)

Ramjee_korada
Active Contributor
0 Kudos

Better to go with option #1.
I see SAP Demo Apps also using same solution.

please see below documentation.
https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/fed023a4ed9d4d7494e5c853b11...

    READ ENTITIES OF /DMO/I_Travel_M IN LOCAL MODE
      ENTITY travel
       ALL FIELDS WITH CORRESPONDING #( keys )
    RESULT DATA(travel_read_result)
    FAILED failed.

    READ ENTITIES OF /DMO/I_Travel_M IN LOCAL MODE
      ENTITY travel BY \_booking
       ALL FIELDS WITH CORRESPONDING #( travel_read_result )
     RESULT DATA(book_read_result).

    READ ENTITIES OF /DMO/I_Travel_M IN LOCAL MODE
      ENTITY booking BY \_booksupplement
       ALL FIELDS WITH CORRESPONDING #( book_read_result )
    RESULT DATA(booksuppl_read_result).
ChrisTh
Explorer
0 Kudos

Ok, thank you. In that case I will try to avoid using consumptoin behaviours with EML and go with interface behaviours instead.

Thanks for your time and support.

Best regards,

Chris

Ramjee_korada
Active Contributor
0 Kudos

Yes. thats also good idea to read from consumption view.

READ ENTITIES OF zct_c_test_md_t024_full
    ENTITY t024
    ALL FIELDS WITH VALUE #( ( %tky-PurchasingDepartment = '001') ( %tky-PurchasingDepartment = '003' ) ( %tky-PurchasingDepartment = '004' ) )
    RESULT DATA(gt_result).
ChrisTh
Explorer
0 Kudos

Coming back to my original problem, the derived type for this consumption does not include the explicitly added attributes of the associated interface view. Only the attributes of the projected interface view are included.

define root view entity ZCT_C_TEST_MD_T024_FULL
  as projection on zct_i_test_md_t024
{
  key PurchasingDepartment,
      PurchasingDepartmentName,
      _extension.PurchasingDepGroup as PurchasingDepartmentGroup
}

That was confusing for me, but obviously my assumption was wrong.
Best regards,Chris
Ramjee_korada
Active Contributor
0 Kudos

Hello Christoph,

EML reads the properties from actual entity but not all fields from all association in a base/interface view.

In this case, you have to add " _Agency.Name as AgencyName " in base view (/DMO/I_Travel_M) as a column . So that it will be visible and accessible in EML logic .

It will be available in derived type as well.

Best wishes,

Ramjee Korada

ChrisTh
Explorer
0 Kudos

Hello Ramjee Korada,

thank you for your answer. As I am unable to change the base view (/DMO/I_Travel_M) I tried to solve the issue in my own little test project.

I created two base views :

define root view entity zct_i_test_md_t024
  as select from t024
  composition [1..1] of ZCT_I_TEST_MD_T024_EXTENSION as _extension 
{
...
}
define view entity ZCT_I_TEST_MD_T024_EXTENSION
  as select from zct_test_md_t024
  association to parent zct_i_test_md_t024 as _t024 on $projection.PurchasingDepartment = _t024.PurchasingDepartment
{
...
}

Now I tried to include an attribute of my composition view into my root view:

Unfortunately this leads to the following syntax error:

Activation of the view fails due to this error.

Do you have any other ideas to solve this problem?

Best regards,

Chris