cancel
Showing results for 
Search instead for 
Did you mean: 

Deep Insert on CDS BOPF

former_member194549
Contributor
0 Kudos

Hey Experts,

i'm trying to execute a deep insert on a CDS-View published via Gateway and SADL. The CDS-View has created a BO and contains a association which is represented as a node in the generated BO.

The root view, which is also exposed as odata-service via sadl and gateway looks as follows


@ObjectModel.compositionRoot: true

@ObjectModel.modelCategory: #BUSINESS_OBJECT

@ObjectModel.writeEnabled: true

@ObjectModel.writeActivePersistence: '*****/CUMT_CUMAT'

@ObjectModel.createEnabled: true

@ObjectModel.deleteEnabled: true

@ObjectModel.updateEnabled: true

define view....

association [1..1] to ****/cumt_i_Text as _text

    on $projection.db_key = _text.parent_key

   and _text.spras = $session.system_language

.....

     @ObjectModel.foreignKey.association: '_text'  

  key db_key    

     ....

// assosiation

     @ObjectModel.association.type:  [ #TO_COMPOSITION_CHILD ]

     _text

The associated view (which represents the header text of the main object) looks as follows


@ObjectModel.writeEnabled: true

@ObjectModel.writeActivePersistence: '*****/CUMT_CUMTX'

@ObjectModel.createEnabled: true

@ObjectModel.deleteEnabled: true

@ObjectModel.updateEnabled: true

define view.....

     key db_key

     ....

Read requests including expand of the _text association are processed correctly. The create request on the root node is also processed correctly and the entry is written to the db-table.

But by calling a deep insert (insert data into root node and child node) a exception occurs in the method /BOBF/CL_SADL_MAPPER~GET_BOPF_ALTERNATIVE_KEY


ev_sadl_key_field_name = mt_fieldmapping[ KEY fieldname_bopf

                                                 COMPONENTS fieldname_bopf = /bobf/if_conf_c=>sc_attribute_name_key ]-fieldname_sadl.

Payload is looks as follows:


<?xml version="1.0" encoding="UTF-8"?>

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

   <atom:content type="application/xml">

     <m:properties>

       <d:active>true</d:active>

       <d:class>T_REEL</d:class>

       <d:cuobj>000000000000000076</d:cuobj>

       <d:kdmat>Test Deep</d:kdmat>

       <d:kunn2 />

       <d:kunnr>90000</d:kunnr>

       <d:matnr>1</d:matnr>

       <d:parvw />

       <d:spart>10</d:spart>

       <d:status />

       <d:vkorg>5000</d:vkorg>

       <d:vtweg>10</d:vtweg>

     </m:properties>

   </atom:content>

   <atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/to_text" type="application/atom+xml;type=entry" title="to_text">

     <m:inline>

       <atom:feed>

         <atom:entry>

           <atom:content type="application/xml">

             <m:properties>

               <d:shdescr>Folie Deep</d:shdescr>

               <d:spras>DE</d:spras>

             </m:properties>

           </atom:content>

         </atom:entry>

       </atom:feed>

     </m:inline>

   </atom:link>

</atom:entry>

I haven't changed anything on the generated BO. Does anybody have an idea how deep inserts can be done on cds views which generated BOs?

System: SAP_BASIS 7.50 SPS01

Regards

Simon

Accepted Solutions (1)

Accepted Solutions (1)

ivo_vollrath
Active Participant
0 Kudos

Hello Simon,

it is hard to provide a qualified answer as there are many stack levels involved in this scenario. There is a chance that text-associations as such (in combination with the fixed filter value for SPRAS) may not work at all in combination with deep insert. This would have to be checked in more detail.

However, I know that there used to be an issue related to the key fields of the CDS view being named DB_KEY. I can imagine why you chose this name, but in this context, it may be the first reason for things to break. Maybe you can either rename the key fields or try a similar scenario in a local copy where you use different names for the key fields. I think you can rename the key fields in your CDS views without renaming them on the DB (while for non key fields, renaming is not supported).

HTH and Kind Regards,

Ivo

former_member194549
Contributor
0 Kudos

Hey Ivo,

thanks for your hint, the issue was caused by the fields named DB_KEY.

I renamed the fields on both db-tables to IDENTIFICATOR, adapted the changes in the CDS views and it works.

Deep insert is working fine.

Thanks and Kind Regards

Simon

dirk_roeckmann
Participant
0 Kudos

Hi Ivo,

this may be a little unrelated, but I have a question concerning SEGW/SADL exposed CDS views as well:

In our system I exposed a CDS view in SEGW via 'DataModel/Reference/Modeled Data Source Reference'.

After generating the runtime artifacts, I noticed to my surprise, that the DPC and DPC_EXT class do not implement the interface 'IF_SADL_GW_QUERY_CONTROL' with the method 'SET_QUERY_OPTIONS' anymore.

Is this a bug or by intention? If the latter, what is now the best practice to customize query options?

The system is 7.5 SP1

Thanks in advance!

ivo_vollrath
Active Participant
0 Kudos

Hi Dirk,

it depends on what you want to achieve. Indeed SET_QUERY_OPTIONS did not make its way to the RDS (referenced data source)-type GW service. With RDS you are using a different programming model where the primary development artefact is supposed to be the CDS view. For a few things which you formerly could control in SET_QUERY_OPTIONS there might now be CDS annotations available. I think you can find information about the available annotations in the ABAP documentation from within eclipse. But not everything is possible, yet.

What exactly do you need to achieve with SET_QUERY_OPTIONS?

Kind Regards,

Ivo

dirk_roeckmann
Participant
0 Kudos

Hi Ivo,

thanks for the reply!

We like to use the SADL/RDS way for its convenience, but miss certain things like a sort on expanded entities via $orderby, which per ODATA 4 should work (even nested filters are possible in 4) in this standard.

The more disappointed we were, when we failed to do so on Netweaver 7.5 (meanwhile SP3), although SAP publishes ODATA 4 compatability for 7.5.

Any advice on how to 'customize' CRUDQ operations on CDS exposed services with additional logic without going back to 'full manual' with 'Map to Data Source' is greatly appreciated (Badis!?, Enhancement Points!?)

regards

Dirk

Former Member
0 Kudos

Hi Dirk, development of SADL ODATA V4 has just been started with 7.51 and only read scenarios are enabled by SADL. For 7.50 SADL ODATA V4 is not enabled. V2 must be used, for additional logic. If the query options (offered by if_sadl_gw_query_control) are needed, MDS must be used. Otherwise RDS (referenced data source) can be used.    Regards, Michael

dirk_roeckmann
Participant
0 Kudos

Hi Michael,

thanks for the update

Answers (0)