Copia este report.
Te dice todos los programas que no han sido utilizados desde la fecha indicada.
REPORT zsbcprog LINE-SIZE 110
NO STANDARD PAGE HEADING.
TABLES: d010sinf, tstc, tstct.
* Pantalla de selección
SELECTION-SCREEN BEGIN OF BLOCK sele WITH FRAME TITLE text-t02.
PARAMETERS: date_fr LIKE sy-datum.
* date_to type d default sy-datum.
SELECTION-SCREEN END OF BLOCK sele.
* Tablas internas
DATA: t_apps LIKE sapwlustcx OCCURS 0.
DATA: wa_apps LIKE sapwlustcx.
DATA: BEGIN OF t_progs OCCURS 0, "Programas que se utilizan
prog(8),
END OF t_progs.
DATA: BEGIN OF t_trans OCCURS 0,
tcode LIKE tstc-tcode,
ttext LIKE tstct-ttext,
END OF t_trans.
* Variables auxiliares.
DATA: used.
DATA: years(4), months(2), days(2).
DATA: aux_date TYPE d.
DATA: prog_texts LIKE textpool OCCURS 0 WITH HEADER LINE.
INITIALIZATION.
* Desde el inicio del año.
date_fr = sy-datum.
date_fr+4 = '0101'.
AT SELECTION-SCREEN.
IF date_fr > sy-datum.
MESSAGE e000(z1).
ENDIF.
TOP-OF-PAGE.
WRITE: / 'Programas no usados desde el día'(t01), date_fr.
ULINE.
START-OF-SELECTION.
REFRESH t_progs.
* Busco los programas utilizados en el periodo especificado
* Years
years = date_fr(4).
aux_date+4 = '0101'.
WHILE years < sy-datum(4).
aux_date(4) = years.
PERFORM get_used_programs USING 'Y' aux_date.
years = years + 1.
ENDWHILE.
aux_date(4) = years.
* Months
months = date_fr+4(2).
aux_date+6 = '01'.
WHILE months <= sy-datum+4(2).
aux_date+4(2) = months.
PERFORM get_used_programs USING 'M' aux_date.
months = months + 1.
ENDWHILE.
* Weeks
WHILE aux_date <= sy-datum.
PERFORM get_used_programs USING 'W' aux_date.
aux_date = aux_date + 7.
ENDWHILE.
aux_date = aux_date - 7.
* Days
WHILE aux_date <= sy-datum.
PERFORM get_used_programs USING 'D' aux_date.
aux_date = aux_date + 1.
ENDWHILE.
* Ordenamos la tabla de programas usados.
SORT t_progs BY prog.
FORMAT RESET.
SELECT * FROM d010sinf
WHERE ( prog LIKE 'Z%' "Reports
OR prog LIKE 'Y%' )
AND subc = '1'
OR ( prog LIKE 'SAPMZ%' "Module-Pools
OR prog LIKE 'SAPMY%' )
AND subc = 'M'.
* or ( prog like 'SAPLZ%' "Function Groups
* or prog like 'SAPLY%' )
* and subc = 'F'.
CLEAR used.
REFRESH t_trans.
* Si se llama por transacción, compruebo si esta se usa
SELECT tcode FROM tstc
INTO TABLE t_trans
WHERE pgmna = d010sinf-prog.
IF sy-subrc = 0.
LOOP AT t_trans.
READ TABLE t_progs WITH KEY prog = t_trans-tcode.
CHECK sy-subrc = 0.
used = 'X'.
EXIT.
ENDLOOP.
ENDIF.
READ TABLE t_progs WITH KEY prog = d010sinf-prog
BINARY SEARCH.
IF sy-subrc <> 0 AND used IS INITIAL.
* append...
REFRESH prog_texts.
READ TEXTPOOL d010sinf-prog INTO prog_texts LANGUAGE sy-langu.
IF sy-subrc = 0.
READ TABLE prog_texts WITH KEY id = 'R'.
ENDIF.
WRITE: / d010sinf-prog COLOR 1,
AT (prog_texts-length) prog_texts-entry COLOR 2.
LOOP AT t_trans.
SELECT SINGLE ttext FROM tstct
INTO t_trans-ttext
WHERE tcode = t_trans-tcode
AND sprsl = sy-langu.
WRITE: /10 t_trans-tcode COLOR 7 INTENSIFIED OFF,
t_trans-ttext INTENSIFIED OFF.
AT LAST.
SKIP.
ENDAT.
ENDLOOP.
ENDIF.
ENDSELECT.
*---------------------------------------------------------------------*
* FORM GET_USED_PROGRAMS *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> P_PERIOD Puede ser 'Y' (Año), 'M' (Mes), ó 'D' (Día) *
* --> P_STARTD Fecha de referencia *
*---------------------------------------------------------------------*
FORM get_used_programs USING p_period p_startd.
REFRESH t_apps.
CALL FUNCTION 'SAPWL_WORKLOAD_GET_STATISTIC'
EXPORTING
periodtype = p_period
hostid = 'TOTAL'
startdate = p_startd
only_application_statistic = 'X'
TABLES
application_statistic = t_apps
EXCEPTIONS
unknown_periodtype = 1
no_data_found = 2
OTHERS = 3.
CHECK sy-subrc = 0.
LOOP AT t_apps INTO wa_apps
WHERE account = 'cumul.' AND
entry_id(1) = 'Z' OR
entry_id(1) = 'Y' OR
entry_id(5) = 'SAPMZ' OR
entry_id(5) = 'SAPMY'.
t_progs-prog = wa_apps-entry_id.
COLLECT t_progs.
ENDLOOP.
ENDFORM. "get_used_programs
Un saludo,
Oscar.