Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

CDS VIEW .. BOPF VALIDATIONS NOT WORKING ..

jinin_thomas2
Explorer
0 Kudos
664

I have created an app using CDS view & BOPF concepts and now i need to add validations,I have list page and object page, when i save data from object page it should stop saving data if data already exist in back end table .

I created validation class(object page view) and added my logic in execute method ( /BOBF/IF_FRW_VALIDATION~EXECUTE ) for stop saving data if conditions meet. But its still allowing me to create data (Its stooping in break point ) and error message is not coming to UI , below is my code can some one guide me regarding this? am i doing anything wrong?.

----

METHOD /bobf/if_frw_validation~execute.
"Declaration-----------------------------------------------------------*
DATA lt_data TYPE ztdemo_i_hbasi.
DATA lv_app_id TYPE zfiori_master-app_id.

DATA(lt_head_master) = VALUE ztdemo_i_hbasi( ).
DATA(lt_item_brole) = VALUE ztdemo_i_ibasi( ).

DATA : lo_msg TYPE REF TO /bobf/cm_frw.
"Program Logic----------------------------------------------------------*

io_read->retrieve(
EXPORTING
iv_node = zif_demo_i_hbasi_c=>sc_node-zdemo_i_ibasi "
it_key = it_key "
iv_fill_data = abap_true
IMPORTING
eo_message = eo_message "
et_data = lt_item_brole " itab with node data
et_failed_key = et_failed_key " pass failures
).
READ TABLE lt_item_brole REFERENCE INTO DATA(lo_item) INDEX 1.
READ TABLE it_key INTO DATA(ls_key) INDEX 1.
SELECT SINGLE brole FROM zfiori_brole INTO @DATA(lv_brole) WHERE app_id = @lo_item->app_id.
if lo_item->brole <> lv_brole.
IF eo_message IS NOT BOUND.
CALL METHOD /bobf/cl_frw_factory=>get_message( RECEIVING eo_message = eo_message ).
ENDIF.
APPEND It_key[ key = lo_item->key ] TO et_failed_key.
eo_message->add_message(
EXPORTING is_msg = VALUE #( msgid = 'ZM' " example
msgno = '005'
msgty = 'E'
)
iv_node = is_ctx-node_key
iv_key = ls_key-key
* iv_attribute = {attribute from UI}
* iv_lifetime = lv_lifetime
).
RETURN.
ENDIF.
ENDMETHOD.

----------------------

0 REPLIES 0