Hi friends,
Though this is an old issue, just thought of sharing the correct answer.
As understood from other responses, this error comes due to existence of deletion indicator in ESKL-LOEKZ field.
At times, when we undelete any PO line item, this deletion indicator in ESKL-LOEKZ field remains as such and creates inconsistency. Hence to remove the deletion indicator, following z program can be implemented and used.
REPORT Z_RESET_ESKL_LOEKZ.
tables : ekpo, eskl,ekkn.
parameter : p_ebeln type ekpo-ebeln,
p_ebelp type ekpo-ebelp,
simu type c as checkbox default 'X'.
data : t_eskl type table of eskl,
u_eskl type table of eskl,
l_count type sy-dbcnt,
INCON_EXISTS.
if p_ebeln is initial or
p_ebelp is initial.
write :/ 'Please enter a PO/Item '.
EXIT.
endif.
select single * from ekpo where ebeln = p_ebeln and ebelp = p_ebelp and loekz = ' '.
if sy-subrc NE 0.
write :/ 'No PO/Item with problem Exists !! '.
EXIT.
endif.
select count(*) into l_count from ekkn where ebeln = ekpo-ebeln and
ebelp = ekpo-ebelp.
if l_count GT 1.
write :/ 'Requires Manual analysis , Multiple account assignment !!'.
exit.
endif .
select * from eskl into corresponding fields of table t_eskl
where hpackno = ekpo-packno.
loop at t_eskl into eskl.
if ekpo-loekz NE eskl-loekz.
INCON_EXISTS = 'X'.
eskl-loekz = ekpo-loekz.
append eskl to u_eskl.
endif.
endloop.
if simu NE 'X'.
update eskl from table u_eskl.
SKIP.
write :/ 'No of records updated in ESKL ', sy-dbcnt color 3.
SKIP.
write:/ 'Database updated successfully !!!' color 5.
else.
Write :/ 'REPORT was run in SIMULATION mode ONLY !!!' color 5.
SKIP.
IF INCON_EXISTS = 'X'.
write :/ 'Inconsistency detected in ESKL table ' color 3.
ENDIF.
endif.
Hope this helps.
Regards
Sathish K B