0% found this document useful (0 votes)
8 views3 pages

ZRFCORR97

The document outlines a correction program (ZRFCORR97) for managing data inconsistencies in SAP S4HANA related to tables A003, KONH, and KONP. It includes functionality for checking data consistency, displaying relevant data, and executing corrections if specified. The program is designed to identify and rectify entries in A003 that do not have corresponding entries in KONH and KONP, ensuring data integrity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

ZRFCORR97

The document outlines a correction program (ZRFCORR97) for managing data inconsistencies in SAP S4HANA related to tables A003, KONH, and KONP. It includes functionality for checking data consistency, displaying relevant data, and executing corrections if specified. The program is designed to identify and rectify entries in A003 that do not have corresponding entries in KONH and KONP, ensuring data integrity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

REPORT ZRFCORR97.

*
* Note 337706 correction program to get rid of A003 w/o KONH and KONP
* For S4HANA = S4CORE
* SAP original in U92 on 20211221
* Pexecute = 'X' means productive run.
*
TABLES: a003,
konh,
konp.

SELECT-OPTIONS: pland FOR a003-aland,


pmwskz FOR a003-mwskz.

PARAMETERS: pdisplay RADIOBUTTON GROUP was, " Zeigt Korrektur an


pexecute RADIOBUTTON GROUP was. " Führt Korrektur durch

DATA: BEGIN OF it_a003 OCCURS 500.


INCLUDE STRUCTURE a003.
DATA: END OF it_a003,
BEGIN OF it_anzeige OCCURS 500, " Anzuzeigende Daten
kappl LIKE a003-kappl,
kschl LIKE a003-kschl,
aland LIKE a003-aland,
mwskz LIKE a003-mwskz,
knumh LIKE a003-knumh,
kotabnr LIKE konh-kotabnr,
datab LIKE konh-datab,
datbi LIKE konh-datbi,
kopos LIKE konp-kopos,
kbetr LIKE konp-kbetr,
mwsk1 LIKE konp-mwsk1,
loevm_ko LIKE konp-loevm_ko,
statush TYPE i, " Status bzgl. Tabelle KONH
statusp TYPE i, " Status bzgl. Tabelle KONP
END OF it_anzeige.

SELECT * FROM a003 INTO TABLE it_a003 WHERE aland IN pland


AND mwskz IN pmwskz.
PERFORM check_consistency.
PERFORM anzeigen_daten.
IF pexecute = 'X'.
PERFORM correct_konp.
ENDIF.

TOP-OF-PAGE.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/ '|', (25) 'A003', '|',
(25) 'KONH', '|',
(24) 'KONP', '|'.
ULINE /(84).

*---------------------------------------------------------------------*
* FORM check_consistency *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM check_consistency.
LOOP AT it_a003.
CLEAR it_anzeige.
it_anzeige-kappl = it_a003-kappl.
it_anzeige-kschl = it_a003-kschl.
it_anzeige-aland = it_a003-aland.
it_anzeige-mwskz = it_a003-mwskz.
it_anzeige-knumh = it_a003-knumh.

* Check the table KONH


SELECT SINGLE * FROM konh WHERE knumh = it_anzeige-knumh.
IF sy-subrc = 0.
it_anzeige-kotabnr = konh-kotabnr.
it_anzeige-datab = konh-datab.
it_anzeige-datbi = konh-datbi.
IF it_anzeige-kotabnr <> '003' AND it_anzeige-kotabnr <> '053'.
it_anzeige-statush = 1. " Warnung
ENDIF.
ELSE.
it_anzeige-statush = 2. " Error
ENDIF.

* Check the table KONP


SELECT * FROM konp WHERE knumh = it_anzeige-knumh.
it_anzeige-kopos = konp-kopos.
it_anzeige-kbetr = konp-kbetr.
it_anzeige-mwsk1 = konp-mwsk1.
it_anzeige-loevm_ko = konp-loevm_ko.
IF it_anzeige-mwsk1 <> it_anzeige-mwskz.
it_anzeige-statusp = 2. " Error
ELSEIF it_anzeige-loevm_ko = 'X'.
it_anzeige-statusp = 1. " Warnung
ELSEIF it_anzeige-kopos <> 1.
it_anzeige-statusp = 1. " Warnung
ENDIF.
APPEND it_anzeige.
ENDSELECT. " * from konp
IF sy-subrc <> 0.
it_anzeige-statusp = 2. " Error
APPEND it_anzeige.
ENDIF.
ENDLOOP. " at it_a003
ENDFORM. " check_consistency

*---------------------------------------------------------------------*
* FORM anzeigen_daten *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM anzeigen_daten.
SORT it_anzeige BY statusp DESCENDING aland kschl mwskz knumh kopos.
LOOP AT it_anzeige.
* Show data of table A003
FORMAT COLOR COL_KEY INTENSIFIED ON.
WRITE:/ '|', it_anzeige-kappl,
it_anzeige-kschl,
it_anzeige-aland,
it_anzeige-mwskz,
it_anzeige-knumh, '|'.

* Show data of table KONH


CASE it_anzeige-statush.
WHEN 0. FORMAT COLOR COL_NORMAL INTENSIFIED ON.
WHEN 1. FORMAT COLOR COL_BACKGROUND INTENSIFIED ON.
WHEN 2. FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
ENDCASE. " it_anzeige-statusH
WRITE it_anzeige-kotabnr.
IF NOT it_anzeige-datab IS INITIAL
OR NOT it_anzeige-datbi IS INITIAL.
WRITE: it_anzeige-datab,
it_anzeige-datbi, '|'.
ELSE.
WRITE: (21) space, '|'.
ENDIF.

* Show data of table KONP


CASE it_anzeige-statusp.
WHEN 0. FORMAT COLOR COL_NORMAL INTENSIFIED ON.
WHEN 1. FORMAT COLOR COL_BACKGROUND INTENSIFIED ON.
WHEN 2. FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
ENDCASE. " it_anzeige-statusP
WRITE: it_anzeige-kopos,
it_anzeige-kbetr CURRENCY '3',
it_anzeige-mwsk1,
it_anzeige-loevm_ko, '|'.
ENDLOOP. " at it_anzeige
ULINE /(84).
ENDFORM. " anzeigen_daten

*---------------------------------------------------------------------*
* FORM correct_KONP *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM correct_konp.
LOOP AT it_anzeige WHERE statusp = 2 AND statush = 2.
SELECT SINGLE * FROM a003 WHERE
kappl = it_anzeige-kappl AND
kschl = it_anzeige-kschl AND
aland = it_anzeige-aland AND
mwskz = it_anzeige-mwskz AND
knumh = it_anzeige-knumh.
IF sy-subrc = 0.
DELETE a003.
ENDIF.
ENDLOOP.

COMMIT WORK.

ENDFORM. " correct_KONP

You might also like