/* @lastChanged: "1998-02-16 12:00"
 
 * @filename:   vta31
 * @purpose:    "TA_command_interface"
 * @release:    7.1.0.0
 * @see:        "-.-"
 *
 * @copyright:  (c) 1998-2004 SAP AG"
 */
 
.tt 1 $SAP$LiveCache$VTA31$
.tt 3 $$TA_command_interface$2000-04-12$
 
.nf
 
 
    ========== licence begin  GPL
    Copyright (c) 1998-2004 SAP AG
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    ========== licence end
 
.fo
***********************************************************
 
Module  : TA_command_interface
 
Define  :
 
        PROCEDURE
              t31mainprocedure;
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              GG_edit_routines : VGG17;
 
        PROCEDURE
              g17sname_to_line (n : tsp00_Sname;
                    VAR ln_len    : integer;
                    VAR ln        : tsp00_Line);
&       ifdef SLOW
 
      ------------------------------ 
 
        FROM
              TA_test_procedures : VTA02;
 
        PROCEDURE
              t02sinit;
 
        PROCEDURE
              t02minbuf (min_wanted : boolean);
&       endif
 
      ------------------------------ 
 
        FROM
              TA_terminal_IO_of_ci : VTA03;
 
        VAR
              t03protfile : tut_vf_fileref;
              t03term     : tut_terminal;
 
      ------------------------------ 
 
        FROM
              TA_RTE_functions : VTA05;
 
        PROCEDURE
              t05getparam (VAR is_batch  : boolean;
                    VAR is_virt_term     : boolean;
                    VAR is_prompting     : boolean;
                    VAR is_command       : boolean;
                    VAR xusertype        : tsp4_xuser;
                    VAR username         : tsp00_KnlIdentifier;
                    VAR param_password   : tsp00_Pw;
                    VAR sqluser_pw       : tsp00_CryptPw;
                    VAR serverdb         : tsp00_DbName;
                    VAR servernode       : tsp00_NodeId;
                    VAR batch_fn         : tsp00_VFilename;
                    VAR param_line       : tsp00_Line;
                    VAR color_foreground : tsp00_VtColor;
                    VAR color_bright     : tsp00_VtColor;
                    VAR color_background : tsp00_VtColor;
                    VAR color_wng_foregr : tsp00_VtColor;
                    VAR color_wng_backgr : tsp00_VtColor;
                    VAR is_ok            : boolean);
 
      ------------------------------ 
 
        FROM
              TA_terminal_IO : VTA09;
 
        PROCEDURE
              t09endscreen (VAR term : tut_terminal);
 
        FUNCTION
              t09external_retcode (VAR t09 : tut_terminal) : integer;
 
        PROCEDURE
              t09initscreen (VAR term : tut_terminal;
                    is_batch          : boolean;
                    is_virt_term      : boolean;
                    is_prompting      : boolean;
                    color_foreground  : tsp00_VtColor;
                    color_bright      : tsp00_VtColor;
                    color_background  : tsp00_VtColor;
                    color_wng_foregr  : tsp00_VtColor;
                    color_wng_backgr  : tsp00_VtColor;
                    VAR batch_fn      : tsp00_VFilename;
                    VAR param_ln      : tsp00_Line;
                    VAR is_ok         : boolean);
 
        FUNCTION
              t09retcode (VAR t09 : tut_terminal) : integer;
 
        PROCEDURE
              t09returncode_set (VAR term : tut_terminal;
                    retcode : integer);
 
      ------------------------------ 
 
        FROM
              TA_write_protfile : VTA12;
 
        PROCEDURE
              t12close_prot (VAR fileref : tut_vf_fileref);
 
        PROCEDURE
              t12create_prot (VAR fileref : tut_vf_fileref);
 
        PROCEDURE
              t12write_prot (VAR fileref : tut_vf_fileref;
                    VAR ln    : tsp00_Line;
                    length    : integer;
                    VAR error : integer);
 
      ------------------------------ 
 
        FROM
              TA_driver_procedures : VTA320;
 
        PROCEDURE
              t320sequential_program (VAR upg  : tta_user_proc_globals;
                    VAR term          : tut_terminal;
                    is_util_cmd       : boolean;
                    VAR util_cmd_line : tsp00_Line);
 
      ------------------------------ 
 
        FROM
              TA_driver_testroutines : VTA370;
 
        PROCEDURE
              t370inittranslate_table (VAR upg : tta_user_proc_globals);
 
      ------------------------------ 
 
        FROM
              RTE_driver : VEN102;
 
        PROCEDURE
              sqlfinish (terminate : boolean);
 
        PROCEDURE
              sqlinit (VAR component : tsp00_CompName;
                    canceladdr       : tsp00_BoolAddr);
 
        PROCEDURE
              sqlresult (result : tsp00_Uint1);
 
        PROCEDURE
              sqltermid (VAR terminalid : tsp00_TermId);
 
        PROCEDURE
              sqluid (VAR uid : tsp00_TaskId);
 
        PROCEDURE
              sqlwrite (VAR text : tsp00_Line);
 
      ------------------------------ 
 
        FROM
              Encrypting : VSP02;
 
        PROCEDURE
              s02applencrypt (pw_clear : tsp00_Name;
                    VAR pw_crypt : tsp00_CryptPw);
 
      ------------------------------ 
 
        FROM
              RTE-Extension-20 : VSP20;
 
        PROCEDURE
              s20ch4sw (val    : tsp00_Int4;
                    sourceswap : tsp00_SwapKind;
                    VAR dest   : tsp00_C4;
                    di         : tsp00_Int4;
                    destswap   : tsp00_SwapKind);
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        PROCEDURE
              s20ch4sw;
 
              tsp00_MoveObj   tsp00_C4
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : JuergenA / ElkeZ
.sp
.cp 3
Created : 1979-08-22
.sp
.cp 3
.sp
.cp 3
Release :      Date : 2000-04-12
.sp
***********************************************************
.sp
.cp 16
.fo
.oc _/1
Specification:
 
