MMPI使用指南
1、 更改个人参数设置
参数ID:MMPI_READ_NOTE
赋值:当前日期,按照YYYYMMDD (Y = year, M = month, D = day)
2、 新建程序Z_DEL_HIST_ENTRIES
代码见附件
3、 执行程序Z_DEL_HIST_ENTRIES
4、 MMPI
5、 MMRV检查
代码:
include mm13qtop.
selection-screen skip 2.
parameters: i_vbukr likerm03q-vbukr obligatory.
data i_bbukr like rm03q-bbukr.
data: i_lfmon like rm03q-nperi,
i_lfgja likerm03q-lfgja.
data: i_xcomp like rm03q-xcomp value 'X',
i_xinco likerm03q-xinco,
i_xmove likerm03q-xmove.
data: i_kzinv like rm03q-kzinv value 'X'.
at selection-screen.
select single * frommarv where bukrs = i_vbukr.
if sy-subrc = 0.
i_lfmon = marv-lfmon.
i_lfgja = marv-lfgja.
else.
exit.
endif.
rm03q-vbukr = i_vbukr.
rm03q-bbukr = i_bbukr.
rm03q-lfmon = i_lfmon.
rm03q-lfgja = i_lfgja.
rm03q-kzinv = i_kzinv.
if i_bbukr is initial.
i_bbukr = rm03q-bbukr = i_vbukr.
endif.
if i_kzinv ne space.
* Sitzt der Benuterparameter?
get parameter id 'MMPI_READ_NOTE' field mmpi_read_note.
if mmpi_read_note ne sy-datlo.
message e016(mm).
endif.
endif.
*--------------------------------------------------------
start-of-selection.
berecht_akt ='51'. "Initialisieren
authority-check object 'M_MATE_PER'
id 'AKTPR' field berecht_akt
id 'BUKRS' dummy.
if sy-subrc ne 0.
berecht_akt = '03'. "Initialisieren
authority-check object 'M_MATE_PER'
id 'AKTPR' field berecht_akt
id 'BUKRS' dummy.
if sy-subrc ne 0.
message e865.
endif.
endif.
perform bukrs_tab_fuellen.
describe table bukrs_tablines zaehler1.
if zaehler1 =0. "kein Buchungskreis gefunden
move '01' to ausnahme_tab.
append ausnahme_tab.
exit.
endif.
perform lesen_marv_seq.
loop at bukrs_tab.
perform periode_ermitteln.
if fehlerflag ne space. "im UpPERIODE_ERMITTELN gesetzt
check sy-subrc ne sy-subrc.
endif.
perform periode_pruefen.
if fehlerflag ne space. "im UpPERIODE_PRUEFEN gesetzt
check sy-subrc ne sy-subrc.
endif.
* neu zu 4.6a: Pr黤en, ob Warenbewegungen vorhanden sind, zu denen
* die Werte noch fortzuschreiben sind.
call function 'MB_STATUS_SEPERATE_VALUATION'
exporting
bukrs = bukrs_tab-bukrs
exceptions
exception_internal_error = 1
exception_entries_found = 2
exception_no_entries_found = 3
others = 4.
if sy-subrc = 2.
clear ausnahme_tab.
move '97' to ausnahme_tab-ausna.
move bukrs_tab-bukrs to ausnahme_tab-bukrs.
append ausnahme_tab.
move '98' to ausnahme_tab-ausna.
append ausnahme_tab.
if sy-msgty = 'E'.
fehlerflag = 'X'.
move '91' to ausnahme_tab-ausna.
append ausnahme_tab.
endif.
endif.
bukrs_tab-relevantflag = 'X'.
modify bukrs_tab.
endloop.
loop at bukrs_tab.
check bukrs_tab-relevantflag ne space.
performin_bwkey_ermitteln.
read table in_bwkey_all index 1.
if sy-subrc = 0 and in_bwkey_all-low is initial.
continue.
endif.
perform in_werks_ermitteln.
read table in_werks_all index 1.
if sy-subrc = 0 and in_werks_all-low is initial.
continue.
endif.
marv-bukrs = bukrs_tab-bukrs.
perform marvcd_zaehler.
marvcd-mandt = sy-mandt.
marvcd-bukrs = bukrs_tab-bukrs.
marvcd-lfgja = bukrs_tab-jahr.
marvcd-lfmon = bukrs_tab-monat.
marvcd-aenam = sy-uname.
marvcd-laeda = sy-datum.
marvcd-uzeit = sy-uzeit.
clear marvcd-lfgja_old.
clear marvcd-lfmon_old.
perform marvcd_insert.
clear flg_no_bwkey.
do.
perform in_bwkey_teil_ermitteln.
if flg_no_bwkey = xwert.
exit.
endif.
if ( bukrs_tab-lfgja > bukrs_tab-jahr )
or ( bukrs_tab-lfgja =bukrs_tab-jahr
and bukrs_tab-lfmon>= bukrs_tab-monat ).
delete from mbewh
where bwkey in in_bwkey
and ( lfgja > bukrs_tab-jahr
or ( lfgja = bukrs_tab-jahr
and lfmon >= bukrs_tab-monat ) ).
delete from ebewh
where bwkey in in_bwkey
and ( lfgja > bukrs_tab-jahr
or ( lfgja = bukrs_tab-jahr
and lfmon >= bukrs_tab-monat ) ).
delete from qbewh
where bwkey in in_bwkey
and ( lfgja > bukrs_tab-jahr
or ( lfgja = bukrs_tab-jahr
and lfmon >= bukrs_tab-monat ) ).
delete from obewh
where bwkey in in_bwkey
and ( lfgja > bukrs_tab-jahr
or ( lfgja = bukrs_tab-jahr
and lfmon >= bukrs_tab-monat ) ).
endif.
enddo.
clearflg_no_werks.
do.
perform in_werks_teil_ermitteln.
if flg_no_werks = xwert.
exit.
endif.
if ( bukrs_tab-lfgja > bukrs_tab-jahr )
or ( bukrs_tab-lfgja =bukrs_tab-jahr
and bukrs_tab-lfmon>= bukrs_tab-monat ).
delete from mardh
where werks in in_werks
and ( lfgja > bukrs_tab-jahr
or ( lfgja = bukrs_tab-jahr
and lfmon >= bukrs_tab-monat ) ).
delete from mchbh
where werks in in_werks
and ( lfgja > bukrs_tab-jahr
or ( lfgja = bukrs_tab-jahr
and lfmon >= bukrs_tab-monat ) ).
delete from mkolh
where werks in in_werks
and ( lfgja > bukrs_tab-jahr
or ( lfgja = bukrs_tab-jahr
and lfmon >= bukrs_tab-monat ) ).
delete from mscah
where werks in in_werks
and ( lfgja > bukrs_tab-jahr
or ( lfgja = bukrs_tab-jahr
and lfmon >= bukrs_tab-monat ) ).
delete from mskah
where werks in in_werks
and ( lfgja > bukrs_tab-jahr
or ( lfgja = bukrs_tab-jahr
and lfmon >= bukrs_tab-monat ) ).
delete from mskuh
where werks in in_werks
and ( lfgja > bukrs_tab-jahr
or ( lfgja = bukrs_tab-jahr
and lfmon >= bukrs_tab-monat ) ).
delete from mslbh
where werks in in_werks
and ( lfgja > bukrs_tab-jahr
or ( lfgja = bukrs_tab-jahr
and lfmon >= bukrs_tab-monat ) ).
delete from msprh
where werks in in_werks
and ( lfgja > bukrs_tab-jahr
or ( lfgja = bukrs_tab-jahr
and lfmon >= bukrs_tab-monat ) ).
delete from mssah
where werks in in_werks
and ( lfgja > bukrs_tab-jahr
or ( lfgja = bukrs_tab-jahr
and lfmon >= bukrs_tab-monat ) ).
delete from mssqh
where werks in in_werks
and ( lfgja > bukrs_tab-jahr
or ( lfgja = bukrs_tab-jahr
and lfmon >= bukrs_tab-monat ) ).
endif.
enddo.
EXEC SQL.
COMMIT
ENDEXEC.
*-------- Meldung Buchungskreisumgesetzt
clear ausnahme_tab.
move '32' to ausnahme_tab-ausna.
move bukrs_tab-bukrs to ausnahme_tab-bukrs.
append ausnahme_tab.
endloop.
end-of-selection.
loop at ausnahme_tab.
select single * from t139a
whereausna = ausnahme_tab-ausna.
if sy-subrc = 0.
move t139a-sortfto ausnahme_tab-sortf.
modify ausnahme_tab.
endif.
endloop.
sort ausnahme_tab by sortf.
skip.
write 'L O G'.
skip.
write : 'client: ', sy-mandt.
write: / 'deletion run for all history table entries >=(month/year)',
rm03q-lfmon,rm03q-lfgja.
skip 2.
loop at ausnahme_tab.
select single * from t139a
where ausna = ausnahme_tab-ausna.
if t139a-abbrune space.
write 'A B E N D'.
skip.
endif.
if ausnahme_tab-ausna = '32'.
concatenate 'history table entries for companycode'
'$$$$ deleted' into t139a-ktextseparated by space.
endif.
*-- Buchungskreis im Kurztext einsetzen
if t139a-ktextca '$'.
replace '$$$$' with ausnahme_tab-bukrs into t139a-ktext.
endif.
*-- Text in der sprachabh鋘gigen Tabelle suchenund ausgeben
select single * from t139b
where spras = sy-langu
and ausna = ausnahme_tab-ausna.
if sy-subrc = 0.
if ausnahme_tab-ausna = '32'.
concatenate 'history table entriesfor company code'
'$$$$ deleted' into t139b-ktext separated by space.
endif.
if t139b-ktext ca '$'.
replace '$$$$' withausnahme_tab-bukrs into t139b-ktext.
endif.
write t139b-ktext.
else.
write t139a-ktext.
endif.
*-- Zus鋞zliche Angaben
if ausnahme_tab-ausna = '05'. "Falsche Periode in MARV
write: 'The current period (month/year) of thecontrol record is',
ausnahme_tab-lfmon, ausnahme_tab-lfgja.
endif.
endloop.
** Ende der Ausgabe
skip 3.
write 'E N D'.
if t139a-abbrune space
or t139a-ausnaeq '93'.
clear cattaktiv.
import cattaktiv from memory id 'CATT'.
if cattaktiv = 'X' and sy-subrc = 0.
message e705. "Periodenverschiebung ist abgebrochen
else.
message s705. "Periodenverschiebung ist abgebrochen
endif.
endif.
include mm13qf00.
include mm13qfsq.
includemm13qf40. "neu zu 4.0 -> EBEW/QBEW-Routinen
INCLUDE MM13QF50.