.ad 8
.bm 8
.fm 4
.bt $Copyright by SAP AG, 2003$$Page %$
.tm 12
.hm 6
.hs 3
.TT 1 $SQL$Project Distributed Database System$VAK506$
.tt 2 $$$
.TT 3 $ElkeZ$Executing_values$$2000-09-13$
***********************************************************
.nf
 
 
    ========== licence begin  GPL
    Copyright (C) 2000 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
.nf
.sp
MODULE  : Executing_values
=========
.sp
Purpose : Module in which the values for the commands to be
          executed are processed.
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        PROCEDURE
              a506fieldvalues (
                    VAR acv       : tak_all_command_glob;
                    VAR dmli      : tak_dml_info;
                    VAR frec      : tak_fill_rec;
                    viewkeybuf    : tak_sysbufferaddress;
                    VAR result    : tsp_moveobj;
                    resultBufSize : tsp00_Int4); (* PTS 1115085 *)
 
        PROCEDURE
              a506lock_fieldvalues (
                    VAR acv    : tak_all_command_glob;
                    VAR dmli   : tak_dml_info;
                    VAR frec   : tak_fill_rec;
                    viewkeybuf : tak_sysbufferaddress);
 
        PROCEDURE
              a506result_name (
                    VAR acv     : tak_all_command_glob;
                    VAR dmli    : tak_dml_info);
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              Scanner : VAK01;
 
        VAR
              a01_il_b_identifier   : tsp_knl_identifier;
              a01_zero_res_name     : tsp_knl_identifier;
              a01defaultkey         : tgg_sysinfokey;
 
      ------------------------------ 
 
        FROM
              AK_semantic_scanner_tools : VAK05;
 
        PROCEDURE
              a05constraint_fulfilled (
                    VAR acv       : tak_all_command_glob;
                    VAR valbuf    : tgg_rec_buf;
                    VAR tree      : tgg00_FileId;
                    constraint_id : integer);
 
        PROCEDURE
              a05_stamp_get (
                    VAR acv    : tak_all_command_glob;
                    VAR dest   : tsp_moveobj;
                    destpos    : integer;
                    mv_dest    : integer);
 
        PROCEDURE
              a05_transaction_get (
                    VAR acv    : tak_all_command_glob;
                    VAR dest   : tsp_moveobj;
                    destpos    : integer;
                    mv_dest    : integer);
 
        PROCEDURE
              a05_nextval_get (
                    VAR acv      : tak_all_command_glob;
                    m2_type      : tgg_message2_type;
                    VAR seq_id   : tgg_surrogate;
                    VAR seq_info : tgg_seq_info;
                    VAR dest     : tsp_moveobj;
                    destpos      : integer;
                    VAR actlen   : integer);
 
        PROCEDURE
              a05qualification_test (
                    VAR acv        : tak_all_command_glob;
                    VAR m          : tgg_mess_block;
                    result_wanted  : boolean;
                    check_new_rec  : boolean;
                    error_pos      : integer;
                    VAR rec        : tgg_rec_buf;
                    VAR result     : tsp_moveobj;
                    resultBufSize  : tsp00_Int4; (* PTS 1115085 *)
                    VAR result_len : integer);
 
        PROCEDURE
              a05serial (
                    VAR acv        : tak_all_command_glob;
                    VAR colinfo    : tak00_columninfo;
                    VAR treeid     : tgg00_FileId;
                    VAR moveobj    : tsp_moveobj;
                    moveobj_size   : tsp_int4;
                    number_pos     : tsp_int4;
                    VAR number_len : integer;
                    with_retpart   : boolean);
 
        PROCEDURE
              a05timestamp_get (
                    VAR acv   : tak_all_command_glob;
                    VAR src   : tsp_moveobj;
                    src_pos   : tsp_int4;
                    VAR dest  : tsp_moveobj;
                    dest_pos  : tsp_int4;
                    check_len : tsp_int4;
                    ch_code   : boolean;
                    VAR b_err : tgg_basis_error);
 
        PROCEDURE
              a05_verify_not_null (
                    VAR acv        : tak_all_command_glob;
                    VAR valbuf     : tgg_rec_buf;
                    VAR stackentry : tgg_stack_entry);
 
      ------------------------------ 
 
        FROM
              AK_error_handling : VAK07;
 
        PROCEDURE
              a07_hex_uni_error (
                    VAR acv     : tak_all_command_glob;
                    uni_err     : tsp8_uni_error;
                    err_code    : tsp_int4;
                    to_unicode  : boolean;
                    bytestr     : tsp_moveobj_ptr;
                    len         : tsp_int4 );
 
        PROCEDURE
              a07_b_put_error (
                    VAR acv : tak_all_command_glob;
                    b_err   : tgg_basis_error;
                    err_code : tsp_int4);
 
        PROCEDURE
              a07_nb_put_error (
                    VAR acv  : tak_all_command_glob;
                    b_err    : tgg_basis_error;
                    err_code : tsp_int4;
                    VAR n    : tsp_knl_identifier);
 
      ------------------------------ 
 
        FROM
              Systeminfo_cache : VAK10;
 
        PROCEDURE
              a10get_sysinfo (
                    VAR acv      : tak_all_command_glob;
                    VAR syskey   : tgg_sysinfokey;
                    dstate       : tak_directory_state;
                    VAR syspoint : tak_sysbufferaddress;
                    VAR b_err    : tgg_basis_error);
 
      ------------------------------ 
 
        FROM
              DML_Parts : VAK55;
 
        PROCEDURE
              a55_const_from_resbuf (
                    VAR acv      : tak_all_command_glob;
                    VAR result   : tsp_moveobj;
                    VAR col_info : tak00_columninfo;
                    pars_kind    : tak_fp_kind_type;
                    VAR start    : integer;
                    VAR leng     : integer;
                    result_index : integer);
 
      ------------------------------ 
 
        FROM
              AK_Insert : VAK56;
 
        PROCEDURE
              a56one_default_value (
                    VAR acv     : tak_all_command_glob;
                    VAR dmli    : tak_dml_info;
                    VAR colinfo : tak00_columninfo;
                    with_length : tak_fp_kind_type);
 
        PROCEDURE
              a56syskey (
                    VAR acv     : tak_all_command_glob;
                    VAR dmli    : tak_dml_info);
 
        PROCEDURE
              a56temp_table_key (
                    VAR acv     : tak_all_command_glob;
                    VAR dmli    : tak_dml_info);
 
      ------------------------------ 
 
        FROM
              AK_Delete : VAK58;
 
        PROCEDURE
              a58_get_currentkey (
                    VAR acv         : tak_all_command_glob;
                    VAR currentnam  : tsp_knl_identifier;
                    VAR sourcetabid : tgg_surrogate;
                    n_pos           : integer);
 
      ------------------------------ 
 
        FROM
              Execute_factor_col_function : VAK641;
 
        PROCEDURE
              a641_get_name (VAR acv : tak_all_command_glob;
                    part_ptr          : tsp1_part_ptr;
                    buf_pos           : tsp_int4;
                    buf_len           : tsp_int2;
                    get_owner         : boolean;
                    objecttype        : tsp_int2;
                    VAR returned_name : tsp00_KnlIdentifier);
 
      ------------------------------ 
 
        FROM
              KB_get : VKB71;
 
        PROCEDURE
              k71col_select (
                    VAR t           : tgg00_TransContext;
                    VAR sel         : tgg_select_fields_param;
                    VAR stack_desc  : tgg_stack_desc;
                    VAR rec_buf     : tgg00_Rec;
                    VAR unqualified : boolean);
 
      ------------------------------ 
 
        FROM
              Single_Select : VKB720;
 
        PROCEDURE
              k720_test_subquery (
                    VAR m   : tgg_mess_block;
                    VAR rec : tgg_rec_buf);
 
      ------------------------------ 
 
        FROM
              Configuration_Parameter : VGG01;
 
        VAR
              g01code           : tgg_code_globals;
              g01unicode        : boolean;
 
      ------------------------------ 
 
        FROM
              Codetransformation_and_Coding : VGG02;
 
        VAR
              g02codetables : tgg_code_tables;
 
        PROCEDURE
              g02pebcdic_pos_ascii(
                    VAR source : tsp_moveobj;
                    srcind   : tsp_int4;
                    VAR dest : tsp_moveobj;
                    destind  : tsp_int4;
                    length   : tsp_int4);
 
        PROCEDURE
              g02p1ebcdic_pos_ascii (
                    VAR source : tsp_c2;
                    srcind   : tsp_int4;
                    VAR dest : tsp_c2;
                    destind  : tsp_int4;
                    length   : tsp_int4);
 
        PROCEDURE
              g02pascii_pos_ebcdic(
                    VAR source : tsp_moveobj;
                    srcind   : tsp_int4;
                    VAR dest : tsp_moveobj;
                    destind  : tsp_int4;
                    length   : tsp_int4);
 
        PROCEDURE
              g02p1ascii_pos_ebcdic (
                    VAR source : tsp_c2;
                    srcind   : tsp_int4;
                    VAR dest : tsp_c2;
                    destind  : tsp_int4;
                    length   : tsp_int4);
 
        PROCEDURE
              g02fromtermchar (
                    messcode   : tsp_code_type;
                    VAR object : tsp_moveobj;
                    pos        : tsp_int4;
                    length     : tsp_int4);
 
      ------------------------------ 
 
        FROM
              Check-Date-Time : VGG03;
 
        PROCEDURE
              g03fdcheck_date (
                    VAR sbuf  : tsp_moveobj;
                    VAR dbuf  : tsp_moveobj;
                    spos      : tsp_int4;
                    dpos      : tsp_int4;
                    actlen    : integer;
                    format    : tgg_datetimeformat;
                    ch_code   : boolean;
                    VAR b_err : tgg_basis_error);
 
        PROCEDURE
              g03fdc_date (
                    sptr       : tsp_moveobj_ptr;
                    dptr       : tsp_moveobj_ptr;
                    spos       : tsp_int4;
                    dpos       : tsp_int4;
                    actlen     : integer;
                    format     : tgg_datetimeformat;
                    ch_code    : boolean;
                    VAR b_err  : tgg_basis_error);
 
        PROCEDURE
              g03ftcheck_time (
                    VAR sbuf  : tsp_moveobj;
                    VAR dbuf  : tsp_moveobj;
                    spos      : tsp_int4;
                    dpos      : tsp_int4;
                    actlen    : integer;
                    format    : tgg_datetimeformat;
                    ch_code   : boolean;
                    VAR b_err : tgg_basis_error);
 
        PROCEDURE
              g03ftc_time (
                    sptr       : tsp_moveobj_ptr;
                    dptr       : tsp_moveobj_ptr;
                    spos       : tsp_int4;
                    dpos       : tsp_int4;
                    actlen     : integer;
                    format     : tgg_datetimeformat;
                    ch_code    : boolean;
                    VAR b_err  : tgg_basis_error);
 
        PROCEDURE
              g03dfchange_format_date (
                    VAR sbuf  : tsp_timestamp;
                    VAR dbuf  : tsp_moveobj;
                    spos      : tsp_int4;
                    dpos      : tsp_int4;
                    format    : tgg_datetimeformat;
                    VAR b_err : tgg_basis_error);
 
        PROCEDURE
              g03tfchange_format_time (
                    VAR sbuf  : tsp_c9;
                    VAR dbuf  : tsp_moveobj;
                    spos      : tsp_int4;
                    dpos      : tsp_int4;
                    format    : tgg_datetimeformat;
                    VAR b_err : tgg_basis_error);
 
        PROCEDURE
              g03tsfchange_format_timestamp (
                    VAR sbuf  : tsp_timestamp;
                    VAR dbuf  : tsp_moveobj;
                    spos      : tsp_int4;
                    dpos      : tsp_int4;
                    format    : tgg_datetimeformat;
                    language  : tsp_c3;
                    VAR b_err : tgg_basis_error);
 
      ------------------------------ 
 
        FROM
              Select_Help_Procedures : VGG04;
 
        PROCEDURE
              g04init_select_fields (
                    VAR sel       : tgg_select_fields_param;
                    data_addr     : tsp_moveobj_ptr;
                    data_size     : tsp_int4;
                    work_st_addr  : tgg_stack_list_ptr;
                    work_st_max   : tsp_int2;
                    work_buf_addr : tsp_moveobj_ptr;
                    work_buf_size : tsp_int4;
                    curr_sqlmode  : tsp_sqlmode);
 
      ------------------------------ 
 
        FROM
              Kernel_move_and_fill : VGG10;
 
        PROCEDURE
              g10mv   (
                    mod_id         : tsp_c6;
                    mod_intern_num : tsp_int4;
                    size1          : tsp_int4;
                    size2          : tsp_int4;
                    VAR val1       : tsp_moveobj;
                    p1             : tsp_int4;
                    VAR val2       : tsp_moveobj;
                    p2             : tsp_int4;
                    cnt            : tsp_int4;
                    VAR e          : tgg_basis_error);
 
        PROCEDURE
              g10mv2  (
                    mod_id         : tsp_c6;
                    mod_intern_num : tsp_int4;
                    size1          : tsp_int4;
                    size2          : tsp_int4;
                    VAR val1       : tsp_timestamp;
                    p1             : tsp_int4;
                    VAR val2       : tsp_moveobj;
                    p2             : tsp_int4;
                    cnt            : tsp_int4;
                    VAR e          : tgg_basis_error);
 
        PROCEDURE
              g10mv3  (
                    mod_id         : tsp_c6;
                    mod_intern_num : tsp_int4;
                    size1          : tsp_int4;
                    size2          : tsp_int4;
                    VAR val1       : tsp_moveobj;
                    p1             : tsp_int4;
                    VAR val2       : tsp_knl_identifier;
                    p2             : tsp_int4;
                    cnt            : tsp_int4;
                    VAR e          : tgg_basis_error);
 
        PROCEDURE
              g10mv4  (
                    mod_id         : tsp_c6;
                    mod_intern_num : tsp_int4;
                    size1          : tsp_int4;
                    size2          : tsp_int4;
                    VAR val1       : tsp_moveobj;
                    p1             : tsp_int4;
                    VAR val2       : tgg_seq_info;
                    p2             : tsp_int4;
                    cnt            : tsp_int4;
                    VAR e          : tgg_basis_error);
 
        PROCEDURE
              g10mv5  (
                    mod_id         : tsp_c6;
                    mod_intern_num : tsp_int4;
                    size1          : tsp_int4;
                    size2          : tsp_int4;
                    VAR val1       : tsp_key;
                    p1             : tsp_int4;
                    VAR val2       : tsp_moveobj;
                    p2             : tsp_int4;
                    cnt            : tsp_int4;
                    VAR e          : tgg_basis_error);
 
        PROCEDURE
              g10mv6  (
                    mod_id         : tsp_c6;
                    mod_intern_num : tsp_int4;
                    size1          : tsp_int4;
                    size2          : tsp_int4;
                    VAR val1       : tsp_buf;
                    p1             : tsp_int4;
                    VAR val2       : tsp_moveobj;
                    p2             : tsp_int4;
                    cnt            : tsp_int4;
                    VAR e          : tgg_basis_error);
 
        PROCEDURE
              g10mv7  (
                    mod_id         : tsp_c6;
                    mod_intern_num : tsp_int4;
                    size1          : tsp_int4;
                    size2          : tsp_int4;
                    VAR val1       : tsp_moveobj;
                    p1             : tsp_int4;
                    VAR val2       : tsp_long_descriptor;
                    p2             : tsp_int4;
                    cnt            : tsp_int4;
                    VAR e          : tgg_basis_error);
 
        PROCEDURE
              g10mv8  (
                    mod_id         : tsp_c6;
                    mod_intern_num : tsp_int4;
                    size1          : tsp_int4;
                    size2          : tsp_int4;
                    VAR val1       : tsp_long_descriptor;
                    p1             : tsp_int4;
                    VAR val2       : tsp_moveobj;
                    p2             : tsp_int4;
                    cnt            : tsp_int4;
                    VAR e          : tgg_basis_error);
 
        PROCEDURE
              g10mv9  (
                    mod_id         : tsp_c6;
                    mod_intern_num : tsp_int4;
                    size1          : tsp_int4;
                    size2          : tsp_int4;
                    VAR val1       : tsp_moveobj;
                    p1             : tsp_int4;
                    VAR val2       : tgg_surrogate;
                    p2             : tsp_int4;
                    cnt            : tsp_int4;
                    VAR e          : tgg_basis_error);
 
        PROCEDURE
              g10mv10 (
                    mod_id         : tsp_c6;
                    mod_intern_num : tsp_int4;
                    size1          : tsp_int4;
                    size2          : tsp_int4;
                    VAR val1       : tsp_moveobj;
                    p1             : tsp_int4;
                    VAR val2       : tsp_number;
                    p2             : tsp_int4;
                    cnt            : tsp_int4;
                    VAR e          : tgg_basis_error);
 
        PROCEDURE
              g10mv11 (
                    mod_id         : tsp_c6;
                    mod_intern_num : tsp_int4;
                    size1          : tsp_int4;
                    size2          : tsp_int4;
                    VAR val1       : tsp_knl_identifier;
                    p1             : tsp_int4;
                    VAR val2       : tsp_moveobj;
                    p2             : tsp_int4;
                    cnt            : tsp_int4;
                    VAR e          : tgg_basis_error);
 
        PROCEDURE
              g10fil  (
                    mod_id         : tsp_c6;
                    mod_intern_num : tsp_int4;
                    size           : tsp_int4;
                    VAR m          : tsp_moveobj;
                    pos            : tsp_int4;
                    len            : tsp_int4;
                    fillchar       : char;
                    VAR e          : tgg_basis_error);
 
        PROCEDURE
              g10filuni (
                    mod_id      : tsp_c6;           mod_num  : tsp_int4;
                    obj_upb     : tsp_int4;
                    VAR obj     : tsp_moveobj;      obj_pos  : tsp_int4;
                    length      : tsp_int4;         fillchar : tsp_c2;
                    VAR e       : tgg_basis_error);
 
      ------------------------------ 
 
        FROM
              RTE-Extension-10 : VSP10;
 
        PROCEDURE
              s10mv1  (
                    size1    : tsp_int4;      size2 : tsp_int4;
                    VAR b1   : tsp_timestamp; pos1  : tsp_int4;
                    VAR b2   : tsp_c9;        pos2  : tsp_int4;
                    move_len : tsp_int4);
 
      ------------------------------ 
 
        FROM
              RTE-Extension-20: VSP20;
 
        PROCEDURE
              s20ch4sw (val     : tsp_int4;
                    source_swap : tsp_swap_kind;
                    VAR destin  : tsp_int4;
                    destin_pos  : tsp_int4;
                    destin_swap : tsp_swap_kind);
 
      ------------------------------ 
 
        FROM
              RTE-Extension-30 : VSP30;
 
        FUNCTION
              s30lnr (
                    VAR str : tsp_moveobj;
                    val   : char;
                    start : tsp_int4;
                    cnt   : tsp_int4) : tsp_int4;
 
        FUNCTION
              s30lnr_defbyte (
                    str       : tsp_moveobj_ptr;
                    defbyte   : char;
                    start_pos : tsp_int4;
                    length    : tsp_int4) : tsp_int4;
 
        FUNCTION
              s30unilnr (
                    str       : tsp_moveobj_ptr;
                    skip_val  : tsp_c2;
                    start_pos : tsp_int4;
                    length    : tsp_int4) : tsp_int4;
 
        PROCEDURE
              s30map (
                    VAR code_t : tsp_ctable;
                    VAR source : tsp_moveobj;
                    spos       : tsp_int4;
                    VAR dest   : tsp_moveobj;
                    dpos       : tsp_int4;
                    length     : tsp_int4);
 
      ------------------------------ 
 
        FROM
              PUT-Conversions : VSP41;
 
        PROCEDURE
              s41plrel (VAR buf : tsp_moveobj;
                    pos         : tsp_int4;
                    len         : integer;
                    frac        : integer;
                    source      : tsp_longreal;
                    VAR res     : tsp_num_error);
 
      ------------------------------ 
 
        FROM
              Patterns : VSP49;
 
        PROCEDURE
              s49build_pattern (
                    VAR pat_buffer : tsp_moveobj;
                    ascii_type  : boolean;
                    start       : tsp_int4;
                    stop        : tsp_int4;
                    escape_char : char;
                    escape      : boolean;
                    string      : boolean;
                    sqlmode     : tsp_sqlmode;
                    VAR ok      : boolean);
 
        PROCEDURE
              s49uni_build_pattern (
                    VAR pat_buffer : tsp_moveobj;
                    start       : tsp_int4;
                    stop        : tsp_int4;
                    escape_char : tsp_c2;
                    escape      : boolean;
                    sqlmode     : tsp_sqlmode;
                    VAR ok      : boolean);
 
      ------------------------------ 
 
        FROM
              Number-Arithmetic : VSP51;
 
        PROCEDURE
              s51kroun (
                    VAR source     : tsp_moveobj;
                    spos           : tsp_int4;
                    slen           : integer;
                    VAR result     : tsp_moveobj;
                    respos         : tsp_int4;
                    reslen         : integer;
                    resfrac        : integer;
                    VAR resbytelen : integer;
                    VAR ret        : tsp_num_error);
 
      ------------------------------ 
 
        FROM
              RTE-Extension-80 : VSP80;
 
        PROCEDURE
              s80uni_trans
                    (src_ptr        : tsp_moveobj_ptr;
                    src_len         : tsp_int4;
                    src_codeset     : tsp_int2;
                    dest_ptr        : tsp_moveobj_ptr;
                    VAR dest_len    : tsp_int4;
                    dest_codeset    : tsp_int2;
                    trans_options   : tsp8_uni_opt_set;
                    VAR rc          : tsp8_uni_error;
                    VAR err_char_no : tsp_int4);
 
      ------------------------------ 
 
        FROM
              RTE_kernel : VEN101;
 
        PROCEDURE
              vtimestamp (VAR ts : tsp00_Timestamp);
 
        PROCEDURE
              vUTCtimestamp (VAR timestamp : tsp00_Timestamp);
 
        FUNCTION
              vTimeZoneDelta : tsp_longreal; (* PTS 1109925 *)