.CM *-END-* specification -------------------------------
.sp 2
.fo;.in
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
 
.oc _/1
.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 20
.nf
.oc _/1
Structure:
 
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
 
 
CONST
      rc_req_failed   = 10000;
      rc_sqlnotok     = -8888;
      rc_sqltasklimit = -8026;
      rc_sqltimeout   =   700;
 
VAR
      t31g : tta_user_proc_globals;
 
 
(*------------------------------*) 
 
PROCEDURE
      init_global (VAR is_util_cmd : boolean;
            VAR util_cmd_line      : tsp00_Line);
 
VAR
      color_foreground : tsp00_VtColor;
      color_bright     : tsp00_VtColor;
      color_background : tsp00_VtColor;
      color_wng_foregr : tsp00_VtColor;
      color_wng_backgr : tsp00_VtColor;
      i                : integer;
      maxlen           : integer;
      i4               : tsp00_Int4;
      s4               : tsp00_C4;
      err              : tsp00_Sname;
      batch_fn         : tsp00_VFilename;
      ln               : tsp00_Line;
 
BEGIN
is_util_cmd := false;
sqluid(t31g.procid);
t31g.termid := bsp_termid;
sqltermid (t31g.termid);
t370inittranslate_table (t31g);
t31g.username         := bsp_c64;
t31g.serverdb         := bsp_dbname;
t31g.sqlmode          := sqlm_internal;
t31g.command_options  := [ ];
t31g.parsing_again    := false;
t31g.reference        := 0;
t31g.stop             := false;
t31g.cancel           := false;
t31g.to_break         := true;
t31g.long_errmsg      := false;
t31g.file_info        := false;
t31g.with_abap_part   := true;
t31g.with_modul_part  := false;
t31g.longdem_cnt      := 0;
t31g.longdem_atonce   := true;
t31g.longdem_length   := -1;
t31g.longdem_pos      := 0;
t31g.cnt              := 0;
t31g.is_batch         := false;
t31g.is_virt_term     := true;
t31g.term_simulation  := tasim_none;
IF  ' ' = csp_ascii_blank
THEN
    t31g.code_type := csp_ascii
ELSE
    t31g.code_type := csp_ebcdic;
(*ENDIF*) 
i4 := 1;
s20ch4sw (i4, sw_normal, s4, 1, sw_normal);
IF  s4[ 4 ] = chr(1)
THEN
    t31g.swap:= sw_normal
ELSE
    IF  s4[ 1 ] = chr(1)
    THEN
        t31g.swap:= sw_full_swapped
    ELSE
        t31g.swap:= sw_part_swapped;
    (*ENDIF*) 
(*ENDIF*) 
err := '*** GETPARAM';
color_foreground := vt_white;
color_bright     := vt_white;
color_background := vt_blue;
color_wng_foregr := vt_white;
color_wng_backgr := vt_red;
t05getparam (t31g.is_batch, t31g.is_virt_term,
      t31g.is_prompting, is_util_cmd, t31g.xusertype, t31g.username,
      t31g.param_pw, t31g.password, t31g.serverdb, t31g.servernode,
      batch_fn, ln, color_foreground, color_bright, color_background,
      color_wng_foregr, color_wng_backgr, t31g.is_ok);
