User Defined function in "Decision between multiple alternatives"
Hello,
I am looking to create my own User Defined function in the formula builder of the process type - "Decision between multiple alternatives" in a process chain.
Could anyone advise please how this can be done?
Many Thanks,
Abhijit
Hi Abhijit,
Where you want create you own user definefunction in Intergation planning or some where else.
Please specify your requirement.
Thanks and Regards,
Venkat.
Similar Messages
-
Decision Between Multiple Alternatives-Process Chain Formula
Hi,
I need to write a formula in the process type 'Decision Between Multiple Alternatives'.
If the current date is on the end of month then i need to trigger a monthly snapshot dataflow if not then daily dataflow needs to be triggered.
Anyone have any idea of how to write a formula for this?You can check both of these docs which defines how to use 'Decision Between Multiple Alternatives' process type:
[http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/900be605-7b59-2b10-c6a8-c4f7b2d98bae&overridelayout=true]
[http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/301fb325-9d90-2c10-7199-89fc7b5a17b9&overridelayout=true] -
Decision Between Multiple Alternatives in Process Chain
Hello all!
I wanted to use the process type "Decision Between Multiple Alternatives" in a process chain, so than i can choose wich DTPs will be executed. I was wondering to use the Function "PREDECESSOR_PARAMETER (<I_FIELDNAME>, <I_LOW_OR_HIGH>, <I_NUMBER_OF_VALUE>)" to get a parameter from an ABAP program step, but i do not know which I_FIELDNAME parameter should i use to receive the parameter. Did anyone use this logic or something similar? Do you think there are better ways of doing this?
Thanks in advance and Best regards,
NunoHi,
The decision process type allows you to determine a set of conditions
For more info go though the below link , as they have explained step by step with screenshots
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/900be605-7b59-2b10-c6a8-c4f7b2d98bae&overridelayout=true
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/301fb325-9d90-2c10-7199-89fc7b5a17b9&overridelayout=true
Regards,
Marasa. -
Decision between multiple alternatives process type
Hi All,
I want to use this process type "decision between multiple alternatives" in one of my process chains, but i want use this process type if the DELTA infopackage pulls ZERO records, skip the next process and more than ZERO records continue the process.
Please suggest me is it possible anyway.
Thanks a lot in advance.
Regards,
Ravi KanthHi,
You can't do it with Decision type process as the conditions allowed are standard System conditions. As Suggested above, you need a code before that. The logic can be sketched as :
1. Load the provider.
2. Obtain the latest request in the provider.
3. Get the data from the request (std SAP prog is available for reading from providers).
4. Raise error upon getting no data (in this case you need to put the steps to be skipped in another chain and use in the main chain as meta chain).
--Akashdeep -
Decision between multiple alternatives -question
Hello all,
I have some doubts about process Decision between Multiple Alternatives, from RSPC transaction.
The problem is like this:
1. I have one main process chain.
2. I have the process decision between multiple alternatives, in this main chain, after start.
I choosed formula and I put an if (as in the code below). Then I put the WORKINGDAY_MONTH
In it I want to test to have the 19-th working day of the current month , factory calender ' 01'.
If I have this day I want , I want to raise an event.
IF( WORKINGDAY_MONTH( Current Date, '01', '' ) = 19, 'ZEVENT_WD', 'ZEVENT_ERROR' )
This event would be usefull so I can start with it a second chain(inserted in the main chain).
The system says (when I check my formula) that it is sintactically correct, but incomplete.
Any clues why this message apears ?
I don't know if it is ok to put the events like that in my IF (one to start the subchain and one as error).
Thank you a lot.Hi,
The decision process type allows you to determine a set of conditions
For more info go though the below link , as they have explained step by step with screenshots
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/900be605-7b59-2b10-c6a8-c4f7b2d98bae&overridelayout=true
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/301fb325-9d90-2c10-7199-89fc7b5a17b9&overridelayout=true
Regards,
Marasa. -
How to use the 'Decision between multiple alternatives' Process variant
Hi ,
Can anyone tell me how to use the 'Decision between multiple alternatives' Process variant in BI 7 Process chains ?
The requuirement is that I have a DSO eg DSO 1 from which i have to load DSO 2 and DSO 3 . Now if the number of Records in DSO 1 are < 100 i will load DSO 2 from DSO 1 else i will load DSO 3 from DSO 1 .
So in the PC i have used a 'ABAP Program' variant (which counts the number of rows in DSO 1) after loading DSO 1 and after this 'ABAP Program' Variant , i have used the 'Decision between multiple alternatives' Process variant. Problem is it is giving me only some some system fields in the formula , like sy-datum or sy-timlo , which are of no use here .
It would be great if i can receive some help here .
--Devrajin RSPC you create a ABAP processing type "ending with specific values".
We use true or false for things as you specify.
your abap program should return a true or a false to indicate which of the situations is applicable.
Is this helpful?
Marco -
Decision between multiple alternatives
Hi,
Can i use the function like this
MONTH_QUARTER1( '0calmonth' ) = 1 where 0calmonth is a infobject either in DSO or cube.
When I checked , syntax is correct.
Can anyone tell me whether I can use the infobject like ocalmonth or 0calday.
Thanks in advance!This will work. You cannot use 0CALDAY directly because the data needs to be in the format YYYYMM. So, 0CALMONTH will work directly, but 0CALDAY will need to be converted first:
MONTH_QUARTER1( DATE_MONTH( 0CALDAY) ) -
Process chains Decision process user defined functions
Hi Experts,
In process chains process type decision we can define user defined functions. How to define these functions. Any help greatly appreciated. Thanks.
Best Regards,
Suresh.I can only find out "decision between multiple alternatives'//are you looking for this?
This is used to decide b/w different options as given in its menu....
--SA -
User defined function to find difference between dates
format of dtActivityStartDate/dtActivityFinishDate: 2010-09-17 14:50:51.150
usdFuncTimeCalc (vcActivityName,dtActivityStartDate, dtActivityFinishDate) -- user defined function
i need to calculate time elapsed for that type of activity following are the rules:
(If Process Request is the activity)
Working Days: Monday through Saturday
Hours of Operation: 9AM – 5PM
only working hours of day need to the counted like for example if it is sep 15 11 Am is dtActivityStartDate & Sep 17 is dtActivityFinishDate is 10 Am. then time elapsed is 11am to 5pm on sep 15 , 9 to 5 on sep 16 & 9 to 10 on sep 17 so total should be
6+ 8 + 1 = 15 hours + minutes.
format of date time: 2010-09-17 14:50:51.150
vcActivityName = Process Request
Don't worry about process request...I hv modified the code to make it more generic inorder to suit any timings (customizable) from Monday - Saturday.
declare
-- ** b u s i n e s s _ h o u r s **
-- business_hours returns the number of work houts (9 am through 5 pm,
-- Monday through Saturday) between in_start_dt and in_end_dt.
-- If in_start_dt > in_end_dt, the results will be <= 0.
-- Holidays are not considered.
in_start_dt DATE := to_date('15-SEP-2010 11:00:00','DD-MON-RRRR HH24:MI:SS');
in_end_dt DATE := to_date('17-SEP-2010 10:00:00','DD-MON-RRRR HH24:MI:SS');
d NUMBER; -- Hours of either start_dt or end_dt after midnight
end_dt DATE := GREATEST(in_start_dt, in_end_dt); -- In case dates were in wrong order
return_val NUMBER; -- Total number of working hours
start_dt DATE := LEAST(in_start_dt, in_end_dt); -- In case dates were in wrong order
start_time number := 9;
end_time number := 17;
BEGIN
WITH all_days AS(
SELECT start_dt + LEVEL - 1 AS a_dt
FROM dual
CONNECT BY LEVEL <= 1 + TRUNC(end_dt) - TRUNC(start_dt))
--SELECT SUM(12)
SELECT SUM(end_time-start_time)
INTO return_val
FROM all_days
WHERE TO_CHAR(a_dt,'Dy','NLS_DATE_LANGUAGE = ''ENGLISH''') NOT IN ('Sun');
dbms_output.put_line('Return_Val_1 : '||return_val);
-- Adjust hours from start_dt, if necessary
IF TO_CHAR(start_dt, 'Dy', 'NLS_DATE_LANGUAGE = ''ENGLISH''') NOT IN ('Sun') THEN
-- Calculate nbr of hours passed from midnight
d := 24 * (start_dt - TRUNC(start_dt));
dbms_output.put_line('d:'||d);
IF d >= end_time THEN -- d has passed 5 PM (end_time)
-- Don't count start_dt if it has passed the closing hours
return_val := return_val - (end_time-start_time);
dbms_output.put_line('if-d:'||return_val);
ELSIF d > start_time and d < end_time THEN -- d has passed 9 AM but less than 5 PM
-- Don't count the part of start_dt which has passed the opening hours
return_val := return_val - (d - start_time);
dbms_output.put_line('else-d:'||return_val);
END IF;
END IF;
dbms_output.put_line('');
dbms_output.put_line('Return_Val_2 : '||return_val);
-- Adjust hours from end_dt, if necessary
IF TO_CHAR(end_dt, 'Dy', 'NLS_DATE_LANGUAGE = ''ENGLISH''') NOT IN ('Sun') THEN
d := 24 * (end_dt - TRUNC(end_dt));
dbms_output.put_line('d:'||d);
IF d <= 9 THEN -- d < 9 AM
-- Don't count end_dt itself
return_val := return_val - (end_time-start_time);
dbms_output.put_line('if-d:'||return_val);
ELSIF d > start_time and d < end_time THEN -- d > 5 PM
-- Don't count part of end_dt
return_val := return_val - (end_time - d);
dbms_output.put_line('else-d:'||return_val);
END IF;
END IF;
dbms_output.put_line('');
dbms_output.put_line('Return_Val_3 : '||return_val);
IF in_start_dt > in_end_dt THEN
return_val := -return_val;
END IF;
dbms_output.put_line('');
dbms_output.put_line('Return_Val_4 : '||return_val);
END;Plz note the following points of the code :
1) You'll need to convert it a function, I just made it a declare..begin..end; block.
2) I hv used the same timings for start & end as you hv mentioned.
3) The 2 variables "start_time" and "end_time" take the opening & closing business hours respectively in a 24 hour format.
4) You might want to remove the DBMS_OUTPUT ... stmts which I had added for debugging.
It was an interesting code block to analyze ... :-) -
User Defined Function VS join - Performance....
Hi All,
while linking the mulitple table and getting the values ....which one is the best ?
Joining or User defined function.....
single row function
select a.name , get_salary(empid) from emp a;
Note : get_salary function will return the salary from salary tables.
Using joins
select a.name ,b.salary from emp a, salary b
where a.empid=b.empid;
which is the performancewise best ?
also if you give any related document also fine.
Thanks in advance.
Edited by: BASKAR NATARAJAN on Jan 6, 2011 10:09 PMDon't use such functions for joins. The function itself has to query the salary table. It will run the query against the salary table separately for each row that it reads from the emp table. You will end up with multiple recursive calls and possibly inconsistency in the output. (Imagine what would happen if the salary table were updated and commited while this query was running -- some rows would have been read with the pre-update values and others with the updated values).
Specifying the join in the query ensures that a single SQL call is executed and provides read consistency across all the rows it reads. And it is much faster, being one single parse and execute.
Hemant K Chitale
http://hemantoracledba.blogspot.com -
User Defined Function (Part 2)
Hi,
István Korös has finally solved my problem on User Defined Function.
See
My objective was to write a simple UDF to represent the following formula which Gordon Du gave me:
(DATEADD (s, -1,
DATEADD (mm, (DATEDIFF (m,0,@refdtzz ) + @mthnumber), 0)))
However, the solution proposed by István, although it works perfectly, leaves me scratching my head. Let's see why?
The only difference between my solution and that proposed by István is that István enclosed the UDF name between .
I wonder how this can make the vital difference between a (simple query!) that works well and one that gets blocked.
I tried several combinations of and am in for a few surprises, listed below. Can anybody explain what's going on?
Solution proposed by István:
CREATE FUNCTION [dbo].[udf_EndOfMonth]
and executed as:
select [dbo].udf_EndOfMonth (@refdt1 , 1)
Remarks: works perfectly
If I execute the UDF with exaclly the same name as in CREATE, it does not work
CREATE FUNCTION [dbo].[udf_EndOfMonth]
and executed as:
select [dbo].[udf_EndOfMonth] (@refdt1 , 1)
Error Msg: Must specify table to select from
If I don't put the , the function is created, but the execution of the calling query returns error
CREATE FUNCTION dbo.udf_EndOfMonth
Remarks : Creation OK
and executed as:
select dbo.udf_EndOfMonth (@refdt1 , 1)
Error Msg: Must specify table to select from
It seems that the only combination that works is that provided by István.
This is surely a simple UDF.
I don't know what to do if I attack a more complicated UDF.
Grateful if anybody could help light my way.
Thanks
Leon LaiHi Leon,
As István has already pointed out, there is no documentation for those small differences to make the SQL work or not. He must be tested quite a few times to find the actual working code. This question can only be answered by the developer who made this part for B1.
Thanks,
Gordon -
User-Defined Function and Context Manipulation
Hi Mapping Gurus, I need your help.
I have a user-defined function and one of my input parameter (c) is in a loop (EDI segment). So one, if I execute my function I get:
Exception:[java.lang.ArrayIndexOutOfBoundsException: 0]
If I change the context or use the remove context node function its working but its always taking the first row in consideration since I'm using c[0] . Here is the logic:
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[0]"'";
So since c is an array [], I have tried different logic to get to the right row.
1- I tried using another parameter (e) to pass a counter or an index to my function. So each time it's looping, it's passing a new value to the function but Im still getting the first row and Im not to sure why?
int G = Integer.parseInt(e[0]); // e[] = My counter field
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
2- I tried using a parameter stored in the container:
String Num;
Num = (String)getParameter(counter);
if (Num == null) G = 0;
else
G = Integer.parseInt(Num);
G = G + 1;
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
Num = "" + G;
setParameter(e[0], Num);
and Im still getting the first one, look like its using a different container each time its looping so the Value is always the same?
4- I created a new user-defined function with the container logic, then its working but Im back to the same problem in my main function, its only looking at e[0] for my counter all the time.
5- I tried using the Seeburger Java Variables and guess what in the main fonction, as new UDF,... and guess what, same result!
So anybody out there that was able to get UDF's working into a multiple context scenario?
Am I missing something?
I will reward points and beer for any help!This is one of the text with passing a counter to the function to try to go to the right row in the array since I'm doing a remove context and I'm getting all the d_234's:
public void ReadTable(String[] a,String[] b,String[] c,String[] d,String[] e,ResultList result,Container container){
int G = Integer.parseInt(e[0]); // My counter
String var;
String DBTABLE = a[0];
String lookUpField = d[0];
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
Now this one was with the internal container logic:
int G;
String DBTABLE = a[0];
String lookUpField = d[0];
String Num;
Num = (String)getParameter(e[0]);
if (Num == null) G = 0;
else
G = Integer.parseInt(Num);
G = G + 1;
Num = "" + G;
setParameter(e[0], Num);
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
And now with the Seeburger Variables:
int G;
try {
VariableBean be=VariableFactory.getVariableInstance("");
G = Integer.parseInt(String.valueOf(be.getStringVariable("yves")));
} catch (Exception f) {
throw new RuntimeException(f);
String DBTABLE = a[0];
String lookUpField = d[0];
String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
try {
G = G + 1;
Num = "" + G;
VariableBean be=VariableFactory.getVariableInstance("");
be.setStringVariable("yves",Num);
catch (Exception f) {
throw new RuntimeException(f);
All 3 logics were returning always the first row or a counter of 1 if the logic is in the main ReadTable function. -
Using a SQL user-defined function in Crystal Reports XI
Post Author: JoannKarp
CA Forum: Formula
Is it possible to use a user defined function in SQL and use this in multiple Crystal reports?
JoannKarpSELECT COALESCE(ufn_GetAddressByBusinessEntityIDandAddressTypeID(table1.BusinessEntityID,712),ufn_GetAddressByBusinessEntityIDandAddressTypeID(table1.BusinessEntityID,712)) AS Zipcode
FROM table1
Nope. This is two function calls. coalesce(a, b, c, ...) is just syntatic sugar for
CASE WHEN a IS NOT NULL THEN a
WHEN b IS NOT NULL THEN b
WHEN c IS NOT NULL THEN c
END
But if you use isnull it's a different matter. (But isnull() permits two arguments.)
Erland Sommarskog, SQL Server MVP, [email protected] -
Multi mapping question using user defined function
Hi,
I have a message with multiple occuring nodes (i.e. one message with multiple orders (header + detail)) that I need to map to a idoc. I need to filter out of the source based on order type (in header) from creating an idoc.. How do I do it using user defined function + message mappping ?
madAll - Thanks much.. Here is my requirement that is no solved by regular mapping
<Root>
<Recordset>
<Ordheader>
<ord>
<ord_type>
</Ordheader>
<Ord_line>
<ord>
<Linnum>
</Ord_line>
</Recordset>
<Recordset>
<Ordheader>
<ord>
<ord_type>
</Ordheader>
<Ord_line>
<ord>
<Linnum>
</Ord_line>
</Recordset>
<Root>
As you see above, each recordset has order transaction. One Root message can contain multiple of these. So, when I map to the IDOC, I want to filter out any ord_type <> XX.
If I use regular graphical map, it only looks at first recordset and accepts all or rejects all.
I need to use UDF. In the UDF, what comes in as input ? Resultset is output -correct ? Now how do I usse graphical mapping with UDF to generate the correct target info -
Using User Defined Function is SQL
Hi
I did the following test to see how expensive it is to use user defined functions in SQL queries, and found that it is really expensive.
Calling SQRT in SQL costs less than calling a dummy function that just returns
the parameter value; this has to do with context switchings, but how can we have
a decent performance compared to Oracle provided functions?
Any comments are welcome, specially regarding the performance of UDF in sql
and for solutions.
create or replace function f(i in number) return number is
begin
return i;
end;
declare
l_start number;
l_elapsed number;
n number;
begin
select to_char(sysdate, 'sssssss')
into l_start
from dual;
for i in 1 .. 20 loop
select max(rownum)
into n
from t_tdz12_a0090;
end loop;
select to_char(sysdate, 'sssssss') - l_start
into l_elapsed
from dual;
dbms_output.put_line('first: '||l_elapsed);
select to_char(sysdate, 'sssssss')
into l_start
from dual;
for i in 1 .. 20 loop
select max(sqrt(rownum))
into n
from t_tdz12_a0090;
end loop;
select to_char(sysdate, 'sssssss') - l_start
into l_elapsed
from dual;
dbms_output.put_line('second: '||l_elapsed);
select to_char(sysdate, 'sssssss')
into l_start
from dual;
for i in 1 .. 20 loop
select max(f(rownum))
into n
from t_tdz12_a0090;
end loop;
select to_char(sysdate, 'sssssss') - l_start
into l_elapsed
from dual;
dbms_output.put_line('third: '||l_elapsed);
end;
Results:
first: 303
second: 1051
third: 1515
Kind regards
TaoufikI find that inline SQL is bad for performance but
good to simplify SQL. I keep thinking that it should
be possible somehow to use a function to improve
performance but have never seen that happen.inline SQL is only bad for performance if the database design (table structure, indexes etc.) is poor or the way the SQL is written is poor.
Context switching between SQL and PL/SQL for a User defined function is definitely a way to slow down performance.
Obviously built-in Oracle functions are going to be quicker than User-defined functions because they are written into the SQL and PL/SQL engines and are optimized for the internals of those engines.
There are a few things you can do to improve function
performance, shaving microseconds off execution time.
Consider using the NOCOPY hints for your parameters
to use pointers instead of copying values. NOCOPY
is a hint rather than a directive so it may or may
not work. Optimize any SQL in the called function.
Don't do anything in loops that does not have to be
done inside a loop.Well, yes, but it's even better to keep all processing in SQL where possible and only resort to PL/SQL when absolutely necessary.
The on-line documentation has suggested that using a
DETERMINISTIC function can improve performance but I
have not been able to demonstrate this and there are
notes in Metalink suggesting that this does not
happen. My experience is that DETERMINISTIC
functions always get executed. There's supposed to
be a feature in 11g that acually caches function
return values.Deterministic functions will work well if used in conjunction with a function based index. That can improve access times when querying data on the function results.
You can use DBMS_PROFILER to get run-time statistics
for each line of your function as it is executed to
help tune it.Or code it as SQL. ;)
Maybe you are looking for
-
Telstra Air App For Windows 8.1 Phone
When will Telstra be providing an Air App for WIndows 8.1 phone?
-
Error Handling in BPM - Send Step
Hello, I would like to implement the following two error handlers using BPM: 1. There is a send step which sends a message to an HTTP receiver. If the HTTP server is down I would like to add 3 retries and just in case after the third retry fails ther
-
Increase speed visa read write
Hi guys, I am using the visa read and write example, but I am facing some issue when using it in a larger software, and I can only receive date when the vi has been slown down (using the lightbulb). The programme definitely works on it own with the s
-
How do i enable the diagnostic pages for OER 11.1.1.3.0?
I'm currently trying to enable the diagnostic pages for OER 11.1.1.3.0. In the documentation the following is stated: In Oracle Enterprise Repository 11g release, Oracle Enterprise Repository Diagnostics page is disabled, by default. Navigate to http
-
Sort the data set after quering
Hi I have a grid where I query and load the data. Is it possible to filter and show the same data set which I have got in the grid with a check box item. Some occasions needs to get input for the said filter from the first row of the grid. (Dev Forms