Help with some processing please

Howard Wolowitz howiewz at aljex.com
Mon May 8 08:37:22 PDT 2006


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




More information about the Filepro-list mailing list