update f00 set p203=peg_chr2sear(p203,0)
where nr01=1 && p203<>peg_chr2sear(p203,0);
/*peg_end*/        

INSERT INTO i99001
(nr01, p01, p03, pgef, p101, p102, 
remfdate, remftime, remfuser, remdate, remtime, remuser)
 
SELECT peg_new_nr01('i99001', 1) as nr01, 
       i13.p01 as p01, 
       i13.p03 as p03, 
       i13.pgef as pgef, 
       '{odbcdtos(my_dt1, .t.)}' as p101, 
       '{odbcdtos(my_dt2, .t.)}' as p102, 
       
       curdate() as remfdate, 
       curtime() as remftime,
       '@mass@'  as remfuser, 
       curdate() as remdate, 
       curtime() as remtime,
       '@mass@'  as remuser
FROM i13
LEFT JOIN i99001 ON i99001.p01=i13.p01
                 && i99001.p03=i13.p03
                 && i99001.p101 = '{odbcdtos(my_dt1, .t.)}'
                 && i99001.p102 = '{odbcdtos(my_dt2, .t.)}'
WHERE i13.p03={my_oldfpa}
   && i99001.nr01 is null;
/*peg_end*/        

update i13 
set p03={my_newfpa}, 
    p02=replace(p02, '{pegtrim(str(my_oldfpa))}', '{pegtrim(str(my_newfpa))}'), 
    remdate=curdate(), 
    remtime=curtime(), 
    remuser='@mass@'
where p03={my_oldfpa};
/*peg_end*/        
       