Skip to Content
0

TV-UDF can cause inconsistency in CV - Why

Jan 15 at 11:06 AM

39

avatar image
Former Member

I have come across a situation which causes my calculation views to become inconsistent when I use a TV-UDF. I have tried to boil it down from its original state to something reasonable.

I have a simple calculation view based on a TV-UDF - it looks as follows:

If I have created the UDF as follows:

FUNCTION "..."."...::TV_UDF_CTRLROD_TEST2" ( ) 
RETURNS TABLE
(
  NAME   VARCHAR(4),
  VALUE  INTEGER
)
LANGUAGE SQLSCRIPT
    SQL SECURITY INVOKER
    DEFAULT SCHEMA "_SYS_BIC"
    AS
      
 _cr INTEGER ARRAY := ARRAY(1, 1);

BEGIN 
    var_out = 
      select '0001' as name, 1 as value from dummy
      where 1 = :_cr[1]
    union all
        select '0002' as name, 1 as value from dummy
        where 1 = :_cr[1]; 

  return :var_out;    
END;

- Then I can use this in a calculation view without any issues - however in my case I want to split the logic into several selects. In the following code I have two selects succeeded by a union to put the datasets together.

FUNCTION "..."."...::TV_UDF_CTRLROD_TEST2" ( ) 
RETURNS TABLE
(
  NAME   VARCHAR(4),
  VALUE  INTEGER
)
LANGUAGE SQLSCRIPT
    SQL SECURITY INVOKER
    DEFAULT SCHEMA "_SYS_BIC"
    AS
      
 _cr INTEGER ARRAY := ARRAY(1, 1);

BEGIN 
  var_out1 = 
      select '0001' as name, 1 as value from dummy
      where 1 = :_cr[1];
      
  var_out2 = 
      select '0002' as name, 1 as value from dummy
      where 1 = :_cr[1]; -- replacing this with _cr[2] would also work
                
  var_out = select * from :var_out1 union all 
            select * from :var_out2;

  return :var_out;    
END;

This however causes a problem if it is used with a calculation view - upon activation of the TV-UDF I get the following message during activation (if it is used in a CV):
Repository: Encountered an error in repository runtime extension;Model inconsistency. t_CR0.

If I force the activation - and reactivate the calcualtion view - that works - but, but viewing the raw data in the view would cause an error:

Error: SAP DBTech JDBC: [2048]: column store error: search table error: [2620] "..."."...::TV_UDF_CTRLROD_TEST2: ...(range 2) InternalFatal exception: table config for index ....:_SYS_SS_CE_31884235_vers1_lang6_type2__1_CS_1_3_RET is not valid

As written in the code(2nd listing) above replacing the :_cr[1] with index 2 would work and not cause an error. Can anyone provide an explanation to what happens here - I have workarounds - but not an explanation ?

Version : 1.00.122

/Bruhn

calcview.png (20.4 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers