cancel
Showing results for 
Search instead for 
Did you mean: 

CDS - BOPF - Update Table - Selected Fields Only

0 Kudos

Hi all,

I have successfully created a CDS view with annotations and made it BOPF proof.
I selected only a few records out of my Z_TABLE and added writeActivePersistence to this Table.

When I now SAVE my edited data it clears all the other fields that are not selected by the CDS.

Is there any option to just SAVE the data that has been changed? LIke you can do within a Determination.

 io_modify->update(
        EXPORTING
          iv_node               = is_ctx-node_key
          iv_key                = <ls_cust>-key
          iv_root_key           = <ls_cust>-root_key
          is_data               = REF #( <ls_cust>-node_data )
          it_changed_fields     = VALUE #(
            ( FIELD1 )
            ( FIELD2 )
            ( ... )
          )
        ).

A second option is to select all the fields within my 2 CDS ( I and Consuming CDS), but what if a new field is added to the Z-table and a developer forgets to add it within the CDS aswell, then this field is always cleared by the fiori app.
Is there an option to select all ( * ) using the annotations? "@Search.defaultSearchElement: true

maheshpalavalli
Active Contributor
0 Kudos

I think the determination looks like it is going to work out for you.. You just to select that complete record and do the corresponding from incoming data to db record and update it the api. This will eliminate your manual adding of fields everytime via cds on every update..
Still wondering why the BOPF api is clearing the other fields though.. Probably you are in the old version? or is the design was like that..?

pratheek_kv2
Explorer
0 Kudos

Hi,

The BOPF logic works like this.

Consider a Table with 3 fields A, B and C.

In your BOPF( CDS ), you have exposed A and B.

Now, on save, BOPF will have a Structure which is of the Type of your Table. That means there will be a structure with fields A,B,C. Lets call this Structure 'Table Structure'.

There would be another structure that represents the BOPF which will only have field A and B since only those 2 are know to BOPF. Lets call this "Combined Structure".

During save, BOPF will perform a Move-Corresponding from Combined Structure to Table Structure. Here, It moves only field A and B to the Table Structure and field C would now be empty.

This table structure is then used to save to DB.

Hence, C will be cleared

One way is to redefine the Save and you handle the Save without allowing BOPF to do it.

or bring all the fields or use the Draft Framework where you have a better control over Save.

Regards,

Pratheek

Accepted Solutions (0)

Answers (0)