Create and display protocol in style of transport tools
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.
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
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 in my infodepot:
Full list of examples in my infodepot
If you have a question, have found an error or just want to contact me, please use this form.
If you have a question, have found an error or just want to contact me, please use this form.
Copyright (C) 2011 http://www.kerum.pl/infodepot/
Disclaimer: I am not affiliated or related to any division or subsidiary of SAP AG.
Trademarks or registered trademarks of any products or companies referred to on this site belong to those companies.
Anyone using the given solutions, is doing it under his/her own responsibility and at own risk.