midrange.com code scratchpad
Name:
Jerry C. Adams
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
09/21/2009 04:37:38 pm
IP:
Logged
Description:
The user was to lazy to give a description
Code:
  1.      H COPYRIGHT('B&W Wholesale, Inc. 2009')
  2.      H/copy $header
  3.       //*******************************************************************************
  4.       // Written By  :‚Jerry C. Adams                            €                   **
  5.       // Date Written:‚18 September 2009          €                                  **
  6.       // Project No :‚ 01398                      €                                  **
  7.       // Program Name:‚ARQ900                                    €                   **
  8.       // Program Desc: Provides the means by which one may inquire into the log of   **
  9.       //               changes to the customer master table.                         **
  10.       //*******************************************************************************
  11.       // Revised By :‚__________     €Revised Date : ___-__-__                       **
  12.       // Project No :‚____ €                                                         **
  13.       // Reason     :                                                                **
  14.       //*******************************************************************************
  15.  
  16.       //********************
  17.       // FILE DEFINITIONS **
  18.       //********************
  19.  
  20.      FARQ900D   CF   E             WORKSTN SFile(ARQ900B:rrnb)
  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   SF_End                            LIKE(*IN) Overlay(Indicators:90)
  33.      D   Help                              LIKE(*IN) Overlay(Indicators:130)    F1
  34.      D   EOJ                               LIKE(*IN) Overlay(Indicators:132)    F3
  35.      D   Cancel                            LIKE(*IN) Overlay(Indicators:141)    F12
  36.  
  37.      D/Define MsgD
  38.      D/Copy $Msg
  39.  
  40.       //*******************
  41.       // FIELD NAMES     **
  42.       //*******************
  43.  
  44.      D sqlString       S            256a
  45.      D InvalidOption   C                   'GEN9901'
  46.      D CustomerNF      C                   'GEN0003'
  47.      D #Error          S               N
  48.      D BasicSlt        S             71a   INZ('SELECT ARDATE, ARTIME, JOB, CUS+
  49.      D                                     TOMER, BARNAME, AARNAME, FROM ARMAIN+
  50.      D                                     TLOG')
  51.      D #Limit          S                   Like(rrnb)
  52.      D #Key            S                   Like(rrnb)
  53.  
  54.       //*************
  55.       // ProtoTypes *
  56.       //*************
  57.  
  58.      D $BuildList      PR
  59.      D $PutList        PR
  60.      D $StartList      PR
  61.      D $ProcessList    PR
  62.      D $ShowCustomer   PR
  63.  
  64.       //*****************
  65.       // ---CONTROL--- **
  66.       //*****************
  67.  
  68.       /FREE
  69.       
  70.        EXEC SQL
  71.          SET Option
  72.              Naming  = *Sys,
  73.              DatFmt  = *ISO,
  74.              Commit  = *None,
  75.              UsrPrf  = *Owner;
  76.  
  77.        EXSR $INIT;
  78.        EXSR $MAIN;
  79.        EXSR $EOJ;
  80.  
  81.        //****************************************************************
  82.        // SUBROUTINE - $INIT                                           **
  83.        //    PURPOSE - Program Initialization                          **
  84.        //****************************************************************
  85.  
  86.        BEGSR $INIT;
  87.  
  88.          EXSR  $MINIT;
  89.  
  90.        ENDSR;
  91.  
  92.        //****************************************************************
  93.        // SUBROUTINE - $MAIN                                           **
  94.        //    PURPOSE - Main Program Logic                              **
  95.        //****************************************************************
  96.  
  97.        BEGSR $MAIN;
  98.  
  99.          DOW not eoj;
  100.  
  101.            WRITE MSGSFLB;
  102.            @List   = *Blanks;
  103.            @cust#  = *Zeros;
  104.            EXFMT ARQ900A;
  105.            EXSR  $CMsg;
  106.  
  107.            IF  not eoj;
  108.              EXSR  $EditA;
  109.              IF  #error;
  110.                ITER;
  111.              ENDIF;
  112.  
  113.              SELECT;
  114.  
  115.                WHEN  @List = 'A';
  116.                  sqlString = basicslt  +
  117.                              ' ORDER BY customer for Read Only';
  118.                WHEN  @List = 'B';
  119.                  sqlString = basicslt  +
  120.                              ' ORDER BY aarname, customer for Read Only';
  121.                OTHER;
  122.                  sqlString = basicslt  +
  123.                              ' WHERE customer  = :@cust#';
  124.  
  125.              ENDSL;
  126.  
  127.              $StartList();
  128.              $BuildList();
  129.              $PutList();
  130.              DOW not cancel
  131.              AND not eoj;
  132.                $ProcessList();
  133.              ENDDO;
  134.            ENDIF;
  135.  
  136.          ENDDO;
  137.  
  138.        ENDSR;
  139.  
  140.        //****************************************************************
  141.        // SUBROUTINE - $EditA                                          **
  142.        //    PURPOSE - Validate Panel 'A' options.                     **
  143.        //****************************************************************
  144.  
  145.        BEGSR $EditA;
  146.  
  147.          #error  = *Off;
  148.  
  149.          IF  @list <>  'A'
  150.          AND @list <>  'B'
  151.          AND @list <>  *Blanks
  152.          AND @cust#  = *Zeros;
  153.            @msgId  = InvalidOption;
  154.            #error  = *On;
  155.            EXSR  $SMsg;
  156.          ENDIF;
  157.  
  158.        ENDSR;
  159.  
  160.        //****************************************************************
  161.        // SUBROUTINE - $EOJ                                            **
  162.        //    PURPOSE - End of Program                                  **
  163.        //****************************************************************
  164.  
  165.        BEGSR $EOJ;
  166.  
  167.          *INLR = *On;
  168.          RETURN;
  169.  
  170.        ENDSR;
  171.  
  172.       /end-free
  173.  
  174.      C/Define MsgC
  175.      C/copy $Msg
  176.  
  177.        //****************************************************************
  178.        // Subprocedure - $StartList                                    **
  179.        //    PURPOSE - Clear the subfile for next request.             **
  180.        //****************************************************************
  181.  
  182.      P $StartList      B
  183.  
  184.      D                 PI
  185.  
  186.       /free
  187.  
  188.        rrnb      = *Zeros;
  189.        SF_Clear  = *On;
  190.        WRITE ARQ900BCTL;
  191.        SF_Clear  = *Off;
  192.  
  193.        RETURN;
  194.  
  195.       /end-free
  196.  
  197.      P                 E
  198.  
  199.        //******************************************************************
  200.        // Subprocedure - $BuildList                                       *
  201.        //      Purpose - Load the subfile with the maintenance log        *
  202.        //                records.                                         *
  203.        //******************************************************************
  204.  
  205.      P $BuildList      B
  206.  
  207.      D                 PI
  208.  
  209.       /free
  210.  
  211.        EXEC SQL
  212.          Prepare MySQLStmt from :sqlString;
  213.  
  214.        EXEC  SQL
  215.         Declare CustList Cursor for MySQLStmt;
  216.  
  217.        EXEC SQL
  218.          Open CustList;
  219.  
  220.        DOW 1 = 1;
  221.  
  222.          EXEC SQL
  223.            Fetch Next from CustList
  224.              INTO :date,:time,:job@,:cust#,:nameBefore,:nameAfter;
  225.  
  226.          IF  sqlState  = '02000'
  227.          OR  sqlCode   < *Zeros;
  228.            EXEC SQL
  229.              CLOSE CustList;
  230.            LEAVE;
  231.          ENDIF;
  232.  
  233.          @option = *Blanks;
  234.          rrnb   += 1;
  235.          WRITE ARQ900B;
  236.  
  237.        ENDDO;
  238.  
  239.        #Limit = rrnb;
  240.  
  241.        RETURN;
  242.  
  243.       /end-free
  244.  
  245.      P                 E
  246.  
  247.       //*******************************************************************
  248.       // Subprocedure - $PutList                                          *
  249.       //      Purpose -  Display the subfile.                             *
  250.       //*******************************************************************
  251.  
  252.      P $PutList        B
  253.  
  254.      D                 PI
  255.  
  256.       /free
  257.  
  258.        IF  rrnb  = *Zeros;
  259.          SF_Display  = *Off;
  260.        ELSE;
  261.          SF_Display  = *On;
  262.          SF_End      = *On;
  263.          rrnb        = 1;
  264.        ENDIF;
  265.  
  266.        WRITE ARQ900BFK;
  267.        EXFMT ARQ900BCTL;
  268.  
  269.        RETURN;
  270.  
  271.       /end-free
  272.  
  273.      P                 E
  274.  
  275.       //*******************************************************************
  276.       // Subprocedure - $ProcessList                                      *
  277.       //      Purpose - Display the transaction(s) chosen by the user.    *
  278.       //*******************************************************************
  279.  
  280.      P $ProcessList    B
  281.  
  282.      D                 PI
  283.  
  284.       /free
  285.  
  286.        IF  rrnb  > *Zeros;
  287.          FOR #key  = 1 to  #limit;
  288.            CHAIN #key  ARQ900B;
  289.            IF  %found()
  290.            AND @option <>  *Blanks;
  291.              $ShowCustomer();
  292.              IF  eoj;
  293.                LEAVE;
  294.              ENDIF;
  295.            ENDIF;
  296.          ENDFOR;
  297.        ENDIF;
  298.  
  299.        RETURN;
  300.  
  301.       /end-free
  302.  
  303.      P                 E
  304.  
  305.       //*******************************************************************
  306.       // Subprocedure - $ShowCustomer                                     *
  307.       //      Purpose - Retrieve the transaction selected by the user and *
  308.       //                display it.                                       *
  309.       //*******************************************************************
  310.  
  311.      P $ShowCustomer   B
  312.  
  313.      D                 PI
  314.  
  315.      D @Action         S              1a
  316.  
  317.       /free
  318.  
  319.        EXEC SQL
  320.          SELECT "ACTION",
  321.                 customer,
  322.                 userid,
  323.                 job,
  324.                 ardate,
  325.                 artime,
  326.                 barname,
  327.                 barcons,
  328.                 barsm#,
  329.                 baradr1,
  330.                 baradr2,
  331.                 barcity,
  332.                 barstat,
  333.                 barzip,
  334.                 bartxcd,
  335.                 barcod5,
  336.                 barcod6,
  337.                 aarname,
  338.                 aarcons,
  339.                 aarsm#,
  340.                 aaradr1,
  341.                 aaradr2,
  342.                 aarcity,
  343.                 aarstat,
  344.                 aarzip,
  345.                 aartxcd,
  346.                 aarcod5,
  347.                 aarcod6
  348.            INTO :@action,
  349.                 :cust#,
  350.                 :userid@,
  351.                 :job@,
  352.                 :date@,
  353.                 :time@,
  354.                 :nameb4,
  355.                 :consb4,
  356.                 :routeB4,
  357.                 :street1b4,
  358.                 :street2b4,
  359.                 :cityb4,
  360.                 :stateb4,
  361.                 :zipb4,
  362.                 :tierb4,
  363.                 :wpcb4,
  364.                 :rpcb4,
  365.                 :nameaf,
  366.                 :consaf,
  367.                 :routeaf,
  368.                 :street1af,
  369.                 :street2af,
  370.                 :cityaf,
  371.                 :stateaf,
  372.                 :zipaf,
  373.                 :tieraf,
  374.                 :wpcaf,
  375.                 :rpcaf
  376.            FROM ARMAINTLOG
  377.            WHERE customer = :@cust# and
  378.                  ardate = :date and
  379.                  artime = :time and
  380.                  job = :job@;
  381.  
  382.        SELECT;
  383.  
  384.          WHEN @action = 'A';
  385.            Type = 'Add';
  386.          WHEN @action - 'B';
  387.            Type = 'Chg';
  388.          WHEN @action = 'D';
  389.            Type = 'Dlt';
  390.          OTHER;
  391.            Type = '???';
  392.  
  393.        ENDSL;
  394.  
  395.        EXFMT ARQ900C;
  396.  
  397.        RETURN;
  398.  
  399.       /end-free
  400.  
  401.      P                 E
  402.  
© 2004-2019 by midrange.com generated in 0.008s valid xhtml & css