Create Functions weirdness
trying to create a function with the following
create or replace function pastClosedSales( repName IN VARCHAR2,
period IN NUMBER , cid IN VARCHAR2)
return NUMBER is grandTotal NUMBER(10,2) ;
begin
select sum(job_act_price) into grandTotal
from job
where to_period(job_finish_time) = period
and job_status = 5
and emp_code_srep = repName
and plant_code = cid ;
end ;
job is a publix synonym and can be used in an ordinary select statement
to_period is a function I've already created that works as expected
when I compile this I get errors like
4/1 PL/SQL: SQL Statement ignored
4/48 PL/SQL: ORA-00942: table or view does not exist
Not sure why as I can take the SQL out of this and put values and things work fine
As explained above, you must grant the SELECT priv. explicitly to the user creating the function.
You probably have a role based access to the table, that is why it works within SQL*Plus. Try this:
SQL> set role none ;
SQL> select * from job ;Does that give you output? if not, you need to gratn the SELECT priv. explicitly.
Similar Messages
-
Create Functional Area via Job Architecture in Non-English language
Dear Experts,
We're running following environment.
- Windows Server 2003 Std SP2 64bit (32bit conversion completed)
- SAP ERP 6.0 EhP 4 Unicode system as back-end system for STVN
- STVN 2.1 SP1 with Japanese Language pack
- Language = Japanese and English
- TREX setting is not ready (will be ready soon)
The problem is we cannot create Functional Area via Job Architecture
if we log on Job Architecture module with JAPANESE.
(We can create Functional Area if we log on with ENGLISH)
[Procedure]
1. Launch Job Architecture module with Japanese
2. Job Architecture => Create Functional Area (under Tasks)
3. Key in [Title] and [Abbreviation], and then click [Add]
4. Error message "Not able to load DLL or CLASS" appears
I have already confirmed that if I do same thing with English,
Functional Area was created in ECC environment.
What settings am I missing?
Best Regards,
Masaya IizumiDear Luke and Eugene
Thank you very much for the reply.
I have understood that it is known issue for .NET platform for 2.1 SP1.
I will communicate with Nakisa Support.
Again, thank you very much for your kind cooperation.
Best Regards,
Masaya -
Doubt in export, import and table para when creating Function Module
Dear fellow ABAPers,
I have a doubt in defining export, import and table parameter while creating a function module.
I am calling a function module inside a user exit. Now in the user exit the SAP fills an internal table called i_lfa1 with all the data user has eneterd.
Now I want to pass this whole internal table to function module and the perform some checks on the values of internal table.
After that function module fills an error structure with values depending on some check.
1)
How do I pass this internal table to function module ?
When I am creating function module in se37 where do I define this iternal table type ? Is it in Import or Table parameter during function module creation?
2)
Where do I define error structure type (which is returned by function module to main program)? Is it in Export or table parameter during function module creation?
Please clear my doubt..
Relevant points will be awarded.
Regards,
Tushar.Hi Tushar,
1. How do I pass this internal table to function module ?
I assume u are creating your own Y/Z FM.
Pass it thru TABLES parameter.
2. When I am creating function module in se37 where do I define this iternal table type
Define this in TABLES interface.
What Type ?
THE SAME TYPE WHICH HAS BEEN DEFINED
WHILE PASSING IN THE USER-EXIT FUNCTION MODULE.
IF U SEE THE FM OF THE USER-EXIT,
U WILL COME TO KNOW.
3.
Where do I define error structure type (which is returned by function module to main program)? Is it in Export or table parameter during function module creation?
Define it in TABLES interace. (not in export, import)
(Since what u are going to return is an internal table)
U can take for eg. BDCMSGCOLL.
OR u can create your own Y/Z structure
for the same purpose.
(or u can use the structure type T100)
I hope it helps.
Regards,
Amit M. -
Creating function to calculate average value
Hi,
The below query was successfully return an average value. It returned 1 row.
SELECT AVG(Volume)
FROM security
WHERE
Type = 'Future' AND
Rating = 'AAA' AND
Code = 1 AND
(Day = ''14-mar-09' OR
Day = '16-mar-09' OR
Day = '');
I tried to use that function on my created function below.
CREATE OR REPLACE FUNCTION fn_Vol_Average
( v_DayLast_1_Week IN DATE,
v_DayLast_2_Week IN DATE,
v_DayLast_3_Week IN DATE )
RETURN NUMBER IS
v_Vol_Average NUMBER;
BEGIN
SELECT AVG(Volume) INTO v_Vol_Average
FROM security
WHERE
Type = 'Future' AND
Rating = 'AAA' AND
Code = 1 AND
(Day = v_DayLast_1_Week OR
Day = v_DayLast_2_Week OR
Day = v_DayLast_3_Week);
RETURN NVL(v_Vol_Average, NULL);
END;
I called that function by the following query. it was work, however it return the whole rows. It looks like the function perform the average calculation of each rows on the table.
Can anyone help me what is going on with the logic?
select fn_Vol_average('14-mar-09','16-mar-09','')
from security
--But since your function calculates the average over the whole security table, you wouldn't call this from a select statement which also reads the security table.
You just want to execute it once.
declare
l_vol_average number;
begin
l_vol_average := fn_Vol_average('14-mar-09','16-mar-09','');
dbms_output.put_line(l_vol_average);
end;By the way, be careful with your date parameters. You should use TO_DATE with a proper format mask to prevent conversion errors. -
How to create function module for getting customer name
Hi Experts,
How to create function module? when in import parameter kunnr values to be passed it must give name1 details according to the customer number...
how to write the logic in source code....
Regards,
Thiru. R1. First of all create function group.
2. Create function module using this function group.
3. If only one kunnr is needed at a time, create import parameter for it. But if many kunnr to be entered at a time,use table.
4. Fetch name1 for each kunnr from KNA1 table.
"->> if many kunnr
if not t_kunnr[] is initial.
select kunnr as kunnr name1 as name1
into table t_kunnr_name1
from kna1
for all entried in table t_kunnr
where kunnr = t_kunnr-kunnr.
endif.
sort t_kunnr_name1 by kunnr name1.
delete adjacent duplicates from t_kunnr_name1 comparing kunnr name1.
table t_kunnr_name1 will contain kunnr and its name1.
I hope logic is clear for you now.
Regards,
Aparna -
In my own NW RFC-SDK based application, I am trying to create a RFC module description the hard way, which is to not download such a description from a SAP system, but to craft the description on-the-fly using API functions RfcCreateFunctionDesc, RfcCreateTypeDesc, RfcAddTypeField, RfcAddParameter and RfcCreateFunction. When calling RfcCreateFunction the system responds with the message
"inconsistence in description detected: non-unicode length is too small".
As far as I can tell all values I provided in the API arguments are correct, including the unicode and non-unicode lengths in the type description of a structure that is underlying the only RFC parameter in the module.
Here is what the module isi supposed to look like:
module has only one Export parameter
the parameter is structured
the structure has a single field only, which is a character array of length 64 (i.e 128 bytes).
My application is unicode based. I added some code to the application to trace the API calls along with the argument values. Here is the output:
API RfcCreateFunctionDesc
Created function description object; returned handle: 024A1880
API RfcCreateTypeDesc
Created type description object; returned handle: 024A1A00
API RfcAddTypeField
Added Field to type description 024A1A00:
name DEST
type 0
nucLength 64
nucOffset 0
ucLength 128
ucOffset 0
decimals 0
typeDescHandle 00000000
extendedDescription 00000000
API RfcAddParameter
Added parameter to funtion description 024A1880:
name ATTRIBUTES
type 17
nucLength 64
ucLength 128
decimals 0
typeDescHandle 024A1A00
optional 0
direction 2
parameterText
defaultValue
extendedDescription 00000000
API RfcCreateFunction
Created function object from description 024A1880; returned handle: 00000000
RFC_INVALID_PARAMETER inconsistence in description detected: non-unicode length
is too small
Thanks so much for any help!Case closed. There was an API call missing in my code, RfcSetTypeLength, which sets the total lengths (unicode and non-unicode) of the structure after adding the structure components.Without that call the system assumes those lengths to be zero, thus the error ...
-
Create function as "/ as sysdba" not shipped/applied to logical standby
As the subject states, I was creating a password verify function and profile that used the function as sys "/ as sysdba" .
The function was not created on the logical standby and thus the profile create statement failed. The function was not even listed in the standby's alertlog, although the create profile statement was.
I created the function manually on the standby by connecting / as sysdba and creating the function and then restarted logical standby apply. The standby then created the profile and continued without error.
Is this a bug?
Should the SYS 'create function' be shipped and applied or not?
When the function create statement was run on the primary as a non-sys user with DBA privs, it created ok and was shipped and appeared on logical standby ok.
Any ideas DataGuard Gurus?
(9.2.0.7 on Solaris 8)I logged a Tar. Oracle says:
"Ideally any object created on sys schema should get skipped automatically. sys is consider as internal schema and objects created in sys schema should get
skipped"
"But because of the internal Bug.3576307 "LOGICAL STANDBY IS NOT SKIPPING DDL IT SHOULD." it is not skipping the DDL executed on sys schema. This bug
is fixed in 10.2.
You can issue following statement to enable the DDL skip on sys schema.
SQL> ALTER DATABASE STOP LOGICAL STANDBY APPLY;
SQL> EXECUTE DBMS_LOGSTDBY.SKIP_ERROR(SCHEMA_DDL, SYS, null, null)
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY;
After which all DDL errors encountered on any object in the SYS schema would be ignored and processing continued. This can render the TEST schema objects unusable and, if necessary, you can later recreate the tables
using the INSTANTIATE_TABLE procedure."
Makes sense now. -
Creating Functions in SQL server
HI
i creating functions for specific purpose in the test database...
is it against SAP Support policy?
suggest me...if you are just going to start entries then you can .
But i have posted then Use replace function in SQL
SQL Syntax:
REPLACE( string1, string2, string3 )
Parameters:
string1
Any character string or binary expression that can contain the string from string2.
string2
Any character string or binary expression. This string is searching in string1.
string3
Any character string or binary expression. This string replace all occurrence of string2.
May it will work
Thanks
Manvendra Singh Niranjan -
How to create function panels for my own C functions?
I've been searching for a way to create my own function panels. CVI documentation seems to suggest that this can be done but the explanation inevitably turns to instrument drivers, not C functions.
I don't yet know what an instrument driver is. So far I've never needed one. I just want to know how to put plain old C functions that I've created into the library tree for coworkers to use. Is that practically possible?The facility is couched in terms of "instrument driver" but it can be used for an arbitrary CVI function you've created.
First make a function tree from File pull down menu new ... Function Tree
Then right click in blank function tree panel and create instrument or use Create pulldown menu, enter name as prompted, use help button. You need to choose a "prefix" for your function names.
The tricky part is when you want to add a function to your "instrument" you right click on the <create class or function panel window> token the first time, thereafter when adding a function you right click on one of the functions you've already added. In either case you want to "create function panel window" which brings up the function panel window editor whcih allows you to place input controls that match the function signature.
There's a learning curve but keep at it. The help is good, use it.
Menchar -
How to create function module in real time
hi experts,
can somebody explain a real time requiremwnt , to create a function module.
its very urgent.
i want elaborately.
regards,
subhasis.hi,
In real time
1. as per my knowledge we create function modules to Inbound IDOC /outbound processing..
2.Interface between a program..
Example we need to take some data from a report say materials and plant and process some bapi and return logfiles to the report we can use FM here too.
To create a function module
First you need to create a function group (function group holds a number of function modules relevant)
SE37>goto>function groups-->create group ..click this create group..
Now in the pop up enter the function groupname Eg: ZW_FG1 plus short text and saveit
Now again goto SE37--> enter new Function module name eg:ZW_FM1
and press F5.
Now again a popup you need to enter
function group name : ZW_FG1
and short test and save it..
Now the Function module is created under the Function group ZW_FG1.
write your export import table parameters and you source code.
rewards if useful
regards,
nazeer
Message was edited by:
nazeer shaik -
How to create function module in abap for VirtualProvider in bi
how to create function module in abap for VirtualProvider in bi ???????????????
can any one help me with simple example ?????????????????
Moderator message : Duplicate post locked. Read forum rules before posting.
Edited by: Vinod Kumar on Jun 15, 2011 4:40 PMHi ,
Thanks for replies about my question??.
If i am using the exit in my char relation ship how can i debugg that exit???
if i am using BPS0 how to do it???If i am using BPS_WB how to do it??
Case1.Variable (type Exit) I known how to do debugg this one in BPS0 but i'm not sure in BPS_WB??
Case2:Char Relation Ship(Type Exit) how to do in BPS0 and BPS_WB??.
Thanks. -
Best practice - creating functions in data model vs. rtf template
Just a general question. Is there a best practice of creating functions in the data model vs. creating the functions in the data template?
For example, is it more efficient to sum two fields in my SQL query or to create a function in the template that sums the two fields? Just curious if there is any performance benefit of one over the other.
Thanks!anything you push it to DB(SQL), will be the faster than processing outside.
-
Server repository could not create function template for ...
Hello,
we are trying to send rfc and idocs from SAP to MII but we always get errors like:
Server repository could not create function template ...
or
The meta data for the IDoc type "HRCC1DNPERSO01" is unavailable.
Has anyone an idea?
Kind Regards,
Christoph MertinsHi Christoph,
Per the resolution of the CSS Ticket:
Parameters that are not mentioned in the SDN guide were needed in your particular situation.
The necessary parameters for configuring the MII side of the IDoc Listener are explained in the MII Help Documentation in the Client Properties section:
http://help.sap.com/saphelp_xmii120/helpdata/en/45/a705b23c14532ae10000000a1553f7/content.htm
All others are described in the Message Listeners section here:
http://help.sap.com/saphelp_xmii120/helpdata/en/45/6a86ac88130dece10000000a11466f/content.htm
Can you please update this post to reflect your particular situation so the SDN community can benefit from your experience?
Kind Regards,
Diana Hoppe
Edited by: Diana Hoppe on Dec 9, 2008 9:06 AM -
How to create function module step by step
hi experts,
i am new to ABAP.
can anybody tell me the step by step process on how to create a function module for adding two numbers without using editor screen.
ex: 2+3=5.Hi,
You can only create function modules and function groups using the Function Builder in the ABAP Workbench. For further information, refer to Creating New Function Modules. This section uses an example to illustrate how a function module is created from the point of view of ABAP programming.
Function Groups and Function Modules:
Firstly, we create a new function group DEMO_SPFLI to hold the function module. Then, we can create the new function module.
Parameter Interface:
You can specify the types of interface parameters in function modules in the
same way as the parameter interfaces of subroutines. Since function
modules can be used anywhere in the system, their interfaces can only contain
references to data types that are declared systemwide. These are the elementary
ABAP data types, the systemwide generic types, such as ANY TABLE, and types
defined in the ABAP Dictionary. You cannot use LIKE to refer to data types
declared in the main program.
Exceptions:
Our function module needs an exception that it can trigger if there are no entries
in table SPFLI that meet the selection criterion. The exception NOT_FOUND
serves this function.
Source Code:
Having defined the parameter interface and exceptions, we can now write the
source code of our function module. To do this, choose Source code in the
Function Builder. This opens the ABAP Editor for the include program
L<fgrp>U<xx> (see Function Groups). This is the include that will
hold the program code for the function module;
Data in Function Modules
You can use the TYPES and DATA statements to create local data types and
objects. The interface parameters also behave like local data objects. In
addition, you can access all of the global data of the main program. This data is
defined in the include program L<fgrp>TOP. To open this include, choose Goto
Global data. The global data behaves like the instance attributes of a class.
The first time you call a function module in a particular function group, the data is
loaded into memory. It can then be accessed and changed by all of the function
modules in the group. The system retains the values until the next time a function
module is called.
Calling Subroutines
You use subroutines for local modularization. Function modules can
also use this technique. The function module that they call are defined in the
corresponding main program.
If you only want to call a subroutine from a single function module, it is best to
define them in the same include program as the function module itself, directly
after the ENDFUNCTION statement. These subroutines can be called from all
function modules in the function group, but for clarity, they should only be called
from the function module that precedes them.
If you want to define a subroutine that will be called from several different function
modules, you can define a special include program for it with the name
L<fgrp>F<xx>.
Raising Exceptions
There are two ABAP statements for raising exceptions. They can only be used in
function modules:
RAISE <except>.
and
MESSAGE..... RAISING <except>.
The effect of these statements depends on whether the calling program handles
the exception or not. If the name <except> of the exception or OTHERS occurs
in the EXCEPTIONS addition of the CALL FUNCTION statement, the exception is
handled by the calling program.
If the calling program does not handle the exception
The RAISE statement terminates the program and switches to debugging mode.
The MESSAGE ..... RAISING statement display the specified message. How the
processing continues depends on the message type.
If the calling program handles the exception, both statements return control to the
program. No values are transferred. The MESSAGE ..... RAISING statement
does not display a message. Instead, it fills the system fields SY-MSGID, SYMSGTY,
SY-MSGNO, and SY-MSGV1 to SY-MSGV4.
Source Code of READ_SPFLI_INTO_TABLE
The entire source code of READ_SPFLI_INTO_TABLE looks like this:
FUNCTION READ_SPFLI_INTO_TABLE.
""Local interface:
*" IMPORTING
*" VALUE(ID) LIKE SPFLI-CARRID DEFAULT 'LH '
*" EXPORTING
*" VALUE(ITAB) TYPE SPFLI_TAB
*" EXCEPTIONS
*" NOT_FOUND
SELECT * FROM SPFLI INTO TABLE ITAB WHERE CARRID = ID.
IF SY-SUBRC NE 0.
MESSAGE E007(AT) RAISING NOT_FOUND.
ENDIF.
ENDFUNCTION.
The function module reads all of the data from the database table SPFLI where
the key field CARRID is equal to the import parameter ID and places the entries
that it finds into the internal table SPFLI_TAB. If it cannot find any entries, the
exception NOT_FOUND is triggered using MESSAGE...RAISING. Otherwise, the
table is passed to the caller as an exporting parameter.
Regards,
Chandru -
AUTO CREATE Function in OM responsibility
Hi,
I did add "auto create" function to OM custom responsibility, i can open the form and query the requisitions but when i tried to create give me error message Function Not available in this responsibility. Change responsibilities or contact system administrator.
Is there any specific purchasing profiles need to setup for the OM custom responsibility?
ThanksHello,
I mean sub menu. I think you must add some additional function many time I had similar problems like you ( not in the same form) and I always must add something more.
On Monday will have access to my apps and I will check it.
Regards,
Luko
Maybe you are looking for
-
Finding DW tutorial [subject edited by moderator]
Is there a way to find a tutorial after you accidentally closed it? I don't remember which one it was, only that it was in dreamweaver cs6 and I was watching it earlier today.
-
WinXP:Ok .vs. Win2000:Error character mode report (6i)
Hello, We have a character mode report designed and running in a Windows XP machine. To make it work was necessary to create a custom PRT file that contains the condensed and non condensed printer codes used by the report. After some tries it is runn
-
Hi, how can configure the logical standby process to start automatically after i restart database? thanks
-
Stationery in different language
When using the stationery in Mail, the body of the message is in a different language. The header and footer are in english. How can I change it to English?
-
Can i use ipad air charge to charge iphone 5s
can i use ipad air charge to charge iphone 5s? same power output?