Problem to save record from array (ArrayToDBF)

Problem to save record from array (ArrayToDBF)

Postby Silvio.Falconi » Thu Apr 29, 2021 8:55 am

As an example I use the same technique created by Nages in yunus.prg
even if I didn't understand why it doesn't work and gives me an error

I use tdatabase

oReservation:=TDatabase():Open( , cDir+"Reserva", "DBFCDX", .T. )
oReservation:setorder(1)
oReservation:gotop()

oPartres:=TDatabase():Open( , cDir+"ResItems", "DBFCDX", .T. )
oPartres:setorder(1)
oPartres:gotop()



at the beginning I declare all the fields of my detail archive

static cItemFlds := "INVNUM,SERIAL,ITEMIMG,ITEMCODE,ITEMNAME,QUANTITY,PRICE,TOTALQ,CHECK_IN,CHECK_OUT,DAYS,DISCOUNT,TOTAL,ITEMSTRUCT,ITEMMULTI,ITEMPRNA4,ITEMPRNPOS,recno()"

at first I create the array for the xbrowse

aItems := ( oPartres:cAlias )->( FW_DbfToArray( cItemFlds, { || AllTrim( FIELD->INVNUM ) = alltrim(nInvoice) }) )


If I delete a record on xbrowse I use ADel( oBrowse:aArrayData, oBrowse:nArrayAt, .t. )

when I must save I made

//before the deleted of xbrowse

if ! Empty( oBrowse:aDeleted )
oPartRes:ArrayToDBF( oBrowse:aDeleted, cItemFlds,nil , .t., .t. )
Endif
except recalling the deleted and filtering by num invoice

SET DELETED ON
oPartRes:setorder(0)
oPartRes:Exec( < ||
SET FILTER TO AllTrim( FIELD->INVNUM ) = alltrim(nInvoice)
return nil
> )
oPartRes:gotop()
oPartRes:ArrayToDBF( aItems, cItemFlds,nil , .t., .t. )
oPartRes:SetFilter( "" )

but it doesn't save anything or it gives me an error on the number of fields
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 119 guests