Showing results for 
Search instead for 
Did you mean: 

Determination before save at field level is not working in Restful ABAP

0 Kudos

Hello All,

I have checked a lot of blogs but could not find a suitable solution. I have a requirement where a sequential number should be calculated whenever a new entry is created and should be updated as a key field in the custom table created. I tried the modify statement but it gives the dump stating 'BEHAVIOR_CONTRACT_VIOLATION'. Please find the code as below :

CLASS lhc_workflowapprovers IMPLEMENTATION. METHOD get_instance_authorizations. ENDMETHOD. METHOD generateidentifier. READ ENTITIES OF zxxx IN LOCAL MODE ENTITY wf ALL FIELDS WITH CORRESPONDING #( keys ) RESULT DATA(ApproversData) FAILED DATA(failed) REPORTED DATA(report). data : update_tab TYPE TABLE FOR UPDATE zxxx. LOOP AT ApproversData INTO DATA(ApproverData). IF ApproverData-Identifier IS INITIAL. TRY. cl_numberrange_runtime=>number_get( EXPORTING * ignore_buffer = nr_range_nr = '01' object = 'ZFT_APP_ID' quantity = 1 * subobject = * toyear = IMPORTING number = DATA(num) returncode = DATA(ret_code) returned_quantity = DATA(ret_quantity) ). CATCH cx_nr_object_not_found. CATCH cx_number_ranges. ENDTRY. DATA current_max_id TYPE c LENGTH 10. SHIFT num LEFT DELETING LEADING '0'. WRITE num TO current_max_id. ApproverData-Identifier = current_max_id. MODIFY ApproversData FROM ApproverData. ENDIF. ENDLOOP. MODIFY ENTITIES OF zxxx IN LOCAL MODE ENTITY wf UPDATE FROM VALUE #( FOR workflowapprovers in ApproversData INDEX INTO i ( identifier = wf-identifier ) ) REPORTED DATA(reported_upd). ENDMETHOD.

Any help and suggestions are highly appreciated. Thank you in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

Active Contributor
0 Kudos

Hi trupti.kanekar

Are you calling COMMIT anywhere in code... RAP framework takes care of COMMIT.

If you want to have key field value generated automatically everytime creating new record you need to use eighter Early Numbering or Late Numbering based on your need. OR try setting below highlighted for your key field

Please visit below blog for more details

Hope this Helps...