|
|||
|
OrderScope or .CDX problem [vo25.b3]
#1 Items.dbf (store items) field1: code [c 12] field2: totsales [n 10] .............. #2 Sales.dbf (items sales) field1: code [c 12] field2: qty [n 10] field3: date [date] .............. I need to update items:totsales reading sales:qty for items:code = sales:code === This is my code METHOD TotSales() CLASS MyWindow LOCAL oItems AS ITEMS LOCAL oSales AS SALES LOCAL sCode AS STRING LOCAL nTot AS INT oItems := ITEMS{} oSales := SALES{} // oSales:SetOrder("CODE") // same result oItems:GoTop() DO WHILE ! oItems:EOF sCode := oItems:CODE nTot := 0 oSales:OrderScope(TOPSCOPE, sCode) oSales:OrderScope(BOTTOMSCOPE, sCode) oSales:GoTop() DO WHILE ! oSales:EoF nTot := nTot + oSales:QTY oSales:Skip() ENDDO oItems:TOTSALES := nTot oItems: . . . := . . . . . . . . . . . . . oItems:Commit() oItems:Skip() ENDDO oItems:Close() oSales:ClosE() |
|
|
||||
|
||||
|
|
|
|||
|
Enzo.
1. You don't say what your problem is. 2. You don't show what the index orders are. 3. The code, as it stands, looks fine, assuming 2 OK. 4. You could simply your code using selective relations. 5. This is a one line execution in SQL (Just threw that in <g>). In short, it all looks good. Geoff "enzo benvenuti" <e.benvenuti@tedvalet.com> wrote in message news:4ecnh.17027$AA.2575@tornado.fastwebnet.it: > OrderScope or .CDX problem [vo25.b3] > > #1 Items.dbf (store items) > field1: code [c 12] > field2: totsales [n 10] > .............. > #2 Sales.dbf (items sales) > field1: code [c 12] > field2: qty [n 10] > field3: date [date] > .............. > > I need to update items:totsales reading sales:qty for items:code = > sales:code > > === This is my code > > METHOD TotSales() CLASS MyWindow > LOCAL oItems AS ITEMS > LOCAL oSales AS SALES > LOCAL sCode AS STRING > LOCAL nTot AS INT > > oItems := ITEMS{} > oSales := SALES{} > // oSales:SetOrder("CODE") // same result > > oItems:GoTop() > > DO WHILE ! oItems:EOF > > sCode := oItems:CODE > nTot := 0 > oSales:OrderScope(TOPSCOPE, sCode) > oSales:OrderScope(BOTTOMSCOPE, sCode) > oSales:GoTop() > > DO WHILE ! oSales:EoF > nTot := nTot + oSales:QTY > oSales:Skip() > ENDDO > > oItems:TOTSALES := nTot > oItems: . . . := . . . > . . . . . . . . . . > oItems:Commit() > oItems:Skip() > ENDDO > > oItems:Close() > oSales:ClosE() |
|
|||
|
I have code very similar to your example except for
DO WHILE in scope AND ! eof don't remember 25 time... maybe some problem with eof with scope? ... HTH Massimo Bighelli ARCA Sistemi S.r.l. "enzo benvenuti" <e.benvenuti@tedvalet.com> ha scritto nel messaggio news:4ecnh.17027$AA.2575@tornado.fastwebnet.it... > OrderScope or .CDX problem [vo25.b3] > > #1 Items.dbf (store items) > field1: code [c 12] > field2: totsales [n 10] > .............. > #2 Sales.dbf (items sales) > field1: code [c 12] > field2: qty [n 10] > field3: date [date] > .............. > > I need to update items:totsales reading sales:qty for items:code = > sales:code > > === This is my code > > METHOD TotSales() CLASS MyWindow > LOCAL oItems AS ITEMS > LOCAL oSales AS SALES > LOCAL sCode AS STRING > LOCAL nTot AS INT > > oItems := ITEMS{} > oSales := SALES{} > // oSales:SetOrder("CODE") // same result > > oItems:GoTop() > > DO WHILE ! oItems:EOF > > sCode := oItems:CODE > nTot := 0 > oSales:OrderScope(TOPSCOPE, sCode) > oSales:OrderScope(BOTTOMSCOPE, sCode) > oSales:GoTop() > > DO WHILE ! oSales:EoF > nTot := nTot + oSales:QTY > oSales:Skip() > ENDDO > > oItems:TOTSALES := nTot > oItems: . . . := . . . > . . . . . . . . . . > oItems:Commit() > oItems:Skip() > ENDDO > > oItems:Close() > oSales:ClosE() > |
|
|||
|
Enzo,
As Geoff mentioned you don't say what your problem is. Only thing I can think of is that maybe the records don't yet exist in Items.Dbf or that your nTot is overflowing as INT, so here my suggestion. One thing to verify however is that CODE is a reserved word in short for CODEBLOCK, so the compiler might complain about #Code, in that case do a nSalesPos := oDb:FieldPos('CODE') and nItemsPos := oDb:FieldPos('CODE') to speed up the process. I would also suggest not to do a commit() after each save which will speed up your process, but only after the last update. I assume this file is not shared in a network or is locked exclusively. METHOD TotSales() CLASS MyWindow LOCAL oItems AS ITEMS LOCAL oSales AS SALES LOCAL sCode AS STRING LOCAL nTot AS INT // Is this big enough? Would suggest DWORD rather... oItems := ITEMS{} oSales := SALES{} oSales:SetOrder("CODE") // same result oSales:GoTop() nTot := 0 nSalesPos := oSales:FieldPos('CODE') nItemsPos := oItems:FieldPos('CODE') sCode := oSales:FieldGet(nSalesPos) DO WHILE TRUE // I know, but don't want to duplicate code for last total IF sCode != oSales:FieldGet(nSalesPos) IF ! oItems:Seek(sCode, FALSE) oItems:Append() oItems:FieldPut(nItemsPos, sCode) ENDIF oItems:FieldPut(#TotSales, nTot) IF oSales:EOF EXIT ELSE sCode := oSales:FieldGet(nSalesPos) nTot := 0 ENDIF ENDIF nTot += oSales:QTY oSales:Skip() ENDDO oItems:Commit() oItems:Close() oSales:ClosE() HTH, Johan Nel Pretoria, South Africa. |
|
|||
|
Geoff,
1) my problem for wrong items records: items:TOTSALES is the sum of sales:QTY for items:code = sales:code. some record results items:TOTSALES > 0 and none items:code = sales:code: Example: items:RecNo = 1547, items:CODE = "800000047892", items:TOTSALES = 45, doesn't exist records sales:CODE = "800000047892" 2) indexing items.dbf on CODE or "natural order" doesn,t change the result, sales.dbf, naturally is indexed on CODE 4) selective relation was my first approach, whit the same result. I think that my prblem to be out of the method, but I cannot understand where. Thank you Enzo "G Schaller" <geoff@soft_ware.com.au> ha scritto nel messaggio news:459d6bfe$1@dnews.tpgi.com.au... > Enzo. > > 1. You don't say what your problem is. > 2. You don't show what the index orders are. > 3. The code, as it stands, looks fine, assuming 2 OK. > 4. You could simply your code using selective relations. > 5. This is a one line execution in SQL (Just threw that in <g>). > > In short, it all looks good. > > Geoff > > > > "enzo benvenuti" <e.benvenuti@tedvalet.com> wrote in message > news:4ecnh.17027$AA.2575@tornado.fastwebnet.it: > >> OrderScope or .CDX problem [vo25.b3] >> >> #1 Items.dbf (store items) >> field1: code [c 12] >> field2: totsales [n 10] >> .............. >> #2 Sales.dbf (items sales) >> field1: code [c 12] >> field2: qty [n 10] >> field3: date [date] >> .............. >> >> I need to update items:totsales reading sales:qty for items:code = >> sales:code >> >> === This is my code >> >> METHOD TotSales() CLASS MyWindow >> LOCAL oItems AS ITEMS >> LOCAL oSales AS SALES >> LOCAL sCode AS STRING >> LOCAL nTot AS INT >> >> oItems := ITEMS{} >> oSales := SALES{} >> // oSales:SetOrder("CODE") // same result >> >> oItems:GoTop() >> >> DO WHILE ! oItems:EOF >> >> sCode := oItems:CODE >> nTot := 0 >> oSales:OrderScope(TOPSCOPE, sCode) >> oSales:OrderScope(BOTTOMSCOPE, sCode) >> oSales:GoTop() >> >> DO WHILE ! oSales:EoF >> nTot := nTot + oSales:QTY >> oSales:Skip() >> ENDDO >> >> oItems:TOTSALES := nTot >> oItems: . . . := . . . >> . . . . . . . . . . >> oItems:Commit() >> oItems:Skip() >> ENDDO >> >> oItems:Close() >> oSales:ClosE() > |
|
|||
|
Enzo,
Could you have a rogue SetDeleted(...) somewhere allowing deleted records to be counted? HTH Dave Francis "enzo benvenuti" <e.benvenuti@tedvalet.com> wrote in message news:A6wnh.397$hU.292@tornado.fastwebnet.it... > Geoff, > > 1) my problem for wrong items records: items:TOTSALES is the sum of > sales:QTY for items:code = sales:code. > some record results items:TOTSALES > 0 and none items:code = sales:code: > Example: items:RecNo = 1547, items:CODE = "800000047892", items:TOTSALES = > 45, doesn't exist records sales:CODE = "800000047892" > 2) indexing items.dbf on CODE or "natural order" doesn,t change the > result, sales.dbf, naturally is indexed on CODE > 4) selective relation was my first approach, whit the same result. > > I think that my prblem to be out of the method, but I cannot understand > where. > > Thank you > > Enzo > > "G Schaller" <geoff@soft_ware.com.au> ha scritto nel messaggio > news:459d6bfe$1@dnews.tpgi.com.au... >> Enzo. >> >> 1. You don't say what your problem is. >> 2. You don't show what the index orders are. >> 3. The code, as it stands, looks fine, assuming 2 OK. >> 4. You could simply your code using selective relations. >> 5. This is a one line execution in SQL (Just threw that in <g>). >> >> In short, it all looks good. >> >> Geoff >> >> >> >> "enzo benvenuti" <e.benvenuti@tedvalet.com> wrote in message >> news:4ecnh.17027$AA.2575@tornado.fastwebnet.it: >> >>> OrderScope or .CDX problem [vo25.b3] >>> >>> #1 Items.dbf (store items) >>> field1: code [c 12] >>> field2: totsales [n 10] >>> .............. >>> #2 Sales.dbf (items sales) >>> field1: code [c 12] >>> field2: qty [n 10] >>> field3: date [date] >>> .............. >>> >>> I need to update items:totsales reading sales:qty for items:code = >>> sales:code >>> >>> === This is my code >>> >>> METHOD TotSales() CLASS MyWindow >>> LOCAL oItems AS ITEMS >>> LOCAL oSales AS SALES >>> LOCAL sCode AS STRING >>> LOCAL nTot AS INT >>> >>> oItems := ITEMS{} >>> oSales := SALES{} >>> // oSales:SetOrder("CODE") // same result >>> >>> oItems:GoTop() >>> >>> DO WHILE ! oItems:EOF >>> >>> sCode := oItems:CODE >>> nTot := 0 >>> oSales:OrderScope(TOPSCOPE, sCode) >>> oSales:OrderScope(BOTTOMSCOPE, sCode) >>> oSales:GoTop() >>> >>> DO WHILE ! oSales:EoF >>> nTot := nTot + oSales:QTY >>> oSales:Skip() >>> ENDDO >>> >>> oItems:TOTSALES := nTot >>> oItems: . . . := . . . >>> . . . . . . . . . . >>> oItems:Commit() >>> oItems:Skip() >>> ENDDO >>> >>> oItems:Close() >>> oSales:ClosE() >> > > |
|
|||
|
Enzo.
You still haven't shown us the complete code, including the index expression. There must be something very fundamental and simple that is wrong. Can you make a small 10 line sample that shows the problem, zip it up with the dbf/cdx and post it here to the forum please? If your news provider doesn't allow that (ours does) then email me the sample. Geoff "enzo benvenuti" <e.benvenuti@tedvalet.com> wrote in message news:A6wnh.397$hU.292@tornado.fastwebnet.it: > Geoff, > > 1) my problem for wrong items records: items:TOTSALES is the sum of > sales:QTY for items:code = sales:code. > some record results items:TOTSALES > 0 and none items:code = sales:code: > Example: items:RecNo = 1547, items:CODE = "800000047892", items:TOTSALES = > 45, doesn't exist records sales:CODE = "800000047892" > 2) indexing items.dbf on CODE or "natural order" doesn,t change the result, > sales.dbf, naturally is indexed on CODE > 4) selective relation was my first approach, whit the same result. > > I think that my prblem to be out of the method, but I cannot understand > where. > > Thank you > > Enzo > > "G Schaller" <geoff@soft_ware.com.au> ha scritto nel messaggio > news:459d6bfe$1@dnews.tpgi.com.au... > > > Enzo. > > > > 1. You don't say what your problem is. > > 2. You don't show what the index orders are. > > 3. The code, as it stands, looks fine, assuming 2 OK. > > 4. You could simply your code using selective relations. > > 5. This is a one line execution in SQL (Just threw that in <g>). > > > > In short, it all looks good. > > > > Geoff > > > > > > > > "enzo benvenuti" <e.benvenuti@tedvalet.com> wrote in message > > news:4ecnh.17027$AA.2575@tornado.fastwebnet.it: > > > > >> OrderScope or .CDX problem [vo25.b3] > >> > >> #1 Items.dbf (store items) > >> field1: code [c 12] > >> field2: totsales [n 10] > >> .............. > >> #2 Sales.dbf (items sales) > >> field1: code [c 12] > >> field2: qty [n 10] > >> field3: date [date] > >> .............. > >> > >> I need to update items:totsales reading sales:qty for items:code = > >> sales:code > >> > >> === This is my code > >> > >> METHOD TotSales() CLASS MyWindow > >> LOCAL oItems AS ITEMS > >> LOCAL oSales AS SALES > >> LOCAL sCode AS STRING > >> LOCAL nTot AS INT > >> > >> oItems := ITEMS{} > >> oSales := SALES{} > >> // oSales:SetOrder("CODE") // same result > >> > >> oItems:GoTop() > >> > >> DO WHILE ! oItems:EOF > >> > >> sCode := oItems:CODE > >> nTot := 0 > >> oSales:OrderScope(TOPSCOPE, sCode) > >> oSales:OrderScope(BOTTOMSCOPE, sCode) > >> oSales:GoTop() > >> > >> DO WHILE ! oSales:EoF > >> nTot := nTot + oSales:QTY > >> oSales:Skip() > >> ENDDO > >> > >> oItems:TOTSALES := nTot > >> oItems: . . . := . . . > >> . . . . . . . . . . > >> oItems:Commit() > >> oItems:Skip() > >> ENDDO > >> > >> oItems:Close() > >> oSales:ClosE() > > > |
|
|||
|
Geoff
I cannot send e-mail to your address ....@soft_ware.com.au, neither .....@software.com.au Enzo "G Schaller" <geoff@soft_ware.com.au> ha scritto nel messaggio news:459eca71$1@dnews.tpgi.com.au... > Enzo. > > You still haven't shown us the complete code, including the index > expression. There must be something very fundamental and simple that is > wrong. Can you make a small 10 line sample that shows the problem, zip it > up with the dbf/cdx and post it here to the forum please? If your news > provider doesn't allow that (ours does) then email me the sample. > > Geoff > > > > "enzo benvenuti" <e.benvenuti@tedvalet.com> wrote in message > news:A6wnh.397$hU.292@tornado.fastwebnet.it: > >> Geoff, >> >> 1) my problem for wrong items records: items:TOTSALES is the sum of >> sales:QTY for items:code = sales:code. >> some record results items:TOTSALES > 0 and none items:code = sales:code: >> Example: items:RecNo = 1547, items:CODE = "800000047892", items:TOTSALES >> = >> 45, doesn't exist records sales:CODE = "800000047892" >> 2) indexing items.dbf on CODE or "natural order" doesn,t change the >> result, >> sales.dbf, naturally is indexed on CODE >> 4) selective relation was my first approach, whit the same result. >> >> I think that my prblem to be out of the method, but I cannot understand >> where. >> >> Thank you >> >> Enzo >> >> "G Schaller" <geoff@soft_ware.com.au> ha scritto nel messaggio >> news:459d6bfe$1@dnews.tpgi.com.au... >> >> > Enzo. >> > >> > 1. You don't say what your problem is. >> > 2. You don't show what the index orders are. >> > 3. The code, as it stands, looks fine, assuming 2 OK. >> > 4. You could simply your code using selective relations. >> > 5. This is a one line execution in SQL (Just threw that in <g>). >> > >> > In short, it all looks good. >> > >> > Geoff >> > >> > >> > >> > "enzo benvenuti" <e.benvenuti@tedvalet.com> wrote in message >> > news:4ecnh.17027$AA.2575@tornado.fastwebnet.it: >> > >> >> >> OrderScope or .CDX problem [vo25.b3] >> >> >> >> #1 Items.dbf (store items) >> >> field1: code [c 12] >> >> field2: totsales [n 10] >> >> .............. >> >> #2 Sales.dbf (items sales) >> >> field1: code [c 12] >> >> field2: qty [n 10] >> >> field3: date [date] >> >> .............. >> >> >> >> I need to update items:totsales reading sales:qty for items:code = >> >> sales:code >> >> >> >> === This is my code >> >> >> >> METHOD TotSales() CLASS MyWindow >> >> LOCAL oItems AS ITEMS >> >> LOCAL oSales AS SALES >> >> LOCAL sCode AS STRING >> >> LOCAL nTot AS INT >> >> >> >> oItems := ITEMS{} >> >> oSales := SALES{} >> >> // oSales:SetOrder("CODE") // same result >> >> >> >> oItems:GoTop() >> >> >> >> DO WHILE ! oItems:EOF >> >> >> >> sCode := oItems:CODE >> >> nTot := 0 >> >> oSales:OrderScope(TOPSCOPE, sCode) >> >> oSales:OrderScope(BOTTOMSCOPE, sCode) >> >> oSales:GoTop() >> >> >> >> DO WHILE ! oSales:EoF >> >> nTot := nTot + oSales:QTY >> >> oSales:Skip() >> >> ENDDO >> >> >> >> oItems:TOTSALES := nTot >> >> oItems: . . . := . . . >> >> . . . . . . . . . . >> >> oItems:Commit() >> >> oItems:Skip() >> >> ENDDO >> >> >> >> oItems:Close() >> >> oSales:ClosE() >> >> > > |
|
|||
|
That is because it is neither <g>. Use this without the underscores:
Geoff_@software_objectives.com.au "enzo benvenuti" <e.benvenuti@tedvalet.com> wrote in message news:34xoh.4874$hU.4657@tornado.fastwebnet.it: > Geoff > I cannot send e-mail to your address ....@soft_ware.com.au, neither > ....@software.com.au > > Enzo |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: SAS Problem | nospam@HOWLES.COM (Howard Schreier | Newsgroup comp.soft-sys.sas | 0 | 05-03-2006 03:23 AM |
| Re: SAS ETL- is Password Protection for files a problem? | GE Consumer Finance | Newsgroup comp.soft-sys.sas | 1 | 01-18-2006 09:17 AM |
| Re: need help in solving this problem | toby dunn | Newsgroup comp.soft-sys.sas | 1 | 07-06-2005 02:26 PM |
| Re: Help on a grouping problem | nospam@HOWLES.COM (Howard Schreier | Newsgroup comp.soft-sys.sas | 0 | 02-16-2005 02:52 AM |
| Re: Help on a grouping problem | Sigurd Hermansen | Newsgroup comp.soft-sys.sas | 0 | 02-15-2005 11:49 PM |