Dear Anil,
Error message FTR0014 occurs if there are inconsitencies in Table
VTBFHAPO. Therefore you can implement the attached report
ZCFM_CORR_HAPO into your system, it can fix the error.
REPORT zcfm_corr_hapo .
TABLES:
vtbfha.
DATA:
l_wa_vtbfha TYPE vtbfha,
l_rfhazu TYPE tb_rfhazu.
* selection screen
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(15) comment2.
SELECTION-SCREEN POSITION POS_LOW.
PARAMETERS p_cc LIKE vtbfha-bukrs.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(15) comment3.
SELECTION-SCREEN POSITION POS_LOW.
PARAMETERS p_rfha LIKE vtbfha-rfha.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(16) comment1.
SELECTION-SCREEN POSITION POS_LOW.
PARAMETERS p_test AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
sy-title = 'Correction RFHAZUL RFHAZUNR in VTBFHA'.
MOVE 'Test run' TO comment1.
MOVE 'Company Code' TO comment2.
MOVE 'Deal' TO comment3.
START-OF-SELECTION.
SELECT SINGLE *
FROM vtbfha
INTO l_wa_vtbfha
WHERE bukrs = p_cc
AND rfha = p_rfha
AND saktiv = '0'.
IF sy-dbcnt = 0.
WRITE: 'Deal does not exist!'.
EXIT.
ENDIF.
* check if rfhazul is correct
SELECT SINGLE rfhazu FROM vtbfhazu
INTO l_rfhazu
WHERE bukrs = p_cc
AND rfha = p_rfha
AND saktiv = '0'.
IF sy-subrc <> 0.
MESSAGE e101(t0) WITH 'Correction not possible!'.
EXIT.
ENDIF.
IF l_rfhazu <> l_wa_vtbfha-rfhazul.
l_wa_vtbfha-rfhazul = l_rfhazu.
ELSE.
MESSAGE s101(t0) WITH 'No correction necessary!'.
EXIT.
ENDIF.
CLEAR l_rfhazu.
* for sec.check rfhazunr, too
SELECT MAX( rfhazu ) FROM vtbfhazu
INTO l_rfhazu
WHERE bukrs = p_cc
AND rfha = p_rfha.
IF NOT l_rfhazu IS INITIAL.
IF l_rfhazu <> l_wa_vtbfha-rfhazunr.
l_wa_vtbfha-rfhazunr = l_rfhazu.
ENDIF.
ENDIF.
* db Update
IF p_test IS INITIAL.
UPDATE vtbfha FROM l_wa_vtbfha.
IF sy-subrc = 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
MESSAGE a101(t0) WITH 'Error during update (vtbfha)'.
ENDIF.
ENDIF.
* log
IF p_test IS INITIAL.
WRITE: 'Real run successful'.
ELSE.
WRITE: 'Test run successful'.
ENDIF.
Best regards,
Jasmine