cancel
Showing results for 
Search instead for 
Did you mean: 

Auto-increment Dictionary Object key from OData/ CDS generated BOPF

0 Kudos

As the title already suggests, I'd like to autoincrement the primary key of a Dictionary Object during CRUD Operations, triggered by an UI5 Application. Just like I'm used to do it in the MySQL World using the keyword autoincrement.

BOPF elements are generated out of CDS Views, enabling basic CRUD functionality. The Consumption-Views are accessed by an OData Service, used by an UI5 App. As far as I understand, auto-increment can be realized using Number-Ranges. I also know how to create these Number-Ranges in the SNRO but I don't see, how I can use them in my generated BOPF elements. Or is there any other CDS or OData related way I am not aware of, to increment the key for every new Entry.

My System is on S/4 NW 7.51

I'd be grateful for help.

Accepted Solutions (1)

Accepted Solutions (1)

cwolter90
Participant
0 Kudos
data: lr_data type ref to bopf_structure.
LOOP AT it_key INTO data(ls_key).
create data lr_data.

call function 'number_get_next'
...
importing
number = lv_new_number
...

lr_data->number = lv_new_number.

io_modify->update(
                    EXPORTING
                      iv_node           = bopf_interface=>sc_node-bopf_node
                      iv_key            = ls_key-key
                      is_data           = lr_data
                      it_changed_fields = value #( ( 'NUMBER' ) ) "--> should be the name of the number field in bopf
).
endloop.

Something like that.

Answers (1)

Answers (1)

cwolter90
Participant

You could create a determination for the BOPF node, which is triggered on create during "Before save (Draw Numbers)". The determination draws a new number from the number ranges and writes it into the key field.

0 Kudos

Thanks for this advice. Look like this is the way to go.

Nevertheless, I was not able to figure out how to implement the execute method. As you know, the only thing I want to do is to change the key value, but how can I do that. How can I set the value of the Evaluation Timepoint Draw Number?

An answer would be really great.