cancel
Showing results for 
Search instead for 
Did you mean: 

BOPF Authorization Class doesn't work

0 Kudos
424

Hi expert,

I created a List Report Page with BOPF.
CRUD action are enabled.

I try to use the Authorization Class, but it doesn't seems to work...
I put my Authority-Check in the method "CHECK_STATIC_AUTHORITY", these code seems to work.
I think the problem comes from the message. It never show up, and the process continue without error.

DATA: ls_textid TYPE scx_t100key.

rv_failed = abap_false.

AUTHORITY-CHECK OBJECT 'ZTEST'
  ID 'ACTVT' FIELD is_ctx-activity.
  IF sy-subrc <> 0.
    rv_failed = abap_true.

    ls_textid = /bobf/cm_lib=>no_auth_display.

    " Message handling if authorization check failed
    IF rv_failed = abap_true AND ls_textid IS NOT INITIAL.
      eo_message = /bobf/cl_frw_factory=>get_message( ).
      eo_message->add_cm( NEW /bobf/cm_lib(
                          textid             = ls_textid
                          severity           = /bobf/cm_lib=>co_severity_error
                          lifetime           = /bobf/cm_lib=>co_lifetime_transition
                          ms_origin_location = VALUE #( bo_key = is_ctx-bo_key node_key = is_ctx-node_key )
                          mv_object_name     = 'ZI_TEST_TP'
                          mv_node_name       = 'ZI_TEST_TP'
                          mv_action_name     = CONV #( is_ctx-action_name )
                          ) ).
    ENDIF.

  ENDIF.

When I use a break-point I don't notice anything strange in the code, sy-subrc is different to 0.

Another problem, when I try to create a record in my List Report Page via the "+" button my Authorization Class is not trigger. Then how to check if I can create record or not ?

Thanks for your help.

Youri

View Entire Topic
0 Kudos

Solution found by some adaptation at the CDS level :

@ObjectModel.createEnabled:#('EXTERNAL_CALCULATION')

"External Calculation" in place of "True"