midrange.com code scratchpad
Name:
Jerry C. Adams
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
03/01/2012 01:27:25 pm
IP:
Logged
Description:
Can't See The Difference - Subroutine CHAIN not working, Subprocedure CHAIN works.
Code:
  1.      H COPYRIGHT('A&K Wholesale, Inc. 2012')
  2.      H/copy $header
  3.       //*******************************************************************************
  4.       // Written By   :‚Jerry C. Adams                           €                   **
  5.       // Date Written :‚28 February 2012          €                                  **
  6.       // Project No   :‚0135                      €                                  **
  7.       // Program Name :‚DTU020                                   €                   **
  8.       // Program Desc : Cigarette Inventory Master Maintenance                       **
  9.       //*******************************************************************************
  10.       // Revised By :‚__________     €Revised Date : ___-__-__                       **
  11.       // Project No :‚____ €                                                         **
  12.       // Reason     :                                                                **
  13.       //*******************************************************************************
  14.  
  15.       //********************
  16.       // FILE DEFINITIONS **
  17.       //********************
  18.  
  19.      FDTU020D   CF   E             WORKSTN SFile(DTU020A:rrna)
  20.      FSTRCIG    UF A E           K DISK
  21.  
  22.       //*******************
  23.       // DATA STRUCTURES **
  24.       //*******************
  25.  
  26.       // Named Indicators
  27.  
  28.      D P_Indicators    S               *   INZ(%Addr(*IN))
  29.      D  Indicators     DS                  Based(P_Indicators)
  30.      D   SF_Display                        LIKE(*IN) Overlay(Indicators:33)
  31.      D   SF_Clear                          LIKE(*IN) Overlay(Indicators:31)
  32.      D   CatError                          LIKE(*IN) Overlay(Indicators:51)
  33.      D   TypeError                         LIKE(*IN) Overlay(Indicators:52)
  34.      D   CtnError                          LIKE(*IN) Overlay(Indicators:53)
  35.      D   PckError                          LIKE(*IN) Overlay(Indicators:54)
  36.      D   SF_End                            LIKE(*IN) Overlay(Indicators:90)
  37.      D   Help                              LIKE(*IN) Overlay(Indicators:130)    F1
  38.      D   EOJ                               LIKE(*IN) Overlay(Indicators:132)    F3
  39.      D   AddRecord                         LIKE(*IN) Overlay(Indicators:135)    F6
  40.      D   Cancel                            LIKE(*IN) Overlay(Indicators:141)    F12
  41.  
  42.      D/Define MsgD
  43.      D/Copy $Msg
  44.  
  45.       //*******************
  46.       // FIELD NAMES     **
  47.       //*******************
  48.  
  49.      D #Error          S               N
  50.      D @Member         S             10a
  51.      D #Limit          S                   Like(rrna)
  52.      D pType           S                   Like(sctype)
  53.      D pCategory       S                   Like(sccategory)
  54.      D X               S                   Like(rrna)
  55.      D ErrorTest       S               N
  56.  
  57.       //*************
  58.       // ProtoTypes *
  59.       //*************
  60.  
  61.      D $BuildList      PR
  62.      D $PostList       PR
  63.  
  64.      D/copy qproto,bwchelp                                                      *In-line help
  65.  
  66.       //*****************
  67.       // ---CONTROL--- **
  68.       //*****************
  69.  
  70.      C     FileKey       KLIST
  71.      C                   KFLD                    pType
  72.      C                   KFLD                    pCategory
  73.  
  74.       /FREE
  75.  
  76.        EXSR $INIT;
  77.        EXSR $MAIN;
  78.        EXSR $EOJ;
  79.  
  80.        //****************************************************************
  81.        // SUBROUTINE - $INIT                                           **
  82.        //    PURPOSE - Program Initialization                          **
  83.        //****************************************************************
  84.  
  85.        BEGSR $INIT;
  86.  
  87.          EXSR  $MINIT;
  88.  
  89.        ENDSR;
  90.  
  91.        //****************************************************************
  92.        // SUBROUTINE - $MAIN                                           **
  93.        //    PURPOSE - Main Program Logic                              **
  94.        //****************************************************************
  95.  
  96.        BEGSR $MAIN;
  97.  
  98.          DOW not eoj;
  99.  
  100.            WRITE MSGSFLB;
  101.            $BuildList();
  102.            WRITE DTU020AFK;
  103.            EXFMT DTU020ACTL;
  104.            EXSR  $CMsg;
  105.  
  106.            IF  eoj;
  107.              LEAVE;
  108.            ENDIF;
  109.  
  110.            IF  AddRecord;
  111.              EXSR  sub002;
  112.              IF  eoj;
  113.                LEAVE;
  114.              ENDIF;
  115.              ITER;
  116.            ENDIF;
  117.  
  118.            IF  Help;
  119.              @member = 'DTU020A';
  120.              bwchelp(@member);
  121.              ITER;
  122.            ENDIF;
  123.  
  124.            EXSR  $EditA;
  125.            IF  #error;
  126.              ITER;
  127.            ENDIF;
  128.  
  129.            $PostList();
  130.  
  131.          ENDDO;
  132.  
  133.        ENDSR;
  134.  
  135.        //****************************************************************
  136.        // SUBROUTINE - SUB002                                          **
  137.        //    PURPOSE - Edit and process new categories.                **
  138.        //****************************************************************
  139.  
  140.        BEGSR sub002;
  141.  
  142.          cattype   = *Blanks;
  143.          category  = *Blanks;
  144.          carton    = *Zeros;
  145.          pack      = *Zeros;
  146.  
  147.          DOW not eoj
  148.          AND not cancel;
  149.  
  150.            WRITE MSGSFLB;
  151.            EXFMT DTU020B;
  152.            EXSR  $CMsg;
  153.  
  154.            IF  Help;
  155.              @member = 'DTU020B';
  156.              bwchelp(@member);
  157.              ITER;
  158.            ENDIF;
  159.  
  160.            IF  eoj
  161.            OR  cancel;
  162.              LEAVE;
  163.            ENDIF;
  164.  
  165.            EXSR  $EditB;
  166.            IF  #error;
  167.              ITER;
  168.            ENDIF;
  169.  
  170.            sctype      = cattype;
  171.            sccategory  = category;
  172.            scctnretl   = carton;
  173.            scpackretl  = pack;
  174.  
  175.            WRITE STRCIGR;
  176.  
  177.            cattype   = *Blanks;
  178.            category  = *Blanks;
  179.            carton    = *Zeros;
  180.            pack      = *Zeros;
  181.  
  182.          ENDDO;
  183.  
  184.        ENDSR;
  185.  
  186.        //****************************************************************
  187.        // SUBROUTINE - $EditA                                          **
  188.        //    PURPOSE - Validate the lines on Panel 'A'.                **
  189.        //****************************************************************
  190.  
  191.        BEGSR $EditA;
  192.  
  193.          #error  = *Off;
  194.  
  195.          IF  #limit  > *Zeros;
  196.            FOR x = 1 to  #limit;
  197.  
  198.              CHAIN x DTU020A;
  199.              IF  %found();
  200.                errorTest = *Off;
  201.                catError  = *Off;
  202.                TypeError = *Off;
  203.                ctnError  = *Off;
  204.                pckError  = *Off;
  205.                IF  cattype <>  *Blanks
  206.                AND cattype <>  'S';
  207.                  typeError = *On;
  208.                  #error    = *On;
  209.                  errorTest = *On;
  210.                  @MsgId  = 'DTO0017';
  211.                  EXSR  $SMsg;
  212.                ENDIF;
  213.  
  214.                IF  category  <=  *Blanks;
  215.                  caterror  = *On;
  216.                  #Error    = *On;
  217.                  errorTest = *On;
  218.                  @MsgId    = 'DTO0016';
  219.                  EXSR  $SMsg;
  220.                ENDIF;
  221.  
  222.                IF  carton  < *Zeros;
  223.                  ctnError  = *On;
  224.                  #error    = *On;
  225.                  errorTest = *On;
  226.                  @MsgId    = 'DTO0015';
  227.                  EXSR  $SMsg;
  228.                ENDIF;
  229.  
  230.                IF  pack  < *Zeros
  231.                OR  pack  > carton;
  232.                  pckError  = *On;
  233.                  #error    = *On;
  234.                  errorTest = *On;
  235.                  @MsgId    = 'DTO0015';
  236.                  EXSR  $SMsg;
  237.                ENDIF;
  238.  
  239.                IF  errorTest;
  240.                  UPDATE  DTU020A;
  241.                ENDIF;
  242.              ENDIF;
  243.  
  244.            ENDFOR;
  245.  
  246.          ENDIF;
  247.  
  248.        ENDSR;
  249.  
  250.        //****************************************************************
  251.        // SUBROUTINE - $EditB                                          **
  252.        //    PURPOSE - Validate new category panel fields.             **
  253.        //****************************************************************
  254.  
  255.        BEGSR $EditB;
  256.  
  257.          #Error  = *Off;
  258.  
  259.          pType     = cattype;
  260.          pCategory = category;
  261.          CHAIN(n)  FileKey STRCIG;
  262.          IF  %found(STRCIG);
  263.            #Error  = *On;
  264.            @MsgId  = 'DTO0018';
  265.            EXSR  $SMsg;
  266.          ENDIF;
  267.  
  268.          IF  cattype <>  *Blanks
  269.          AND cattype <>  'S';
  270.            #Error  = *On;
  271.            @MsgId  = 'DTO0017';
  272.            EXSR  $SMsg;
  273.          ENDIF;
  274.  
  275.          IF  category  <=  *Blanks;
  276.            #Error  = *On;
  277.            @MsgId  = 'DTO0016';
  278.            EXSR  $SMsg;
  279.          ENDIF;
  280.  
  281.          IF  carton  < *Zeros;
  282.            #Error  = *On;
  283.            @MsgId  = 'DTO0015';
  284.            EXSR  $SMsg;
  285.          ELSE;
  286.            IF  pack  < *Zeros
  287.            OR  pack  > carton;
  288.              #Error  =  *On;
  289.              @MsgId  = 'DTO0015';
  290.              EXSR  $SMsg;
  291.            ENDIF;
  292.          ENDIF;
  293.  
  294.        ENDSR;
  295.  
  296.        //****************************************************************
  297.        // SUBROUTINE - $EOJ                                            **
  298.        //    PURPOSE - End of Program                                  **
  299.        //****************************************************************
  300.  
  301.        BEGSR $EOJ;
  302.  
  303.          *INLR = *On;
  304.          RETURN;
  305.  
  306.        ENDSR;
  307.  
  308.       /END-FREE
  309.  
  310.      C/Define MsgC
  311.      C/Copy $Msg
  312.  
  313.        //******************************************************************
  314.        // Subprocedure - $BuildList                                       *
  315.        //      Purpose - Build the list of current cigarette categories.  *
  316.        //******************************************************************
  317.  
  318.      P $BuildList      B
  319.  
  320.      D                 PI
  321.  
  322.       /free
  323.  
  324.        SF_Clear  = *On;
  325.        WRITE DTU020ACTL;
  326.        SF_Clear  = *Off;
  327.        rrna      = *Zeros;
  328.  
  329.        SETLL *Loval  STRCIG;
  330.        READ(n) STRCIG;
  331.  
  332.        DOW not %eof(STRCIG);
  333.  
  334.          rrna      = rrna  + 1;
  335.          cattype   = sctype;
  336.          category  = sccategory;
  337.          carton    = scctnretl;
  338.          pack      = scpackretl;
  339.          cattypeH  = sctype;
  340.          categoryH = sccategory;
  341.  
  342.          WRITE DTU020A;
  343.  
  344.          READ(n) STRCIG;
  345.  
  346.        ENDDO;
  347.  
  348.        #Limit  = rrna;
  349.        IF  rrna  > *Zeros;
  350.          SF_Display  = *On;
  351.          SF_End      = *On;
  352.          rrna        = 1;
  353.        ELSE;
  354.          SF_Display  = *Off;
  355.          SF_End      = *Off;
  356.        ENDIF;
  357.  
  358.        RETURN;
  359.  
  360.       /end-free
  361.  
  362.      P                 E
  363.  
  364.        //******************************************************************
  365.        // Subprocedure - $PostList                                        *
  366.        //      Purpose - Update the master file with the new retail       *
  367.        //                prices.                                          *
  368.        //******************************************************************
  369.  
  370.      P $PostList       B
  371.  
  372.      D                 PI
  373.  
  374.       /free
  375.  
  376.        IF  #Limit  > *Zeros;
  377.  
  378.          FOR x = 1 to  #Limit;
  379.  
  380.            CHAIN x DTU020A;
  381.            IF  %found();
  382.              IF  category  <>  categoryH
  383.              OR  cattype   <>  cattypeH;
  384.                pCategory = categoryH;    //  Either the type or category were
  385.                pType     = cattypeH;     //  changed.  Delete the old one.
  386.                CHAIN FileKey STRCIG;
  387.                IF  %found(STRCIG);
  388.                  DELETE  STRCIGR;
  389.                ENDIF;
  390.                pCategory = category;
  391.                pType     = cattype;
  392.                CHAIN(n) FileKey STRCIG;
  393.                IF  not %found(STRCIG);   //  Add the changed back as a new
  394.                  sctype      = cattype;  //  only if it doesn't already exist.
  395.                  sccategory  = category;
  396.                  scctnretl   = carton;
  397.                  scpackretl  = pack;
  398.                  WRITE STRCIGR;
  399.                ENDIF;
  400.              ELSE;                       //  Simply update existing record.
  401.                pCategory = category;
  402.                pType     = cattype;
  403.                CHAIN FileKey STRCIG;
  404.                IF  %found(STRCIG);
  405.                  scctnretl   = carton;
  406.                  scpackretl  = pack;
  407.                  UPDATE  STRCIGR;
  408.                ENDIF;
  409.              ENDIF;
  410.            ENDIF;
  411.  
  412.          ENDFOR;
  413.  
  414.        ENDIF;
  415.  
  416.        RETURN;
  417.  
  418.       /end-free
  419.  
  420.      P                 E
  421.  
  422.  
  423. Display File: DTU020D
  424.  
  425.       *********************************************************************
  426.       * Name        :‚DTU020D                                            €*
  427.       * Date        :‚27 February 2012                                   €*
  428.       * Programmer  :‚Jerry C. Adams                                     €*
  429.       * Project No. :‚0135                                               €*
  430.       * Description : Cigarette Inventory Master Maintenance.             *
  431.       *               Define cigarette categories and retail prices of    *
  432.       *               each category for store inventory.                  *
  433.       *********************************************************************
  434.       * Revised By:‚                  €Revision Date:‚dd mmmmmmmmm ccyy  €*
  435.       * Project No:‚                                                     €*
  436.       * Reason    :                                                       *
  437.       *********************************************************************
  438.  
  439.                                             DSPSIZ(24 80 *DS3)
  440.                                             CF03
  441.                                             CF01
  442.  
  443.                 R DTU020A                   SFL
  444.                   CATTYPE        1   B  5  3DSPATR(CS)
  445.         51                                  DSPATR(RI)
  446.                   CATEGORY      50   B  5  7DSPATR(CS)
  447.         52                                  DSPATR(RI)
  448.                                             CHECK(LC)
  449.                   CARTON         5  2B  5 58EDTWRD('   .  ')
  450.                                             DSPATR(CS)
  451.         53                                  DSPATR(RI)
  452.                   PACK           5  2B  5 65EDTWRD('   .  ')
  453.                                             DSPATR(CS)
  454.         54                                  DSPATR(RI)
  455.                   CATTYPEH       1   H
  456.                   CATEGORYH     50   H
  457.  
  458.                 R DTU020ACTL                SFLCTL(DTU020A)
  459.                                             SFLSIZ(9999)
  460.                                             SFLPAG(17)
  461.         33                                  SFLDSP
  462.        N31                                  SFLDSPCTL
  463.         31                                  SFLCLR
  464.         90                                  SFLEND(*MORE)
  465.                                             CF06
  466.                                             OVERLAY
  467.                   RRNA           4S 0H      SFLRCDNBR
  468.                                         1  2'DTU020A'
  469.                                         1 28'Cigarette Inventory Master'
  470.                                             DSPATR(UL)
  471.                                         1 66DATE
  472.                                             EDTCDE(Y)
  473.                                         2 66TIME
  474.                                         3 58'Carton'
  475.                                         3 66'Pack'
  476.                                         4  2'Type'
  477.                                             DSPATR(UL)
  478.                                         4  7'Category                          -
  479.                                                             '
  480.                                             DSPATR(UL)
  481.                                         4 58'Retail'
  482.                                             DSPATR(UL)
  483.                                         4 65'Retail'
  484.                                             DSPATR(UL)
  485.  
  486.                 R DTU020AFK
  487.                                        23  2'F1=Help'
  488.                                             DSPATR(UL)
  489.                                             COLOR(BLU)
  490.                                        23 10'F3=End'
  491.                                             DSPATR(UL)
  492.                                             COLOR(BLU)
  493.                                        23 17'F6=Add Category'
  494.                                             DSPATR(UL)
  495.                                             COLOR(BLU)
  496.  
  497.                 R DTU020B
  498.                                             CF12
  499.                                             OVERLAY
  500.                                         1  2'DTU020B'
  501.                                         1 28'Cigarette Inventory Master'
  502.                                             DSPATR(UL)
  503.                                         1 66TIME
  504.                                         2 66DATE
  505.                                             EDTCDE(Y)
  506.                                         4  2'Mode: Add Category'
  507.                                         6  3'Category..............'
  508.                   CATEGORY      50   B  6 26DSPATR(CS)
  509.                                             CHECK(LC)
  510.                                         7  3'Carton Retail Price...'
  511.                   CARTON         5  2B  7 26EDTWRD('   .  ')
  512.                                             DSPATR(CS)
  513.                                         7 33'(2 dec.)'
  514.                                         8  3'Pack Retail Price.....'
  515.                   PACK           5  2B  8 26EDTWRD('   .  ')
  516.                                             DSPATR(CS)
  517.                                         8 33'(2 dec.)'
  518.                                         9  3'Type..................'
  519.                   CATTYPE        1   B  9 26DSPATR(CS)
  520.                                         9 28'(S=Specialty Cigarette)'
  521.                                        23  2'F1=Help'
  522.                                             DSPATR(UL)
  523.                                             COLOR(BLU)
  524.                                        23 10'F3=End'
  525.                                             DSPATR(UL)
  526.                                             COLOR(BLU)
  527.                                        23 17'F12=Cancel'
  528.                                             DSPATR(UL)
  529.                                             COLOR(BLU)
  530.  
  531.                 R MSGSFLA                   SFL
  532.                                             SFLMSGRCD(24)
  533.                                             TEXT('Error message subfile')
  534.                   @KEY                      SFLMSGKEY
  535.                   @PGMQ                     SFLPGMQ
  536.  
  537.                 R MSGSFLB                   SFLCTL(MSGSFLA)
  538.                                             TEXT('Error message control file')
  539.                                             OVERLAY
  540.                                             SFLDSP
  541.                                             SFLDSPCTL
  542.                                             SFLINZ
  543.        N03                                  SFLEND
  544.                                             SFLSIZ(0002)
  545.                                             SFLPAG(0001)
  546.                   @PGMQ                     SFLPGMQ
  547.  
  548.  
  549. PF: STRCIG
  550.  
  551.       *********************************************************************
  552.       * Name        :‚STRCIG                                             €*
  553.       * Date        :‚27 February 2012                                   €*
  554.       * Programmer  :‚Jerry C. Adams                                     €*
  555.       * Project No. :‚0135                                               €*
  556.       * Description : Cigarette categories for store inventory.           *
  557.       *********************************************************************
  558.       * Revised By:‚                  €Revision Date:‚dd mmmmmmmmm ccyy  €*
  559.       * Project No:‚                                                     €*
  560.       * Reason    :                                                       *
  561.       *********************************************************************
  562.  
  563.                                             UNIQUE
  564.                 R STRCIGR                   TEXT('Cigarette Categories')
  565.                   SCTYPE         1A         TEXT('Type: S=Specialty')
  566.                                             COLHDG('Type')
  567.                   SCCATEGORY    50A         TEXT('Cigarette category')
  568.                                             COLHDG('Category')
  569.                   SCCTNRETL      9P 2       TEXT('Retail price per carton')
  570.                                             COLHDG('Carton' 'Retail' 'Price')
  571.                                             EDTCDE(J)
  572.                   SCPACKRETL     9P 2       TEXT('Retail price per pack')
  573.                                             COLHDG('Pack' 'Retail' 'Price')
  574.                                             EDTCDE(J)
  575.  
  576.                 K SCTYPE
  577.                 K SCCATEGORY
  578.  
© 2004-2019 by midrange.com generated in 0.007s valid xhtml & css