2021 Oct 08 9:26 PM
I need to create a Z report to show the dumps list and dump details like t-code ST22. Does anyone know a function or program that I could use?
Here is the code that I have already done, but the details are not in a 'beautiful' way.
*&---------------------------------------------------------------------*
*& Report ZZSHOWDUMP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zzshowdump.
TYPE-POOLS: slis.
DATA: it_layout TYPE slis_layout_alv.
DATA: it_events TYPE slis_t_event,
wa_events LIKE LINE OF it_events.
DATA: lt_rsdumptab TYPE rsdumptab,
ls_rsdumpinfo TYPE rsdumpinfo,
ls_snap TYPE snap,
ft TYPE rsdump_ft OCCURS 1000 WITH HEADER LINE,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_fieldcat2 TYPE slis_t_fieldcat_alv.
PARAMETERS: p_data TYPE d.
it_layout-zebra = 'X'.
it_layout-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
IMPORTING
et_events = it_events.
READ TABLE it_events INTO wa_events WITH KEY = 'USER_COMMAND'.
wa_events-form = 'FORM_USER_COMMAND'.
MODIFY it_events FROM wa_events INDEX sy-tabix.
IF p_data IS INITIAL.
p_data = sy-datum.
ENDIF.
BREAK-POINT.
CALL FUNCTION 'RS_ST22_GET_DUMPS'
EXPORTING
p_day = p_data
IMPORTING
p_infotab = lt_rsdumptab.
START-OF-SELECTION.
IF lt_rsdumptab IS NOT INITIAL.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-cprog
i_structure_name = 'RSDUMPINFO'
CHANGING
ct_fieldcat = lt_fieldcat[].
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = lt_fieldcat
it_events = it_events
i_structure_name = 'RSDUMPINFO'
is_layout = it_layout
TABLES
t_outtab = lt_rsdumptab.
IF sy-subrc IS INITIAL.
ENDIF.
ENDIF.
AT LINE-SELECTION.
*&---------------------------------------------------------------------*
*& Form form_user_command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->UCOMM text
* -->SELFIELD text
*----------------------------------------------------------------------*
FORM form_user_command USING ucomm TYPE sy-ucomm
selfield TYPE slis_selfield.
CONSTANTS:
l_c_ic1 TYPE char4 VALUE '&IC1',
l_c_vl TYPE char2 VALUE 'VL',
l_c_vl03n TYPE char5 VALUE 'VL03N'.
CASE ucomm.
WHEN l_c_ic1.
IF selfield-tabindex NE space.
READ TABLE lt_rsdumptab INTO ls_rsdumpinfo INDEX selfield-tabindex.
SELECT *
FROM snap
INTO ls_snap
WHERE datum = ls_rsdumpinfo-sydate
AND uzeit = ls_rsdumpinfo-sytime
AND uname = ls_rsdumpinfo-syuser
AND ahost = ls_rsdumpinfo-syhost
AND mandt = sy-mandt.
PERFORM extract_strings_from_snap.
ENDSELECT.
IF ft IS NOT INITIAL.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'RSDUMP_FT'
CHANGING
ct_fieldcat = lt_fieldcat2[].
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = lt_fieldcat2
it_events = it_events
i_structure_name = 'RSDUMP_FT'
is_layout = it_layout
TABLES
t_outtab = ft[].
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. "form_user_command
*&---------------------------------------------------------------------*
*& Form EXTRACT_STRINGS_FROM_SNAP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM extract_strings_from_snap .
DATA: snap_error(60). "#EC NEEDED
FIELD-SYMBOLS: <id> TYPE c, <len> TYPE c, <value> TYPE c.
* Process field list
DO.
IF sy-index = 1.
ASSIGN ls_snap-flist TO <id> RANGE ls_snap. "First string
ELSE.
ASSIGN <value>+<len>(2) TO <id>."Next string
ENDIF.
* Check field id
IF <id> LE space.
snap_error = text-nco. " Short Dump not consistent
EXIT.
ENDIF.
* Short dump not complete ?
IF <id> = '%A'.
snap_error = text-ncm. "Short Dump not complete
EXIT.
ENDIF.
* End of this SNAP record ?
IF <id> = '%E' OR <id> = '%M'.
EXIT.
ENDIF.
* Check format of length field
ASSIGN <id>+2(3) TO <len> TYPE 'C'.
IF <len> CN '0123456789' OR <len> = '000'.
snap_error = text-nco. "Short Dump not consistent
EXIT.
ENDIF.
ASSIGN <id>+5(<len>) TO <value> TYPE 'C'.
* Append field
ft-id = <id>.
ft-len = <len>.
ft-value = <value>.
APPEND ft.
ENDDO.
ENDFORM. " EXTRACT_STRINGS_FROM_SNAP
2021 Oct 08 10:03 PM
Do you mean you want to display a short dump exactly the way ST22 displays it?
2021 Oct 10 12:34 PM
2021 Oct 10 7:20 PM
Check ABAP Dump Texts – Quick and Dirty | SAP Blogs
REPORT yy_dump_texts.
*---------------------------------------------------------------------*
*by Horst Keller, http://scn.sap.com/community/abap/blog/2015/01/08/
*abap-dump-texts--quick-and-dirty
* Edited by Jacques Nomssi Nzali - tested on Netweaver 6.20
*---------------------------------------------------------------------*
PARAMETERS: errid TYPE snapt-errid,
langu TYPE sylangu DEFAULT sy-langu.
*----------------------------------------------------------------------*
* CLASS section DEFINITION
*----------------------------------------------------------------------*
CLASS dump_section DEFINITION.
PUBLIC SECTION.
METHODS constructor
IMPORTING langu TYPE sylangu DEFAULT sy-langu
section TYPE snapt-ttype
key TYPE clike.
METHODS write_lines IMPORTING errid TYPE snapt-errid.
PRIVATE SECTION.
CONSTANTS c_prog TYPE sycprog VALUE 'SAPMS380'.
CONSTANTS c_include TYPE char08 VALUE '&INCLUDE'.
DATA language TYPE sylangu.
DATA ttype TYPE snapt-ttype.
CLASS-DATA pool TYPE table_of_textpool.
METHODS title IMPORTING text_key TYPE clike.
ENDCLASS. "dump_section DEFINITION
*----------------------------------------------------------------------*
* CLASS dump_section IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS dump_section IMPLEMENTATION.
METHOD constructor.
IF language NE langu. " refresh buffer?
language = langu.
READ TEXTPOOL c_prog INTO pool LANGUAGE langu.
ENDIF.
ttype = section.
title( key ).
ENDMETHOD. "constructor
METHOD title.
DATA pool_entry LIKE LINE OF pool.
DATA header_text TYPE char72.
READ TABLE pool INTO pool_entry
WITH KEY key = text_key
id = 'I'. " ID of a text symbol
IF sy-subrc EQ 0.
header_text = pool_entry-entry.
ELSE.
header_text = text_key. " Type conversion
ENDIF.
WRITE / header_text COLOR COL_HEADING. " Title
ENDMETHOD. "read_text
METHOD write_lines.
DATA tline TYPE snapt-tline.
DATA id TYPE snapt-errid.
DATA seqno TYPE snapt-seqno. " needed for ORDER BY
SELECT tline seqno
FROM snapt INTO (tline, seqno)
WHERE langu = language AND
errid = errid AND
ttype = ttype
ORDER BY seqno.
IF STRLEN( tline ) >= 8 AND tline(8) = c_include AND ttype NE 'K'.
REPLACE c_include IN tline WITH ``.
CONDENSE tline.
id = tline. " type conversion
write_lines( id ). " max. incl. depth = max.no. of open cursors
ELSE.
WRITE / tline COLOR COL_NORMAL INTENSIFIED. " Output line
ENDIF.
ENDSELECT.
ENDMETHOD.
ENDCLASS. "dump_section IMPLEMENTATION
DEFINE print_section.
create object section
exporting langu = langu
section = &1
key = &2.
section->write_lines( errid ).
SKIP.
END-OF-DEFINITION.
START-OF-SELECTION.
DATA section TYPE REF TO dump_section.
print_section: 'K' errid, " Run time error short text
'W' '201', " What happened?
'T' '202', " What can I do?
'U' '203', " Error analysis
'H' '204', " Hints for Error handling
'I' '232'. " Internal notes
2021 Oct 10 8:23 PM
Macros are discouraged. Don't use them - you don't need to with methods anyway.
new section( langu = langu section = 'K' key = errid )->write_lines( errid ).
new section( langu = langu section = 'W' key = 201 )->write_lines( errid ).
...
Although fair enough, it does say dirty. Very dirty indeed!
2021 Oct 10 10:20 PM
Yeah, the same as shown on ST22 and I can't use ST22 because I don't have authorization.
2021 Oct 11 6:22 AM
If you run this program, do you still have problem with authorization ?
2021 Oct 11 7:56 AM
Of course, the right way is to ask for authorizations, I can't imagine an organization not giving developers access to short dumps ! 🙂
2021 Oct 11 8:13 AM
Time taken to ask for authorisations - 15 minutes.
Time taken to copy the ST22 program or reverse engineer it - 5 days.
I know which I'd prefer to pay for if I were your employer.