W Pub: ABAP Rut STATS

  1. * Ini : STATS v 0.2 ------------------ 23.12.2004
  2. define stats_create.
  3. data: begin of stats occurs 0,
  4.         _t(30),      "Tabla/Rutina
  5.         _r type i,   "Registros / Leidos
  6.         _u type i,   "Registros modificados
  7.         _i type i,   "Registros insertados
  8.         _d type i,   "Registros Borrados
  9.         _e type i,   "Registros no encontrados/error
  10.       end of stats,
  11.       stats_my_tab(30).
  12. end-of-definition.
  13.  
  14. define stats_add.
  15.   stats_my_tab = &1.
  16.   translate stats_my_tab to upper case.
  17.   clear stats.
  18.   case &2.
  19.     when 'R' or 'r'. stats-_r = 1.
  20.     when 'U' or 'u'. stats-_u = 1.
  21.     when 'I' or 'i'. stats-_i = 1.
  22.     when 'D' or 'd'. stats-_d = 1.
  23.     when 'E' or 'e'. stats-_e = 1.
  24.     when others. exit.
  25.   endcase.
  26.   stats-_t = stats_my_tab.
  27.   collect stats.
  28. end-of-definition.
  29.  
  30. define stats_write.
  31.    loop at stats.
  32.       write: / stats-_t.
  33.       if stats-_r <> 0. format color col_positive on. endif.
  34.       write: /010 'Read:', stats-_r.
  35.       format color col_positive off.
  36.       if stats-_u <> 0. format color col_heading on. endif.
  37.       write:  030 'Save:', stats-_u.
  38.       format color col_heading off.
  39.       if stats-_i <> 0. format color col_total on. endif.
  40.       write:  050 'Ins :', stats-_i.
  41.       format color col_total off.
  42.       if stats-_d <> 0. format color col_negative on. endif.
  43.       write:  070 'Dele:', stats-_d.
  44.       format color col_negative off.
  45.       if stats-_e <> 0. format color col_group on. endif.
  46.       write:  090 'Err :', stats-_e.
  47.       format color col_group off.
  48.    endloop.
  49.    check sy-subrc ne 0.
  50.    write: / '*** No stats'.
  51. end-of-definition.
  52. * End : STATS v 0.2 ------------------ 23.12.2004
  53.