Hello, Guys,
I have created a HANA Query Calculation view to select data from vbak and vbap table on where vkorg is "RR" and mandt is client 100.
I have multiple client in my S4HANA box , my issue that I am getting data in calculation view from mutiple client inspite of sending where clause as my current client. My user is created with client 100 , I am not sure why the data is coming from multiple clients ,following is the code for Calc view:
/********* Begin Procedure Script ************/
BEGIN
DECLARE simuuid NVARCHAR(100);
DECLARE team NVARCHAR(1);
DECLARE role NVARCHAR(1);
DECLARE bukrs NVARCHAR(4);
DECLARE aggregate INT;
DECLARE max_days INT;
DECLARE qtr INT;
DECLARE simday INT;
DECLARE last_day INT;
DECLARE mandt NVARCHAR(3);
DECLARE countrows INT;
select VALUE into mandt from USER_PARAMETERS where USER_NAME = SESSION_USER and PARAMETER = 'CLIENT';
select
case
when SUBSTRING ("PARVA",0,9) = 'TEAM_MEMB' then
SUBSTRING ("PARVA",13,1)
when SUBSTRING ("PARVA",0,9) = 'SELFSTUDY' then
SUBSTRING ("PARVA",11,1)
when SUBSTRING ("PARVA",0,9) = 'SUPERADMI' then
'+'
when SUBSTRING ("PARVA",0,9) = 'DEVELOPER' then
'+'
else ''
end as team into team from saperp.USR05 where parid = 'ERPRole' and bname = SESSION_USER and mandt = :mandt; -- CURRENT_USER;
select case
when SUBSTRING ("PARVA",0,9) = 'TEAM_MEMB' then
'U'
when SUBSTRING ("PARVA",0,9) = 'SELFSTUDY' then
'U'
when SUBSTRING ("PARVA",0,9) = 'SUPERADMI' then
'A'
when SUBSTRING ("PARVA",0,9) = 'DEVELOPER' then
'D'
else ''
end as role into role from saperp.USR05 where parid = 'ERPRole' and bname = SESSION_USER and mandt = :mandt;
select count(*) into countrows from saperp.USR05 where parid = 'BUK' and bname = SESSION_USER and mandt = :mandt;
if :countrows = 0 then
select CONCAT(:team,:team) into bukrs from dummy;
else
select "PARVA" into bukrs from saperp.USR05 where parid = 'BUK' and bname = SESSION_USER and mandt = :mandt;
end if;
select count(*) into countrows from "<tablename>" where bukrs = :bukrs and mandt = :mandt;
if :countrows > 0 then
select simuuid into simuuid
from "<tablename>" where bukrs = :bukrs and mandt = :mandt;
end if;
var_out = SELECT
h.vkorg,s.crqtr, s.crday,
i.arktx AS maktx,
SUM( i.netwr ) AS netwr, SUM( i.kwmeng ) AS kwmeng, COUNT( * ) AS orders
FROM vbak AS h
INNER Join vbap AS i ON i.vbeln = h.vbeln
INNER JOIN "<tablename>" AS s ON s.vbeln = h.vbeln
WHERE h.vkorg = :bukrs and h.mandt = :mandt
GROUP BY h.vkorg, i.arktx, s.crqtr, s.crday;
END /********* End Procedure Script ************/