What should be a simple thing? 
Author Message
 What should be a simple thing?

 I am new to the CW20 environment. I have written a simple check writing
program that the user filles out a check on the screen and then presses the
'Register' button and fills in disbur{*filter*}ts for that check, and on some
lines just writes a note. And some checks have no disbur{*filter*}ts.

The ultimate goal is to filter by user input via global variables: 1)A batch
number. 2)Start Date. 3)End Date. The filtered info will be written to two
flat ascii batch files (one for positive amounts ie 260 batch and another
for negative amounts ie 270 batch, zero amounts don't count) that will feed
the NCR main frame and bypass the keypunch department.

Sorry for the long intro just want everyone to understand what I'm trying to do.

The global info is being gathered by a window with the entry controls on it
and the 'OK' button calls a scorce template to loop through the filtered
records twice, once to gather record counts & totals, and the second to
create the batch files.

When I run this it locks up the computer sometimes, but never gives me the
info I'm after. Each Batch File should have a header record, several detail
records one for each qualifying register entry, and a trailer record.

After I have just put everyone to sleep, this is the code I used, I have
tried it with and without the GET statment:

  OPEN(CHECK, ReadWrite+DenyNone)
  IF ERRORCODE() THEN STOP (ERROR()).
  OPEN(REGISTER, ReadWrite+DenyNone)
  IF ERRORCODE() THEN STOP (ERROR()).

  Count260 = 0                           !Clearing Locals to catch
  Count270 = 0                           !data for header and trailer
  BatchAmt260 = 0                        !record of batch file. This is
  BatchAmt270 = 0                        !to be done on the first trip
  AcctTotal260 = 0                       !through.
  AcctTotal270 = 0                       !

  CLEAR(CHE:RECORD)                          !Get file ready, retriving
  SET(Che:Date_Key, Che:Date_Key)            !Parent record.
  Che:Date = Glo:StartDate                   !
  Get(Check,Che:Date_Key)                    !
    Loop UNTIL Che:Date > Glo:EndDate        !Start primary loop and check
       NEXT(CHECK)                           !date of parent record.
         IF ERRORCODE() = BadRecErr
            Break
         END

           CLEAR(REG:RECORD)                          !Get Child file ready
           SET(REG:CHECK_NO_KEY, REG:CHECK_NO_KEY)
           REG:CHECK_NO = CHE:CHECK_NO
           Get(Register, Reg:Check_No_Key)
             Loop                                     !Loop Child file
               NEXT(REGISTER)
                 IF ERRORCODE() = BadRecErr
                    BREAK
                 END
                   IF REG:AMOUNT = 0                  !If this line of the
                      CYCLE                           !check register is a
                      ELSIf REG:AMOUNT > 0            !note move on.
                            COUNT260 += 1
                            BatchAmt260 += REG:AMOUNT       !If not geather
                            AcctTotal260 += REG:ACCOUNT_NO  !info for proper
ELSIF REG:AMOUNT < 0
                                COUNT270 += 1               !batch file.
                                BatchAmt270 += REG:AMOUNT
                                AcctTotal270 += REG:ACCOUNT_NO
                   END

             . !End Nested Loop
    . !End Primary Loop

  CLOSE(BF1)                                !If BF1 & BF2 are open close
  CLOSE(BF2)                                !so they can be recreated.

  CREATE(BF1)
  IF ERRORCODE() THEN STOP (ERROR()).
  CREATE(BF2)
  IF ERRORCODE() THEN STOP (ERROR()).

  OPEN(BF1, ReadWrite+DenyNone)             !Open files with full access.
  IF ERRORCODE() THEN STOP (ERROR()).
  OPEN(BF2, ReadWrite+DenyNone)
  IF ERRORCODE() THEN STOP (ERROR()).

  DO HEADERRECORD260                        !Write the header record for
  IF ERRORCODE() THEN STOP (ERROR()).       !each file.
  DO HEADERRECORD270
  IF ERRORCODE() THEN STOP (ERROR()).

  CLEAR(CHE:RECORD)
  SET(Che:Date_Key, Che:Date_Key)           !Same file handling as above
  Che:Date = Glo:StartDate                  !for processing.
  Get(Check, Che:Date_Key)
    Loop UNTIL Che:Date > Glo:EndDate
       NEXT(CHECK)
         IF ERRORCODE() = BadRecErr
            BREAK
         END

           CLEAR(REG:RECORD)
           SET(REG:CHECK_NO_KEY, REG:CHECK_NO_Key)
           REG:CHECK_NO = CHE:CHECK_NO
           Get(Register, Reg:Check_No_Key)
             Loop
                NEXT(REGISTER)
                  IF ERRORCODE() = BadRecErr
                     BREAK
                  END
                    IF REG:AMOUNT = 0
                       CYCLE
                         ELSIF REG:AMOUNT > 0
                            BF1:DetID = 'b'
                            BF1:DetTranCode = '333'
                            BF1:DetChkNo = REG:CHECK_NO
                            BF1:DetDate = CHE:Date
                            BF1:DetInvoiceNo = '000000'
                            BF1:DetVendorNo = '099933335'
                            BF1:DetFactor = '0'
                            BF1:DetTerms = '600'
                            BF1:DetDistribution = '0000000000'
                            BF1:DetAmount = REG:AMOUNT
                            BF1:DetExpenseID = '1'
                            BF1:DetExpenceNo = REG:ACCOUNT_NO
                            BF1:DetPayee = CHE:LINE1

                              ADD(BF1)
                              IF ERRORCODE() THEN STOP (ERROR()).

                                 ELSIF REG:AMOUNT < 0
                                   BF2:DetID = 'b'
                                   BF2:DetTranCode = '333'
                                   BF2:DetChkNo = REG:CHECK_NO
                                   BF2:DetDate = CHE:Date
                                   BF2:DetInvoiceNo = '000000'
                                   BF2:DetVendorNo = '099933335'
                                   BF2:DetFactor = '0'
                                   BF2:DetTerms = '600'
                                   BF2:DetDistribution = '0000000000'
                                   BF2:DetAmount = REG:AMOUNT
                                   BF2:DetExpenseID = '1'
                                   BF2:DetExpenceNo = REG:ACCOUNT_NO
                                   BF2:DetPayee = CHE:LINE1

                              ADD(BF2)
                              IF ERRORCODE() THEN STOP (ERROR()).
                    END
             . !End Nested Loop
    . !End Primary Loop

  DO EndRecord260                          !After all file processing
  IF ERRORCODE() THEN STOP (ERROR()).      !write trailer record for
  DO EndRecord270                          !each batch file.
  IF ERRORCODE() THEN STOP (ERROR()).

  CLOSE(BF1)                               !Close all files
  IF ERRORCODE() THEN STOP (ERROR()).

  CLOSE(BF2)
  IF ERRORCODE() THEN STOP (ERROR()).

  CLOSE(Check)
  IF ERRORCODE() THEN STOP (ERROR()).

  CLOSE(Register)
  IF ERRORCODE() THEN STOP (ERROR()).

  RETURN                                  !End process

HEADERRECORD260         ROUTINE

    BF1:ID = 'a'
    BF1:HdrFill1 = '000'
    BF1:HdrBatchNo = Glo:BatchNumber
    BF1:HdrFill2 = '000000'
    BF1:BatchTotal = Count260
    BF1:HdrFill3 = '00000000000000000000000'
    BF1:BatchType = '260'
    BF1:HdrFill4 = '                              '
    BF1:HdrEndMk = '63'

        ADD(BF1)
        IF ERRORCODE() THEN STOP (ERROR()).
  EXIT

HEADERRECORD270         ROUTINE

    BF2:ID = 'a'
    BF2:HdrFill1 = '000'
    BF2:HdrBatchNo = Glo:BatchNumber
    BF2:HdrFill2 = '000000'
    BF2:BatchTotal = Count270
    BF2:HdrFill3 = '00000000000000000000000'
    BF2:BatchType = '270'
    BF2:HdrFill4 = '                              '
    BF2:HdrEndMk = '63'

        ADD(BF2)
        IF ERRORCODE() THEN STOP (ERROR()).
  EXIT

EndRecord260            ROUTINE
    BF1:TraID = 'z'
    BF1:TraFill = '0'
    BF1:TraPipe = '|'
    BF1:TraBatTotal = BatchAmt260
    BF1:TraHashTotal = AcctTotal260

        ADD(BF1)
        IF ERRORCODE() THEN STOP (ERROR()).
  EXIT

EndRecord270            ROUTINE
    BF2:TraID = 'z'
    BF2:TraFill = '0'
    BF2:TraPipe = '|'
    BF2:TraBatTotal = BatchAmt270
    BF2:TraHashTotal = AcctTotal270

        ADD(BF2)
        IF ERRORCODE() THEN STOP (ERROR()).
  EXIT

Carter B. Bennett
Little House Computer Services
Fort Worth, Texas

Proud user of Clarion/TopSpeed 2.1, 3.07, CW1.5, CW2.0
Message sent with Eudora Pro 2.2(32)

You may be able to kill two birds with one stone, but in the end; all you
really have is two dead birds, and your short one stone.



Fri, 16 Apr 1999 03:00:00 GMT  
 What should be a simple thing?

 I am new to the CW20 environment. I have written a simple check writing
program that the user filles out a check on the screen and then presses the
'Register' button and fills in disbur{*filter*}ts for that check, and on some
lines just writes a note. And some checks have no disbur{*filter*}ts.

The ultimate goal is to filter by user input via global variables: 1)A batch
number. 2)Start Date. 3)End Date. The filtered info will be written to two
flat ascii batch files (one for positive amounts ie 260 batch and another
for negative amounts ie 270 batch, zero amounts don't count) that will feed
the NCR main frame and bypass the keypunch department.

Sorry for the long intro just want everyone to understand what I'm trying to do.

The global info is being gathered by a window with the entry controls on it
and the 'OK' button calls a scorce template to loop through the filtered
records twice, once to gather record counts & totals, and the second to
create the batch files.

When I run this it locks up the computer sometimes, but never gives me the
info I'm after. Each Batch File should have a header record, several detail
records one for each qualifying register entry, and a trailer record.

After I have just put everyone to sleep, this is the code I used, I have
tried it with and without the GET statment:

  OPEN(CHECK, ReadWrite+DenyNone)
  IF ERRORCODE() THEN STOP (ERROR()).
  OPEN(REGISTER, ReadWrite+DenyNone)
  IF ERRORCODE() THEN STOP (ERROR()).

  Count260 = 0                           !Clearing Locals to catch
  Count270 = 0                           !data for header and trailer
  BatchAmt260 = 0                        !record of batch file. This is
  BatchAmt270 = 0                        !to be done on the first trip
  AcctTotal260 = 0                       !through.
  AcctTotal270 = 0                       !

  CLEAR(CHE:RECORD)                          !Get file ready, retriving
  SET(Che:Date_Key, Che:Date_Key)            !Parent record.
  Che:Date = Glo:StartDate                   !
  Get(Check,Che:Date_Key)                    !
    Loop UNTIL Che:Date > Glo:EndDate        !Start primary loop and check
       NEXT(CHECK)                           !date of parent record.
         IF ERRORCODE() = BadRecErr
            Break
         END

           CLEAR(REG:RECORD)                          !Get Child file ready
           SET(REG:CHECK_NO_KEY, REG:CHECK_NO_KEY)
           REG:CHECK_NO = CHE:CHECK_NO
           Get(Register, Reg:Check_No_Key)
             Loop                                     !Loop Child file
               NEXT(REGISTER)
                 IF ERRORCODE() = BadRecErr
                    BREAK
                 END
                   IF REG:AMOUNT = 0                  !If this line of the
                      CYCLE                           !check register is a
                      ELSIf REG:AMOUNT > 0            !note move on.
                            COUNT260 += 1
                            BatchAmt260 += REG:AMOUNT       !If not geather
                            AcctTotal260 += REG:ACCOUNT_NO  !info for proper
ELSIF REG:AMOUNT < 0
                                COUNT270 += 1               !batch file.
                                BatchAmt270 += REG:AMOUNT
                                AcctTotal270 += REG:ACCOUNT_NO
                   END

             . !End Nested Loop
    . !End Primary Loop

  CLOSE(BF1)                                !If BF1 & BF2 are open close
  CLOSE(BF2)                                !so they can be recreated.

  CREATE(BF1)
  IF ERRORCODE() THEN STOP (ERROR()).
  CREATE(BF2)
  IF ERRORCODE() THEN STOP (ERROR()).

  OPEN(BF1, ReadWrite+DenyNone)             !Open files with full access.
  IF ERRORCODE() THEN STOP (ERROR()).
  OPEN(BF2, ReadWrite+DenyNone)
  IF ERRORCODE() THEN STOP (ERROR()).

  DO HEADERRECORD260                        !Write the header record for
  IF ERRORCODE() THEN STOP (ERROR()).       !each file.
  DO HEADERRECORD270
  IF ERRORCODE() THEN STOP (ERROR()).

  CLEAR(CHE:RECORD)
  SET(Che:Date_Key, Che:Date_Key)           !Same file handling as above
  Che:Date = Glo:StartDate                  !for processing.
  Get(Check, Che:Date_Key)
    Loop UNTIL Che:Date > Glo:EndDate
       NEXT(CHECK)
         IF ERRORCODE() = BadRecErr
            BREAK
         END

           CLEAR(REG:RECORD)
           SET(REG:CHECK_NO_KEY, REG:CHECK_NO_Key)
           REG:CHECK_NO = CHE:CHECK_NO
           Get(Register, Reg:Check_No_Key)
             Loop
                NEXT(REGISTER)
                  IF ERRORCODE() = BadRecErr
                     BREAK
                  END
                    IF REG:AMOUNT = 0
                       CYCLE
                         ELSIF REG:AMOUNT > 0
                            BF1:DetID = 'b'
                            BF1:DetTranCode = '333'
                            BF1:DetChkNo = REG:CHECK_NO
                            BF1:DetDate = CHE:Date
                            BF1:DetInvoiceNo = '000000'
                            BF1:DetVendorNo = '099933335'
                            BF1:DetFactor = '0'
                            BF1:DetTerms = '600'
                            BF1:DetDistribution = '0000000000'
                            BF1:DetAmount = REG:AMOUNT
                            BF1:DetExpenseID = '1'
                            BF1:DetExpenceNo = REG:ACCOUNT_NO
                            BF1:DetPayee = CHE:LINE1

                              ADD(BF1)
                              IF ERRORCODE() THEN STOP (ERROR()).

                                 ELSIF REG:AMOUNT < 0
                                   BF2:DetID = 'b'
                                   BF2:DetTranCode = '333'
                                   BF2:DetChkNo = REG:CHECK_NO
                                   BF2:DetDate = CHE:Date
                                   BF2:DetInvoiceNo = '000000'
                                   BF2:DetVendorNo = '099933335'
                                   BF2:DetFactor = '0'
                                   BF2:DetTerms = '600'
                                   BF2:DetDistribution = '0000000000'
                                   BF2:DetAmount = REG:AMOUNT
                                   BF2:DetExpenseID = '1'
                                   BF2:DetExpenceNo = REG:ACCOUNT_NO
                                   BF2:DetPayee = CHE:LINE1

                              ADD(BF2)
                              IF ERRORCODE() THEN STOP (ERROR()).
                    END
             . !End Nested Loop
    . !End Primary Loop

  DO EndRecord260                          !After all file processing
  IF ERRORCODE() THEN STOP (ERROR()).      !write trailer record for
  DO EndRecord270                          !each batch file.
  IF ERRORCODE() THEN STOP (ERROR()).

  CLOSE(BF1)                               !Close all files
  IF ERRORCODE() THEN STOP (ERROR()).

  CLOSE(BF2)
  IF ERRORCODE() THEN STOP (ERROR()).

  CLOSE(Check)
  IF ERRORCODE() THEN STOP (ERROR()).

  CLOSE(Register)
  IF ERRORCODE() THEN STOP (ERROR()).

  RETURN                                  !End process

HEADERRECORD260         ROUTINE

    BF1:ID = 'a'
    BF1:HdrFill1 = '000'
    BF1:HdrBatchNo = Glo:BatchNumber
    BF1:HdrFill2 = '000000'
    BF1:BatchTotal = Count260
    BF1:HdrFill3 = '00000000000000000000000'
    BF1:BatchType = '260'
    BF1:HdrFill4 = '                              '
    BF1:HdrEndMk = '63'

        ADD(BF1)
        IF ERRORCODE() THEN STOP (ERROR()).
  EXIT

HEADERRECORD270         ROUTINE

    BF2:ID = 'a'
    BF2:HdrFill1 = '000'
    BF2:HdrBatchNo = Glo:BatchNumber
    BF2:HdrFill2 = '000000'
    BF2:BatchTotal = Count270
    BF2:HdrFill3 = '00000000000000000000000'
    BF2:BatchType = '270'
    BF2:HdrFill4 = '                              '
    BF2:HdrEndMk = '63'

        ADD(BF2)
        IF ERRORCODE() THEN STOP (ERROR()).
  EXIT

EndRecord260            ROUTINE
    BF1:TraID = 'z'
    BF1:TraFill = '0'
    BF1:TraPipe = '|'
    BF1:TraBatTotal = BatchAmt260
    BF1:TraHashTotal = AcctTotal260

        ADD(BF1)
        IF ERRORCODE() THEN STOP (ERROR()).
  EXIT

EndRecord270            ROUTINE
    BF2:TraID = 'z'
    BF2:TraFill = '0'
    BF2:TraPipe = '|'
    BF2:TraBatTotal = BatchAmt270
    BF2:TraHashTotal = AcctTotal270

        ADD(BF2)
        IF ERRORCODE() THEN STOP (ERROR()).
  EXIT

Carter B. Bennett
Little House Computer Services
Fort Worth, Texas

Proud user of Clarion/TopSpeed 2.1, 3.07, CW1.5, CW2.0
Message sent with Eudora Pro 2.2(32)

You may be able to kill two birds with one stone, but in the end; all you
really have is two dead birds, and your short one stone.



Fri, 16 Apr 1999 03:00:00 GMT  
 What should be a simple thing?



Quote:
> The global info is being gathered by a window with the entry controls on
it
> and the 'OK' button calls a scorce template to loop through the filtered
> records twice, once to gather record counts & totals, and the second to
> create the batch files.

> When I run this it locks up the computer sometimes, but never gives me
the
> info I'm after. Each Batch File should have a header record, several
detail
> records one for each qualifying register entry, and a trailer record.

Well, first, I think I'd use a process template, and put the code for what
I want to do in the "processing for each record" embed.  The process
template has logic built in for a thermometer, and to allow other windows
stuff to run while the process is running.

Quote:
>   CLEAR(CHE:RECORD)                          !Get file ready, retriving
>   SET(Che:Date_Key, Che:Date_Key)            !Parent record.
>   Che:Date = Glo:StartDate                   !
>   Get(Check,Che:Date_Key)                    !
>     Loop UNTIL Che:Date > Glo:EndDate        !Start primary loop and
check
>        NEXT(CHECK)                           !date of parent record.

I think you've got a mistake here.  What you want is:
   CLEAR( CHE:RECORD)
   Che:Date = Glo:StartDate
   SET( Che:Date_Key, Che:Date_Key )
   LOOP
       NEXT( CHECK )
       IF ERRORCODE() THEN BREAK .
       IF Che:Date > GLO:EndDate THEN BREAK .
       other nonsense
       END

I didn't look through the rest of your code for possible hangups, but you
get the idea.  When working with data, use SET and NEXT, as GET doesn't
seem to Get (or at least I never have any luck with it).

--
Tom Ruby
--------------------------------------------------------------------

http://www.netins.net/showcase/tomruby/
I don't know anything.  I just have to make this stuff work.



Sat, 17 Apr 1999 03:00:00 GMT  
 What should be a simple thing?

Carter,

You are on the right track.

There is no need to issue a GET() statement as the NEXT() statement will do
that for you.  It will get the NEXT() record as ordered by the SET()
statement, so your code as written will get the first record and then
NEXT() another record.  The first record in effect is skipped.

Remove the GET() statement and see if this does not get you better results.
 Also, you might want to step through your code with the de{*filter*} and see
how your code is being executed.  This is a wonderful tool that is actually
fun to use!  You can see the contents of the fields anywhere in your
program's execution.  This may open up a few more ideas for you.

HTH,

--
Russell B. Eggen
Topspeed Corporation
Consulting Division

[Using MS Newserver]



Sat, 17 Apr 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Things I am wondering...

2. Am I seeing things?...

3. Could someone help with a very simple thing?

4. Simple things

5. gcc inline asm, can't do even simple things :-(

6. Doing the simplest thing with Tkinter Canvas

7. Seemingly simple problem with adding things to a canvas

8. programming -- keep things simple

9. Question: Simple things in Allegro

10. Another simple thing from me

11. Simple thing about printing

12. Simple threading thing

 

 
Powered by phpBB® Forum Software