home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / dbms_mag / 9107 / techtip1 < prev    next >
Text File  |  1991-05-21  |  2KB  |  59 lines

  1. LISTING 1
  2.  
  3. * In an Order Entry Program, a user wants to be able to add
  4. * a new Sales Order Number that increments by 10. If for any
  5. * reason the complete order cannot be shipped together, then
  6. * the number is to be incremented by 1. This allows for nine
  7. * partial shipments from the original Sales order.
  8. *
  9. * The program example computes the next Partial Shipment order
  10. * number given the present order number.
  11. *
  12. * Author: Ronald K. Pickett 
  13. *
  14. ************** Example Sales Order Database *********************
  15. *  Record   SO_NUM        Record   SO_NUM        Record   SO_NUM
  16. *    1        10            6        32           11        37
  17. *    2        20            7        33           12        38
  18. *    3        21            8        34           13        39
  19. *    4        30            9        35           14        40
  20. *    5        31           10        36           EOF
  21. *
  22.  
  23. USE SALES
  24. INDEX ON SO_NUM TO SALES
  25. STORE SO_NUM TO mSO_NUM
  26. CLEAR
  27. @ 12,12 SAY 'ENTER SALES ORDER NUMBER' GET mSO_NUM
  28. READ                    && Program will find the next available from
  29. SEEK mSO_NUM            && the record pointer.
  30. IF MOD(mSO_NUM,10)=0    && Adjusts record pointer to allow for partial
  31.   SKIP                  && sales orders (order #'s ending in 1 to 9)
  32.   IF !EOF()                   && to be checked.
  33.     STORE SO_NUM TO mSO_NUM   && Store the 'skipped' Sales order # for
  34.   ENDIF                       && further testing.
  35. ENDIF
  36. DO WHILE MOD(mSO_NUM,10)>0 .AND. !EOF() .AND. MOD(mSO_NUM,10)<9
  37.   SKIP                        && Locate the last Partial Order #.
  38.   STORE SO_NUM TO mSO_NUM        
  39. ENDDO                            
  40. DO CASE                          
  41.   CASE MOD(mSO_NUM,10)=9
  42.     @ 24,10 SAY 'This is the Last Partial Shipment for this Sales Order '
  43.     WAIT ''
  44.   CASE EOF()
  45.     SKIP -1
  46.     STORE SO_NUM TO mSO_NUM
  47.     mSO_NUM=mSO_NUM+1
  48.   CASE MOD(mSO_NUM,10)=0      && Checks for two successive records 
  49.     SKIP -1                   && (Sales orders) ending in zero.
  50.     STORE SO_NUM TO mSO_NUM
  51.     mSO_NUM=mSO_NUM+1
  52.   OTHERWISE
  53.     mSO_NUM=mSO_NUM+1
  54. ENDCASE
  55. @ 13,12 SAY 'NEW SALES # = '+STR(INT(mSO_NUM))
  56. WAIT
  57. CLOSE DATA
  58. QUIT
  59.