&       ifdef TRACE
 
      ------------------------------ 
 
        FROM
              Test_Procedures : VTA01;
 
        PROCEDURE
              t01int4 (
                    debug    : tgg00_Debug;
                    nam      : tsp00_Sname;
                    int      : tsp00_Int4);
 
        PROCEDURE
              t01buf (
                    layer    : tgg00_Debug;
                    VAR buf  : tsp00_Buf;
                    startpos : integer;
                    endpos   : integer);
 
        PROCEDURE
              t01buf1 (
                    layer    : tgg00_Debug;
                    VAR buf  : tak_field_pars;
                    startpos : integer;
                    endpos   : integer);
 
        PROCEDURE
              t01char  (
                    level : tgg00_Debug;
                    nam : tsp00_Sname;
                    c   : char);
 
        PROCEDURE
              t01name (
                    level : tgg00_Debug;
                    nam : tsp00_Name);
 
        PROCEDURE
              t01messblock (
                    debug         : tgg00_Debug;
                    nam           : tsp00_Sname;
                    VAR m         : tgg00_MessBlock);
&       endif
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        PROCEDURE
              a55_const_from_resbuf;
 
              tsp_buf tsp_moveobj
 
        PROCEDURE
              a05qualification_test;
 
              tsp_buf tsp_moveobj
 
        PROCEDURE
              g02p1ebcdic_pos_ascii;
 
              tsp_moveobj tsp_c2
 
        PROCEDURE
              g02p1ascii_pos_ebcdic;
 
              tsp_moveobj tsp_c2
 
        PROCEDURE
              g03dfchange_format_date;
 
              tsp_moveobj tsp_timestamp
 
        PROCEDURE
              g03tfchange_format_time;
 
              tsp_moveobj tsp_c9
 
        PROCEDURE
              g03tsfchange_format_timestamp;
 
              tsp_moveobj tsp_timestamp
 
        PROCEDURE
              g10mv2;
 
              tsp_moveobj tsp_timestamp
 
        PROCEDURE
              g10mv3;
 
              tsp_moveobj tsp_knl_identifier
 
        PROCEDURE
              g10mv4;
 
              tsp_moveobj tgg_seq_info
 
        PROCEDURE
              g10mv5;
 
              tsp_moveobj tsp_key
 
        PROCEDURE
              g10mv6;
 
              tsp_moveobj tsp_buf
 
        PROCEDURE
              g10mv7;
 
              tsp_moveobj tsp_long_descriptor
 
        PROCEDURE
              g10mv8;
 
              tsp_moveobj tsp_long_descriptor
 
        PROCEDURE
              g10mv9;
 
              tsp_moveobj tgg_surrogate
 
        PROCEDURE
              g10mv10;
 
              tsp_moveobj tsp_number
 
        PROCEDURE
              g10mv11;
 
              tsp_moveobj tsp_knl_identifier
 
        PROCEDURE
              s20ch4sw;
 
              tsp_moveobj  tsp_int4
 
        PROCEDURE
              s10mv1;
 
              tsp_moveobj  tsp_timestamp
              tsp_moveobj  tsp_c9
 
        PROCEDURE
              t01buf1;
 
              tsp00_Buf tak_field_pars
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : ElkeZ
.sp
.cp 3
Created : 1985-04-15
.sp
.cp 3
.sp
.cp 3
Release :      Date : 2000-09-13
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
.sp 2
A506FIELDVALUES
.sp
This procedure is called by a505MOST_EXECUTE and
PARSINFO_WITH_VALUES and KEY_EXECUTE in such a way that all data
from the SQL_PACKET belonging to the (sub)command are entered
in the mess buffer.  The call from LOCK_FIELDVALUES leads only to
the reading of a datum since, in the case of LOCK commands, the layout
of the mess buffer is different from normal and severe length
restrictions must be complied with (erec.fno = erec.last_fno).
.br
For each datum to be input by the user, there is normally one
field-information record (except in the case of LIKE where there are
three, compare VAK65).  In addition, there are also
'field-information records' that force the internal jump forward to
specific positions or the usage of join-view keys.
.sp;.in +8;.un 8
gotopos After this 'field-information record', it is ensured that the
current mess buffer has part2 with an exactly specified length.  This is
necessary, for example, if the data must begin at particular positions
for search conditions since the pointers to them in the stack entries
are contained in part1 with fixed position information.  For this reason,
a 'field-information record' is generated with gotopos before a search
condition.  As a result, the part that has not yet been copied is copied
up to the specifed position from the parsed buffer to the current buffer.
.un 8
twuseold This 'field-information record' means that the first part (length
specified in fptopos) of part2 of the current mess buffer remains
as it is at this point in time.  This field-information record is then
used if the data in part2 are to be used for more than one KB request.
This is the case, for example, for complicated SELECTs, which are first
divided into several KB requests after the normal field-information
records have been generated.
.un 8
twviewkey This type of 'field-information record' designates the case when
a key must be transferred to the mess buffer from the buffer containing the
keys of the base records that participate in a change operation applied to a
join view.  Fpfrompos specifies the particular key (and the number of the
table from which it comes).
This key is always written to the beginning of part2 of the mess
buffer.
.un 8
copy_withlen This type is used for SELECT FIRST/LAST/NEXT/PREV
(see VAK62).
.un 8
varcolwithlen This is a real field-information record that specifies that
the value from the SQL_PACKET is fetched to the mess buffer;
only the fields designated with st_varcol are to receive a length byte.
This type is used for INSERT and for KEY... .
.un 8
allwithlen This is a real field-information record that causes all field
values to receive a length byte.  This type is used for UPDATE in the
SET clause.
.un 8
allwithoutlen This is a real field-information record that is responsible
for the fact that no values receive a length byte but, if necessary, only
the current length is identified in the associated stack entry.  This
type is used in the search condition.
.in -8;.sp
Fpmovebefore specifies the number of bytes that must be transferred from the
parsed mess buffer to the current buffer before the datum can be
fetched from the SQL_PACKET (mixture of data already known at the
time of parsing and unknown data).
.br
Ilen specifies the maximum number of bytes that belong to the value.
Start identifies the position in part2 of the mess buffer at which
the value is to begin.
.br
Selord_key only serves to simplify the next query.  In the case of
ordered SELECTs, the values must be filled to the required maximum
length.
.br
In the case of real field-information records, fptopos specifies the
number of the stack entry that contains the pointer to the value.  Since
it is not always ensured (e.g. join) that this stack entry is available
in the mess buffer that is currently being viewed, if necessary the
field value must be filled to its maximum length (to_fill).  This can
be omitted only if it is possible to write the actual
length of the value
to the stack entry (elen_var).
.br
Negative fpfrompos values designate very special data.
They are not fetched from the SQL_PACKET, but are available
internally: date(-1), time(-2), system number (STAMP, -3).  Of course,
these cannot already be determined at the time of parsing.  They are identified
via an RTE routine (vdattime) or via a query to KB (A05_STAMP_GET) and,
if necessary, entered in the mess buffer ASCII-EBCDIC-converted.
Since mxgg_surrogate = mv_date = mv_time, i.e. all three values have
the same length (8 bytes), one query
determines whether or not they must be
filled.
.br
For normal data (fpfrompos > 0, position in part2 of the SQL_PACKET)
a column description like the one that is also present in the
base records of the system-information records
must be generated in order to be able to call
VAL_FROM_PART2 and undertake the type checking.
This description must include
the data type, length, number of decimal places, inoutlen, entry as to
whether or not it is a field of variable length
and the column numbers (for range
checks).  Since a maximum of 300 parameters can be contained in one
command and this information, together with the internal field-information
records, must fit in one system-information record (during parsing, sparr
has 2 buffers: 1 for the field-information records for the user, 1 for
internal use), one field-information record can be only 12-bytes long.
The entry for the decimal places is placed in fpdatatyp only under
unusual conditions.
.br
After VAL_FROM_PART2 is called, leng contains the current length
that is entered in the associated stack entry, if necessary.
.br
The length byte, if one has been requested is then written to part2
and the entry concerning the key length for single-record commands
is raised.
.br
If a range check of the value is required (fprange), it is executed in
A05_VALUE_IN_RANGE.  If an error occurs, it is ensured via error-text
mechanisms in RANGE_ERROR that the user receives the name of the column
whose range is being violated.
.br
It is not permissible to simultaneously have a range definition for a
field and to specify NOT NULL for it.  Therefore, a check can be run in
the ELSE branch to determine whether a mandatory field has received the
NULL value.
.br
If the value belongs to a LIKE condition, an attempt is made to transform
this into an equal or BETWEEN condition.  A LIKE value usually appears in
the mess buffer 3 times (twice with st_dummy for use with strategies and
once for the actual LIKE condition).  It is also helpful for the strategies
if these values are transformed in such a way that they form a
BETWEEN condition (filled with binary zeros or ones beginning at the
first dummy).
.br
It is determined (for the 1st or 2nd value) whether filling is to take
place.  Then the value is gone through.  If it must be filled, it is
filled starting at the first placeholder ('*', '_', '%', '?').
For the first value, '00'h is entered.
ff'h is entered for the second one.  For the
third value, all placeholder
are replaced by the corresponding special
values (star1, any1); the differences between ASCII and EBCDIC are to
be taken into account.
.br
If all data must be entered without length information, this means that
pointers exist in the stack entries.  Therefore, the mess buffer must
be filled to the maximum length corresponding to the value to be read
at the moment (this amount of space would have to be left free during
parsing).
.sp 2
ONE_FIELD_COPY
.sp
A value that is already contained in part2 of the mess buffer is copied
to the end of part2 that is currently built.  In the case of a
'field-information record', this procedure is called with the type
copy_withlen.
.sp 2
RANGE_ERROR
.sp
In the event of an error, this procedure is called after A05_VALUE_IN_RANGE
from A506FIELDVALUES.  It assigns only the global information in VBD06 in
such a way that a subsequent A07_B_PUT_ERROR can use it to form an error text
containing the table name and column name of the column that has violated
the range condition (compare VAK07).
.sp 2
IN_MESS_BUF_MOVE
.sp
This procedure is called if data are to be copied from the parsed
mess buffer to the current mess buffer.  The length to be copied
is specified in total_leng and part1_pos designates the current position
in the parse-information record.  Each parse-information record that has a
successor is filled to the end (parsbuf_length).  The desired part is
copied; the only difficulty is that this part could be divided between
two parse-information records.
.sp 2
VAL_FROM_PART2
.sp
From the SQL_PACKET at the position valpos, this procedure fetches
a value that corresponds to the data type specified in colinfo.  The
data are partially checked for reliability and, if necessary,
ASCII-EBCDIC-converted.
.br
Destpos specifies the position at which the value is to begin in the
info part of part2 of the mess buffer.  Actlen contains the true
(written/to be written) length of the value.
.br
If the precompiler has not correctly filled the data part, an error
is supplied.
.br
If the null value is contained in the SQL_PACKET, the undef byte
is assigned NULL and the value is filled with '00'h.
.br
If the null value is not contained in the SQL_PACKET, the written
length of the value is identified in the case of variable-length fields
(actlen not including the undef byte).  In the case of values with a
fixed length, the inoutlen-1 is declared to be actlen.
.br
The undef byte is assigned according to the data type.  It is not
taken from the SQL_PACKET since it is not assumed that all
user components always assign it properly.
.br
A check is run because no ASCII or EBCDIC field must have '00'h as
its last assigned byte since this would leads to problems in transitions
from page to page (BD side) if this value is inverted.
.br
For FIXED fields, a check is run to determine whether a number with the
specified exponents is displayable in this FIXED field.  For all
numerical values, a check is run in the case of an uneven number of
digits that are allowed in the field, to determine whether one half-byte
too many was written.  It is also checked whether all half-bytes
contain values from 0 to 9 only (no 'a' -  'f').  Otherwise, there
would be invalid numerical entries.
.br
Inputs to DATE and TIME fields must be checked for validity (no 70 min
or 19 months).  This is done via G03_DCHECK_DATE or G03_TCHECK_TIME.
The EBCDIC-ASCII_conversion is already done, if required, for the
check within s8 since all DATE/TIME values are checked as ASCII and
are stored later.  In addition, the TIME value (5-byte minimum length)
must be changed to 8 bytes and again stored in the SQL_PACKET in
this form.
.br
For all non-numerical values, the ASCII-EBCDIC conversion is performed
when they are copied from the SQL_PACKET to the mess buffer.
.br
If the field value must be increased to its maximum length, it is filled
with the appropriate blank or '00'h.
.sp 2
LOCK_FIELDVALUES
.sp
There is a special variant of the mess buffer for lock commands.
40 lock entries are available with a length of 92 bytes each
(lockinfolength).
.sp
The number of lock entries is known (lock_count).  A loop is performed
via the lock entries.
.br
The lock entry that is next is copied from the parsed mess buffer
to the current one.  All field-information records that belong to this
lock entry are then processed in a loop.  Fpfrompos = 0 marks the last
field-information record of a lock entry.
.br
If WHERE CURRENT OF was specified for a lock entry, the 30 bytes to which
the key is to be written contain the name of the result set.  L_len is
located where len is normally located in part2 of the mess buffer.
Since it is operated on by the key procedures, l_len must be set to a
value so that the key is moved to the correct position.
.br
A58_GET_CURRENTKEY is called to take the current key from the result.
.br
Since these procedures cause an implicit change in
part2.keylen (the total length of the key is entered), this length must
be written to lockKeyLen_gg00 in the current lock entry and the value saved
beforehand must again be transferred by mlockc to the mess buffer.
.br
If the key does not g10fil the 30 bytes provided, they are filled with
'00'h because these 30 bytes are always stored in the lock list and
compared, i.e. a defined value must also be in the bytes that are
actually  unimportant.  Since the result-set name was formerly located
in this part, nothing can be said about the layout of this
key part.  It must be assigned accordingly.
.br
If no CURRENT OF is to be used, A506FIELDVALUES is called once for each
parameter (last_fno = fno).  Part2.len must have been appropriately
assigned beforehand (see above) and fptopos must temporarily be set to 0
so that no stack entry for entering the data length is searched for in
A506FIELDVALUES.
.br
If the last key field was specified as a parameter, lockKeyLen_gg00 is set to
the maximum key length.  This means that the maximum length of this
field must be subtracted and its current length added.
This causes the length to be correctly assigned but only the first 30
bytes of the key are stored (the next lock entry overwrites the other
bytes).  The lock-list comparison ends in true only if both the true
length and the first 30 bytes of the key are alike.  Nevertheless, a
'key lock' can still, of course, lead to the locking of several records.
.br
The total length of part2 is the result of: number of lock entries *
lockinfolength + 4.
.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:
 
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
 
 
CONST
      c_old_maxnumbytes= 11;
      c_old_maxnumlen  = 18;
      c_result_wanted  = true    (* a05qualification_test *);
      c_check_new_rec  = true    (* a05qualification_test *);
      c_string         = true    (* s49build_pattern *);
      c_trans_to_uni   = true;   (* a07_hex_uni_err *)
 
 
