Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

Assignment of variable to another variable inside a procedure

$
0
0

Hello All,

 

I am trying to assign the output of a procedure (which is an integer variable) to another variable declared inside my master procedure.

 

But some how assignment is not working. Please help me figure out how to write the correct assignment statement.

 

Code Snippets:

 

Sub Procedure:

 

CREATE PROCEDURE SC_PROFIT_CENTER.PR_AGENT_TIME

(IN     CLIENT_LOB          VARCHAR(30),

IN PROCESS_TYPE     VARCHAR(30),

IN CIRCLE               VARCHAR(30),

IN LOCATION          VARCHAR(30),

IN CATEGORY          VARCHAR(30),

IN SUB_CATEGORY     VARCHAR(30),

IN START_DATE           DATE,

IN     END_DATE           DATE,

OUT     AGENT_UTILIZATION_TIME INTEGER)

LANGUAGE SQLSCRIPT

SQL SECURITY INVOKER

READS SQL DATA

AS

BEGIN

Select SUM(C."TALK_TIME"+C."HOLD_TIME"+C."WRAP_TIME")INTO AGENT_UTILIZATION_TIME  FROM

"SC_PROFIT_CENTER"."Profit_Center.Data::DT_HIERARCHY" A,

"SC_PROFIT_CENTER"."Profit_Center.Data::DT_EMPLOYEE _MASTER" B,

"SC_PROFIT_CENTER"."Profit_Center.Data::FT_AGENT_CALL_PRFM_STAT" C

WHERE      A."CLIENT_LOB" = :CLIENT_LOB

AND      A."PROCESS_TYPE" = :PROCESS_TYPE

AND      A."CIRCLE" = :CIRCLE

AND      A."LOCATION" = :LOCATION

AND      A."CATEGORY" = :CATEGORY

AND      A."SUB_CATEGORY" = :SUB_CATEGORY

AND          A."LOCATION" = B."LOCATION"

AND          B."AGENT_ID" = C."AGENT_ID"

AND          CAST("TIMESTAMP" AS DATE) >= :START_DATE

AND          CAST("TIMESTAMP" AS DATE) <= :END_DATE

AND      B."DATE" >= :START_DATE

AND      B."DATE" <= :END_DATE;

END;

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


Above procedure outputs an integer through variable "AGENT_UTILIZATION_TIME" and this procedure is called in another second procedure which consumes the the integer value being outputted.

 

Between the call statement used for above procedure returns the expected result. Following is the call statement and its result.

 

CALL "SC_PROFIT_CENTER"."PR_AGENT_TIME"(

'INBOUND121', 'Postpaid', 'Karnataka', 'Bangalore', 'CAT-B', 'HOTLINE',

'2013-06-01', '2013-06-30',?)

 

Result:

Out(1)

16,074,932

 

 

Main Procedure (Second Procedure which is consumes the integer value from first Procedure)

 

CREATE PROCEDURE SC_PROFIT_CENTER.PR_ACTUAL_AGENT_UTILIZATION_TX

(IN     CLIENT_LOB          VARCHAR(30),

IN PROCESS_TYPE     VARCHAR(30),

IN CIRCLE               VARCHAR(30),

IN LOCATION          VARCHAR(30),

IN CATEGORY          VARCHAR(30),

IN SUB_CATEGORY     VARCHAR(30),

IN START_DATE           DATE,

IN     END_DATE           DATE,

OUT     ACTUAL_AGENT_UTILIZATION DECIMAL(5,2))

LANGUAGE SQLSCRIPT

SQL SECURITY INVOKER

READS SQL DATA

AS

BEGIN

 

DECLARE V_AGENT_UTILIZATION_TIME INTEGER;

DECLARE V_TARGET_LOGIN_HOURS INTEGER;

DECLARE V_EMP_ATTENDANCE INTEGER;

DECLARE ACTUAL_AGENT_UTILIZATION DECIMAL(5,2);

DECLARE TARGET_TYPE VARCHAR(30);

 

CALL "SC_PROFIT_CENTER"."PR_AGENT_TIME"(

:CLIENT_LOB, :PROCESS_TYPE, :CIRCLE, :LOCATION, :CATEGORY, :SUB_CATEGORY,

:START_DATE, :END_DATE, V_AGENT_UTILIZATION_TIME);

 

ACTUAL_AGENT_UTILIZATION := :V_AGENT_UTILIZATION_TIME;

 

  END;

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

The above procedure calls the first procedure and the output of this procedure is captured in a integer variable declared "V_AGENT_UTILIZATION_TIME ".

 

Also this captured variable is assigned directly to another decimal variable declared in the following statement:

ACTUAL_AGENT_UTILIZATION := :V_AGENT_UTILIZATION_TIME;

 


Now after creating this procedure I am trying to call this procedure using the following call but is returns no result expect for a "?"

 

The call statement used to call the main procedure:

 

CALL "SC_PROFIT_CENTER"."PR_ACTUAL_AGENT_UTILIZATION_TX"(

'INBOUND121', 'Postpaid', 'Karnataka', 'Bangalore', 'CAT-B', 'HOTLINE',

'2013-06-01', '2013-06-30',?)

 

Result:

Out(1)

?

 

Question 1:

Please tell me what is wrong in my assignment statement ? or how to write correct assignment statement ?

 

Question 2:

Instead of having the above assignment statement if I have more complicated assignment statement like below, will the procedure still work ?

 

ACTUAL_AGENT_UTILIZATION :=              ( :V_AGENT_UTILIZATION_TIME/

                                        (   (:V_TARGET_LOGIN_HOURS*60*60)    *     (:V_EMP_ATTENDANCE)   )    )  *  100;

 

where :V_AGENT_UTILIZATION_TIME - is coming from first procedure

          :V_TARGET_LOGIN_HOURS  -  comes from other procedure just like first procedure

          :V_EMP_ATTENDANCE - comes from other procedure just like first procedure

 

using these three variables I am calculating a percentage value and assigning it to a decimal variable. Is this possible and is this correct way of calculating and assigning  a percentage value ?

 

Please help me in getting these answers.

 

Thanks in advance,

Chandan S Murthy


Viewing all articles
Browse latest Browse all 6412

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>