In Hintergrund Prozessen ist es manchmal nur schwer möglich die Fehlerursache zu ermitteln, besonders ärgerlich ist es, wenn Berechtigungen der Grund sind.
Hier ein Baustein der bei der Fehlersuche helfen soll. Besonders in ODATA Services eine willkommene Hilfe.
![Wink ;)](./images/smilies/icon_e_wink.gif)
Implementation:
1.) Struktur anlegen
2.) Tabellentyp ZTTAU_SU53BUFFER für die Struktur ZAU_SU53BUFFER anlegen.
3.) RFC Baustein anlegen
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
- FUNCTION z_au_read_auth_status.
- *"----------------------------------------------------------------------
- *"*"Local Interface:
- *" IMPORTING
- *" VALUE(I_USER) TYPE XUBNAME DEFAULT SY-UNAME
- *" EXPORTING
- *" VALUE(TT_SU53_BUFF) TYPE ZTTAU_SU53BUFFER
- *"----------------------------------------------------------------------
- *&---------------------------------------------------------------------*
- *& Form get_authorization_checks / see SAPMS01G
- *&---------------------------------------------------------------------*
- *&---------------------------------------------------------------------*
- *& Form get_authorization_checks from last call
- *&---------------------------------------------------------------------*
- iv_read_from_db TYPE char01
- it_su53_buff TYPE zttau_su53buffer.
- *---------------------------------------------------------------------*
- * Global TYPES
- *---------------------------------------------------------------------*
- gc_last_seconds TYPE i VALUE 10800
- , gc_last_entries TYPE i VALUE 100
- .
- * , gv_new_kernel_avail TYPE abap_bool
- * , gv_save_available TYPE abap_bool
- , gv_checks_since_time TYPE timestampl
- , g_bname TYPE usr07-bname "Current user (global variable)
- , g_refuser TYPE usrefus-refuser
- , g0010_bname TYPE usr07-bname "Screen fields
- , g0010_read_from_db TYPE char01
- , g_ok_code TYPE sy-ucomm
- , g_datum TYPE sy-datum "#EC NEEDED
- , g_zeit TYPE sy-uzeit "#EC NEEDED
- , gt_usr07_new TYPE tt_usr07_new
- , gt_range_object TYPE RANGE OF xuobject
- , g_result_item_key_table TYPE treemiks
- , g_find_string TYPE string
- , g_instance TYPE msxxlist-name.
- , lr_usr07_new TYPE REF TO ty_usr07_new
- , lv_retcode TYPE sy-subrc
- , lt_su53buf TYPE cl_susr_tools_kernel=>tt_usr07p
- , lr_su53buf TYPE REF TO cl_susr_tools_kernel=>ty_usr07p
- , ls_range_object LIKE LINE OF gt_range_object
- , ls_usr07 TYPE usr07
- , lv_since_hours TYPE timestampl
- , lv_lines TYPE i.
- objct TYPE usr07-objct,
- fiel1 TYPE usr07-fiel0,
- fiel2 TYPE usr07-fiel0,
- fiel3 TYPE usr07-fiel0,
- fiel4 TYPE usr07-fiel0,
- fiel5 TYPE usr07-fiel0,
- fiel6 TYPE usr07-fiel0,
- fiel7 TYPE usr07-fiel0,
- fiel8 TYPE usr07-fiel0,
- fiel9 TYPE usr07-fiel0,
- fiel0 TYPE usr07-fiel0,
- END OF usr07key.
- val01 TYPE usr07-val01,
- val02 TYPE usr07-val01,
- val03 TYPE usr07-val01,
- val04 TYPE usr07-val01,
- val05 TYPE usr07-val01,
- val06 TYPE usr07-val01,
- END OF usr07val1.
- val07 TYPE usr07-val01,
- val08 TYPE usr07-val01,
- val09 TYPE usr07-val01,
- val10 TYPE usr07-val01,
- END OF usr07val2.
- CLEAR: gt_usr07_new
- , gt_range_object
- , gv_checks_since_time
- .
- PERFORM check_environment.
- " Get local instance
- g_instance = cl_abap_syst=>get_instance_name( ).
- " ---- New kernel -------
- " Read last hours from shared memory
- TRY.
- CALL METHOD cl_abap_tstmp=>subtractsecs
- EXPORTING
- tstmp = gv_checks_since_time
- secs = gc_last_seconds
- RECEIVING
- r_tstmp = gv_checks_since_time.
- CATCH cx_parameter_invalid_range cx_parameter_invalid_type.
- lv_since_hours = gv_checks_since_time.
- CALL METHOD cl_susr_tools_kernel=>get_su53_buffer
- EXPORTING
- iv_bname = iv_bname
- iv_no_auth_only = abap_true
- iv_max_entries = gc_last_entries
- iv_entries_since = gv_checks_since_time
- IMPORTING
- et_su53_buffer = lt_su53buf
- ev_entries_since = gv_checks_since_time
- ev_retcode = lv_retcode.
- ls_usr07_new-rc = 40.
- ELSE.
- ls_usr07_new-rc = lr_su53buf->authrc * 4.
- " Set instance
- ls_usr07_new-instance = g_instance.
- " Time since checks..
- gv_checks_since_time = lv_since_hours.
- DESCRIBE TABLE lt_su53buf LINES lv_lines.
- READ TABLE lt_su53buf REFERENCE INTO lr_su53buf INDEX lv_lines.
- gv_checks_since_time = lr_su53buf->timestamp.
- it_su53_buff[] = lt_su53buf[].
- ELSE.
- " Read from USR07
- INTO CORRESPONDING FIELDS OF TABLE gt_usr07_new ##too_many_itab_fields
- WHERE bname EQ iv_bname.
- " Get instance from database
- READ TABLE gt_usr07_new REFERENCE INTO lr_usr07_new INDEX 1.
- g_instance = lr_usr07_new->instance.
- ELSE.
- ELSE.
- " ---- Old kernel with parameter ---------------
- " Get result of last authorization check
- " Store result of last authorization check
- CLEAR ls_usr07.
- ls_usr07-bname = iv_bname.
- " Store on db
- " Fill internal table
- ELSE.
- " Read from USR07
- INTO CORRESPONDING FIELDS OF TABLE gt_usr07_new ##too_many_itab_fields
- WHERE bname = iv_bname.
- " Only one entry allowed
- " Get objects
- ls_range_object-low = lr_usr07_new->objct.
- ls_range_object-sign = 'I'.
- ls_range_object-option = 'EQ'.
- *&---------------------------------------------------------------------*
- *& Form check_environment
- *&---------------------------------------------------------------------*
- * text
- *----------------------------------------------------------------------*
- FORM check_environment.
- , lv_status TYPE char01
- .
- CALL METHOD cl_susr_tools_kernel=>get_su53_status
- RECEIVING
- rv_status = lv_status.
- gv_new_kernel_avail = abap_true.
- CALL FUNCTION 'DDIF_NAMETAB_GET'
- EXPORTING
- tabname = 'USR07'
- lfieldname = 'TIMESTAMP'
- IMPORTING
- dfies_wa = ls_dfies
- EXCEPTIONS
- not_found = 0
- OTHERS = 0.
- gv_save_available = abap_true.
- GeSHi ©
TOP INCLUDE
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
- * INCLUDE LZMD_ODATAD... " Local class definition
- * INCLUDE LZBC_READ_FAILED_AUTHD... " Local class definition
- *&---------------------------------------------------------------------*
- *& Form get_authorization_checks / see SAPMS01G
- *&---------------------------------------------------------------------*
- , mandt TYPE usr07-mandt
- , bname TYPE usr07-bname
- , timestamp TYPE timestampl " New
- , objct TYPE usr07-objct
- , fiel1 TYPE usr07-fiel0
- , fiel2 TYPE usr07-fiel0
- , fiel3 TYPE usr07-fiel0
- , fiel4 TYPE usr07-fiel0
- , fiel5 TYPE usr07-fiel0
- , fiel6 TYPE usr07-fiel0
- , fiel7 TYPE usr07-fiel0
- , fiel8 TYPE usr07-fiel0
- , fiel9 TYPE usr07-fiel0
- , fiel0 TYPE usr07-fiel0
- , val01 TYPE usr07-val01
- , val02 TYPE usr07-val01
- , val03 TYPE usr07-val01
- , val04 TYPE usr07-val01
- , val05 TYPE usr07-val01
- , val06 TYPE usr07-val01
- , val07 TYPE usr07-val01
- , val08 TYPE usr07-val01
- , val09 TYPE usr07-val01
- , val10 TYPE usr07-val01
- , tcode TYPE usr07-tcode
- , progname TYPE usr07-progname
- , cdate TYPE usr07-cdate
- , ctime TYPE usr07-ctime
- , abapline TYPE i " New
- , abapprog TYPE programm " New
- , foruser TYPE sutrforuser " New
- , rc TYPE int4 " New
- , reason TYPE char01 " New
- , p_tcode TYPE tcode " New
- , name TYPE sobj_name " New
- , type TYPE usobtype " New
- , instance TYPE msxxlist-name " New
- , END OF ty_usr07_new.
- data:
- gv_new_kernel_avail type abap_bool
- , gv_save_available type abap_bool.
- GeSHi ©