I like the style of protocols produced by transport tools, for example
export/import protocols of transactions STMS, SE10, etc.
Such protocols are easy to read and have clear structure,
there is a possibility to expand/collapse details.
They are also easy to use in your own programs and are a great alternative to the WRITE’s,
making your programs look attractive and professional.
Have a look at the sample screenshot and coding:
REPORT zsprot1.
DATA:
gt_prot TYPE TABLE OF sprot_u.
*&---------------------------------------------------------------------*
*& START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
* create protocol
PERFORM prot_add USING '' 1 'I' 'B1' '999' 'Message 1' '' '' ''.
PERFORM prot_add USING '' 2 'I' 'B1' '999' 'Message 1' 'next level' '' ''.
PERFORM prot_add USING '' 1 'I' 'B1' '999' 'Message 2' '' '' ''.
PERFORM prot_add USING 'X' 1 'W' 'B1' '999' 'Warning' '' '' ''.
PERFORM prot_add USING '' 1 'E' 'B1' '999' 'Error' '' '' ''.
PERFORM prot_add USING '' 1 'A' 'B1' '999' 'Critical' '' '' ''.
* display protocol
PERFORM prot_display.
*&---------------------------------------------------------------------*
*& Form prot_display
*&---------------------------------------------------------------------*
FORM prot_display.
* Save in memory
CALL FUNCTION 'TRINT_WRITE_LOG_TO_MEMORY'
EXPORTING
iv_logname_memory = 'PROTOCOL'
TABLES
it_msgs = gt_prot.
* Display from memory
CALL FUNCTION 'TR_READ_AND_DISPLAY_LOG'
EXPORTING
iv_log_type = 'MEMORY'
iv_logname_memory = 'PROTOCOL'
iv_titlebar = 'Title'
iv_heading = 'Heading'
iv_display_level = '1'.
ENDFORM. "prot_display
*&---------------------------------------------------------------------*
*& Form prot_add
*&---------------------------------------------------------------------*
FORM prot_add USING pi_newobj TYPE protnewobj
pi_level TYPE protlevel
pi_severity TYPE errortyp
pi_ag TYPE arbgb
pi_msgnr TYPE msgnr
pi_var1 TYPE csequence
pi_var2 TYPE csequence
pi_var3 TYPE csequence
pi_var4 TYPE csequence.
DATA:
ls_prot TYPE sprot_u.
ls_prot-level = pi_level.
ls_prot-severity = pi_severity.
ls_prot-langu = sy-langu.
ls_prot-ag = pi_ag.
ls_prot-msgnr = pi_msgnr.
ls_prot-newobj = pi_newobj.
ls_prot-var1 = pi_var1.
ls_prot-var2 = pi_var2.
ls_prot-var3 = pi_var3.
ls_prot-var4 = pi_var4.
APPEND ls_prot TO gt_prot.
ENDFORM. "prot_add
See other related notes on my website: