CREATE CURSOR tt (xh c(3),kskmdm c(3), xm c(10))
INSERT INTO tt VALUES ("","304","张1")
INSERT INTO tt VALUES ("","303","张2")
INSERT INTO tt VALUES ("","303","张3")
INSERT INTO tt VALUES ("","304","张4")
INSERT INTO tt VALUES ("","303","张5")
INSERT INTO tt VALUES ("","303","张6")
INSERT INTO tt VALUES ("","305","张7")
INSERT INTO tt VALUES ("","306","张8")
INDEX on kskmdm TAG px
nXh = 1
cDm = ""
SCAN
IF kskmdm == cDm
nXh = nXh + 1
ELSE
nXh = 1
ENDIF
cDm = Kskmdm
REPLACE xh WITH PADL(nXh, 3, "0")
ENDSCAN
BROWSE