Help with some processing please
Nancy Palmquist
nlp at vss3.com
Mon May 8 12:05:37 PDT 2006
Howard Wolowitz wrote:
> I'm investigating a problem and I'm not sure is the following code is
> correct. Please review it and tell me what you think.
>
> Background:
> We have a file that defines "sales teams". An "M" in a certain field
> indicates that this is a master team record. There is one master record
> for
> each salesrep on that team.
>
> i.e.: Sales team "test" has two master records - one for Tom and one for
> Joe.
>
> What is supposed to happen is that each time a shipment is created for team
> "test" two records should be created on the sales team file, which
> associates
> each member of the sales team with that load#. (I have objected to the
> fact
> that a single file is used for this and that may explain the problem.)
>
> Sometimes, not all the records are created and I am wondering that,
> since we
> are adding records to the file that also contains the master records, if
> the
> "getnext grd" at the end could be failing because the index has been
> changed.
>
> Here is the code:
>
> If:
> Then: ky = "M" & 654 '654 has the team code
> If:
> (index N is built on the field 30 and field 40)
> Then: lookup grd = gocomgrid k=ky i=N -nx
> grdloop If: not grd
> Then: return
> If: grd(40) ne 654 'grd(40) has the team code
> Then: return
> If: grd(39) ne "M" 'grd(39) indicates a master team record
> Then: return
> If:
> (checking if a record already exists for this team/load#/repID)
> Then: ky = 654 & 26 & grd(1) '26 is the load# and grd(1) is the
> repID
> If:
> Then: lookup gr2 = gocomgrid k=ky i=L -nx
> If: gr2
> Then: getnext grd ; goto grdloop
> If:
> Then: lookup gr2 = gocomgrid r=free -e '<=====
> If: 'copy pro not a master
> Then: copy grd to gr2 ; gr2(26) = 26 ; gr2(39) = "" ; write gr2
> If:
> Then: getnext grd ; goto grdloop '<====
>
> The code looks good to me but after creating a new record in the file could
> the getnext no longer point to the next master record? That is the only
> way
> I can see it fail to create all the records required.
>
> Thanks,
>
> Howie
> PS My solution would be to loop through the master records for this team
> and place all the repIDs in a table then check (and create if needed) each
> one in a separate loop
>
>
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> http://mailman.celestial.com/mailman/listinfo/filepro-list
>
>
Howie,
I think you are on the right track. If you are adding records to the
gocomgrid file in the middle of a getnext loop you may very well be
affecting the pointer location that is used to move to the next record
in the index.
I might suggest that instead of getnext, start the lookups at the
beginning. Look at each record to see if you need to add a missing one,
if so add it and start at the beginning again.
You only suggested that 2 or 3 records were added, so a little
redundancy would not affect performance.
I have always made it a rule with filePro to avoid the use of getnext or
getprev when adding or deleting records. I have found very weird issues
in both cases.
Also when a getnext loop is affecting the KEY used for the index you
might find a very strange result.
I don't think other users would be adding anything in the loop you are
working in, since it relates to exactly one order and you are the only
one processing that order, (I THINK)
Nancy
--
Nancy Palmquist MOS & filePro Training Available
Virtual Software Systems Web Based Training and Consulting
PHONE: (412) 835-9417 Web site: http://www.vss3.com
More information about the Filepro-list
mailing list