CLOSE DATABASES ALL 

IF ! OPENFILE(.T.)
	DO ERR_MSG WITH 'FOR THIS OPTION NO OTHER USER MUST BE WORKING IN THIS PROGRAM' + CHR(13) + ';TRY AGAIN WHEN ALL OTHER USERS HAVE QUIT FROM THE PROGRAM'
	QUIT 
ENDIF 

PRIVATE LCJOB_NO,LCSERIES
STORE '' TO LCJOB_NO,LCSERIES

WAIT WINDOW "!!! REPLACING JOBCARD NO. IN JOB_MAST...." NOWA
SELECT JOB_MAST
IF LEN(JOB_MAST.JOBCARD_NO) < 7
	ALTER TABLE JOB_MAST ALTER COLUMN JOBCARD_NO C(7)
	
	SELECT JOB_MAST
	SET ORDER TO JOBCARD_NO
	GO TOP
	SCAN
		LCSERIES = SUBS(JOB_MAST.JOBCARD_NO,1,2)
		REPLACE JOBCARD_NO WITH LCSERIES + padl(ltrim(str(val(subs(JOBCARD_NO,len(LCSERIES) + 1)))),len(JOBCARD_NO) - len(LCSERIES),'0')
		SELECT JOB_MAST
	ENDS
ENDIF

WAIT WINDOW "!!! REPLACING JOBCARD NO. IN JOB_BODY...." NOWA
SELECT JOB_BODY
IF LEN(JOB_BODY.JOBCARD_NO) < 7
	ALTER TABLE JOB_BODY ALTER COLUMN JOBCARD_NO C(7)
	
	SELECT JOB_BODY
	SET ORDER TO JOBCARD_NO
	GO TOP
	SCAN
		LCSERIES = SUBS(JOB_BODY.JOBCARD_NO,1,2)
		REPLACE JOBCARD_NO WITH LCSERIES + padl(ltrim(str(val(subs(JOBCARD_NO,len(LCSERIES) + 1)))),len(JOBCARD_NO) - len(LCSERIES),'0')
		SELECT JOB_BODY
	ENDS
ENDIF

WAIT WINDOW "!!! REPLACING JOBCARD NO. IN WARRANTY...." NOWA
SELECT WARRANTY
IF LEN(WARRANTY.JOBCARD_NO) < 7
	ALTER TABLE WARRANTY ALTER COLUMN JOBCARD_NO C(7)
	
	SELECT WARRANTY
	SET ORDER TO JOBCARD_NO
	GO TOP
	SCAN
		LCSERIES = SUBS(WARRANTY.JOBCARD_NO,1,2)
		REPLACE JOBCARD_NO WITH LCSERIES + padl(ltrim(str(val(subs(JOBCARD_NO,len(LCSERIES) + 1)))),len(JOBCARD_NO) - len(LCSERIES),'0')
		SELECT WARRANTY
	ENDS
ENDIF
WAIT WINDOW "!!! REPLACING JOBCARD NO. IN JRECEIPT...." NOWA
SELECT JRECEIPT
IF LEN(JRECEIPT.JOBCARD_NO) < 7
	ALTER TABLE JRECEIPT ALTER COLUMN JOBCARD_NO C(7)
	
	SELECT JRECEIPT
	SET ORDER TO JOBCARD_NO
	GO TOP
	SCAN
		LCSERIES = SUBS(JRECEIPT.JOBCARD_NO,1,2)
		REPLACE JOBCARD_NO WITH LCSERIES + padl(ltrim(str(val(subs(JOBCARD_NO,len(LCSERIES) + 1)))),len(JOBCARD_NO) - len(LCSERIES),'0')
		SELECT JRECEIPT
	ENDS
ENDIF
WAIT WINDOW "!!! REPLACING JOBCARD NO. IN ISSUE...." NOWA
SELECT ISSUE
IF LEN(ISSUE.JOBCARD_NO) < 7
	ALTER TABLE ISSUE ALTER COLUMN JOBCARD_NO C(7)
	
	SELECT ISSUE
	SET ORDER TO JOBCARD_NO
	GO TOP
	SCAN
		LCSERIES = SUBS(ISSUE.JOBCARD_NO,1,2)
		REPLACE JOBCARD_NO WITH LCSERIES + padl(ltrim(str(val(subs(JOBCARD_NO,len(LCSERIES) + 1)))),len(JOBCARD_NO) - len(LCSERIES),'0')
		SELECT ISSUE
	ENDS
ENDIF

WAIT WINDOW "!!! REPLACING JOBCARD NO. IN ESTIMATE...." NOWA
SELECT ESTIMATE
IF LEN(ESTIMATE.JOBCARD_NO) < 7
	ALTER TABLE ESTIMATE ALTER COLUMN JOBCARD_NO C(7)
	
	SELECT ESTIMATE
	SET ORDER TO JOBCARD_NO
	GO TOP
	SCAN
		LCSERIES = SUBS(ESTIMATE.JOBCARD_NO,1,2)
		REPLACE JOBCARD_NO WITH LCSERIES + padl(ltrim(str(val(subs(JOBCARD_NO,len(LCSERIES) + 1)))),len(JOBCARD_NO) - len(LCSERIES),'0')
		SELECT ESTIMATE
	ENDS
ENDIF

WAIT WINDOW "!!! REPLACING JOBCARD NO. IN CLM_MAST...." NOWA
SELECT CLM_MAST
IF LEN(CLM_MAST.JOBCARD_NO) < 7
	ALTER TABLE CLM_MAST ALTER COLUMN JOBCARD_NO C(7)
	
	SELECT CLM_MAST
	SET ORDER TO JOBCARD_NO
	GO TOP
	SCAN
		LCSERIES = SUBS(CLM_MAST.JOBCARD_NO,1,2)
		REPLACE JOBCARD_NO WITH LCSERIES + padl(ltrim(str(val(subs(JOBCARD_NO,len(LCSERIES) + 1)))),len(JOBCARD_NO) - len(LCSERIES),'0')
		SELECT CLM_MAST
	ENDS
ENDIF

DO OPENFILE