CLOSE TABLES >OPEN DATABASE '\\ECNC\M2M\data\DATA01\m2mdata.dbc' shared >USE '\\ECNC\M2M\data\DATA01\prod\jomast.dbf' in 1 shared >USE '\\ECNC\M2M\data\DATA01\sales\somast.dbf' in 2 shared >USE '\\ECNC\M2M\data\DATA01\sales\soitem.dbf' in 3 shared >USE '\\ECNC\M2M\data\DATA01\prod\joitem.dbf' in 4 shared >use '\\ECNC\PUBLIC\data\ecnc\data\rel_orders.dbf' in 5 exclusive >** had to get the group code from soitem instead of joitem. >**If it's entered incorrectly >** you can reenter on soitem but joitem doesn't get refreshed. >set exact on >set deleted on >set safety off >zap in 5 >local llFound > > >SELECT 1 >SCAN for fstatus='RELEASED' > llfound=(.F.) > IF FITYPE != '2' > SCATTER MEMVAR > m.drawingnum=val(substr(m.fpartno,5)) > SELECT 2 > SCAN for fsono==m.fsono and len(fsono)>2 > m.fcustpono=fcustpono > SELECT 3 > llFound=(.F.) > SCAN for fsono==m.fsono and fpartno=m.fpartno > m.gennotes=fdesc > **remover CR and repl dbl spc with single > m.gennotes=ALLTRIM(STRTRAN(m.gennotes,CHR(13),'')) > m.gennotes=STRTRAN(m.gennotes,' ',' ') > m.fgroup=fgroup > m.finumber=finumber > INSERT into rel_orders from memvar > llFound=(.T.) > ENDSCAN > endscan > ** if there is no sales order. > if llFound=(.F.) > select 4 > go top > scan for alltrim(fjobno)==alltrim(m.fjobno) > m.gennotes=fdesc > m.fgroup=fgroup > m.fcustpono='' > insert into rel_orders from memvar > endscan > endif > ENDIF >ENDSCAN