(*------------------------------*) 
 
PROCEDURE
      ak506normal_value (
            VAR acv        : tak_all_command_glob;
            VAR dmli       : tak_dml_info;
            VAR frec       : tak_fill_rec;
            VAR result     : tsp_moveobj;
            ind            : integer;
            VAR currentdif : integer);
 
VAR
      b_err        : tgg_basis_error;
      one_col      : tak00_columninfo;
      stop_search  : boolean;
      patt_ok      : boolean;
      to_fill      : boolean;
      fill_part1   : boolean;
      ascii_type   : boolean;
      len_add      : boolean;
      lendiff      : integer;
      iolen        : integer; (* length in order interface       *)
      (*                         may be different from cinoutlen *)
      (*                         ddate, dtimestamp               *)
      digits       : integer;
      seq_exp      : integer;
      errorpos     : integer;
      frompos      : integer;
      move_len     : integer;
      start        : integer;
      k            : integer;
      i            : integer;
      ic2          : tsp_int_map_c2;
      seq          : tak_sysbufferaddress;
      sysk         : tgg_sysinfokey;
      seq_name     : tsp_knl_identifier;
 
      sequenceinfo : RECORD
            seq_info : tgg_seq_info;
            seq_id   : tgg_surrogate;
            seq_next : boolean;
            seq_fill : boolean;
      END;
 
 
BEGIN
WITH acv, a_mblock, mb_data^,
     dmli, d_sparr.px[ 1 ]^.sparsinfo, p_pars_infos[ ind ],
     frec DO
    BEGIN
&   ifdef TRACE
    t01int4 (ak_sem, '-fp_movebefo', fp_movebefore_v1);
    t01int4 (ak_sem, '-fp_frompos ', fp_frompos_v1);
    t01int4 (ak_sem, '-fp_extcolno', fp_rangeextcolno);
    t01int4 (ak_sem, '-fp_inoutlen', fp_inoutlen_v1);
    IF  fp_opt in fp_colset
    THEN
        t01name (ak_sem, 'OPTIONAL          ');
    (*ENDIF*) 
    IF  fp_like in fp_colset
    THEN
        t01name (ak_sem, 'LIKE CHECK        ');
    (*ENDIF*) 
    IF  fp_default in fp_colset
    THEN
        t01name (ak_sem, 'DEFAULT           ');
    (*ENDIF*) 
    IF  fp_escape in fp_colset
    THEN
        t01name (ak_sem, 'ESCAPE            ');
    (*ENDIF*) 
    IF  fp_serial in fp_colset
    THEN
        t01name (ak_sem, 'SERIAL            ');
&   endif
    (*ENDIF*) 
    fill_part1 := false;
    IF  fp_movebefore_v1 > 0
    THEN
        IF  fp_kind = fp_val_all_without_l
        THEN
            BEGIN
            fr_total_leng := fp_movebefore_v2 - mb_data_len;
            IF  fr_total_leng > 0
            THEN
                ak506in_mess_buf_move (acv, dmli, frec)
            (*ENDIF*) 
            END
        ELSE
            BEGIN
            fr_total_leng := fp_movebefore_v1;
            ak506in_mess_buf_move (acv, dmli, frec)
            END;
        (*ENDIF*) 
    (*ENDIF*) 
    lendiff := 0;
    iolen   := fp_inoutlen_v1;
    IF  (((fp_kind  = fp_val_varcol_with_len) AND
        (  fp_etype = st_varlongchar))
        OR
        (fp_kind = fp_val_all_with_len))
        AND
        (iolen > cak_maxvarcoliolen)
    THEN
        IF  ((fp_datatyp = dunicode) AND
            ((2 * fp_len_and_frac_v1.lf_datalen) + 1 <= cak_maxvarcoliolen))
            OR
            ((a_in_packet^.sp1_header.sp1h_mess_code in
            [ csp_unicode_swap, csp_unicode ]) AND
            (fp_datatyp in [ dcha, dche,
            dvarchara, dvarchare ]) AND
            (fp_len_and_frac_v1.lf_datalen + 1 <= cak_maxvarcoliolen))
        THEN
            lendiff := 1
        ELSE
            lendiff := 2
        (*ENDIF*) 
    ELSE
        IF  (((fp_kind  = fp_val_varcol_with_len) AND
            (  fp_etype = st_varcol))
            OR
            (fp_kind = fp_val_all_with_len))
        THEN
            lendiff := 1;
        (*ENDIF*) 
    (*ENDIF*) 
    start := mb_data_len + lendiff + 1;
    mb_data_len := mb_data_len + lendiff;
    WITH one_col, ccolstack DO
        BEGIN
        cbinary := false;
        to_fill := false;
        IF  fp_kind = fp_val_all_without_l
        THEN
            BEGIN
            IF  ((fp_stackpos <= 0) OR
                ( fp_stackpos >= a_mblock.mb_qual^.mfirst_free))
            THEN
                to_fill := true
            ELSE
                IF  (NOT (mb_st^ [fp_stackpos].etype in [st_value, st_dummy])
                    OR
                    (mb_st^ [fp_stackpos].epos <> start))
                THEN
                    to_fill := true
                ELSE
                    IF  (mb_st^[ fp_stackpos ].etype = st_value) AND
                        ((mb_st^[ fp_stackpos ].ecol_tab[ 1 ] in
                        [ cgg_param_in_between_expr, cgg_param_in_in_expr]) OR
                        ((mb_st^[ fp_stackpos ].ecol_tab[ 1 ] = chr(0)) AND
                        (mb_st^[ fp_stackpos].ecol_tab[ 2 ] <> chr(0))))
                    THEN
                        to_fill := true
                    (*ENDIF*) 
                (*ENDIF*) 
            (*ENDIF*) 
            END
        ELSE
            IF  (fp_datatyp = dunicode)             AND
                (fp_kind = fp_val_varcol_with_len ) AND
                (fp_etype in [ st_fixkey, st_fixcol ])
            THEN
                to_fill := true;
            (*ENDIF*) 
        (*ENDIF*) 
        cdatafrac := cak_frac_offset;
        IF  fp_kind in [ fp_val_varcol_with_len,
            fp_val_all_with_len,
            fp_val_from_res_buffer ]
        THEN
            BEGIN
            creccolno := fp_rangeextcolno;
            cextcolno := fp_rangeextcolno;
            END
        ELSE
            BEGIN
            creccolno := 0;
            cextcolno := 0
            END;
        (*ENDIF*) 
        errorpos := fp_frompos_v1;
        frompos := fp_frompos_v1;
        cinoutlen := iolen;
        ccolumnn_len  := chr(1);
        ccolumnn      := a01_il_b_identifier;
        ccolpropset   := [  ];
        etype         := fp_etype;
        eop           := op_none;
        epos          := 0;
        elen_var      := 0;
        ecol_tab[ 1 ] := chr(0);
        ecol_tab[ 2 ] := bsp_c1;
        IF  ((fp_frompos_v1 < 0 (* compare with fp_consts*)
            ) AND
            (fp_kind <> fp_val_from_res_buffer))
        THEN
            BEGIN
            IF  fp_frompos_v1 < cak_fp_nextval
            THEN
                BEGIN
                (* NEXTVAL, CURRVAL and SERIAL*)
                move_len := 0;
                IF  fp_serial in fp_colset
                THEN
                    BEGIN
                    cdatalen := fp_len_and_frac_v1.lf_fixed_datalen;
                    IF  cinoutlen > 0
                    THEN
                        BEGIN
                        (* constant was 0, get value from sequence cache *)
                        mbp_buf[start]   := csp_defined_byte;
                        mbp_buf[start+1] := csp_zero_exponent;
                        k                := 2
                        END
                    ELSE
                        BEGIN
                        (* constant <> 0, send value to sequence cache *)
                        start   := start + cinoutlen;
                        k       := -cinoutlen;
                        to_fill := false;
                        END;
                    (*ENDIF*) 
                    a05serial (acv, one_col, mb_qual^.mtree,
                          mbp_buf, mb_data_size, start, k, (mb_type = m_insert));
                    IF  cinoutlen > 0
                    THEN
                        fr_leng := k
                    ELSE
                        fr_leng := 0
                    (*ENDIF*) 
                    END
                ELSE
                    BEGIN
                    IF  fp_kind = fp_val_all_without_l
                    THEN
                        BEGIN
                        fr_total_leng := fp_inoutlen_v2;
                        ak506in_mess_buf_move (acv, dmli, frec);
                        END;
                    (*ENDIF*) 
                    move_len :=
                          sizeof (sequenceinfo.seq_info) +
                          sizeof (sequenceinfo.seq_id  ) +
                          sizeof (sequenceinfo.seq_next);
                    sequenceinfo.seq_fill := false;
                    fr_total_leng := move_len;
                    ak506in_mess_buf_move (acv, dmli, frec);
                    mb_data_len := mb_data_len - move_len;
                    IF  ((fp_kind in [ fp_val_varcol_with_len,
                        fp_selord_val_no_len ]) AND
                        (fp_etype in [ st_varkey, st_fixkey ]))
                    THEN
                        mbp_keylen := mbp_keylen - move_len;
                    (*ENDIF*) 
                    g10mv4 ('VAK506',   1,    
                          mb_data_size, sizeof(sequenceinfo.seq_info) +
                          sizeof (sequenceinfo.seq_id) +
                          sizeof (sequenceinfo.seq_next),
                          mbp_buf, mb_data_len+1,
                          sequenceinfo.seq_info, 1, move_len,
                          a_return_segm^.sp1r_returncode);
                    (* cak_fp_nextval is negative ! *)
                    WITH sequenceinfo DO
                        IF  seq_next
                        THEN
                            a05_nextval_get (acv, mm_nil,
                                  seq_id, seq_info, mbp_buf, start, k)
                        ELSE
                            a05_nextval_get (acv, mm_same,
                                  seq_id, seq_info, mbp_buf, start, k);
                        (*ENDIF*) 
                    (*ENDWITH*) 
                    frec.fr_leng := k;
                    IF  fp_datatyp = dfloat
                    THEN
                        digits := fp_len_and_frac_v1.lf_fixed_datalen
                    ELSE
                        digits := fp_len_and_frac_v1.lf_fixed_datalen -
                              fp_len_and_frac_v1.lf_frac + 1;
                    (*ENDIF*) 
                    seq_exp := ord (mbp_buf[start+1]);
                    IF  (digits < seq_exp - 192) OR
                        (digits < 64 - seq_exp )
                    THEN
                        BEGIN
                        sysk           := a01defaultkey;
                        sysk.stableid  := sequenceinfo.seq_id;
                        sysk.sentrytyp := cak_esequence;
                        a10get_sysinfo (acv, sysk, d_release, seq, b_err);
                        IF  b_err = e_ok
                        THEN
                            seq_name := seq^.ssequence.seq_name
                        ELSE
                            seq_name := a01_il_b_identifier;
                        (*ENDIF*) 
                        a07_nb_put_error (acv, e_num_overflow, 1, seq_name)
                        END
                    (*ENDIF*) 
                    END;
                (*ENDIF*) 
                IF  (cinoutlen > 0) AND (a_return_segm^.sp1r_returncode = 0)
                THEN
                    IF  (to_fill OR
                        (fp_etype in [ st_fixkey, st_fixcol ]))
                    THEN
                        BEGIN
                        IF  iolen > frec.fr_leng
                        THEN
                            g10fil ('VAK506',   2,    
                                  mb_data_size, mbp_buf,
                                  start+frec.fr_leng,
                                  iolen-frec.fr_leng, csp_defined_byte,
                                  a_return_segm^.sp1r_returncode);
                        (*ENDIF*) 
                        frec.fr_leng := iolen;
                        END;
                    (*ENDIF*) 
                (*ENDIF*) 
                IF  fp_kind = fp_val_all_without_l
                THEN
                    mb_data_len := mb_data_len + move_len;
                (*ENDIF*) 
                currentdif := currentdif + move_len - frec.fr_leng;
                END
            ELSE
                BEGIN
                cinoutlen := iolen;
                CASE fp_datatyp OF
                    ddate :
                        cinoutlen := mxsp_date + 1;
                    dtime :
                        cinoutlen := mxsp_time + 1;
                    dtimestamp :
                        cinoutlen := mxsp_timestamp + 1;
                    dunicode :
                        cinoutlen :=
                              (2 * fp_len_and_frac_v1.lf_datalen ) + 1;
                    dcha, dche, dvarchara, dvarchare :
                        cinoutlen :=
                              fp_len_and_frac_v1.lf_datalen + 1;
                    OTHERWISE
                        BEGIN
                        END
                    END;
                (*ENDCASE*) 
&               ifdef TRACE
                t01int4 (ak_sem, 'cinoutlen   ', cinoutlen);
                t01int4 (ak_sem, 'iolen       ', iolen    );
&               endif
                ak506datetime (acv, p_pars_infos[ fr_f_no ], frec,
                      cinoutlen, to_fill, start);
                END;
            (*ENDIF*) 
            frompos := -1
            END
        ELSE
            BEGIN
            cdatafrac := 0;
&           ifdef TRACE
            t01int4 (ak_sem, 'cinoutlen   ', cinoutlen);
            t01int4 (ak_sem, 'fp_datatyp  ', ord(fp_datatyp));
&           endif
            IF  fp_datatyp in [ dfixed, dsmallint, dinteger ]
            THEN
                BEGIN
                cdatatyp  := dfixed;
                cdatalen  := fp_len_and_frac_v1.lf_fixed_datalen;
                cdatafrac := fp_len_and_frac_v1.lf_frac;
                IF  fp_datatyp <> dfixed
                THEN
                    cbinary := true
                (*ENDIF*) 
                END
            ELSE
                IF  fp_datatyp = dfloat
                THEN
                    BEGIN
                    cdatatyp  := dfloat;
                    cdatalen  := fp_len_and_frac_v1.lf_fixed_datalen;
                    cdatafrac := fp_len_and_frac_v1.lf_frac;
                    END
                ELSE
                    BEGIN
                    cdatatyp := fp_datatyp;
                    cdatalen := fp_len_and_frac_v1.lf_datalen
                    END;
                (*ENDIF*) 
            (*ENDIF*) 
&           ifdef TRACE
            t01int4 (ak_sem, 'startpos    ', start);
&           endif
            cinoutlen := iolen;
            CASE cdatatyp OF
                ddate :
                    cinoutlen := mxsp_date + 1;
                dtime :
                    cinoutlen := mxsp_time + 1;
                dtimestamp :
                    cinoutlen := mxsp_timestamp + 1;
                dunicode :
                    cinoutlen := (2 * cdatalen) + 1;
                dcha, dche, dvarchara, dvarchare :
                    cinoutlen := cdatalen + 1;
                OTHERWISE
                    BEGIN
                    END
                END;
            (*ENDCASE*) 
&           ifdef TRACE
            t01int4 (ak_sem, 'cinoutlen   ', cinoutlen);
