W Pub: ABAP Prog Propios SM 50

  1. report znadar_sm50 line-size 110 no standard page heading.
  2.  
  3. constants: opcode_wp_stop(1)  type x value 2,
  4.            opcode_wp_debug(1) type x value 6.
  5.  
  6. data: wp_tabl like wpinfo occurs 0 with header line,
  7.       bkp like wpinfo occurs 0 with header line,
  8.       begin of conta occurs 0,
  9.         WP_TYP like bkp-WP_TYP,
  10.         ecx type i,
  11.       end of conta.
  12.  
  13. at line-selection.
  14.    clear bkp. refresh bkp.
  15.    do.
  16.      read line sy-index.
  17.      if sy-subrc ne 0. exit. endif.
  18.      check sy-lisel+0(1) = 'X'.
  19.      bkp = wp_tabl.
  20.      append bkp.
  21.    enddo.
  22. * Matix Reload
  23.    if sy-cucol >= 02 and sy-cucol <= 10.
  24.       sy-LSIND = 0. perform load_Data.
  25.    endif.
  26. * DON'T STOP ME
  27.    if sy-cucol >= 14 and sy-cucol <= 17. perform stop. endif.
  28. * &iquest; Quieres la pastilla azul o la roja ?
  29.    if sy-cucol >= 21 and sy-cucol <= 25. perform debug_me. endif.
  30.  
  31. end-of-selection.
  32.    perform load_Data.
  33.  
  34. form load_data.
  35. data: with_cpu type x value 0,
  36.       nom(30),
  37.       ape(160).
  38.   clear conta. refresh conta.
  39.   call function 'TH_WPINFO'
  40.   EXPORTING  WITH_CPU   = with_cpu
  41.   tables     wplist     = wp_tabl
  42.   EXCEPTIONS SEND_ERROR = 1
  43.               OTHERS    = 2.
  44.   loop at wp_tabl.
  45.     clear conta.
  46.     conta-WP_TYP = wp_tabl-WP_TYP.
  47.     conta-ecx = 1.
  48.     collect conta.
  49.     check wp_tabl-WP_BNAME is initial.
  50.     delete wp_tabl.
  51.   endloop.
  52.   loop at wp_tabl.
  53.     at first.
  54.       write: / 'Refrescar' hotspot on color col_total, sy-vline,
  55.                'STOP'      hotspot on color col_total, sy-vline,
  56.                'DEBUG'     hotspot on color col_total, sy-vline.
  57.       loop at conta.
  58.         write conta-ecx to nom.
  59.         if conta-ecx is initial. nom = '0'. endif.
  60.         concatenate ape conta-WP_TYP ':' nom '|'
  61.                                               into ape separated by ' '.
  62.         condense ape.
  63.       endloop.
  64.       write: ape(60) color col_positive.
  65.       uline /001(120).
  66.     endat.
  67.     if wp_tabl-WP_BNAME = sy-uname.
  68.       format color col_heading.
  69.     else.
  70.       format color col_normal.
  71.     endif.
  72.     clear syst-FTYPE.
  73.     write: / syst-FTYPE as checkbox,
  74.              wp_tabl-WP_TYP,
  75.              wp_tabl-WP_MANDT,
  76.              wp_tabl-WP_BNAME,
  77.              wp_tabl-WP_ELTIME,
  78.              wp_tabl-WP_REPORT,
  79.              wp_tabl-WP_TABLE,
  80.              wp_tabl-WP_ACTION.
  81.     hide: syst-FTYPE, wp_tabl.
  82.     select single p~name_first p~name_last into (nom, ape)
  83.      from usr21 as f inner join adrp as p on f~persnumber = p~persnumber
  84.      where f~BNAME = wp_tabl-WP_BNAME.
  85.     concatenate nom ape into ape separated by ' '.
  86.     condense ape.
  87.     write: / ape(30) under wp_tabl-WP_BNAME.
  88.     clear ape.
  89.     select single text into ape from trdirt
  90.                           where name = wp_tabl-WP_REPORT
  91.                           and  sprsl = sy-langu.
  92.     write: ape(30) under wp_tabl-WP_REPORT.
  93.     clear ape.
  94.     select single ddtext into ape from  dd02t
  95.                           where tabname  = wp_tabl-WP_TABLE
  96.                           and ddlanguage = sy-langu.
  97.     write: ape(30) under wp_tabl-WP_TABLE.
  98.     uline /001(120).
  99.   endloop.
  100. endform.
  101.  
  102. form stop.
  103.   perform decide using 'Matar el proceso'.
  104.   check syst-FTYPE = 'J'.
  105.   loop at bkp.
  106.     CALL 'ThWpInfo' ID 'OPCODE' FIELD OPCODE_WP_STOP
  107.                     ID 'PID'    FIELD bkp-WP_PID.
  108.     check SY-SUBRC eq 0.
  109.     MESSAGE S398(00) WITH 'Proceso ' bkp-WP_PID ' cancelado'.
  110.   endloop.
  111. endform.
  112.  
  113. form debug_me.
  114.   perform decide using 'Depurar el proceso'.
  115.   check syst-FTYPE = 'J'.
  116.   loop at bkp.
  117.     call 'ThWpInfo' id 'OPCODE'   field opcode_wp_debug
  118.                     id 'WP_INDEX' field bkp-wp_index.
  119.     exit.
  120.   endloop.
  121. endform.
  122.  
  123. form decide using txt.
  124.   CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
  125.   EXPORTING TEXTLINE1     = txt
  126.             TITEL         = 'RED ALERT'
  127.   IMPORTING ANSWER        = syst-FTYPE.
  128. endform.