最近在做钉钉的集成,将全部报错集成到机器人里面,包含了SAP内存硬盘的预警和ST22等信息
*&---------------------------------------------------------------------*
*& Report ZBSRP0009
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zbsrp0009.
DATA:
epp_root_context_id TYPE epp_root_context_id,
epp_connection_id TYPE epp_connection_id,
epp_connection_counter TYPE epp_connection_counter.
TYPES: BEGIN OF snap_alv.
INCLUDE TYPE rdumpov.
TYPES: ct TYPE lvc_t_scol.
TYPES: END OF snap_alv.
DATA sy_inst LIKE sy-host.
CONSTANTS: yes(1) TYPE c VALUE 'X', no(1) TYPE c VALUE space.
DATA:gt_snap TYPE TABLE OF snap_alv.
TABLES:snap,snapt,rdumpov.
SELECTION-SCREEN BEGIN OF BLOCK block3 WITH FRAME TITLE title3. "#EC NEEDED
SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE title2.
SELECT-OPTIONS:
s_ahost FOR snap-ahost, " memory id st22_host,
s_wpid FOR snap-modno, " memory id ST22_wpid,
s_uname FOR snap-uname, " memory id st22_name,
s_mandt FOR snap-mandt. " memory id st22_mandt MODIF ID MDA.
PARAMETERS:
mandt LIKE sy-mandt DEFAULT sy-mandt MODIF ID md1.
SELECT-OPTIONS:
s_xhold FOR snap-xhold, " memory id st22_xhold,
s_errid FOR snapt-errid, " memory id st22_errid,
s_prg FOR rdumpov-gprogram, " memory id st22_prgname,
s_except FOR rdumpov-rexception, " memory id st22_except,
s_tid FOR rdumpov-tid. " memory id st22_tid.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (26) st_eprid FOR FIELD s_epprid.
SELECT-OPTIONS
s_epprid FOR epp_root_context_id.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (26) st_epcid FOR FIELD s_eppcid.
SELECT-OPTIONS
s_eppcid FOR epp_connection_id.
SELECTION-SCREEN END OF LINE.
SELECT-OPTIONS
s_eppcc FOR epp_connection_counter NO-DISPLAY.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK block2.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN COMMENT 1(70) restrict.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS flag_exc TYPE st22exc AS CHECKBOX. " memory id st22_exc.
SELECTION-SCREEN COMMENT (60) ftxt_exc FOR FIELD flag_exc.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS flag_com TYPE c AS CHECKBOX. " memory id st22_comp.
SELECTION-SCREEN COMMENT (75) flag_txt FOR FIELD flag_com. "#EC NEEDED
SELECTION-SCREEN END OF LINE.
" 754 tx ST22OLD is obsolete
" selection-screen skip 1.
" selection-screen begin of line.
" parameters flag_old type c no-display. " only temporarily redefined
"parameters flag_old type c as checkbox memory id st22_old.
" selection-screen comment (60) old_txt for field flag_old. "#EC NEEDED
" selection-screen end of line.
SELECTION-SCREEN END OF BLOCK block3.
INITIALIZATION.
PERFORM frm_initial.
START-OF-SELECTION.
SELECT * INTO CORRESPONDING FIELDS OF TABLE @gt_snap FROM snap WHERE datum = @sy-datum AND seqno = '000'.
PERFORM select_snap_beg CHANGING gt_snap.
IF sy-batch = 'X'.
PERFORM frm_send_dd.
ENDIF.
FORM select_snap_beg CHANGING p_gt_snap LIKE gt_snap[].
TYPES: bmt_function_ranges TYPE bm_components.
CONSTANTS: dump_id(2) TYPE c VALUE 'FC',
dump_exception(2) TYPE c VALUE 'XC',
dump_program(2) TYPE c VALUE 'AP',
dump_tid(2) TYPE c VALUE 'TD',
dump_eeprootid TYPE c LENGTH 2 VALUE 'GX',
dump_eepconnid TYPE c LENGTH 2 VALUE 'VX',
dump_eepcalcnt TYPE c LENGTH 2 VALUE 'AX',
dump_krnproj_path TYPE c LENGTH 2 VALUE 'CM'. "
DATA dump_id_ok(1) TYPE c. " I processed dumptext
DATA dump_exception_ok(1) TYPE c.
DATA dump_program_ok(1) TYPE c.
DATA dump_tid_ok(1) TYPE c.
DATA dump_eeprootid_ok TYPE c LENGTH 1.
DATA dump_eepconnid_ok TYPE c LENGTH 1.
DATA dump_eepcalcnt_ok TYPE c LENGTH 1.
DATA dump_id_found(1) TYPE c.
DATA dump_exception_found(1) TYPE c.
DATA dump_program_found(1) TYPE c.
DATA dump_tid_found(1) TYPE c.
DATA dump_eeprootid_found TYPE c LENGTH 1.
DATA dump_eepconnid_found TYPE c LENGTH 1.
DATA dump_eepcalcnt_found TYPE c LENGTH 1.
DATA dump_krnproj_path_found TYPE c LENGTH 1.
DATA wa_color TYPE LINE OF lvc_t_scol.
DATA l_end TYPE i.
DATA wa_snap_beg TYPE snap.
DATA e_line TYPE c LENGTH 400.
DATA wa_snap TYPE snap_alv .
DATA: BEGIN OF struc,
id(2) TYPE c,
len(3) TYPE c,
text(50) TYPE c,
END OF struc.
DATA: struc_length TYPE i .
FIELD-SYMBOLS: <f> TYPE any.
DATA: pointer TYPE i, l TYPE i, l1 TYPE i, l2 TYPE i.
DATA list_krnproj_path TYPE string.
DATA: BEGIN OF param_appcomp,
errorid LIKE wa_snap-errorid,
pgmid LIKE wa_snap-gprogram,
krnproj_path LIKE list_krnproj_path,
END OF param_appcomp.
DESCRIBE FIELD e_line LENGTH l IN CHARACTER MODE.
DESCRIBE FIELD struc-id LENGTH l1 IN CHARACTER MODE.
DESCRIBE FIELD struc-len LENGTH l2 IN CHARACTER MODE.
DESCRIBE FIELD struc LENGTH struc_length IN CHARACTER MODE.
l_end = l - struc_length.
REFRESH: p_gt_snap.
PERFORM adjust_snap_range_to_authoriz.
DATA:
l_error TYPE string,
l_cx_st22 TYPE REF TO cx_st22_error,
l_datetime_where TYPE cl_st22_pal=>t_sql_where.
TRY.
l_datetime_where =
cl_st22_pal=>get_datetime_where_from_prog(
i_progname = sy-repid ).
CATCH cx_st22_error INTO l_cx_st22.
l_error = l_cx_st22->get_text( ).
MESSAGE l_error TYPE 'S' DISPLAY LIKE 'W'.
RETURN.
ENDTRY.
cl_st22_pal=>progress_indicator_init( ).
CLEAR p_gt_snap[].
SELECT * FROM snap INTO wa_snap_beg
WHERE seqno = '000'
* and datum in s_datum
* and uzeit in s_uzeit
"AND (l_datetime_where)
AND ahost IN s_ahost
AND modno IN s_wpid
AND uname IN s_uname
AND mandt IN s_mandt
AND xhold IN s_xhold
ORDER BY
datum DESCENDING
uzeit DESCENDING
ahost uname mandt modno.
cl_st22_pal=>progress_indicator_push(
i_cnt_valid = lines( p_gt_snap ) ).
CLEAR wa_color.
CLEAR pointer.
CLEAR wa_snap.
CLEAR list_krnproj_path.
CLEAR: dump_id_ok, dump_exception_ok, dump_program_ok, dump_tid_ok,
dump_eeprootid_ok, dump_eepconnid_ok, dump_eepcalcnt_ok.
CLEAR: dump_exception_found, dump_id_found, dump_program_found, dump_tid_found,
dump_eeprootid_found, dump_eepconnid_found, dump_eepcalcnt_found, dump_krnproj_path_found.
REFRESH: wa_snap-ct.
MOVE-CORRESPONDING wa_snap_beg TO wa_snap.
DATA: sy_uname LIKE sy-uname.
sy_uname = sy-uname.
IF wa_snap-uname = sy_uname.
wa_color-color-col = 6.
wa_color-fname = 'UNAME'.
APPEND wa_color TO wa_snap-ct.
ENDIF.
IF wa_snap-ahost = sy-host OR wa_snap-ahost = sy_inst.
wa_color-color-col = 6.
wa_color-fname = 'AHOST'.
APPEND wa_color TO wa_snap-ct.
ENDIF.
e_line(200) = wa_snap_beg-flist.
e_line+200 = wa_snap_beg-flist02.
WHILE pointer < l_end.
struc = e_line+pointer(struc_length).
IF ( struc-len CO '0123456789' ) AND ( struc-len <> '000' ) AND
( struc-len < '050' ).
ASSIGN struc-text(struc-len) TO <f>.
CASE struc-id.
WHEN dump_id.
dump_id_found = yes.
IF <f> IN s_errid.
wa_snap-errorid = <f>.
dump_id_ok = yes.
ELSE.
EXIT.
ENDIF.
WHEN dump_exception.
dump_exception_found = yes.
IF <f> IN s_except.
wa_snap-rexception = <f>.
dump_exception_ok = yes.
ELSE.
EXIT.
ENDIF.
WHEN dump_program.
dump_program_found = yes.
IF <f> IN s_prg .
wa_snap-gprogram = <f>.
dump_program_ok = yes.
ELSE.
EXIT.
ENDIF.
WHEN dump_tid.
dump_tid_found = yes.
IF <f> IN s_tid .
wa_snap-tid = <f>.
dump_tid_ok = yes.
ELSE.
EXIT.
ENDIF.
WHEN dump_eeprootid.
dump_eeprootid_found = yes.
IF <f> IN s_epprid.
dump_eeprootid_ok = yes.
ELSE.
EXIT.
ENDIF.
WHEN dump_eepconnid.
dump_eepconnid_found = yes.
IF <f> IN s_eppcid.
dump_eepconnid_ok = yes.
ELSE.
EXIT.
ENDIF.
WHEN dump_eepcalcnt.
dump_eepcalcnt_found = yes.
IF <f> IN s_eppcc.
dump_eepcalcnt_ok = yes.
ELSE.
EXIT.
ENDIF.
WHEN dump_krnproj_path.
dump_krnproj_path_found = yes.
list_krnproj_path = <f>.
ENDCASE.
ELSE.
struc-text = '?????'.
IF struc-len CO '0123456789' AND struc-len <> '000'.
pointer = pointer + l1 + l2 + struc-len. " Neuer Versuch
CONTINUE.
ELSE .
EXIT.
ENDIF.
ENDIF.
IF ( dump_id_found = yes AND
dump_exception_found = yes AND
dump_program_ok = yes AND
dump_tid_ok = yes AND
dump_eeprootid_ok = yes AND
dump_eepconnid_ok = yes AND
dump_eepcalcnt_ok = yes AND
dump_krnproj_path_found = yes )
.
EXIT.
ENDIF.
pointer = pointer + l1 + l2 + struc-len.
ENDWHILE.
IF dump_id_found = no.
wa_snap-errorid = '?????'.
ENDIF.
IF dump_program_found = no.
wa_snap-gprogram = '?????'.
ENDIF.
IF dump_id_found = yes AND dump_id_ok = no.
CONTINUE.
ENDIF.
IF dump_program_found = yes AND dump_program_ok = no.
CONTINUE.
ENDIF.
IF dump_tid_found = yes AND dump_tid_ok = no.
CONTINUE.
ENDIF.
IF dump_eeprootid_found = yes AND dump_eeprootid_ok = no.
CONTINUE.
ENDIF.
IF dump_eepconnid_found = yes AND dump_eepconnid_ok = no.
CONTINUE.
ENDIF.
IF dump_eepcalcnt_found = yes AND dump_eepcalcnt_ok = no.
CONTINUE.
ENDIF.
IF dump_exception_found = yes AND dump_exception_ok = no.
CONTINUE.
ENDIF.
IF NOT s_except[] IS INITIAL AND dump_exception_ok = no AND NOT space IN s_except[].
CONTINUE.
ENDIF.
IF ( flag_com = yes ).
" and ( dump_program_ok = yes ).
CLEAR param_appcomp.
IF dump_id_ok = yes.
param_appcomp-errorid = wa_snap-errorid.
ENDIF.
IF dump_program_ok = yes.
param_appcomp-pgmid = wa_snap-gprogram.
ENDIF.
IF dump_krnproj_path_found = yes.
param_appcomp-krnproj_path = list_krnproj_path.
ENDIF.
DATA:
" l_rc type i,
" l_faulty_position TYPE cl_runtime_error=>ty_abap_position,
l_snap_key TYPE snap_key,
l_runtime_error TYPE REF TO cl_runtime_error.
MOVE-CORRESPONDING wa_snap_beg TO l_snap_key.
TRY.
CREATE OBJECT l_runtime_error
EXPORTING
key = l_snap_key
from_database = ''.
l_runtime_error->build_field_table(
short_version = 'X'
force = 'X' ).
wa_snap-component =
l_runtime_error->get_effective_appl_component( ).
wa_snap-devobject =
l_runtime_error->get_effective_dev_object( ).
IF wa_snap-component IS INITIAL.
wa_snap-component = 'Nicht zugeordnet'(al1).
ENDIF.
IF wa_snap-devobject IS INITIAL.
wa_snap-devobject = 'Nicht zugeordnet'(al1).
ENDIF.
CATCH cx_runtime_error_exc_auth cx_parameter_invalid_range.
ENDTRY.
ENDIF.
APPEND wa_snap TO p_gt_snap.
ENDSELECT.
cl_st22_pal=>progress_indicator_finish(
i_cnt_valid = lines( gt_snap ) ).
IF p_gt_snap[] IS INITIAL.
MESSAGE s404(sn) DISPLAY LIKE 'W'.
ENDIF.
ENDFORM.
FORM adjust_snap_range_to_authoriz.
IF cl_dump_authorization=>is_authoriz_displ_all_clients( ) <> abap_true.
CLEAR: s_mandt[], s_mandt.
s_mandt-low = sy-mandt.
s_mandt-option = 'EQ'.
s_mandt-sign = 'I'.
APPEND s_mandt.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRm_INITIAL
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_initial .
DATA:
buffer TYPE c LENGTH 20, "#EC NEEDED
icon_text TYPE c LENGTH 100,
l_excl_it TYPE TABLE OF rsexfcode.
restrict =
cl_st22_pal=>get_text(
textpool = TEXT-s78
text = 'Further options:' ##NO_TEXT
).
IF flag_txt IS INITIAL.
flag_txt = 'Anwendungskomponente ermitteln (zeitaufwendig)'(s05).
ENDIF.
ftxt_exc = 'Gekürzte Darstellung des Laufzeitfehlers'(sex).
st_eprid = 'EPP Root Context ID'.
st_epcid = 'EPP Connection ID'.
DATA: l_subrc TYPE sy-subrc.
cl_st22_pal=>import_to_prog(
EXPORTING
i_progname = cl_st22_pal=>c_prog-rsshowrabax
i_memory_id = cl_st22_pal=>c_memory_id-st22_sel_start
IMPORTING
e_subrc = l_subrc ).
IF l_subrc NE 0.
cl_st22_pal=>get_param_ids(
i_progname = sy-repid
i_fields = cl_st22_pal=>s_sel_fields_all ).
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_send_dd
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_send_dd .
DATA:lt_ztrdumpov TYPE TABLE OF ztrdumpov.
DATA:lv_mtype TYPE bapi_mtype,
lv_msg TYPE bapi_msg.
DELETE gt_snap WHERE datum <> sy-datum.
CHECK gt_snap[] IS NOT INITIAL.
SELECT zmandt
datum
uzeit
ahost
uname
xhold
errorid
rexception
component
devobject
gprogram
modno
tid
times INTO CORRESPONDING FIELDS OF TABLE lt_ztrdumpov
FROM ztrdumpov
FOR ALL ENTRIES IN gt_snap
WHERE zmandt = gt_snap-mandt AND
datum = gt_snap-datum AND
uzeit = gt_snap-uzeit AND
ahost = gt_snap-ahost AND
uname = gt_snap-uname AND
xhold = gt_snap-xhold AND
errorid = gt_snap-errorid AND
rexception = gt_snap-rexception AND
component = gt_snap-component AND
devobject = gt_snap-devobject AND
gprogram = gt_snap-gprogram AND
modno = gt_snap-modno AND
tid = gt_snap-tid.
DATA:i_text TYPE zdeztstext.
LOOP AT gt_snap INTO DATA(lw_snap).
READ TABLE lt_ztrdumpov ASSIGNING FIELD-SYMBOL(<fs_ztrdumpov>) WITH KEY zmandt = lw_snap-mandt
datum = lw_snap-datum
uzeit = lw_snap-uzeit
ahost = lw_snap-ahost
uname = lw_snap-uname
xhold = lw_snap-xhold
errorid = lw_snap-errorid
rexception = lw_snap-rexception
component = lw_snap-component
devobject = lw_snap-devobject
gprogram = lw_snap-gprogram
modno = lw_snap-modno
tid = lw_snap-tid .
IF sy-subrc EQ 0.
IF <fs_ztrdumpov>-times > 1.
CONTINUE.
ENDIF.
<fs_ztrdumpov>-times = <fs_ztrdumpov>-times + 1.
ELSE.
lt_ztrdumpov = VALUE #( BASE lt_ztrdumpov ( zmandt = lw_snap-mandt
datum = lw_snap-datum
uzeit = lw_snap-uzeit
ahost = lw_snap-ahost
uname = lw_snap-uname
xhold = lw_snap-xhold
errorid = lw_snap-errorid
rexception = lw_snap-rexception
component = lw_snap-component
devobject = lw_snap-devobject
gprogram = lw_snap-gprogram
modno = lw_snap-modno
tid = lw_snap-tid
times = 1 ) ).
ENDIF.
CLEAR:i_text.
i_text = 'ST22存在报错:' && cl_abap_char_utilities=>newline
&& '客户端标识:' && lw_snap-mandt && cl_abap_char_utilities=>newline
&& '系统日期:' && lw_snap-datum && cl_abap_char_utilities=>newline
&& '系统时间:' && lw_snap-uzeit && cl_abap_char_utilities=>newline
&& '应用服务器:' && lw_snap-ahost && cl_abap_char_utilities=>newline
&& '用户名:' && lw_snap-uname && cl_abap_char_utilities=>newline
&& '短转储的存储:' && lw_snap-xhold && cl_abap_char_utilities=>newline
&& 'ABAP 运行时错误的名称:' && lw_snap-errorid && cl_abap_char_utilities=>newline
&& 'ST22 ALV 的例外列:' && lw_snap-rexception && cl_abap_char_utilities=>newline
&& '应用组件:' && lw_snap-component && cl_abap_char_utilities=>newline
&& '对象目录中的对象名称:' && lw_snap-devobject && cl_abap_char_utilities=>newline
&& 'ABAP 程序:当前主程序:' && lw_snap-gprogram && cl_abap_char_utilities=>newline
&& '工作进程索引:' && lw_snap-modno && cl_abap_char_utilities=>newline
&& '事务标识:' && lw_snap-tid && cl_abap_char_utilities=>newline.
CALL METHOD zcl_common=>send_dd_jqr(
EXPORTING
i_zid = 'DD001'
i_appname = 'DD001'
i_text = i_text
IMPORTING
e_mtype = lv_mtype
e_msg = lv_msg ).
ENDLOOP.
IF lt_ztrdumpov[] IS NOT INITIAL.
MODIFY ztrdumpov FROM TABLE lt_ztrdumpov[].
COMMIT WORK AND WAIT.
ENDIF.
ENDFORM.