&           endif
            IF  fp_kind = fp_val_from_res_buffer
            THEN
                BEGIN
                a55_const_from_resbuf (acv, result, one_col,
                      fp_glob_fp_kind, start, i, fp_res_buf_index);
                fr_leng := i
                END
            ELSE
                IF  a_data_ptr = NIL
                THEN
                    a07_b_put_error (acv, e_too_short_datapart, 1)
                ELSE
                    IF  a_data_ptr^[ fp_frompos_v1 ] = csp_default_byte
                    THEN
                        IF  fp_default in fp_colset
                        THEN
                            BEGIN
                            mb_data_len := mb_data_len - lendiff;
                            lendiff     := 0;
                            ccolpropset := [  ];
                            a56one_default_value(acv, dmli, one_col,
                                  fp_kind);
                            IF  a_input_data_pos < (fp_frompos_v1 + iolen)
                            THEN
                                a_input_data_pos := fp_frompos_v1 + iolen;
                            (*ENDIF*) 
                            IF  a_return_segm^.sp1r_returncode = 0
                            THEN
                                IF  ((fp_etype = st_varkey)
                                    OR
                                    (fp_etype = st_fixkey))
                                THEN
                                    fr_leng := mb_data_len -
                                          cgg_rec_key_offset - mbp_keylen
                                (*ENDIF*) 
                            (*ENDIF*) 
                            END
                        ELSE
                            a07_b_put_error (acv,
                                  e_default_not_allowed, -errorpos)
                        (*ENDIF*) 
                    ELSE
                        (* PTS 1106107 E.Z. *)
                        ak506val_from_part2 (acv, fp_frompos_v1, fp_kind,
                              one_col, iolen, frec, to_fill);
                    (*ENDIF*) 
                (*ENDIF*) 
            (*ENDIF*) 
            IF  fp_serial in fp_colset
            THEN
                BEGIN
                i := fr_leng;
                a05serial (acv, one_col, mb_qual^.mtree,
                      mbp_buf, mb_data_size, start, i, (mb_type = m_insert));
                fr_leng := i
                END;
            (*ENDIF*) 
            IF  ((a_return_segm^.sp1r_returncode = 0) AND
                (fp_kind = fp_val_all_without_l)
                AND
                NOT to_fill)
            THEN
                mb_st^ [fp_stackpos].elen_var := fr_leng;
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        IF  ((a_return_segm^.sp1r_returncode = 0) AND
            (NOT fill_part1))
        THEN
            BEGIN
            IF  lendiff = 1
            THEN
                mbp_buf[ start-1 ] := chr(fr_leng)
            ELSE
                IF  lendiff = 2
                THEN
                    BEGIN
                    ic2.map_int := fr_leng;
                    mbp_buf[ start-2 ] := ic2.map_c2[ 1 ];
                    mbp_buf[ start-1 ] := ic2.map_c2[ 2 ]
                    END;
                (*ENDIF*) 
            (*ENDIF*) 
            IF  ((fp_kind in [ fp_val_varcol_with_len,
                fp_selord_val_no_len ]) AND
                (fp_etype in [ st_varkey, st_fixkey ]))
            THEN
                BEGIN
                mbp_keylen := mbp_keylen + fr_leng;
                IF  ((fp_kind = fp_selord_val_no_len) AND
                    (fp_stackpos <> 0))
                THEN (*  add up start-/stopkeylengths*)
                    WITH mb_st^ [fp_stackpos] DO
                        elen_var := elen_var + fr_leng;
                    (*ENDWITH*) 
                (*ENDIF*) 
                END;
            (*ENDIF*) 
            IF  mbp_buf[ start ] = csp_undef_byte
            THEN
                IF  NOT (fp_opt in fp_colset)
                THEN
                    a07_b_put_error (acv,
                          e_mandatory_field_is_null, -errorpos);
                (*ENDIF*) 
            (*ENDIF*) 
            IF  fp_like in fp_colset
            THEN
                BEGIN
                (*  ================= *)
                (*  Replacement of    *)
                (*   '*','%','?','_'  *)
                (*  by 'xFF' and 'xFE'*)
                (*  in buffer         *)
                (*  ================= *)
                i := start + 1;
                stop_search := false;
                IF  fp_datatyp = dunicode
                THEN
                    BEGIN
                    WHILE (i < start + fr_leng) AND
                          NOT stop_search DO
                        IF  ((fp_escape in fp_colset) AND
                            (mbp_buf[ i   ] = dmli.d_escape_char[ 1 ]) AND
                            (mbp_buf[ i+1 ] = dmli.d_escape_char[ 2 ]))
                        THEN
                            i := i+4
                        ELSE
                            IF  ((mbp_buf [ i   ] = csp_unicode_mark) AND
                                ((a_sqlmode = sqlm_adabas) AND
                                ((mbp_buf[ i+1 ] = csp_ascii_star) OR
                                ( mbp_buf[ i+1 ] = csp_ascii_question_mark) OR
                                ( mbp_buf[ i+1 ] = csp_ascii_open_bracket))) OR
                                ( mbp_buf[ i+1 ] = csp_ascii_underline) OR
                                ( mbp_buf[ i+1 ] = csp_ascii_percent))
                            THEN
                                stop_search := true
                            ELSE
                                i := i + 2
                            (*ENDIF*) 
                        (*ENDIF*) 
                    (*ENDWHILE*) 
                    END
                ELSE
                    BEGIN
                    WHILE (i < start + fr_leng) AND
                          NOT stop_search DO
                        IF  ((fp_escape in fp_colset) AND
                            (mbp_buf[ i ] = dmli.d_escape_char[ 2 ]))
                        THEN
                            i := i+2
                        ELSE
                            IF  (((fp_datatyp      = dche)
                                AND
                                (((a_sqlmode = sqlm_adabas) AND
                                ((mbp_buf[ i ] = csp_ebcdic_star) OR
                                ( mbp_buf[ i ] = csp_ebcdic_question_mark) OR
                                ( mbp_buf[ i ] = csp_ebcdic_open_bracket))) OR
                                ( mbp_buf[ i ] = csp_ebcdic_underline) OR
                                ( mbp_buf[ i ] = csp_ebcdic_percent)))
                                OR
                                ((fp_datatyp      <> dche)
                                AND
                                (((a_sqlmode = sqlm_adabas) AND
                                ((mbp_buf[ i ] = csp_ascii_star) OR
                                ( mbp_buf[ i ] = csp_ascii_question_mark) OR
                                ( mbp_buf[ i ] = csp_ascii_open_bracket))) OR
                                ( mbp_buf[ i ] = csp_ascii_underline) OR
                                ( mbp_buf[ i ] = csp_ascii_percent))))
                            THEN
                                stop_search := true
                            ELSE
                                i := succ(i);
                            (*ENDIF*) 
                        (*ENDIF*) 
                    (*ENDWHILE*) 
                    END;
                (*ENDIF*) 
&               ifdef TRACE
                t01int4 (ak_sem, 'fr_leng     ', fr_leng);
                t01int4 (ak_sem, 'i           ', i);
                t01int4 (ak_sem, 'cinoutlen   ', cinoutlen);
                t01int4 (ak_sem, 'start       ', start);
