case r_ucomm.
when 'UPDT'.
select max( zcounter_cpd ) from zcpdhtry into gv_ln.
delete it_data where errlog <> ' '.
loop at it_data.
gv_ln = gv_ln + 1.
translate it_data-zedatu_cpd using '/ '.
condense it_data-zedatu_cpd no-gaps.
modify it_data.
select single * from zcpdcurr where vbeln = it_data-vbeln
and posnr = it_data-posnr.
if sy-subrc eq 0.
move-corresponding it_data to w_zcpdhtry.
w_zcpdhtry-erdat = sy-datum.
w_zcpdhtry-erzet = sy-uzeit .
w_zcpdhtry-author = sy-uname .
w_zcpdhtry-zcounter_cpd = gv_ln.
insert zcpdhtry from w_zcpdhtry .
move-corresponding it_data to w_zcpdcurr.
delete zcpdcurr from w_zcpdcurr .
clear : w_zcpdhtry , w_zcpdcurr .
else.
at new vbeln.
clear count.
endat.
at new posnr.
clear count.
endat.
count = count + 1.
w_zcpdcurr-etenr = count.
w_zcpdcurr-erdat = sy-datum.
w_zcpdcurr-erzet = sy-uzeit .
w_zcpdcurr-author = sy-uname .
insert zcpdcurr from w_zcpdcurr .
clear w_zcpdcurr.
endif.
endloop.
commit work.
endcase.
notes here is logic need to add to histry table in exist current table and delete current table data later