cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP BTP Environment - Application Log Objects - You are not authorized to display the specified log

ChristianSilva
Explorer
0 Likes
660

Hi everyone,

In the ABAP BTP Trial environment, we can create Application Log Objects, add messages, and save them successfully. However, our users currently lack the authorization to view the logs we’ve created.

Example:

METHOD if_oo_adt_classrun~main.
    TRY.

        " Create log object
        DATA(lo_log) = cl_bali_log=>create( ).

        " Create and set header
        DATA(lo_header) = cl_bali_header_setter=>create( object      = 'ZZLOG'
                                                         subobject   = 'CONN'
                                                         external_id = '12345'
        )->set_expiry( expiry_date       = CONV d( cl_abap_context_info=>get_system_date( ) + 7 )
                       keep_until_expiry = abap_true ).

        lo_log->set_header( lo_header ).

        " Classic Message
        DATA(lo_msg) = cl_bali_message_setter=>create(
            severity   = if_bali_constants=>c_severity_error
            id         = 'ZZMSGCLS'
            number     = '001' ).

        lo_log->add_item( lo_msg ).

        " Save logs
        DATA(lo_log_db) = cl_bali_log_db=>get_instance( ).

        lo_log_db->save_log( lo_log ).

        " Get the handle
        DATA(l_handle) = lo_log->get_handle( ).

        out->write( |Log created: { l_handle }| ).

        " Read messages from handle
        lo_log = lo_log_db->load_log(
                   handle           = l_handle
                   read_only_header = abap_true
                 ).

        DATA(lt_items) = lo_log->get_all_items( ).

        LOOP AT lt_items ASSIGNING FIELD-SYMBOL(<ls_item>).
          out->write( <ls_item>-item->get_message_text( ) ).
        ENDLOOP.

      CATCH cx_bali_runtime INTO DATA(lo_cx_bali_runtime).

        out->write( lo_cx_bali_runtime->get_text( ) ).

    ENDTRY.

The method call:

        " Read messages from handle
        lo_log = lo_log_db->load_log(
                   handle           = l_handle
                   read_only_header = abap_true
                 ).

throws the exception with the text: You are not authorized to display the specified log

Does anyone know if there is any other way to read the logs?

Thank you,
Christian

Accepted Solutions (1)

Accepted Solutions (1)

BjoernSchulz
SAP Mentor
SAP Mentor

Hallo @ChristianSilva,

That's the normal behavior. You have to add the authorization (S_APPL_LOG) to an IAM App and assign it to role and than to you. Without this object not possible.

Greetings 

Björn 

ChristianSilva
Explorer
0 Likes
Hello Björn,
ChristianSilva
Explorer
0 Likes
Hello Björn, I forgot to mention that I'm using the ABAP Trial Environment. As far as I know, it is not possible to add authorizations to a user in this environment. It would be great if, by default, trial users have the authorization to read Z* logs. Thank you!
ChristianSilva
Explorer
0 Likes
Hello @BjoernSchulz, I forgot to mention that I'm using the ABAP Trial Environment. As far as I know, it is not possible to add authorizations to a user in this environment. It would be great if, by default, trial users have the authorization to read Z* logs. Thank you!
ChristianSilva
Explorer
0 Likes
Hello Björn, I forgot to mention that I'm using the ABAP Trial Environment. As far as I know, it is not possible to add authorizations to a user in this environment. It would be great if, by default, trial users have the authorization to read Z* logs. Thank you!
ChristianSilva
Explorer
0 Likes
Sorry @BjoernSchulz, but the system was returning an error when I tried to post the comment and I thought it was not saving them.
ChristianSilva
Explorer
0 Likes
Conclusion: The use of Application Log Objects is prohibited in the ABAP Trial Environment.

Answers (0)