&               endif
                IF  (start+fr_leng-i > 0)
                THEN
                    IF  fp_like1 in fp_colset
                    THEN
                        IF  mbp_buf[ start ] = csp_unicode_def_byte
                        THEN
                            g10filuni ('VAK506',   3,    
                                  mb_data_size, mbp_buf, i,
                                  start + frec.fr_leng - i, csp_unicode_blank,
                                  a_return_segm^.sp1r_returncode)
                        ELSE
                            g10fil ('VAK506',   4,    
                                  mb_data_size, mbp_buf, i,
                                  start + fr_leng - i, mbp_buf [start],
                                  a_return_segm^.sp1r_returncode)
                        (*ENDIF*) 
                    ELSE
                        IF  fp_like2 in fp_colset
                        THEN
                            BEGIN
                            g10fil ('VAK506',   5,    
                                  mb_data_size, mbp_buf, i,
                                  start + cinoutlen - i, chr(255),
                                  a_return_segm^.sp1r_returncode);
                            IF  ((a_return_segm^.sp1r_returncode = 0) AND
                                (fp_kind = fp_val_all_without_l)
                                AND
                                NOT to_fill)
                            THEN
                                mb_st^ [fp_stackpos].elen_var := cinoutlen;
                            (*ENDIF*) 
                            END;
                        (*ENDIF*) 
                    (*ENDIF*) 
                (*ENDIF*) 
                patt_ok    := false;
                IF  fp_datatyp = dunicode
                THEN
                    s49uni_build_pattern (mbp_buf, start + 1,
                          start + fr_leng - 1, dmli.d_escape_char,
                          fp_escape in fp_colset,
                          sqlm_ansi, patt_ok)
                ELSE
                    BEGIN
                    ascii_type := NOT(
                          (fp_datatyp  = dche)
                          OR
                          ((fp_datatyp = dchb)
                          AND
                          (g01code.ctype = csp_ebcdic)));
                    s49build_pattern (mbp_buf, ascii_type, start + 1,
                          start + fr_leng - 1, dmli.d_escape_char[ 2 ],
                          fp_escape in fp_colset, NOT c_string,
                          sqlm_ansi, patt_ok );
                    END;
                (*ENDIF*) 
                IF  NOT patt_ok
                THEN
                    IF  a_sqlmode = sqlm_ansi
                    THEN
                        a07_b_put_error ( acv,
                              e_illegal_escape_sequence, 1)
                    ELSE
                        a07_b_put_error ( acv,
                              e_invalid_pattern, 1);
                    (*ENDIF*) 
                (*ENDIF*) 
                END;
            (*ENDIF*) 
            IF  (frompos < 0) OR
                (fp_kind = fp_val_from_res_buffer)
            THEN
                len_add := true
            ELSE
                IF  a_data_ptr^[ frompos ] <> csp_default_byte
                THEN
                    len_add := true
                ELSE
                    len_add := false;
                (*ENDIF*) 
            (*ENDIF*) 
            IF  len_add
            THEN
                BEGIN
                IF  fp_kind = fp_val_all_without_l
                THEN
                    BEGIN
                    mb_data_len := mb_data_len + cinoutlen;
                    d_pos_in_parsbuf := d_pos_in_parsbuf + cinoutlen;
                    END
                ELSE
                    mb_data_len := mb_data_len + fr_leng;
                (*ENDIF*) 
                END;
            (*ENDIF*) 
            END
        (*ENDIF*) 
        END
    (*ENDWITH*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      a506fieldvalues (
            VAR acv       : tak_all_command_glob;
            VAR dmli      : tak_dml_info;
            VAR frec      : tak_fill_rec;
            viewkeybuf    : tak_sysbufferaddress;
            VAR result    : tsp_moveobj;
            resultBufSize : tsp00_Int4); (* PTS 1115085 *)
 
CONST
      ak506swap_unicode_blank = '\20\00';
 
VAR
      currentdif   : integer;
      k            : integer;
      ind          : integer;
      escape_c2    : tsp_c2;
      uniinlen     : integer;
      univallen    : integer;
      data_len     : tsp_int4;
      error        : tsp8_uni_error;
      err_char_no  : tsp_int4;
      currentnam   : tsp_knl_identifier;
      mblock       : tgg_mess_block;
 
BEGIN
currentdif := 0;
data_len   := 0;
dmli.d_first_longdesc_pos := 0;
dmli.d_cnt_longdesc       := 0;
dmli.d_longdesc_found     := false;
IF  (acv.a_in_packet^.sp1_header.sp1h_mess_code = csp_unicode) OR
    (acv.a_in_packet^.sp1_header.sp1h_mess_swap = sw_normal)
THEN
    frec.fr_uni_fill_c2 := csp_unicode_blank
ELSE
    frec.fr_uni_fill_c2 := ak506swap_unicode_blank;
(*ENDIF*) 
WHILE ((frec.fr_f_no <= frec.fr_last_fno) AND
      (acv.a_return_segm^.sp1r_returncode = 0)) DO
    BEGIN
    (* *** Make shure, that index "fr_f_no" will not be changed     *)
    (*     in different WITH statements                         *** *)
    ind := frec.fr_f_no;
    WITH acv, dmli, frec, a_mblock, mb_data^,
         d_sparr.px[ 1 ]^.sparsinfo, p_pars_infos[ ind ] DO
        BEGIN
&       ifdef TRACE
        t01name (ak_sem, 'one parse-task :  ');
        t01int4 (ak_sem, '-reclen     ', mbp_reclen);
        t01int4 (ak_sem, '-datalen    ', mb_data_len);
        t01int4 (ak_sem, '-fp_kind    ', ord(fp_kind));
        t01int4 (ak_sem, '-fp_etype   ', ord(fp_etype));
        t01int4 (ak_sem, '-fp_datatyp ', ord(fp_datatyp     ));
        t01buf1 (ak_sem, p_pars_infos[ ind ], 5, 16);
        t01int4 (ak_sem, 'frec.fr_f_no', frec.fr_f_no);
        t01int4 (ak_sem, '-fp_movebefo', fp_movebefore_v1);
        t01int4 (ak_sem, '-fp_frompos ', fp_frompos_v1);
        t01int4 (ak_sem, '-fp_extcolno', fp_rangeextcolno);
        t01int4 (ak_sem, '-fp_inoutlen', fp_inoutlen_v1);
&       endif
        CASE fp_kind OF
            fp_result_name :
                BEGIN
                (* skip pars info *)
                END;
            fp_catalog_column :
                ak506catalog_val_from_datapart (acv, fp_etype,
                      fp_frompos_v1, fp_inoutlen_v1);
            fp_current_of_key :
                BEGIN
                fr_total_leng := fp_curr_keylen+fp_movebefore_v5;
                ak506in_mess_buf_move (acv, dmli, frec);
                mb_data_len := mb_data_len-fp_curr_keylen;
                g10mv3 ('VAK506',   6,    
                      mb_data_size, sizeof(currentnam), mbp_buf,
                      mb_data_len + 1,
                      currentnam, 1, sizeof(currentnam),
                      a_return_segm^.sp1r_returncode);
                a58_get_currentkey (acv, currentnam, p_tabid, 1);
                IF  ((mb_type  =  m_select_row) AND
                    ( mb_type2 <> mm_direct))
                THEN
                    mb_st^ [mb_qual^.mstrat_pos].elen_var := mbp_keylen;
                (*ENDIF*) 
                currentdif := fp_curr_keylen-mbp_keylen;
                END;
            fp_escape_val :
                dmli.d_escape_char := fp_escape_char;
            fp_fill_part2_to_len :
                BEGIN
                fr_total_leng := fp_len - mb_data_len - currentdif;
                ak506in_mess_buf_move (acv, dmli, frec);
                mb_data_len   := mb_data_len + currentdif;
                currentdif    := 0;
&               ifdef TRACE
                t01int4 (ak_sem, 'pos_in_parsb', d_pos_in_parsbuf);
                t01messblock (ak_sem, 'MBLOCK 506fi', a_mblock);
&               endif
                d_pos_in_parsbuf := succ(fp_len);
&               ifdef TRACE
                t01messblock (ak_sem, 'MBLOCK 506fi', a_mblock);
                t01int4 (ak_sem, 'total_leng  ', fr_total_leng);
                t01int4 (ak_sem, 'pos_in_parsb', d_pos_in_parsbuf);
&               endif
                END;
            fp_ordered_select_key :
                ak506one_field_copy (acv, dmli, frec);
            fp_pseudo_ins_select :
                BEGIN
                fr_total_leng := fp_movebeforev11;
                ak506in_mess_buf_move (acv, dmli, frec);
                ak506pseudo_insert_select (acv, dmli);
                WITH d_sparr.px[ d_sparr.pcount ]^.smessblock DO
                    d_pos_in_parsbuf := mbr_mess_block.mb_data_size + 1;
                (*ENDWITH*) 
                END;
            fp_reclen :
                BEGIN
                fr_total_leng := fp_movebefore_v4;
                ak506in_mess_buf_move (acv, dmli, frec);
                mb_data^.mbp_reclen := mb_data_len;
                IF  (mb_type = m_insert) AND
                    (mb_data^.mbp_reclen > mxgg_record)
                THEN
                    a07_b_put_error (acv, e_too_long_record,
                          -mxgg_record)
                (*ENDIF*) 
                END;
            fp_syskey :
                a56syskey (acv, dmli);
            fp_temp_table_key :
                BEGIN
                fr_total_leng := fp_movebeforev11;
                IF  ((fr_total_leng = 0) AND (d_pos_in_parsbuf = 1))
                THEN
                    BEGIN
                    fr_total_leng := cgg_rec_key_offset+2+mxgg_surrogate;
                    ak506in_mess_buf_move (acv, dmli, frec);
                    END
                ELSE
                    BEGIN
                    ak506in_mess_buf_move (acv, dmli, frec);
                    d_pos_in_parsbuf := d_pos_in_parsbuf + mxgg_surrogate;
                    END;
                (*ENDIF*) 
&               ifdef TRACE
                t01messblock (ak_sem, 'MBLOCK 506fi', a_mblock);
&               endif
                a56temp_table_key (acv, dmli);
                IF  a_mblock.mb_type = m_insert_select
                THEN
                    IF  mb_data_len < cgg_rec_key_offset+2+mxgg_surrogate
                    THEN
                        mb_data_len := cgg_rec_key_offset+2+mxgg_surrogate
                    (*ENDIF*) 
                (*ENDIF*) 
                END;
            fp_use_old_values_up_to_len :
                BEGIN
                IF  a_mblock.mb_type = m_insert_select
                THEN
                    BEGIN
                    fr_total_leng := 2; (* byte 5,6 duplicate_spec*)
                    ak506in_mess_buf_move (acv, dmli, frec);
                    d_pos_in_parsbuf := succ(fp_len) - 2;
                    mb_data_len := fp_len
                    END
                ELSE
                    IF  d_corr = correlation
                    THEN
                        BEGIN
                        (* build new parsinfo incl. data *)
                        fr_total_leng := fp_len - mb_data_len - currentdif;
                        ak506in_mess_buf_move (acv,
                              dmli, frec);
                        END
                    ELSE
                        BEGIN
                        d_pos_in_parsbuf := succ(fp_len);
                        mb_data_len := fp_len;
                        END
                    (*ENDIF*) 
                (*ENDIF*) 
                END;
            fp_verify_constraint :
                BEGIN
                fr_total_leng := fp_movebeforev11;
                ak506in_mess_buf_move (acv, dmli, frec);
&               ifdef TRACE
                t01messblock (ak_sem, 'MBLOCK 506fi', a_mblock);
&               endif
                a05constraint_fulfilled (acv,a_mblock.mb_data^.mbp_rec,
                      a_mblock.mb_qual^.mtree, fp_reccolno)
                END;
            fp_verify_not_null :
                BEGIN
                (* PTS 1001154 E.Z. *)
                a05_verify_not_null (acv, a_mblock.mb_data^.mbp_rec,
                      fp_stackentry);
                END;
            fp_verify_view :
                BEGIN
                fr_total_leng := fp_movebeforev11;
                ak506in_mess_buf_move (acv, dmli, frec);
&               ifdef TRACE
                t01messblock (ak_sem, 'MBLOCK 506fi', a_mblock);
&               endif
                mblock.mb_header       := a_mblock.mb_header;
                mblock.mb_trailer      := a_mblock.mb_trailer;
                mblock.mb_work_st      := a_work_st_addr;
                mblock.mb_work_st_max  := a_work_st_max;
                mblock.mb_workbuf      := a_work_buf_addr;
                mblock.mb_workbuf_size := a_work_buf_size;
                a05qualification_test (acv, mblock,
                      NOT c_result_wanted, c_check_new_rec, 1,
                      a_mblock.mb_data^.mbp_rec, result, resultBufSize (* PTS 1115085 *), k);
                a_mblock.mb_header := mblock.mb_header;
                IF  a_return_segm^.sp1r_returncode <> 0
                THEN
                    a_transinf.tri_trans.trState_gg00 :=
                          mblock.mb_trns^.trState_gg00
                ELSE
                    a_mblock.mb_qual^.mview_cnt := 0;
                (*ENDIF*) 
                END;
            fp_viewkey_to_mess_buf :
                WITH viewkeybuf^.sviewkey DO
                    BEGIN
                    d_pos_in_parsbuf := d_pos_in_parsbuf + cgg_rec_key_offset;
                    mbp_keylen  := vkjvkeylen;
                    mb_data_len := mbp_keylen+cgg_rec_key_offset;
                    currentdif := fp_curr_keylen-mbp_keylen;
                    g10mv5 ('VAK506',   7,    
                          sizeof(vkjvkey), mb_data_size, vkjvkey, 1,
                          mbp_buf, cgg_rec_key_offset + 1,
                          mbp_keylen,
                          a_return_segm^.sp1r_returncode);
&                   ifdef TRACE
                    t01int4 (ak_sem, 'currentdif  ', currentdif);
&                   endif
                    END;
                (*ENDWITH*) 
            (* PTS 1111577 E.Z. *)
            fp_get_name_value :
                BEGIN
                fr_total_leng := fp_movebefore_v15 - mb_data_len;
                IF  fr_total_leng > 0
                THEN
                    ak506in_mess_buf_move (acv, dmli, frec);
                (*ENDIF*) 
                IF  a_data_ptr^[ fp_frompos_v15 ] = csp_undef_byte
                THEN
                    a07_b_put_error (acv, e_mandatory_field_is_null,
                          -fp_frompos_v15)
                ELSE
                    BEGIN
                    currentnam := a01_il_b_identifier;
                    (* PTS 1112167 E.Z. *)
                    IF  g01unicode AND
                        (acv.a_in_packet^.sp1_header.sp1h_mess_swap <> sw_normal) AND
                        (acv.a_in_packet^.sp1_header.sp1h_mess_code <> csp_unicode)
                    THEN
                        BEGIN
                        (* PTS 1114579 E.Z. *)
                        univallen  := fp_inoutlen_v1 - 1;
                        s80uni_trans (@a_data_ptr^[ fp_frompos_v1+1], fp_inoutlen_v1 - 1,
                              csp_unicode_swap,
                              @a_data_ptr^[ fp_frompos_v1+1], univallen, csp_unicode,
                              [ ], error, err_char_no);
                        IF  error <> uni_ok
                        THEN
                            BEGIN
&                           ifdef TRACE
                            t01int4 (ak_sem, 'err_char_no ', err_char_no);
&                           endif
                            a07_hex_uni_error (acv, error,
                                  -(fp_frompos_v1+err_char_no), c_trans_to_uni,
                                  @(a_data_ptr^[ fp_frompos_v1 + err_char_no ]),
                                  a_max_codewidth);
                            END
                        (*ENDIF*) 
                        END;
                    (*ENDIF*) 
                    a641_get_name (acv, a_data_part,
                          succ(fp_frompos_v15), pred(fp_inoutlen_v15),
                          (fp_sc_symbol = s_get_owner), ord(fp_objecttype[1]),
                          currentnam);
                    (* PTS 1112167 E.Z. *)
                    (* leave data unchanged in the end in case we come along for the second time *)
                    IF  g01unicode AND
                        (acv.a_in_packet^.sp1_header.sp1h_mess_swap <> sw_normal) AND
                        (acv.a_in_packet^.sp1_header.sp1h_mess_code <> csp_unicode)
                    THEN
                        BEGIN
                        (* PTS 1114579 E.Z. *)
                        univallen  := fp_inoutlen_v1 - 1;
                        s80uni_trans (@a_data_ptr^[ fp_frompos_v1+1], fp_inoutlen_v1 - 1,
                              csp_unicode,
                              @a_data_ptr^[ fp_frompos_v1+1], univallen, csp_unicode_swap,
                              [ ], error, err_char_no);
                        IF  error <> uni_ok
                        THEN
                            BEGIN
&                           ifdef TRACE
                            t01int4 (ak_sem, 'err_char_no ', err_char_no);
&                           endif
                            a07_hex_uni_error (acv, error,
                                  -(fp_frompos_v1+err_char_no), c_trans_to_uni,
                                  @(a_data_ptr^[ fp_frompos_v1 + err_char_no ]),
                                  a_max_codewidth);
                            END
                        (*ENDIF*) 
                        END;
                    (*ENDIF*) 
                    IF  currentnam = a01_il_b_identifier
                    THEN
                        BEGIN
                        mbp_buf[mb_data_len+1] := csp_undef_byte;
                        g10fil ('VAK506',   8,    
                              mb_data_size, mbp_buf, mb_data_len+2,
                              fp_inoutlen_v15 - 1, csp_defined_byte,
                              a_return_segm^.sp1r_returncode)
                        END
                    ELSE
                        BEGIN
                        IF  fp_datatyp = dunicode
                        THEN
                            mbp_buf[mb_data_len+1] := csp_unicode_def_byte
                        ELSE
                            mbp_buf[mb_data_len+1] := csp_ascii_blank;
                        (*ENDIF*) 
                        g10mv11 ('VAK506',   9,    
                              sizeof(currentnam), mb_data_size, currentnam, 1,
                              mbp_buf, mb_data_len+2, sizeof(currentnam),
                              a_return_segm^.sp1r_returncode);
                        IF  mbp_buf[mb_data_len+1] = csp_unicode_def_byte
                        THEN
                            g10filuni ('VAK506',  10,    
                                  mb_data_size, mbp_buf, mb_data_len+2+sizeof(currentnam),
                                  fp_inoutlen_v15 - 1 - sizeof(currentnam), csp_unicode_blank,
                                  a_return_segm^.sp1r_returncode)
                        ELSE
                            g10fil ('VAK506',  11,    
                                  mb_data_size, mbp_buf, mb_data_len+2+sizeof(currentnam),
                                  fp_inoutlen_v15 - 1 - sizeof(currentnam), csp_ascii_blank,
                                  a_return_segm^.sp1r_returncode)
                        (*ENDIF*) 
                        END;
                    (*ENDIF*) 
                    mb_data_len := mb_data_len + fp_inoutlen_v15;
                    END
                (*ENDIF*) 
                END;
            OTHERWISE
                IF  fp_datatyp in [dstra, dstre, dstrb, dstrdb, dstruni,
                    dlonga, dlonge, dlonguni, dlongb, dlongdb]
                THEN
                    ak506long_support (acv, dmli, frec, ind)
                ELSE
                    IF  ((fp_kind = fp_val_all_without_l) AND
                        (fp_escape in fp_colset) AND
                        NOT (fp_like in fp_colset))
                    THEN
                        IF  a_data_ptr = NIL
                        THEN
                            a07_b_put_error (acv, e_too_short_datapart, 1)
                        ELSE
                            (* escape_char as parameter *)
                            IF  a_data_ptr^[ fp_frompos_v1 ]
                                = csp_undef_byte
                            THEN
                                a07_b_put_error (acv,
                                      e_mandatory_field_is_null,
                                      -fp_frompos_v1)
                            ELSE
                                BEGIN
                                IF  (fp_datatyp      = dche       ) OR
                                    (fp_datatyp      = dcha       )
                                THEN
                                    g02fromtermchar (a_mess_code, a_data_ptr^,
                                          fp_frompos_v1 + 1, 1);
                                (*ENDIF*) 
                                IF  ((a_in_packet^.sp1_header.sp1h_mess_code
                                    <= cgg_end_termsets) AND
                                    ((fp_datatyp = dche) OR
                                    ( fp_datatyp = dcha))
                                    ) OR
                                    (fp_datatyp = dchb)
                                THEN
                                    dmli.d_escape_char[ 2 ] :=
                                          a_data_ptr^[
                                          fp_frompos_v1 + 1 ]
                                ELSE
                                    IF  fp_datatyp = dunicode
                                    THEN
                                        IF  a_in_packet^.sp1_header.sp1h_mess_swap = sw_normal
                                        THEN
                                            BEGIN
                                            dmli.d_escape_char[ 1 ] := a_data_ptr^[ fp_frompos_v1+1];
                                            dmli.d_escape_char[ 2 ] := a_data_ptr^[ fp_frompos_v1+2];
                                            END
                                        ELSE
                                            BEGIN
                                            dmli.d_escape_char[ 1 ] := a_data_ptr^[ fp_frompos_v1+2];
                                            dmli.d_escape_char[ 2 ] := a_data_ptr^[ fp_frompos_v1+1];
                                            END
                                        (*ENDIF*) 
                                    ELSE
                                        BEGIN
                                        IF  a_in_packet^.sp1_header.sp1h_mess_code in
                                            [ csp_unicode, csp_unicode_swap ]
                                        THEN
                                            uniinlen := fp_inoutlen_v1 - 1
                                        ELSE
                                            uniinlen := s30lnr (a_data_ptr^, csp_ascii_blank,
                                                  fp_frompos_v1 + 1, fp_inoutlen_v1 - 1);
                                        (*ENDIF*) 
                                        univallen := 2;
                                        s80uni_trans (@a_data_ptr^[ fp_frompos_v1+1], uniinlen,
                                              a_in_packet^.sp1_header.sp1h_mess_code,
                                              @escape_c2, univallen, csp_unicode,
                                              [ ], error, err_char_no);
                                        IF  error = uni_ok
                                        THEN
                                            BEGIN
                                            uniinlen := 1;
                                            s80uni_trans (@escape_c2, univallen, csp_unicode,
                                                  @dmli.d_escape_char[ 2 ], uniinlen, csp_ascii,
                                                  [ ], error, err_char_no);
                                            END;
                                        (*ENDIF*) 
                                        IF  error <> uni_ok
                                        THEN
                                            BEGIN
&                                           ifdef TRACE
                                            t01int4 (ak_sem, 'err_char_no ', err_char_no);
&                                           endif
                                            a07_hex_uni_error (acv, error,
                                                  -(fp_frompos_v1+err_char_no), c_trans_to_uni,
                                                  @(a_data_ptr^[ fp_frompos_v1 + err_char_no ]),
                                                  a_max_codewidth);
                                            END
                                        (*ENDIF*) 
                                        END;
                                    (*ENDIF*) 
                                (*ENDIF*) 
                                IF  ((a_basic_code   <> csp_ebcdic) AND
                                    ( fp_datatyp      = dche))
                                THEN
                                    g02p1ascii_pos_ebcdic (dmli.d_escape_char, 2,
                                          dmli.d_escape_char, 2, 1)
                                ELSE
                                    IF  ((a_basic_code    = csp_ebcdic) AND
                                        ( fp_datatyp      = dcha))
                                    THEN
                                        g02p1ebcdic_pos_ascii (
                                              dmli.d_escape_char, 2,
                                              dmli.d_escape_char, 2, 1)
                                    (*ENDIF*) 
                                (*ENDIF*) 
                                END
                            (*ENDIF*) 
                        (*ENDIF*) 
                    ELSE
                        ak506normal_value (acv, dmli, frec,
                              result, ind, currentdif);
                    (*ENDIF*) 
                (*ENDIF*) 
            END;
        (*ENDCASE*) 
        END;
    (*ENDWITH*) 
    IF  acv.a_stored_proc_call AND
        (acv.a_mblock.mb_data_len > data_len)
    THEN
        data_len := acv.a_mblock.mb_data_len;
    (*ENDIF*) 
    frec.fr_f_no := succ(frec.fr_f_no)
    END;
(*ENDWHILE*) 
IF  acv.a_stored_proc_call
THEN
    acv.a_mblock.mb_data_len := data_len;
&ifdef trace
(*ENDIF*) 
t01messblock (ak_sem, 'MBLOCK 506fi', acv.a_mblock);
&endif
END;
 
(*------------------------------*) 
 
PROCEDURE
      a506lock_fieldvalues (
            VAR acv    : tak_all_command_glob;
            VAR dmli   : tak_dml_info;
            VAR frec   : tak_fill_rec;
            viewkeybuf : tak_sysbufferaddress);
 
VAR
      last_value     : boolean;
      i              : integer;
      currentnam     : tsp_knl_identifier;
      nil_surrogate  : tgg_surrogate;
 
BEGIN
WITH dmli, frec, acv, a_mblock, mb_qual^ DO
    BEGIN
    nil_surrogate := cgg_zero_id;
    fr_f_no       := 1;
    i             := 1;
    a_mblock.mb_data_len := cgg_rec_key_offset;
    d_pos_in_parsbuf := d_pos_in_parsbuf + cgg_rec_key_offset;
&   ifdef trace
    t01int4 (ak_sem, 'lock_count  ', mlock_cnt);
    t01int4 (ak_sem, 'p_cnt_infos ',
          d_sparr.px[ 1 ]^.sparsinfo.p_cnt_infos);
&   endif
    WHILE ((i <= mlock_cnt) AND (a_return_segm^.sp1r_returncode = 0)) DO
        BEGIN
&       ifdef TRACE
        t01messblock (ak_sem, 'MBLOCK 506lo', a_mblock);
&       endif
        IF  ((mlock[ i ].lockMode_gg00 <> lckTabShare_egg00) AND
            (mlock[ i ].lockMode_gg00 <> lckTabExcl_egg00))
        THEN
            BEGIN
            mlock[ i ].lockKeyPos_gg00 := a_mblock.mb_data_len-cgg_rec_key_offset+1;
            IF  fr_f_no <= d_sparr.px[ 1 ]^.sparsinfo.p_cnt_infos
            THEN
                BEGIN
                last_value := false;
                WHILE (NOT last_value AND (a_return_segm^.sp1r_returncode = 0)) DO
                    BEGIN
                    WITH d_sparr.px[ 1 ]^.sparsinfo,
                         p_pars_infos[ fr_f_no ] DO
                        IF  fp_kind = fp_last_lock
                        THEN
                            BEGIN
                            IF  fp_movebefore_v4 > 0
                            THEN
                                BEGIN
                                fr_total_leng := fp_movebefore_v4;
                                ak506in_mess_buf_move (acv,
                                      dmli, frec)
                                END;
                            (*ENDIF*) 
                            last_value := true;
                            WITH mlock[ i ] DO
                                lockKeyLen_gg00 :=
                                      a_mblock.mb_data_len -
                                      cgg_rec_key_offset + 1 - lockKeyPos_gg00
                            (*ENDWITH*) 
                            END
                        ELSE
                            IF  fp_kind = fp_lock_val
                            THEN
                                BEGIN
                                fr_last_fno := fr_f_no;
                                a506fieldvalues (acv, dmli, frec, viewkeybuf,
                                      a_mblock.mb_data^.mbp_buf, a_mblock.mb_data_size);
                                END
                            ELSE
                                WITH mlock[ i ] DO
                                    BEGIN
                                    fr_f_no       := succ(fr_f_no);
                                    fr_total_leng := fp_curr_keylen+fp_movebefore_v5;
                                    ak506in_mess_buf_move (acv,
                                          dmli, frec);
&                                   ifdef TRACE
                                    t01int4 (ak_sem, 'total_leng  ',
                                          fr_total_leng);
                                    t01int4 (ak_sem, 'pos_in_parsb',
                                          d_pos_in_parsbuf);
                                    t01messblock (ak_sem, 'MBLOCK 506lo', a_mblock);
&                                   endif
                                    mb_data_len := mb_data_len-fp_curr_keylen;
                                    g10mv3 ('VAK506',  12,    
                                          mb_data_size, sizeof (currentnam),
                                          mb_data^.mbp_buf,
                                          mb_data_len+1, currentnam, 1,
                                          sizeof(currentnam),
                                          a_return_segm^.sp1r_returncode);
                                    a58_get_currentkey (acv, currentnam,
                                          nil_surrogate, 1);
                                    END;
                                (*ENDWITH*) 
                            (*ENDIF*) 
                        (*ENDIF*) 
                    (*ENDWITH*) 
                    END;
                (*ENDWHILE*) 
                fr_f_no := succ(fr_f_no);
&               ifdef TRACE
                t01messblock (ak_sem, 'MBLOCK 506lo', a_mblock);
&               endif
                END
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        i := succ(i)
        END;
    (*ENDWHILE*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      a506result_name (
            VAR acv     : tak_all_command_glob;
            VAR dmli    : tak_dml_info);
 
VAR
      movelen     : integer;
      err_char_no : tsp_int4;
      uni_err     : tsp8_uni_error;
 
BEGIN
WITH acv, dmli.d_sparr.px[ 1 ]^.sparsinfo DO
    IF  p_cnt_infos > 0
    THEN
        WITH p_pars_infos[ 1 ] DO
            IF  fp_kind = fp_result_name
            THEN
                BEGIN
                IF  g01unicode
                THEN
                    BEGIN
                    movelen := sizeof (dmli.d_resname);
                    IF  (acv.a_in_packet^.sp1_header.sp1h_mess_swap <> sw_normal) AND
                        (acv.a_in_packet^.sp1_header.sp1h_mess_code <> csp_unicode)
                    THEN
                        s80uni_trans (@a_data_ptr^[ fp_fromposv14 + 1 ],
                              fp_dataiolenv14 - 1, csp_unicode_swap,
                              @dmli.d_resname, movelen, csp_unicode, [ ],
                              uni_err, err_char_no)
                    ELSE
                        s80uni_trans (@a_data_ptr^[ fp_fromposv14 + 1 ],
                              fp_dataiolenv14 - 1, csp_unicode,
                              @dmli.d_resname, movelen, csp_unicode, [ ],
                              uni_err, err_char_no);
                    (*ENDIF*) 
                    IF  (uni_err <> uni_ok) AND
                        (uni_err <> uni_dest_too_short)
                    THEN
                        a07_b_put_error (acv, e_invalid_tablename, 1)
                    (*ENDIF*) 
                    END
                ELSE
                    BEGIN
                    g02fromtermchar (a_mess_code, a_data_ptr^,
                          fp_fromposv14 + 1, fp_dataiolenv14 - 1);
                    g10mv3 ('VAK506',  13,    
                          a_data_length, sizeof (dmli.d_resname),
                          a_data_ptr^, fp_fromposv14 + 1,
                          dmli.d_resname, 1, fp_dataiolenv14 - 1,
                          a_return_segm^.sp1r_returncode);
                    END;
                (*ENDIF*) 
                IF  dmli.d_resname = a01_zero_res_name
                THEN
                    a07_b_put_error (acv, e_invalid_parameter, -fp_fromposv14)
                ELSE
                    dmli.d_resname_found := true;
                (*ENDIF*) 
                IF  a_input_data_pos <  (fp_fromposv14 + fp_datalenv14)
                THEN
                    a_input_data_pos :=  fp_fromposv14 + fp_datalenv14
                (*ENDIF*) 
                END;
            (*ENDIF*) 
        (*ENDWITH*) 
    (*ENDIF*) 
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak506catalog_val_from_datapart (
            VAR acv      : tak_all_command_glob;
            etype        : tgg_stack_entry_type;
            valpos       : integer;
            inoutlen     : integer);
 
VAR
      b_err   : tgg_basis_error;
      actlen  : integer;
      ix      : integer;
      i2c2    : tsp_int_map_c2;
      segm_id : tsp_c2;
      sysbuf  : tak_sysbufferaddress;
      sysk    : tgg_sysinfokey;
 
BEGIN
WITH acv, a_mblock, mb_data^ DO
    BEGIN
&   ifdef trace
    t01int4 (ak_sem, 'data_length ', a_data_length);
    t01int4 (ak_sem, 'valpos      ', valpos);
    t01int4 (ak_sem, 'inoutlen    ', inoutlen);
&   endif
    IF  mb_data_len = 0
    THEN
        mb_data_len := cgg_rec_key_offset;
    (*ENDIF*) 
    IF  a_data_length + 1 < valpos + inoutlen
    THEN
        a07_b_put_error (acv, e_too_short_datapart, -valpos)
    ELSE
        IF  a_data_ptr^[ valpos ] = csp_undef_byte
        THEN
            a07_b_put_error (acv,
                  e_mandatory_field_is_null, -valpos)
        ELSE
            BEGIN
            IF  etype = st_varkey
            THEN
                actlen := s30lnr (a_data_ptr^, csp_defined_byte,
                      valpos + 1, inoutlen - 1)
            ELSE
                BEGIN
                i2c2.map_c2[ 1 ] := a_data_ptr^[ valpos+1 ];
                i2c2.map_c2[ 2 ] := a_data_ptr^[ valpos+2 ];
                actlen           := i2c2.map_int;
                valpos           := valpos + 2
                END;
            (*ENDIF*) 
&           ifdef trace
            t01int4 (ak_sem, 'actlen      ', actlen);
&           endif
            g10mv ('VAK506',  14,    
                  sizeof(a_data_ptr^), mb_data_size,
                  a_data_ptr^, valpos + 1,
                  mbp_buf, mb_data_len + 1, actlen,
                  a_return_segm^.sp1r_returncode);
            mb_data_len := mb_data_len + actlen;
            IF  etype = st_varkey
            THEN
                BEGIN
                mbp_keylen := mb_data_len - cgg_rec_key_offset;
                IF  ((mb_type  =  m_select_row) AND
                    ( mb_type2 <> mm_direct))
                THEN
                    mb_st^ [mb_qual^.mstrat_pos].elen_var := mbp_keylen
                ELSE
                    IF  mb_type = m_delete
                    THEN
                        BEGIN
                        sysk.skeylen := mbp_keylen;
                        FOR ix := 1 TO actlen DO
                            sysk.all[ix] := mbp_buf[cgg_rec_key_offset+ix];
                        (*ENDFOR*) 
                        a10get_sysinfo (acv, sysk, d_release, sysbuf, b_err);
                        IF  b_err = e_ok
                        THEN
                            WITH sysbuf^ DO
                                BEGIN
                                segm_id[1] := ssysbuf[cgg_rec_key_offset+b_kl+1];
                                segm_id[2] := ssysbuf[cgg_rec_key_offset+b_kl+2];
                                IF  segm_id = cgg_public_segment_id
                                THEN
                                    BEGIN
                                    mb_replicated := rpl_full;
                                    END;
                                (*ENDIF*) 
                                END;
                            (*ENDWITH*) 
                        (*ENDIF*) 
                        END;
                    (*ENDIF*) 
                (*ENDIF*) 
                END;
            (*ENDIF*) 
            END;
        (*ENDIF*) 
    (*ENDIF*) 
    END;
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak506datetime (
            VAR acv   : tak_all_command_glob;
            VAR fp    : tak_field_pars;
            VAR frec  : tak_fill_rec;
            mbufiolen : integer;
            to_fill   : boolean;
            start     : integer);
 
CONST
      time_durationlen = 6;
 
VAR
      i         : integer;
      b_err     : tgg_basis_error;
      curr_time : tsp_c9;
      utcdiff   : tsp00_Longreal;
      timestamp : tsp00_Timestamp;
      num_err   : tsp_num_error;
 
BEGIN
WITH fp, acv.a_mblock, mb_data^ DO
    BEGIN
    IF  fp_datatyp = dche
    THEN
        mbp_buf[ start ] := csp_ebcdic_blank
    ELSE
        IF  ((fp_datatyp = dcha)  OR
            ( fp_datatyp = ddate) OR
            ( fp_datatyp = dtime) OR
            ( fp_datatyp = dtimestamp))
        THEN
            mbp_buf[ start ] := csp_ascii_blank
        ELSE
            IF  fp_datatyp = dunicode
            THEN
                mbp_buf[ start ] := csp_unicode_def_byte
            ELSE
                mbp_buf[ start ] := csp_defined_byte;
            (*ENDIF*) 
        (*ENDIF*) 
    (*ENDIF*) 
    (* PTS 1116175 E.Z. *)
    IF  ((fp_frompos_v1 = cak_fp_date)      OR
        ( fp_frompos_v1 = cak_fp_time)      OR
        ( fp_frompos_v1 = cak_fp_timestamp) OR
        ( fp_frompos_v1 = cak_fp_utcdate))
    THEN
        BEGIN
        IF  fp_frompos_v1 = cak_fp_utcdate
        THEN
            vUTCtimestamp (timestamp)
        ELSE
            BEGIN
            IF  acv.a_timestamp = bsp_c20
            THEN
                vtimestamp (acv.a_timestamp);
            (*ENDIF*) 
            timestamp := acv.a_timestamp;
            END;
        (*ENDIF*) 
        IF  (fp_datatyp = ddate)      OR
            (fp_datatyp = dtime)      OR
            (fp_datatyp = dtimestamp) OR
            (acv.a_dt_format = dtf_normal)
        THEN
            BEGIN
            frec.fr_leng := mxsp_date + 1;
            IF  fp_frompos_v1 = cak_fp_date
            THEN
                g10mv2 ('VAK506',  15,    
                      sizeof(timestamp), mb_data_size,
                      timestamp, 1, mbp_buf, start + 1, mxsp_date,
                      acv.a_return_segm^.sp1r_returncode)
            ELSE
                IF  fp_frompos_v1 = cak_fp_time
                THEN
                    BEGIN
                    mbp_buf[ start+1 ] := '0';
                    mbp_buf[ start+2 ] := '0';
                    g10mv2 ('VAK506',  16,    
                          sizeof(timestamp), mb_data_size,
                          timestamp, mxsp_date + 1,
                          mbp_buf, start + 3, mxsp_time - 2,
                          acv.a_return_segm^.sp1r_returncode);
                    END
                ELSE
                    BEGIN
                    g10mv2 ('VAK506',  17,    
                          sizeof(timestamp), mb_data_size,
                          timestamp, 1, mbp_buf, start + 1,
                          sizeof(timestamp),
                          acv.a_return_segm^.sp1r_returncode);
                    frec.fr_leng := mxsp_timestamp + 1;
                    END;
                (*ENDIF*) 
            (*ENDIF*) 
            END
        ELSE
            CASE fp_frompos_v1 OF
                cak_fp_date :
                    BEGIN
                    b_err := e_ok;
                    g03dfchange_format_date (timestamp, mbp_buf,
                          1, start+1, acv.a_dt_format, b_err);
                    IF  b_err <> e_ok
                    THEN
                        a07_b_put_error (acv, b_err, 1)
                    ELSE
                        frec.fr_leng := mxsp_extdate + 1;
                    (*ENDIF*) 
                    END;
                cak_fp_time :
                    BEGIN
                    b_err := e_ok;
                    curr_time[ 2 ] := '0';
                    curr_time[ 3 ] := '0';
                    s10mv1 (sizeof (timestamp), sizeof (curr_time),
                          timestamp, mxsp_date+1, curr_time, 4, mxsp_time-2);
                    g03tfchange_format_time (curr_time, mbp_buf,
                          2, start+1, acv.a_dt_format, b_err);
                    IF  b_err <> e_ok
                    THEN
                        a07_b_put_error (acv, b_err, 1)
                    ELSE
                        frec.fr_leng := mxsp_exttime + 1;
                    (*ENDIF*) 
                    END;
                cak_fp_timestamp, cak_fp_utcdate :
                    BEGIN
                    b_err := e_ok;
                    g03tsfchange_format_timestamp (timestamp, mbp_buf,
                          1, start+1, acv.a_dt_format,
                          acv.a_ak_language, b_err);
                    IF  b_err <> e_ok
                    THEN
                        a07_b_put_error (acv, b_err, 1)
                    ELSE
                        frec.fr_leng := mxsp_exttimestamp + 1;
                    (*ENDIF*) 
                    END
                END;
            (*ENDCASE*) 
        (*ENDIF*) 
        IF  ((g01code.ctype = csp_ebcdic) AND
            ((fp_datatyp      = dcha)  OR
            ( fp_datatyp      = ddate) OR
            ( fp_datatyp      = dtime) OR
            ( fp_datatyp      = dtimestamp)))
        THEN
            g02pebcdic_pos_ascii(mbp_buf, start+1,
                  mbp_buf, start+1, frec.fr_leng)
        ELSE
            IF  ((g01code.ctype   = csp_ascii) AND
                ( fp_datatyp      = dche))
            THEN
                g02pascii_pos_ebcdic(mbp_buf, start+1,
                      mbp_buf, start+1, frec.fr_leng)
            ELSE
                IF  fp_datatyp = dunicode
                THEN
                    BEGIN
                    FOR i := frec.fr_leng-1 DOWNTO 1 DO
                        BEGIN
                        mbp_buf[ start+2*i   ] := mbp_buf[ start+i ];
                        mbp_buf[ start+2*i-1 ] := csp_unicode_mark;
                        END;
                    (*ENDFOR*) 
                    frec.fr_leng := (frec.fr_leng-1)*2 + 1
                    END
                (*ENDIF*) 
            (*ENDIF*) 
        (*ENDIF*) 
        END
    ELSE
        IF  fp_frompos_v1 = cak_fp_stamp
        THEN
            BEGIN
            a05_stamp_get (acv, mbp_buf, start+1, mb_data_size);
            frec.fr_leng := mxgg_surrogate + 1;
            END
        ELSE
            IF  fp_frompos_v1 = cak_fp_transaction
            THEN
                BEGIN
                a05_transaction_get (acv, mbp_buf, start+1, mb_data_size);
                WITH acv.a_transinf.tri_trans DO
                    frec.fr_leng := 1 + sizeof(trTransId_gg00);
                (*ENDWITH*) 
                END
            ELSE
                IF  fp_frompos_v1 = cak_fp_utcdiff
                THEN
                    BEGIN
                    utcdiff := vTimeZoneDelta;
                    s41plrel (mbp_buf, start + 1, cak_utcdiff_len, cak_utcdiff_frac,
                          utcdiff, num_err);
                    IF  (num_err <> num_ok)
                    THEN
                        CASE num_err OF
                            num_invalid :
                                a07_b_put_error (acv,
                                      e_num_invalid, 1);
                            num_trunc :
                                a07_b_put_error (acv,
                                      e_num_truncated, 1);
                            num_overflow :
                                a07_b_put_error (acv,
                                      e_num_overflow, 1);
                            END
                        (*ENDCASE*) 
                    ELSE
                        frec.fr_leng := (cak_utcdiff_len + 1) DIV 2 + 2;
                    (*ENDIF*) 
                    END
                ELSE
                    IF  (fp_frompos_v1 = cak_fp_timezone)
                    THEN
                        BEGIN
                        utcdiff := vTimeZoneDelta;
                        (* from fixed (4,2) example 8,5 --> duration example 083000 *)
                        utcdiff := trunc(utcdiff) * 10000 +
                              (utcdiff - trunc(utcdiff)) * 6000;
                        s41plrel (mbp_buf, start + 1, time_durationlen, 0,
                              utcdiff, num_err);
                        IF  (num_err <> num_ok)
                        THEN
                            CASE num_err OF
                                num_invalid :
                                    a07_b_put_error (acv,
                                          e_num_invalid, 1);
                                num_trunc :
                                    a07_b_put_error (acv,
                                          e_num_truncated, 1);
                                num_overflow :
                                    a07_b_put_error (acv,
                                          e_num_overflow, 1);
                                END
                            (*ENDCASE*) 
                        ELSE
                            frec.fr_leng := (time_durationlen + 1) DIV 2 + 2;
                        (*ENDIF*) 
                        END;
                    (*ENDIF*) 
                (*ENDIF*) 
            (*ENDIF*) 
        (*ENDIF*) 
    (*ENDIF*) 
    IF  (to_fill OR
        (fp_etype in [ st_fixkey, st_fixcol ]))
    THEN
        BEGIN
        IF  mbufiolen > frec.fr_leng
        THEN
            IF  fp_datatyp = dunicode
            THEN
                g10filuni ('VAK506',  18,    
                      mb_data_size, mbp_buf, start+frec.fr_leng,
                      mbufiolen-frec.fr_leng, csp_unicode_blank,
                      acv.a_return_segm^.sp1r_returncode)
            ELSE
                g10fil ('VAK506',  19,    
                      mb_data_size, mbp_buf, start+frec.fr_leng,
                      mbufiolen-frec.fr_leng, mbp_buf[ start ],
                      acv.a_return_segm^.sp1r_returncode);
            (*ENDIF*) 
        (*ENDIF*) 
        frec.fr_leng := mbufiolen;
        END
    (*ENDIF*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak506in_mess_buf_move (
            VAR acv  : tak_all_command_glob;
            VAR dmli : tak_dml_info;
            VAR frec : tak_fill_rec);
 
VAR
      pmbp : tgg_mess_block_ptr;
      pdbp : tgg_datapart_ptr;
 
BEGIN
WITH acv, a_mblock, mb_data^, dmli, frec DO
    BEGIN
    pmbp    := @dmli.d_sparr.px[ d_sparr.pcount ]^.
          smessblock.mbr_mess_block;
    pdbp    := pmbp^.mb_data;
    IF  (fr_total_leng > 0) AND  (pdbp <> NIL)
    THEN
        BEGIN
&       ifdef trace
        t01int4( ak_sem, 'from size   ', pmbp^.mb_data_size );
        t01int4( ak_sem, 'to   size   ', mb_data_size );
        t01int4( ak_sem, 'from pos    ', d_pos_in_parsbuf );
        t01int4( ak_sem, 'to   pos    ', mb_data_len + 1 );
&       endif
        g10mv ('VAK506',  20,    
              pmbp^.mb_data_size, mb_data_size,
              pdbp^.mbp_buf, d_pos_in_parsbuf,
              mb_data^.mbp_buf, mb_data_len + 1,
              fr_total_leng,
              a_return_segm^.sp1r_returncode);
        END;
    (*ENDIF*) 
    fr_leng := 0;
&   ifdef TRACE
    t01int4 (ak_sem, 'total_leng  ', fr_total_leng);
    t01int4 (ak_sem, 'pos_in_parsb', d_pos_in_parsbuf);
    t01int4 (ak_sem, 'leng        ', fr_leng);
    t01int4 (ak_sem, 'mb_data_len ', mb_data_len);
    t01int4 (ak_sem, 'mbp_reclen  ', mbp_reclen);
    t01int4 (ak_sem, 'mbp_keylen  ', mbp_keylen);
&   endif
    mb_data_len      := mb_data_len      + fr_total_leng;
    d_pos_in_parsbuf := d_pos_in_parsbuf + fr_total_leng;
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak506long_support (
            VAR acv  : tak_all_command_glob;
            VAR dmli : tak_dml_info;
            VAR frec : tak_fill_rec;
            ind      : integer);
 
VAR
      desc_len   : integer;
      long_desc  : tsp_long_descriptor;
      is_longlit : boolean;
 
BEGIN
WITH acv, dmli, d_sparr.px[1]^.sparsinfo, p_pars_infos[ind],
     a_mblock, mb_data^ DO
    BEGIN
    IF  fp_kind = fp_val_all_without_l
    THEN
        BEGIN
        frec.fr_total_leng := fp_movebefore_v2 - mb_data_len;
        IF  frec.fr_total_leng > 0
        THEN
            ak506in_mess_buf_move (acv, dmli, frec)
        (*ENDIF*) 
        END
    ELSE
        IF  fp_movebefore_v1 > 0
        THEN
            BEGIN
            frec.fr_total_leng := fp_movebefore_v1;
            ak506in_mess_buf_move (acv, dmli, frec)
            END;
        (*ENDIF*) 
    (*ENDIF*) 
    is_longlit := false;
    IF  dmli.d_literalrec <> NIL
    THEN
        WITH dmli.d_literalrec^.slongliteral DO
            BEGIN
            litcolcount := succ (litcolcount);
            is_longlit  := (litcoldesc [litcolcount].llcdatapos <> -1)
            END;
        (*ENDWITH*) 
    (*ENDIF*) 
    IF  NOT is_longlit
    THEN
        BEGIN
        d_longdesc_found := true;
        d_cnt_longdesc := succ(d_cnt_longdesc);
        IF  d_first_longdesc_pos = 0
        THEN
            d_first_longdesc_pos := fp_frompos_v1;
        (* PTS 1116801 E.Z. *)
        (*ENDIF*) 
        desc_len := mxsp_long_desc;
        IF  a_input_data_pos < (fp_frompos_v1 + desc_len + 1)
        THEN
            a_input_data_pos := fp_frompos_v1 + desc_len + 1;
        (*ENDIF*) 
        a_data_part^.sp1p_arg_count := d_cnt_longdesc;
&       ifdef TRACE
        t01int4 (ak_sem, 'd_first_ldps', d_first_longdesc_pos);
        t01int4 (ak_sem, 'd_cntlongdes', d_cnt_longdesc);
        t01int4 (ak_sem, 'fp_fromposv1', fp_frompos_v1);
        t01int4 (ak_sem, 'input_data_p', a_input_data_pos);
&       endif
        IF  a_data_ptr^[fp_frompos_v1] = csp_undef_byte
        THEN
            BEGIN
            mbp_buf [ mb_data_len + 1] := csp_undef_byte;
            g10fil ('VAK506',  21,    
                  mb_data_size, mbp_buf, mb_data_len + 2,
                  cgg_str_col_entry_size, csp_defined_byte,
                  a_return_segm^.sp1r_returncode);
            mb_data_len := mb_data_len + cgg_str_col_entry_size + 1
            END
        ELSE
            BEGIN
            g10mv7 ('VAK506',  22,    
                  a_data_length, sizeof(long_desc),
                  a_data_ptr^, fp_frompos_v1 + 1,
                  long_desc, 1, desc_len,
                  a_return_segm^.sp1r_returncode);
            WITH long_desc DO
                BEGIN
                ld_tabid       := p_treeid.fileTabId_gg00;
                ld_intern_pos  := 1;
                IF  fp_datatyp in [dlonga, dlonge, dlonguni,
                    dlongb, dlongdb]
                THEN
                    BEGIN
                    IF  ((a_mblock.mb_type = m_insert) OR
                        ( a_mblock.mb_type = m_insert_select))
                    THEN
                        ld_intern_pos  := -1;
                    (* PTS 1105838 E.Z. *)
                    (*ENDIF*) 
                    ld_state   := [ ];
                    ld_infoset := [ ld_without_shortcol ]
                    END
                ELSE
                    BEGIN
                    ld_state   := [ ld_short_scol ];
                    ld_infoset := [ ];
                    END;
                (*ENDIF*) 
                (* PTS 1117525 *)
                IF  (a_out_packet^.sp1_header.sp1h_mess_swap <>
                    g01code.kernel_swap)
                THEN
                    BEGIN
                    s20ch4sw (ld_intern_pos, g01code.kernel_swap,
                          ld_intern_pos, 1,
                          a_out_packet^.sp1_header.sp1h_mess_swap);
                    END;
                (*ENDIF*) 
                IF  fp_datatyp in [dstruni, dlonguni]
                THEN
                    ld_infoset := ld_infoset + [ ld_unicode ];
                (*ENDIF*) 
                IF  (
                    ((a_basic_code <> csp_ebcdic) AND
                    ((fp_datatyp = dstre) OR
                    ( fp_datatyp  = dlonge)))
                    OR
                    ((a_basic_code = csp_ebcdic) AND
                    ((fp_datatyp = dstra) OR
                    ( fp_datatyp  = dlonga)))
                    )
                THEN
                    ld_state := ld_state + [ld_use_conversion];
                (*ENDIF*) 
                IF  ((fp_datatyp = dstruni) OR (fp_datatyp = dlonguni)) AND
                    (a_out_packet^.sp1_header.sp1h_mess_swap <> sw_normal)
                THEN
                    ld_state := ld_state + [ld_use_ucs_2_swap];
                (*ENDIF*) 
                IF  (fp_datatyp in [dstra, dstre, dlonga, dlonge]) AND
                    (a_out_packet^.sp1_header.sp1h_mess_code
                    >= cgg_begin_termsets)               AND
                    (a_out_packet^.sp1_header.sp1h_mess_code
                    <= cgg_end_termsets)
                THEN
                    ld_state := ld_state + [ld_use_termchar];
                (*ENDIF*) 
                IF  (fp_datatyp in [dstra, dstre, dlonga, dlonge]) AND
                    (a_out_packet^.sp1_header.sp1h_mess_code
                    in [csp_unicode, csp_unicode_swap])
                THEN
                    ld_state := ld_state + [ld_use_toascii];
                (*ENDIF*) 
                mbp_buf [ mb_data_len + 1] := csp_defined_byte;
                IF  ((a_mblock.mb_type = m_insert) OR
                    ( a_mblock.mb_type = m_insert_select))
                THEN
                    BEGIN
                    a05_stamp_get (acv,
                          mbp_buf, mb_data_len + 2, mb_data_size);
                    g10mv7 ('VAK506',  23,    
                          mb_data_size, sizeof(tsp_long_descriptor),
                          mbp_buf, mb_data_len + 2,
                          long_desc, 1, cgg_str_col_entry_size,
                          a_return_segm^.sp1r_returncode);
                    mb_data_len := mb_data_len + cgg_str_col_entry_size + 1;
                    IF  a_mblock.mb_type = m_insert_select
                    THEN
                        d_pos_in_parsbuf := d_pos_in_parsbuf + succ(mxgg_surrogate);
                    (*ENDIF*) 
                    END
                ELSE
                    BEGIN
                    g10fil ('VAK506',  24,    
                          mb_data_size,  mbp_buf, mb_data_len + 1,
                          cgg_str_col_entry_size+1, csp_defined_byte,
                          a_return_segm^.sp1r_returncode);
                    mb_data_len := mb_data_len + cgg_str_col_entry_size + 1;
                    END;
                (*ENDIF*) 
                g10mv8 ('VAK506',  25,    
                      sizeof(long_desc), a_data_length, long_desc, 1,
                      a_data_ptr^, fp_frompos_v1 + 1, desc_len,
                      a_return_segm^.sp1r_returncode);
                END;
            (*ENDWITH*) 
            END;
        (*ENDIF*) 
        END
    ELSE
        BEGIN
        mbp_buf [ mb_data_len + 1] := csp_defined_byte;
        IF  a_mblock.mb_replicated = rpl_full
        THEN
            a05_stamp_get (acv,
                  mbp_buf, mb_data_len + 2, mb_data_size)
        ELSE
            a05_stamp_get (acv,
                  mbp_buf, mb_data_len + 2, mb_data_size);
        (*ENDIF*) 
        WITH dmli.d_literalrec^.slongliteral, litcoldesc [litcolcount] DO
            g10mv9 ('VAK506',  26,    
                  mb_data_size, sizeof(llclongid),
                  mbp_buf, mb_data_len + 2,
                  llclongid, 1, cgg_str_col_entry_size,
                  a_return_segm^.sp1r_returncode);
        (*ENDWITH*) 
        mb_data_len := mb_data_len + cgg_str_col_entry_size + 1;
        END;
    (*ENDIF*) 
    END
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak506one_field_copy (
            VAR acv  : tak_all_command_glob;
            VAR dmli : tak_dml_info;
            VAR frec : tak_fill_rec);
 
VAR
      ind        : integer;
      curval_len : integer;
      currlen    : tsp_int_map_c2;
 
BEGIN
WITH acv, frec, dmli.d_sparr.px[ 1 ]^.sparsinfo,
     p_pars_infos[ fr_f_no ], a_mblock, mb_data^ DO
    BEGIN
    ind := fr_f_no;
    IF  fp_movebefore_v8 > 0
    THEN
        BEGIN
        fr_total_leng := fp_movebefore_v8;
        ak506in_mess_buf_move (acv, dmli, frec)
        END;
    (*ENDIF*) 
    WITH dmli.d_sparr.px[ 1 ]^.sparsinfo, p_pars_infos[ ind ] DO
        BEGIN
        fr_leng := mb_st^ [fp_keystack].elen_var;
        IF  (fp_key_low_handl <> cak_keycol_low_def)
        THEN
            BEGIN
            curval_len := 1 + s30lnr_defbyte (@mbp_buf,
                  mbp_buf [mb_st^ [fp_keystack].epos],
                  mb_st^ [fp_keystack].epos + 1, fr_leng - 1);
            IF  (fp_key_low_handl = cak_keycol_low_trunc)
            THEN
                fr_leng := curval_len;
            (*ENDIF*) 
            END;
        (*ENDIF*) 
        IF  (fp_to_stack = 0)
        THEN
            IF  fp_fill_81 > 255
            THEN
                BEGIN
                currlen.map_int := fr_leng;
                mbp_buf [mb_data_len + 1] := currlen.map_c2[1];
                mbp_buf [mb_data_len + 2] := currlen.map_c2[2];
                mb_data_len := mb_data_len + 2;
                END
            ELSE
                BEGIN
                mb_data_len := succ(mb_data_len);
                mbp_buf [mb_data_len] := chr(fr_leng);
                END
            (*ENDIF*) 
        ELSE
            WITH mb_st^ [fp_to_stack] DO
                elen_var := elen_var + fr_leng;
            (*ENDWITH*) 
        (*ENDIF*) 
        g10mv ('VAK506',  27,    
              mb_data_size, mb_data_size,
              mbp_buf, mb_st^ [fp_keystack].epos,
              mbp_buf, mb_data_len + 1, fr_leng,
              a_return_segm^.sp1r_returncode);
        IF  (fp_key_low_handl = cak_keycol_low_zero)
        THEN
            g10fil ('VAK506',  28,    
                  mb_data_size, mbp_buf, mb_data_len + curval_len + 1,
                  fr_leng - curval_len, csp_defined_byte,
                  a_return_segm^.sp1r_returncode);
        (*ENDIF*) 
        mb_data_len := mb_data_len + fr_leng;
&       ifdef TRACE
        t01name (ak_sem, 'after copy_withlen');
        t01messblock (ak_sem, 'MBLOCK 506on', a_mblock);
&       endif
        END;
    (*ENDWITH*) 
    END;
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak506pseudo_insert_select (
            VAR acv  : tak_all_command_glob;
            VAR dmli : tak_dml_info);
 
VAR
      dummy_bool : boolean;
      aux_len    : integer;
      rec_buf    : tgg_rec_buf;
      res_buf    : tgg_rec_buf;
      sel        : tgg_select_fields_param;
 
BEGIN
WITH acv, a_mblock, mb_data^ DO
    BEGIN
    mb_work_st      := a_work_st_addr;
    mb_work_st_max  := a_work_st_max;
    mb_workbuf      := a_work_buf_addr;
    mb_workbuf_size := a_work_buf_size;
    g04init_select_fields (sel, @mbp_buf, mb_data_size,
          mb_work_st, mb_work_st_max, mb_workbuf, mb_workbuf_size,
          a_sqlmode);
    sel.sfp_result_wanted := true;
    sel.sfp_result_length := cgg_rec_key_offset;
    sel.sfp_m_result_addr := @res_buf;
    sel.sfp_m_result_size := sizeof (res_buf);
    rec_buf.len           := cgg_rec_key_offset;
    rec_buf.keylen        := 0;
    IF  ( a_mblock.mb_qual^.msubquery )
    THEN
        k720_test_subquery( a_mblock, res_buf );
    (*ENDIF*) 
    res_buf.keylen        := 0;
    k71col_select (mb_trns^, sel, mb_qual^.mstack_desc,
          rec_buf, dummy_bool);
    IF  mb_trns^.trError_gg00 <> e_ok
    THEN
        a07_b_put_error (acv,
              a_mblock.mb_trns^.trError_gg00, 1)
    ELSE
        BEGIN
&       ifdef trace
        t01buf (ak_sem, res_buf.buf, 1, res_buf.len);
&       endif
        res_buf.len := sel.sfp_result_length;
        g10mv6 ('VAK506',  29,    
              sizeof(res_buf.buf), mb_data_size,
              res_buf.buf, 1, mbp_buf, 1, sel.sfp_result_length,
              a_return_segm^.sp1r_returncode);
        mb_qual^.mqual_cnt  := 0;
        mb_qual^.mstrat_cnt := 0;
        mb_data_len         := res_buf.len;
        mb_type             := m_insert;
        IF  mb_data^.mbp_keylen = 0
        THEN
            BEGIN
            mbp_buf [cgg_rec_key_offset + 1] := csp_defined_byte;
            IF  mb_replicated = rpl_full
            THEN
                a05_stamp_get (acv,
                      mb_data^.mbp_buf, cgg_rec_key_offset + 2,
                      mb_data_size)
            ELSE
                IF  ftsTemp_egg00 in mb_qual^.mtree.fileType_gg00
                THEN
                    BEGIN
                    aux_len := mb_data_len ;
                    a56temp_table_key (acv, dmli);
                    mb_data^.mbp_reclen := aux_len;
                    mb_data_len         := aux_len
                    END
                ELSE
                    mb_type2 := mm_nokey;
                (*ENDIF*) 
            (*ENDIF*) 
            mb_data^.mbp_keylen := mxgg_surrogate + 1
            END
        ELSE
            mb_type2 := mm_nil
        (*ENDIF*) 
        END;
    (*ENDIF*) 
    END;
(*ENDWITH*) 
END;
 
(* PTS 1106107 E.Z. *)
(*------------------------------*) 
 
PROCEDURE
      ak506val_from_part2 (
            VAR acv     : tak_all_command_glob;
            valpos      : integer;
            field_kind  : tak_fp_kind_type;
            VAR colinfo : tak00_columninfo;
            iolen       : integer;
            VAR frec    : tak_fill_rec;
            VAR to_fill : boolean);
 
CONST
      c_no_ebcdic_to_ascii = true;
 
VAR
      b_err      : tgg_basis_error;
      truncated  : boolean;
      destpos    : integer;
      i          : integer;
      val        : integer;
      numlen     : integer;
      uniinlen   : integer;
      univallen  : integer;
      intern_num : tsp_number;
      err        : tsp_num_error;
      error      : tsp8_uni_error;
      err_char_no: tsp_int4;
      c64        : tsp_c64;
      c64_ptr    : tsp_moveobj_ptr;
      no_ebcdic_to_ascii : boolean;
 
BEGIN
WITH acv, a_mblock, mb_data^, colinfo DO
    BEGIN
&   ifdef trace
    t01int4 (ak_sem, 'data_length ', a_data_length);
    t01int4 (ak_sem, 'valpos      ', valpos);
&   endif
    b_err     := e_ok;
    truncated := false;
    destpos   := mb_data_len + 1;
    frec.fr_leng    := 0;
    IF  a_input_data_pos < (valpos + iolen)
    THEN
        a_input_data_pos := valpos + iolen;
    (*ENDIF*) 
    IF  a_data_length + 1 < valpos + iolen
    THEN
        IF  ((a_comp_vers < '62080') OR
            (a_comp_type = at_unknown))
            AND
            (cdatalen > c_old_maxnumlen)
            AND
            ((cdatatyp = dfixed)  OR
            ( cdatatyp = dfloat)  OR
            ( cdatatyp = dvfloat))
        THEN
            BEGIN
            IF  a_data_length + 1 < valpos + c_old_maxnumbytes
            THEN
                a07_b_put_error (acv, e_too_short_datapart, -valpos)
            (*ENDIF*) 
            END
        ELSE
            a07_b_put_error (acv, e_too_short_datapart, -valpos);
        (*ENDIF*) 
    (*ENDIF*) 
    IF  a_return_segm^.sp1r_returncode = 0
    THEN
        IF  a_data_ptr^[ valpos ] = csp_undef_byte
        THEN
            BEGIN
            mbp_buf[ destpos ] := csp_undef_byte;
            IF  ((ccolstack.etype = st_varkey) OR
                ( ccolstack.etype = st_varcol) OR
                ( ccolstack.etype = st_varlongchar))
            THEN
                frec.fr_leng := 0
            ELSE
                BEGIN
                frec.fr_leng := cinoutlen - 1;
                g10fil ('VAK506',  30,    
                      mb_data_size, mbp_buf, destpos+1, frec.fr_leng,
                      csp_defined_byte, a_return_segm^.sp1r_returncode)
                END
            (*ENDIF*) 
            END
        ELSE
            BEGIN
            IF  (((ccolstack.etype = st_varkey) OR
                (  ccolstack.etype = st_varcol) OR
                (  ccolstack.etype = st_varlongchar))
                AND
                (NOT to_fill))
            THEN
                IF  ((cdatatyp = dfixed)    OR
                    ( cdatatyp = dfloat)    OR
                    ( cdatatyp = dvfloat)   OR
                    ( cdatatyp = dinteger)  OR
                    ( cdatatyp = dsmallint) OR
                    ( cdatatyp = dchb))
                THEN
                    BEGIN
                    IF  ((a_comp_vers < '62080') OR
                        (a_comp_type = at_unknown))
                        AND
                        (cdatalen > c_old_maxnumlen)
                        AND
                        ((cdatatyp = dfixed)  OR
                        ( cdatatyp = dfloat)  OR
                        ( cdatatyp = dvfloat))
                    THEN
                        frec.fr_leng := s30lnr (a_data_ptr^, csp_defined_byte,
                              valpos + 1, c_old_maxnumbytes-1)
                    ELSE
                        frec.fr_leng := s30lnr (a_data_ptr^, csp_defined_byte,
                              valpos + 1, iolen - 1);
                    (*ENDIF*) 
                    truncated := true
                    END
                ELSE
                    BEGIN
                    (* ddbyteebcdic und basic_code = ebcdic   *)
                    (* gibt es nicht mehr; ueberzaehliges raus, Feb.96 *)
                    IF  ((a_in_packet^.sp1_header.sp1h_mess_code in
                        [ csp_unicode, csp_unicode_swap ]) AND
                        (cdatatyp in [ dunicode, dcha, dche,
                        dvarchara, dvarchare,
                        ddate, dtime, dtimestamp ]))
                        OR
                        (cdatatyp = dunicode)
                    THEN
                        frec.fr_leng := s30unilnr (a_data_ptr,
                              frec.fr_uni_fill_c2,
                              valpos + 1, iolen - 1)
                    ELSE
                        frec.fr_leng := s30lnr (a_data_ptr^, csp_ascii_blank,
                              valpos + 1, iolen - 1);
                    (*ENDIF*) 
                    truncated := true
                    END
                (*ENDIF*) 
            ELSE
                IF  ((a_comp_vers < '62080') OR
                    (a_comp_type = at_unknown))
                    AND
                    (cdatalen > c_old_maxnumlen)
                    AND
                    ((cdatatyp = dfixed)    OR
                    ( cdatatyp = dfloat)    OR
                    ( cdatatyp = dvfloat)   OR
                    ( cdatatyp = dinteger)  OR
                    ( cdatatyp = dsmallint))
                THEN
                    (* PTS 1106107 E.Z. *)
                    BEGIN
                    IF  (field_kind = fp_val_varcol_with_len ) AND
                        (ccolstack.etype in [ st_fixkey, st_fixcol ])
                    THEN
                        to_fill := true;
                    (*ENDIF*) 
                    frec.fr_leng := c_old_maxnumbytes - 1
                    END
                ELSE
                    frec.fr_leng := iolen - 1;
                (*ENDIF*) 
            (*ENDIF*) 
&           ifdef TRACE
            t01int4 (ak_sem, 'to_fill     ', ord(to_fill));
            t01int4  (ak_sem, 'valpos      ', valpos);
            t01char (ak_sem, 'undef_byte  ', a_data_ptr^[ valpos ]);
            t01int4  (ak_sem, 'start       ', destpos);
            t01int4  (ak_sem, 'frec.fr_leng', frec.fr_leng);
&           endif
            CASE cdatatyp OF
                dunicode :
                    BEGIN
                    mbp_buf[ destpos ] := csp_unicode_def_byte;
                    IF  frec.fr_leng = iolen - 1
                    THEN
                        uniinlen := s30unilnr (a_data_ptr,
                              frec.fr_uni_fill_c2,
                              valpos + 1, iolen - 1)
                    ELSE
                        uniinlen := frec.fr_leng;
                    (*ENDIF*) 
                    IF  (a_in_packet^.sp1_header.sp1h_mess_swap <> sw_normal) AND
                        (a_in_packet^.sp1_header.sp1h_mess_code <> csp_unicode)
                    THEN
                        BEGIN
                        univallen := cinoutlen - 1;
                        s80uni_trans (@a_data_ptr^[ valpos + 1], uniinlen,
                              csp_unicode_swap,
                              @mbp_buf[ destpos + 1], univallen, csp_unicode,
                              [ ], error, err_char_no);
                        END
                    ELSE
                        BEGIN
                        univallen := uniinlen;
                        error := uni_ok;
                        g10mv ('VAK506',  31,    
                              a_data_length, mb_data_size,
                              a_data_ptr^, valpos + 1,
                              mbp_buf, destpos + 1, uniinlen,
                              a_return_segm^.sp1r_returncode)
                        END;
                    (*ENDIF*) 
                    IF  error = uni_ok
                    THEN
                        IF  (((ccolstack.etype = st_varkey) OR
                            (  ccolstack.etype = st_varcol) OR
                            (  ccolstack.etype = st_varlongchar))
                            AND
                            (NOT to_fill))
                        THEN
                            frec.fr_leng := univallen
                        ELSE
                            BEGIN
                            i := cinoutlen-univallen-1;
&                           ifdef TRACE
                            t01int4 (ak_sem, 'fill_length ', i);
&                           endif
                            IF  i > 0
                            THEN
                                g10filuni ('VAK506',  32,    
                                      mb_data_size, mbp_buf,
                                      destpos+1+univallen, i,
                                      csp_unicode_blank,
                                      a_return_segm^.sp1r_returncode);
                            (*ENDIF*) 
                            frec.fr_leng := pred(cinoutlen)
                            END
                        (*ENDIF*) 
                    ELSE
                        BEGIN
&                       ifdef TRACE
                        t01int4 (ak_sem, 'err_char_no ', err_char_no);
&                       endif
                        a07_hex_uni_error (acv, error,
                              -(valpos+err_char_no), c_trans_to_uni,
                              @(a_data_ptr^[ valpos + err_char_no ]),
                              a_max_codewidth);
                        END
                    (*ENDIF*) 
                    END;
                dboolean :
                    BEGIN
                    mbp_buf[ destpos ] := csp_defined_byte;
                    IF  (a_data_ptr^[ valpos + 1 ] <> cgg_truechar)
                        AND (a_data_ptr^[ valpos + 1 ] <> cgg_falsechar)
                    THEN
                        a07_b_put_error (acv,
                              e_const_incompatible_with_typ, -valpos)
                    ELSE
                        mbp_buf [destpos + 1] := a_data_ptr^ [valpos + 1];
                    (*ENDIF*) 
                    END;
                dfixed, dfloat, dvfloat, dsmallint, dinteger :
                    BEGIN
                    mbp_buf[ destpos ] := csp_defined_byte;
                    FOR i := valpos+2 TO valpos+frec.fr_leng DO
                        BEGIN
                        val := ord(a_data_ptr^[ i ]);
                        IF  ((val > 153) OR ((val MOD 16) > 9))
                        THEN
                            a07_b_put_error (acv,
                                  e_invalid_number_variable, -valpos)
                        (*ENDIF*) 
                        END;
                    (*ENDFOR*) 
                    s51kroun (a_data_ptr^, valpos+1, frec.fr_leng,
                          mbp_buf, destpos+1,
                          cdatalen, cdatafrac-cak_frac_offset,
                          numlen, err);
                    IF  ((err = num_ok) AND
                        cbinary)
                    THEN
                        BEGIN
                        intern_num := csp_null_number;
                        g10mv10 ('VAK506',  33,    
                              mb_data_size, sizeof(intern_num),
                              mbp_buf, destpos+1, intern_num, 1, numlen,
                              a_return_segm^.sp1r_returncode);
                        IF  cdatalen = 5
                        THEN
                            BEGIN
                            IF  ((intern_num > csp_maxsint) OR
                                ( intern_num < csp_minsint))
                            THEN
                                err := num_overflow
                            (*ENDIF*) 
                            END
                        ELSE
                            IF  ((intern_num > csp_maxlint) OR
                                ( intern_num < csp_minlint))
                            THEN
                                err := num_overflow
                            (*ENDIF*) 
                        (*ENDIF*) 
                        END;
                    (*ENDIF*) 
                    IF  (err <> num_ok)
                    THEN
                        CASE err OF
                            num_invalid :
                                a07_b_put_error (acv,
                                      e_num_invalid, -valpos);
                            num_trunc :
                                a07_b_put_error (acv,
                                      e_num_truncated, -valpos);
                            num_overflow :
                                a07_b_put_error (acv,
                                      e_num_overflow, -valpos);
                            END;
                        (*ENDCASE*) 
                    (*ENDIF*) 
                    END;
                ddate :
                    BEGIN
                    mbp_buf [destpos] := csp_ascii_blank;
                    IF  a_in_packet^.sp1_header.sp1h_mess_code in
                        [ csp_unicode, csp_unicode_swap ]
                    THEN
                        BEGIN
                        frec.fr_leng := s30unilnr (a_data_ptr,
                              frec.fr_uni_fill_c2,
                              valpos + 1, frec.fr_leng);
                        univallen := sizeof (c64);
                        c64_ptr   := @c64;
                        s80uni_trans (@a_data_ptr^[ valpos + 1], frec.fr_leng,
                              a_in_packet^.sp1_header.sp1h_mess_code,
                              c64_ptr, univallen, csp_ascii,
                              [ ], error, err_char_no);
                        IF  error = uni_ok
                        THEN
                            g03fdc_date(@c64, @mbp_buf, 1, destpos+1,
                                  univallen, a_dt_format,
                                  c_no_ebcdic_to_ascii, b_err)
                        ELSE
                            a07_hex_uni_error (acv, error,
                                  -(valpos+err_char_no), NOT c_trans_to_uni,
                                  @(a_data_ptr^[ valpos + err_char_no ]),
                                  a_max_codewidth);
                        (*ENDIF*) 
                        END
                    ELSE
                        BEGIN
                        g02fromtermchar (a_mess_code, a_data_ptr^,
                              valpos, iolen);
                        frec.fr_leng := s30lnr(a_data_ptr^, csp_ascii_blank,
                              valpos + 1, mxsp_extdate);
&                       ifdef trace
                        t01int4 (ak_sem, 'g1code.ctype', g01code.ctype);
                        t01int4 (ak_sem, 'basic_code  ', a_basic_code);
&                       endif
                        no_ebcdic_to_ascii :=
                              (g01code.ctype = a_basic_code) OR
                              (a_basic_code  <> csp_ebcdic);
                        g03fdcheck_date(a_data_ptr^, mbp_buf,
                              valpos+1, destpos+1, frec.fr_leng,
                              a_dt_format, no_ebcdic_to_ascii, b_err);
                        END;
                    (*ENDIF*) 
                    frec.fr_leng := mxsp_date
                    END;
                dtime :
                    BEGIN
                    mbp_buf [destpos] := csp_ascii_blank;
                    IF  a_in_packet^.sp1_header.sp1h_mess_code in
                        [ csp_unicode, csp_unicode_swap ]
                    THEN
                        BEGIN
                        frec.fr_leng := s30unilnr (a_data_ptr,
                              frec.fr_uni_fill_c2,
                              valpos + 1, frec.fr_leng);
                        univallen := sizeof (c64);
                        c64_ptr   := @c64;
                        s80uni_trans (@a_data_ptr^[ valpos + 1], frec.fr_leng,
                              a_in_packet^.sp1_header.sp1h_mess_code,
                              c64_ptr, univallen, csp_ascii,
                              [ ], error, err_char_no);
                        IF  error = uni_ok
                        THEN
                            g03ftc_time(@c64, @mbp_buf, 1, destpos+1,
                                  univallen, a_dt_format,
                                  c_no_ebcdic_to_ascii, b_err)
                        ELSE
                            a07_hex_uni_error (acv, error,
                                  -(valpos+err_char_no), NOT c_trans_to_uni,
                                  @(a_data_ptr^[ valpos + err_char_no ]),
                                  a_max_codewidth);
                        (*ENDIF*) 
                        END
                    ELSE
                        BEGIN
                        g02fromtermchar (a_mess_code, a_data_ptr^,
                              valpos, iolen);
                        frec.fr_leng := s30lnr(a_data_ptr^, csp_ascii_blank,
                              valpos + 1, mxsp_exttime);
                        no_ebcdic_to_ascii :=
                              (g01code.ctype = a_basic_code) OR
                              (a_basic_code  <> csp_ebcdic);
                        g03ftcheck_time(a_data_ptr^, mbp_buf,
                              valpos+1, destpos+1, frec.fr_leng,
                              a_dt_format, no_ebcdic_to_ascii, b_err);
                        END;
                    (*ENDIF*) 
                    frec.fr_leng := mxsp_time
                    END;
                dtimestamp :
                    BEGIN
                    mbp_buf [destpos] := csp_ascii_blank;
                    IF  a_in_packet^.sp1_header.sp1h_mess_code in
                        [ csp_unicode, csp_unicode_swap ]
                    THEN
                        BEGIN
                        frec.fr_leng := s30unilnr (a_data_ptr,
                              frec.fr_uni_fill_c2,
                              valpos + 1, frec.fr_leng);
                        c64[ 1 ]  := csp_ascii_blank;
                        c64_ptr   := @c64[ 2 ];
                        univallen := sizeof (c64) - 1;
                        s80uni_trans (@a_data_ptr^[ valpos + 1], frec.fr_leng,
                              a_in_packet^.sp1_header.sp1h_mess_code,
                              c64_ptr, univallen, csp_ascii,
                              [ ], error, err_char_no);
                        c64_ptr   := @c64;
                        IF  error = uni_ok
                        THEN
                            (* Funny but correct: the source buffer *)
                            (* starts at the defined byte, but      *)
                            (* univallen is the length without it.  *)
                            a05timestamp_get (acv, c64_ptr^, 1,
                                  mbp_buf, destpos+1, univallen,
                                  c_no_ebcdic_to_ascii, b_err)
                        ELSE
                            a07_hex_uni_error (acv, error,
                                  -(valpos+err_char_no), NOT c_trans_to_uni,
                                  @(a_data_ptr^[ valpos + err_char_no ]),
                                  a_max_codewidth);
                        (*ENDIF*) 
                        END
                    ELSE
                        BEGIN
                        g02fromtermchar (a_mess_code,
                              a_data_ptr^, valpos, iolen);
                        frec.fr_leng := s30lnr (a_data_ptr^,
                              csp_ascii_blank, valpos + 1,
                              mxsp_exttimestamp);
                        no_ebcdic_to_ascii :=
                              (g01code.ctype = a_basic_code) OR
                              (a_basic_code  <> csp_ebcdic);
                        a05timestamp_get (acv, a_data_ptr^, valpos,
                              mbp_buf, destpos+1, frec.fr_leng,
                              no_ebcdic_to_ascii, b_err)
                        END;
                    (*ENDIF*) 
                    frec.fr_leng := mxsp_timestamp
                    END;
                OTHERWISE
                    BEGIN
                    CASE cdatatyp OF
                        dcha, dvarchara :
                            BEGIN
                            mbp_buf [destpos] := csp_ascii_blank;
                            g02fromtermchar (a_mess_code, a_data_ptr^,
                                  valpos, iolen);
                            END;
                        dche, dvarchare :
                            BEGIN
                            mbp_buf [destpos] := csp_ebcdic_blank;
                            g02fromtermchar (a_mess_code, a_data_ptr^,
                                  valpos, iolen);
                            END;
                        OTHERWISE
                            mbp_buf [destpos] := csp_defined_byte
                        END;
                    (*ENDCASE*) 
                    IF  (a_in_packet^.sp1_header.sp1h_mess_code in
                        [ csp_unicode, csp_unicode_swap ]) AND
                        (cdatatyp in [ dcha, dche,
                        dvarchara, dvarchare ])
                    THEN
                        BEGIN
                        univallen := cdatalen;
                        s80uni_trans (@a_data_ptr^[ valpos + 1], frec.fr_leng,
                              a_in_packet^.sp1_header.sp1h_mess_code,
                              @mbp_buf[destpos+1], univallen, csp_ascii,
                              [ ], error, err_char_no);
                        IF  error = uni_ok
                        THEN
                            BEGIN
                            frec.fr_leng := univallen;
                            IF  cdatatyp = dche
                            THEN
                                s30map (g02codetables.tables[ cgg_to_ebcdic ],
                                      mbp_buf, destpos + 1,
                                      mbp_buf, destpos + 1, frec.fr_leng)
                            (*ENDIF*) 
                            END
                        ELSE
                            a07_hex_uni_error (acv, error,
                                  -(valpos+err_char_no), NOT c_trans_to_uni,
                                  @(a_data_ptr^[ valpos + err_char_no ]),
                                  a_max_codewidth);
                        (*ENDIF*) 
                        END
                    ELSE
                        BEGIN
                        IF  cdatatyp = dche
                        THEN
                            s30map (g02codetables.tables[ cgg_to_ebcdic ],
                                  a_data_ptr^, valpos + 1,
                                  mbp_buf, destpos + 1, frec.fr_leng)
                        ELSE
                            g10mv ('VAK506',  34,    
                                  a_data_length, mb_data_size,
                                  a_data_ptr^, valpos + 1,
                                  mbp_buf, destpos + 1, frec.fr_leng,
                                  a_return_segm^.sp1r_returncode)
                        (*ENDIF*) 
                        END
                    (*ENDIF*) 
                    END
                END;
            (*ENDCASE*) 
            IF  b_err <> e_ok
            THEN
                a07_b_put_error (acv, b_err, -valpos);
            (*ENDIF*) 
            IF  (ccolstack.etype = st_varkey) AND (NOT truncated)
                AND (a_return_segm^.sp1r_returncode = 0)
                AND (a_mblock.mb_type = m_key)
            THEN
                BEGIN
                (* in case of join view upd truncate key *)
                (* if not already done;                  *)
                (* e.g. cdatatype = dfloat               *)
                frec.fr_leng := s30lnr_defbyte (@mbp_buf, mbp_buf [destpos],
                      destpos + 1, frec.fr_leng)
                END;
            (*ENDIF*) 
            IF  (to_fill AND
                (a_return_segm^.sp1r_returncode = 0))
            THEN
                BEGIN
                i := cinoutlen-frec.fr_leng-1;
&               ifdef TRACE
                t01int4 (ak_sem, 'fill_length ', i);
&               endif
                IF  i > 0
                THEN
                    CASE mbp_buf[ destpos ] OF
                        csp_ascii_blank :
                            g10fil ('VAK506',  35,    
                                  mb_data_size, mbp_buf,
                                  destpos+1+frec.fr_leng, i, csp_ascii_blank,
                                  a_return_segm^.sp1r_returncode);
                        csp_ebcdic_blank :
                            g10fil ('VAK506',  36,    
                                  mb_data_size, mbp_buf,
                                  destpos+1+frec.fr_leng, i, csp_ebcdic_blank,
                                  a_return_segm^.sp1r_returncode);
                        csp_unicode_def_byte :
                            g10filuni ('VAK506',  37,    
                                  mb_data_size, mbp_buf,
                                  destpos+1+frec.fr_leng, i, csp_unicode_blank,
                                  a_return_segm^.sp1r_returncode);
                        OTHERWISE
                            g10fil ('VAK506',  38,    
                                  mb_data_size, mbp_buf,
                                  destpos+1+frec.fr_leng, i, csp_defined_byte,
                                  a_return_segm^.sp1r_returncode)
                        END;
                    (*ENDCASE*) 
                (* PTS 1106107 E.Z. *)
                (*ENDIF*) 
                frec.fr_leng := pred(cinoutlen)
                END
            (*ENDIF*) 
            END;
        (*ENDIF*) 
    (*ENDIF*) 
    frec.fr_leng := succ(frec.fr_leng)
    END
(*ENDWITH*) 
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
.PA 
