Hi friends.
How to create a dbf table from adt (ADS) table.
There's something automatic.?
Thank you.
Saludos.
Enviado desde mi Redmi Note 8 Pro mediante Tapatalk
USE NOMTABLA0 NEW ALIAS CTRL
...
USE NOMTABLA10 NEW ALIAS CXDT
...
Adt2Dbf()
...
PROC Adt2Dbf()
//RddSetDefault( "DBFCDX" )
SELECT CTRL
Mig("control")
SELECT USUA
Mig("usuarios")
SELECT FERI
Mig("feriados")
SELECT PLAZ
Mig("plazos")
SELECT ZONA
Mig("zonas")
SELECT CIUD
Mig("ciudades")
SELECT GEST
Mig("gestores")
SELECT COBR
Mig("cobradores")
SELECT RUTA
Mig("rutas")
SELECT CLIE
Mig("clientes")
SELECT PROG
Mig("programacion")
SELECT PBAK
Mig("programacion_bak")
SELECT PRES
Mig("prestamos")
SELECT DIFE
Mig("diferidos")
SELECT MOVI
Mig("movimientos")
SELECT FLUJ
Mig("flujos")
SELECT MCXR
Mig("mcobrosxruta")
SELECT DCXR
Mig("dcobrosxruta")
SELECT CAJA
Mig("caja")
SELECT CXDI
Mig("cobroxdia")
SELECT CXDC
Mig("cobroxdiac")
SELECT CXDT
Mig("cobroxdiat")
RddSetDefault( "ads" )
RETURN
PROC Mig(cTabla)
LOCAL cOldAlias := Alias()
LOCAL xT,xT1
LOCAL aTab
LOCAL n,o,i
aTab := DBStruct()
FOR x:=1 TO Len( aTab )
IF aTab[ x, 2 ]="D"
aTab[ x, 3 ]=8
ENDIF
NEXT
DbCreate( "d:\dbc\" + (cTabla), aTab, "DBFCDX", .T. )
USE ( "d:\dbc\" + (cTabla) ) ALIAS TEMP VIA "dbfcdx"
// SELECT (cAlias)
//
// n:=1
// DO WHILE .T.
// IF Empty( OrdName(n) )
// EXIT
// ENDIF
// TRY
// TEMP->( OrdCondSet((cAlias)->( OrdFor(n)),,.t.,,,, nil, nil, nil, nil,, nil, .F., .F., .F., .F.))
// TEMP->( dbGoTop() )
// TEMP->( ordCreate(,(cAlias)->( OrdName(n) ), (cAlias)->( OrdKey(n) ), &("{||"+(cAlias)->( OrdKey(n) )+"}") ))
// CATCH o
// SELECT (cAlias)
// ?cTabla,(cAlias)->( OrdName(n) ), (cAlias)->( ordKey(n) )
// END
// ++n
// ENDDO
SELECT ( cOldAlias )
WaitOn("Procesando: " + cTabla )
i:=0
GO TOP
DO WHILE !Eof()
TEMP->( DBAppend() )
FOR x:=1 TO FCount()
xT := FieldGet( x )
TEMP->( FieldPut( x, xT ) )
NEXT
SKIP
IF Mod( ++i, 100 )=0
SysRefresh()
ENDIF
ENDDO
WaitOff()
TEMP->( DBCloseArea() )
SELECT (cOldAlias)
RETURN
USE CUSTADT NEW VIA "ADSADT" // "ADT" in xHarbour
COPY TO CUSTDBF VIA "DBFCDX"
#include "fivewin.ch"
#include "ads.ch"
REQUEST DBFCDX
REQUEST ADSKEYCOUNT, ADSGETRELKEYPOS, ADSSETRELKEYPOS, ADSKEYNO
static cRddADT
function main()
local aStruct
RddRegister( "ADS", 1 )
AdsSetServerType( ADS_LOCAL_SERVER )
cRddAdt := If( AScan( RddList(), "ADSADT" ) > 0, "ADSADT", "ADT" )
// DBF TO ADT
aStruct := FW_DBFSTRUCT( "CUSTOMER.DBF" ) // no need to open the dbf
AEval( aStruct, { |a| If( a[ 2 ] == "N", a[ 3 ] += 1, ) } )
DBCREATE( "CUSTADT.ADT", aStruct, cRddAdt, .t., "DST" )
APPEND FROM CUSTOMER VIA "DBFCDX"
GO TOP
XBROWSER
// ADT TO DBF
GO TOP
COPY TO CUSTDBF VIA "DBFCDX"
CLOSE DATA
USE CUSTDBF VIA "DBFCDX"
XBROWSER
return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 41 guests