IF  t31g.is_ok
THEN
    BEGIN
    IF  is_util_cmd
    THEN
        util_cmd_line := ln;
    (*ENDIF*) 
    err := '*** T09INIT ';
    t09initscreen (t03term, t31g.is_batch,
          t31g.is_virt_term, t31g.is_prompting,
          color_foreground, color_bright, color_background,
          color_wng_foregr, color_wng_backgr, batch_fn, ln, t31g.is_ok)
    END;
(*ENDIF*) 
IF  NOT t31g.is_ok
THEN
    BEGIN
    FOR i := 1 TO LINE_MXSP00 DO
        ln[ i ] := ' ';
    (*ENDFOR*) 
    i := 0;
    g17sname_to_line (err, i, ln);
    g17sname_to_line (' failed     ', i, ln);
    sqlwrite(ln)
    END
ELSE
    BEGIN
    IF  (t31g.xusertype = sp4xu_sql_userparms) AND
        (t31g.param_pw <> bsp_name)
    THEN
        s02applencrypt (t31g.param_pw, t31g.password);
    (*ENDIF*) 
    IF  (t31g.username = bsp_c64) OR (t31g.serverdb = bsp_dbname)
    THEN
        t31g.xusertype := sp4xu_sql_usermask;
    (*ENDIF*) 
    ln := t03term.blankline;
    IF  VFILENAME_MXSP00 > sizeof (ln)
    THEN
        maxlen := sizeof(ln)
    ELSE
        maxlen := VFILENAME_MXSP00;
    (*ENDIF*) 
    IF  t31g.is_batch
    THEN
        FOR i := 1 TO maxlen DO
            ln[ i ] := batch_fn [ i ]
        (*ENDFOR*) 
    ELSE
        BEGIN
        i := 0;
        g17sname_to_line ('PROTOKOLL   ', i, ln)
        END;
    (*ENDIF*) 
    t12write_prot (t03protfile, ln, maxlen, i);
    t31g.prot.refer := t03protfile;
    FOR i := 5 DOWNTO 1 DO
        t31g.open_cols [ i ].free := true;
    (*ENDFOR*) 
    t31g.left_header  := 'DB:                 ';
    t31g.is_connected := false;
    t31g.digiset := [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ]
    END
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      init_environment;
 
VAR
      i           : integer;
      component   : tsp00_CompName;
      c_component : tsp00_Name;
 
BEGIN
t31g.is_ok               := true;
t03protfile.utvf_handle  := 0;
t03term.is_virt_term     := false;
t03term.curr_inputfile   := 0;
t03term.retcode_external := -1;
t03term.use_script       := true;
t09returncode_set (t03term, 0);
component   := bsp_c64;
c_component := 'terminaldriver    ';
FOR i := 1 TO NAME_MXSP00 DO
    component[ i ] := c_component[ i ];
(*ENDFOR*) 
sqlinit (component, @t03term.is_reset_called);
t12create_prot (t03protfile)
END;
 
(*------------------------------*) 
 
PROCEDURE
      t31mainprocedure;
 
VAR
      is_util_cmd   : boolean;
      util_cmd_line : tsp00_Line;
 
BEGIN
t31g.is_ok := true;
&ifdef SLOW
t02sinit;
t02minbuf (false);
&endif
init_environment;
IF  t31g.is_ok
THEN
    init_global (is_util_cmd, util_cmd_line);
(*ENDIF*) 
IF  t31g.is_ok
THEN
    BEGIN
    t320sequential_program (t31g, t03term, is_util_cmd, util_cmd_line);
    t09endscreen (t03term);
    END;
(*ENDIF*) 
IF  t09external_retcode (t03term) <> -1
THEN
    t31g.cnt := t09external_retcode (t03term)
ELSE
    IF  t09retcode (t03term) <=-9000
    THEN
        t31g.cnt := 9
    ELSE
        IF  (t09retcode (t03term) = rc_req_failed  ) OR
            (t09retcode (t03term) = rc_sqlnotok    ) OR
            (t09retcode (t03term) = rc_sqltasklimit) OR
            (t09retcode (t03term) = rc_sqltimeout  )
        THEN
            t31g.cnt := 2
        ELSE
            IF  t09retcode (t03term) <> 0
            THEN
                t31g.cnt := 1
            ELSE
                t31g.cnt := 0;
            (*ENDIF*) 
        (*ENDIF*) 
    (*ENDIF*) 
(*ENDIF*) 
sqlresult (t31g.cnt);
t12close_prot (t03protfile);
sqlfinish (true)
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
.PA 
