text: 
  var sql = require('mssql');
  
  import * as PORTACTION from "../../../actions/production/port/PORTActionConst.js"
  import * as PORTSTATE from "../../../actions/production/port/PORTState.js"
  import * as PORTCHK from "../../../const/ChkConst.js"
  import * as CONNECT from "../../../const/SQLConst.js"
  import * as MISC from "../../../const/Misc.js"
  
  var sql1Done=false;
  var sql1Cnt=0;
  var sql1Failed=false;
  var contPORT=false;
  const ATTEMPTS=1;
  
  
  
  export async function sql1(disp,getSt){
  //  var that = this;
    var dispatch = disp;
    var getState = getSt;
    var state = getState(); 
    if ('development'==process.env.NODE_ENV) {
      console.dir(state);
    }
  
  
    var cnt=0;
    init();
    execSQL1(dispatch);
  
    while(!isDone() && !didFail()){
      if(++cnt>15){
        dispatch({ type:PORTACTION.SET_REASON, reason:`PORTSetSQLCurrentPO.sql1() Timed Out or Failed.` });
        dispatch({ type:PORTACTION.SET_STATE, state:PORTSTATE.FAILURE });
        break;
      }else{
        await MISC.sleep(2000);
      }
    }
  
    if(isDone()){
      if ('development'==process.env.NODE_ENV) {
        console.log(`PORTSQLSetCurrentPO.sql1(): Completed`)
      }
  
    }else{
      if ('development'==process.env.NODE_ENV) {
        console.log(`PORTSQLSetCurrentPO.sql1(): Did NOT Complete`)
      }
    }
  
    if(didFail()){
      if ('development'==process.env.NODE_ENV) {
        console.log(`PORTSQLSetCurrentPO.sql1(): Failed`)
      }
  
    }else{
      if ('development'==process.env.NODE_ENV) {
        console.log(`PORTSQLSetCurrentPO.sql1(): Suceeded`)
      }
    }
  
  }
  
  function init(){
    sql1Done=false;
    sql1Cnt=0;
    sql1Failed=false;
    contPORT=false;
  }
  
  export function isDone(){
    if(
      (true==sql1Done)
      )
    {
      return true;
    } else{
      return false;
    }
  }
  
  export function didFail(){
    if(
      (true==sql1Failed)
      )
    {
      return true;
    } else{
      return false;
    }
  }
  export function continuePORT(){
    if(true==contPORT)
    {
      return true;
    } else{
      return false;
    }
  }
  
  
  
  function execSQL1(disp){
    var dispatch = disp;
    if ('development'==process.env.NODE_ENV) {
      console.log(`PORTSQLSetCurrentPO.execSQL1() top=>${sql1Cnt}`);
    }
  
  
    var connection = new sql.Connection(CONNECT.m2mDefTO, function(err) {
      // ... error checks
      if(null==err){
        if ('development'==process.env.NODE_ENV) {
          console.log(`PORTSQLSetCurrentPO.execSQL1() Connection Sucess`);
        }
  
        let qry;
  
        if (MISC.PROD===true) {
          qry = `
            SELECT rtrim(fcnumber) fcnumber
            FROM sysequ 
            WHERE fcclass = 'POMAST.STD'
            `;
        }else{
          qry = `
            SELECT rtrim(fcnumber) fcnumber
            FROM btsysequ 
            WHERE fcclass = 'POMAST.STD'
            `;
        }
  
  
        var request = new sql.Request(connection); 
        request.query(qry, function(err, recordset) {
          // ... error checks
          if(null==err){
            if ('development'==process.env.NODE_ENV) {
              console.log(`PORTSQLSetCurrentPO.execSQL1() Sucess`);
            }
            if(recordset.length!==0){
              let currentPO=parseInt(recordset[0].fcnumber);
              if ('development'==process.env.NODE_ENV) {
                console.log("PORTSQLSetCurrentPO.execSQL1() had records.");
                console.dir(recordset[0].fcnumber);
                console.log(`currentPO=>${currentPO}`);
              }
              dispatch({ type:PORTACTION.SET_CURRENT_PO, currentPO:currentPO});
              contPORT=true;
            }else{
              if ('development'==process.env.NODE_ENV) {
                console.log(`PORTSQLSetCurrentPO.execSQL1() err: Could not retrieve fcnumber.` );
              }
              dispatch({ type:PORTACTION.SET_REASON, reason:'Could not retrieve fcnumber.' });
              dispatch({ type:PORTACTION.SET_STATE, state:PORTSTATE.FAILURE });
              sql1Failed=true;
            }
            sql1Done=true;
          }else {
            if(++sql1Cnt<ATTEMPTS) {
              if ('development'==process.env.NODE_ENV) {
                console.log(`PORTSQLSetCurrentPO.execSQL1().query:  ${err.message}` );
                console.log(`sql1Cnt = ${sql1Cnt}`);
              }
            }else{
              if ('development'==process.env.NODE_ENV) {
                console.log(`PORTSQLSetCurrentPO.execSQL1() err:  ${err.message}` );
              }
              dispatch({ type:PORTACTION.SET_REASON, reason:err.message });
              dispatch({ type:PORTACTION.SET_STATE, state:PORTSTATE.FAILURE });
              sql1Failed=true;
            }
          }
        });
      }else{
        if(++sql1Cnt<ATTEMPTS) {
          if ('development'==process.env.NODE_ENV) {
            console.log(`PORTSQLSetCurrentPO.Connection: ${err.message}` );
            console.log(`sql1Cnt = ${sql1Cnt}`);
          }
        }else{
          if ('development'==process.env.NODE_ENV) {
            console.log(`PORTSQLSetCurrentPO.Connection: ${err.message}` );
          }
          dispatch({ type:PORTACTION.SET_REASON, reason:err.message });
          dispatch({ type:PORTACTION.SET_STATE, state:PORTSTATE.FAILURE });
          sql1Failed=true;
        }
      }
    });
    
    connection.on('error', function(err) {
      if(++sql1Cnt<ATTEMPTS) {
        if ('development'==process.env.NODE_ENV) {
          console.log(`PORTSQLSetCurrentPO.connection.on(error): ${err.message}` );
          console.log(`sql1Cnt = ${sql1Cnt}`);
        }
  
      }else{
        if ('development'==process.env.NODE_ENV) {
          console.log(`PORTSQLSetCurrentPO.connection.on(error): ${err.message}` );
        }
        dispatch({ type:PORTACTION.SET_REASON, reason:err.message });
        dispatch({ type:PORTACTION.SET_STATE, state:PORTSTATE.FAILURE });
        sql1Failed=true;
      }
    });
  }
  
  
  