MMPI使用指南
SAP 2010-07-09 15:22:36 阅读1 评论0 字号:大中小
1、 更改个人参数设置(su3)
参数ID:MMPI_READ_NOTE
赋值:当前日期,按照YYYYMMDD (Y = year, M =month, D = day
2、 新建程序Z_DEL_HIST_ENTRIES(se38)
代码见附件
建完程序之后需要激活才能运行
3、 执行程序Z_DEL_HIST_ENTRIES(se38)
4、 MMPI
5、 MMRV检查
代码:
includemm13qtop.
selection-screenskip 2.
parameters:i_vbukr like rm03q-vbukr obligatory.
data i_bbukr like rm03q-bbukr.
data: i_lfmon like rm03q-nperi,
i_lfgja like rm03q-lfgja.
data: i_xcomp like rm03q-xcomp value 'X',
i_xinco like rm03q-xinco,
i_xmove like rm03q-xmove.
data: i_kzinv like rm03q-kzinv value 'X'.
atselection-screen.
select single * from marv wherebukrs = 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' fieldmmpi_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_tab lines 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 nespace. "im Up PERIODE_ERMITTELN gesetzt
check sy-subrc ne sy-subrc.
endif.
perform periode_pruefen.
if fehlerflag nespace. "im Up PERIODE_PRUEFEN gesetzt
check sy-subrc ne sy-subrc.
endif.
*neu zu 4.6a: Pr黤en, ob Warenbewegungen vorhandensind, 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 toausnahme_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.
perform in_bwkey_ermitteln.
read table in_bwkey_all index 1.
if sy-subrc = 0 andin_bwkey_all-low is initial.
continue.
endif.
perform in_werks_ermitteln.
read table in_werks_all index 1.
if sy-subrc = 0 andin_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.
clear flg_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 Buchungskreis umgesetzt
clear ausnahme_tab.
move '32' to ausnahme_tab-ausna.
move bukrs_tab-bukrs toausnahme_tab-bukrs.
append ausnahme_tab.
endloop.
end-of-selection.
loop at ausnahme_tab.
select single * from t139a
where ausna = ausnahme_tab-ausna.
if sy-subrc = 0.
move t139a-sortf to 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 historytable entries >= (month/year)',
rm03q-lfmon, rm03q-lfgja.
skip 2.
loop at ausnahme_tab.
select single * from t139a
where ausna = ausnahme_tab-ausna.
if t139a-abbru ne space.
write 'A B E N D'.
skip.
endif.
if ausnahme_tab-ausna = '32'.
concatenate 'history table entries forcompany code'
'$$$$ deleted' into t139a-ktextseparated by space.
endif.
*--Buchungskreis im Kurztext einsetzen
if t139a-ktext ca '$'.
replace '$$$$' with ausnahme_tab-bukrsinto t139a-ktext.
endif.
*--Text in der sprachabh鋘gigen Tabelle suchen und 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 entries forcompany code'
'$$$$ deleted' into t139b-ktextseparated by space.
endif.
if t139b-ktext ca '$'.
replace '$$$$' with ausnahme_tab-bukrsinto 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 the control record is',
ausnahme_tab-lfmon, ausnahme_tab-lfgja.
endif.
endloop.
**Ende der Ausgabe
skip 3.
write 'E N D'.
if t139a-abbru ne space
or t139a-ausna eq '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.