Passing reference to a function as a parameter?
Is it possible to pass a reference to a function as a parameter to a function in Java? If so, how would I do this?
banker2010 wrote:
georgemc wrote:
banker2010 wrote:
georgemc wrote:
banker2010 wrote:
ner0 wrote:
Is it possible to pass a reference to a function as a parameter to a function in Java? If so, how would I do this?how do you pass a reference? where did you get this idea?Where did you get the idea you couldn't? Not from the old "Java is pass-by-value" thing, I hope. Because references are indeed passed. By value. Think about itgeorge, doesnt the book say an address or a pointer is passed in? where did you get the idea that java passes references? NO! it does not! and nobody does! never!I said "think about it"
Don't tell me, we're mocked by valoo or some such rubbishyeah, think! the bits that are passed in represent an address or a pointer, NOT a reference! who or what passes a reference!
demock yourself!Bye bye, daffy
Similar Messages
-
How to pass select-option filed to Function Module Exporting Parameter
Hi,
How to pass select-option filed to Function Module Exporting Parameter.
ThanksHi,
DATA: BEGIN OF ITAB5_WRK OCCURS 0,
KUNNR TYPE KNKK-KUNNR, "CUSTOMER #
SBGRP TYPE KNKK-SBGRP, "CREDIT REP
KLIMK TYPE KNKK-KLIMK, "CREDIT LIMIT
NAME1 TYPE KNA1-NAME1, "CUSTOMER NAME
SKFOR TYPE KNKK-SKFOR, "TOTAL A/R
AMT1 TYPE KNKK-SKFOR, "CURRENT
AMT2 TYPE KNKK-SKFOR, "01-30
AMT3 TYPE KNKK-SKFOR, "31-60
AMT4 TYPE KNKK-SKFOR, "61-90
AMT5 TYPE KNKK-SKFOR, "91-120
AMT6 TYPE KNKK-SKFOR, "OVR 120
BZIRK TYPE KNVV-BZIRK,
END OF ITAB5_WRK.
SELECT-OPTIONS P_COMP FOR T001-BUKRS
SELECT KUNNR SBGRP FROM KNKK
INTO TABLE ITAB5_WRK
WHERE SBGRP IN P_REP
AND KUNNR GE '0001000000'
AND SKFOR NE 0.
LOOP AT ITAB5_WRK.
DELETE ADJACENT DUPLICATES FROM ITAB5_WRK COMPARING KUNNR.
ENDLOOP.
PERFORM GET_CREDIT_LIMITS.
*=======================================================================
IF P_DIST NE SPACE.
LOOP AT ITAB5_WRK.
SELECT SINGLE * FROM KNVV WHERE KUNNR EQ ITAB5_WRK-KUNNR
AND VKORG EQ P_COMP
AND VTWEG EQ '20'
AND SPART EQ '10'
AND BZIRK IN P_DIST.
IF SY-SUBRC EQ 0.
MOVE KNVV-BZIRK TO ITAB5_WRK-BZIRK.
MODIFY ITAB5_WRK.
ELSE.
DELETE ITAB5_WRK.
ENDIF.
ENDLOOP.
ENDIF.
*==============================================================
LOOP AT ITAB5_WRK.
MOVE: 'F/S' TO WRK-KKBER,
ITAB5_WRK-KUNNR TO WRK-KUNNR.
PERFORM AGING.
ADD: W_SNFAE TO ITAB5_WRK-AMT1,
W_SFAE1 TO ITAB5_WRK-AMT2,
W_SFAE2 TO ITAB5_WRK-AMT3,
W_SFAE3 TO ITAB5_WRK-AMT4,
W_SFAE4 TO ITAB5_WRK-AMT5,
W_SFAE5 TO ITAB5_WRK-AMT6,
W_SFAEL TO ITAB5_WRK-SKFOR,
W_SNFAE TO ITAB5_WRK-SKFOR.
MOVE: 'SPEC' TO WRK-KKBER,
ITAB5_WRK-KUNNR TO WRK-KUNNR.
*PERFORM AGING.*
ADD: W_SNFAE TO ITAB5_WRK-AMT1,
W_SFAE1 TO ITAB5_WRK-AMT2,
W_SFAE2 TO ITAB5_WRK-AMT3,
W_SFAE3 TO ITAB5_WRK-AMT4,
W_SFAE4 TO ITAB5_WRK-AMT5,
W_SFAE5 TO ITAB5_WRK-AMT6,
W_SFAEL TO ITAB5_WRK-SKFOR,
W_SNFAE TO ITAB5_WRK-SKFOR.
MODIFY ITAB5_WRK.
ENDLOOP.
FORM AGING.
*CALL FUNCTION 'CUSTOMER_DUE_DATE_ANALYSIS'*
EXPORTING
BUKRS = P_COMP
KKBER = WRK-KKBER
KUNNR = WRK-KUNNR
RASID = 'FEND'
KLIMP = 'X'
IMPORTING
SFAE1 = W_SFAE1
SFAE2 = W_SFAE2
SFAE3 = W_SFAE3
SFAE4 = W_SFAE4
SFAE5 = W_SFAE5
SFAE6 = W_SFAE6
SFAEL = W_SFAEL
SNFA1 = W_SNFA1
SNFA2 = W_SNFA2
SNFA3 = W_SNFA3
SNFA4 = W_SNFA4
SNFA5 = W_SNFA5
SNFA6 = W_SNFA6
SNFAE = W_SNFAE
EXCEPTIONS
NO-AGING_SCHEDULE = 1
NO_TABLE_INPUT = 2.
CASE SY-SUBRC.
WHEN 1.
MESSAGE E999 WITH 'PLEASE ENTER AGING SCHEDULE'.
WHEN 2.
MESSAGE E999 WITH 'DO NOTHING ??'.
ENDCASE.
ENDFORM. "AGING
Thanks -
Adding a CM: Invalid length parameter passed to the RIGHT function. (CINF)
We started seeing this error message a week ago when attempting to add a Credit Memo. We only see this error message when entering Credit Memos and not any other finacial documents. I've done some preliminary research and haven't really come up with anything to point to the issue. Prior to reporting this to my support partner, I wanted to see if anybody here has seen this before or give me some ideas to look into the source of the issue.
Full error message: Microsoft SQL Native Client SQL Server Invalid length parameter passed to the RIGHT function. (CINF)Checking the list of form ID's at [http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/892] shows the A/R Credit Memo as 179 and the A/P Credit Memo as 181. This also corresponds with what I see when viewing the system information on the form.
-
Problem with empty report parameters when passed to PL/SQL function
Hi,
We have come across what appears to be a bug in the JRC. When passing a report parameter to a PL/SQL function as a parameter, empty parameters are changed before being sent to the function. More specifically, an empty string "" ends up as the value "(')" in the PL/SQL function parameter. In our report we print the report parameters on the first page so we know that the parameters are OK before being passed to the database.
The problem exists for version 12.2.203, 12.2.204 and 12.2.205 of the JRC.
We have identified a workaround, but it is not exactly elegant: Before executing the report we modify all empty parameters ("") to " " . In the PL/SQL function, we trim all parameters before using them.
We call the function using a command object with a sql syntax like this example:
select * from table (qa_batch_release.get_qa_br('{?p_report_id}','{?p_reg_set_number}','{?p_cr_number}','{?p_change_id_decode}','{?p_country_id}','{?p_mfg_item_no}','{?p_4_no}','{?p_5_no}','{?p_7_no}'))
The PL/SQL function is a table returning function.
Best regards, ThorHi Kishore,
using #COLUMN_VALUE# would probably not make much sense, because normally a report has multiple columns and not just the numeric column which you want to verify if it's negative. But APEX will fire the template condition for each column, because the report template is a column cell template.
What you can do to make it more generic is to use for example
#CHECK_AMOUNT#
in the template and provide a not displayed column in your SQL statement which contains your value which is named CHECK_AMOUNT. For example:
SELECT NAME
, BALANCE
, BALANCE AS CHECK_AMOUNT
FROM XXX;Because this CHECK_AMOUNT column would be a generic name, you can use this template in all your reports as long as you provide this column.
Thope that helps
Patrick -
How to pass strin in a function
Hi,
I have 1 function and the parameter is v1 varchar2(2000).
Now I am calling this function in Select query and I want to pass 'SME','DSP' string in a function parameter.How can I pass
Please help.
Regards
AnantI have 1 function and the parameter is v1 varchar2(2000)A basic thing is that, you can not specify length in parameter specification. How can you say parameter is
VARCHAR2(200) ?
Post your function code and what you want to do clearly. -
How to use INVOKE function with INT parameter types
Can you tell me how to use invoke function with int parameter type ?
Pass the int as an Integer.
-
Hi, i'm new to Coldfusion, and i'm a little confused in
regards to passing parameters to a function using
<cfinvokeargument>. My question is: Does the name of
parameter in the cfinvokearguments have to be the same name as the
cfargument name that you're passing the value to? Because that
seems to go against the whole "black box" thing i was taught. And
is there a way to pass the values without having to have to know
the name of the variables in the function?If you are passing variables to the function then yes the
names need to be the same. There are ways around this which goes to
your second question about passing variables without knowing the
name. (see
http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm ?context=ColdFusion_Documentation&file=00001056.htm)
As an example I have a document that I want to index and some
indexes will be filled out by the user and some will not so how
would I be able to tell which vars are passed to the
function….So I would loop the Indexes assigned to the
document and check to see if they were passed to the CFC doing
something like this...
EXAMPLE:
<cfquery name="getDocIndexes_rs"
... this is a query to the get the document's indexes ....
</cfquery>
<cfloop query="getDocIndexes_rs">
<!--- check the arguments scope to see if this index var
exist --->
<cfif
isDefined("arguments.Index#getDocIndexes_rs.IndexID#")>
<!--- if defined then get the value ---->
<cfset IndexValue =
arguments["Index"&getDocIndexes_rs.DMIndexID]>
<!--- do something with indexvalue ....... ---->
Ok that was probably a bit much so to simplify this here....
When I sent the variables to the function I did not use the
cfargument to specify the name(s) because I have no idea what they
were at the time.
As an example for yourself pass a variable to a function
using the cfinvokeargument but do not use the cfargument tag. Then
return the variable by doing this.
<!---- THE CFC PAGE (named testreturn.cfc) --->
<cfcomponent>
<cffunction name="myFunction" access="public"
returntype="string">
<cfset myResult= arguments.testvar>
<cfreturn myResult>
</cffunction>
</cfcomponent>
<!---- THE CFM PAGE THAT CALLS THE CFC --->
<cfinvoke component="YourPath.testreturn"
method="myFunction" returnvariable="myResult">
<cfinvokeargument name="testvar" value="HELLO">
</cfinvoke>
<cfoutput>#myResult#</cfoutput>
Hope that wasn’t confusing enough for you...I am tired
so that is my excuse and this is the best I can do at the moment. -
Passing Select-option to Function Module
Hi ,
I want to pass a select-option directly to the function Module tables parameter . Can anyone highlight on how i can declare the table in Function module side .
Thanks & Regards,
RajHi.
In the TABLES tab of the specific FM ,
give the parameter name ( which u have defined as Select options ). Since select options is like an Internal Table with values sign,option,low and high , u can give it here.
Also give the ref. type and type specification.
Pl try this.
Thanks,
Maheshwari.V -
Is it possible in java to pass reference of object in Java?
Hello,
I'm relativily new to Java but I have "solid" knowledge in C+ and C# .NET+.
Is it possible in java to pass reference of object in Java? I read some articles about weakreferences, softreferences, etc. but it seems that it's not what I'm looking for.
Here is a little piece of code I wrote:
package Software;
import java.util.Random;
* @author Rodrigue
public class RandomText
private Random rand = new Random();
private Thread t;
private String rText = "Rodrigue";
public RandomText()
t = new Thread()
@Override
public void run()
try
while(true)
UpdateText();
sleep(100);
catch(InterruptedException ex)
t.start();
private void UpdateText()
int i = rand.nextInt();
synchronized (rText)
rText = String.valueOf(i);
public String GetText()
return rText;
}It's just a class which start a thread. This class updates a text with a random integer 10 times per second.
I would like to get a reference on the String rText (like in C++ ;) yes I know, I must think in Java :D). So, like that, I could get one time the reference, thanks to the GetText function, and update the text when my application will repaint. Otherwise, I always have to call the GetText method ... which is slow, no?
Are objects passed by reference in java? Or, my string is duplicated each time?
Thank you very much in advance!
RodriguedisturbedRod wrote:
Ok, "Everything in Java is passed by value. Objects, however, are never passed at all.". Reference of object is passed by value too.
But, how to solve my problem in Java_? I have an object which is continually modified in a thread. From an another side, this object is continually repainted in a form.I'm not sure I totally understand your problem. If you pass a reference to an object, then both the caller and the method point to the same object. Changing the internal state of the object (e.g. by calling a setter method) through one reference will be observed through both references, since they both point to the same object.
No, calling a method is not particularly slow. Especially if it's just a simple getter method that returns the value of a member variable.
If this is happening in a multithreaded context, you'll have to use proper synchronization to ensure that each thread sees the others' changes. -
Class overhead, function overhead and parameter overhead
Hi all,
I am interested in class overhead, function overhead (each function in a class) and parameter overhead (each parameter in function).
I saw somewhere that class overhead are 200 bytes.
Is it wise to give up on class and go for functional programming? (Only classes required to run the j2me app are created and nothing else)
How does function get called? Does it work like a stack? Where each parameters get pushed into the stack and later on pop out when control pass on to the function?
If your program is full of functions doesn't this make it very processor intensive?
What is the best solution?
Thanks in advance!Hallo,
silly question: but what exactly do you mean when you say "full of attributes and methods that will never be used for this instance"?
I assume that when you have created your class you thought about the attributes and methods you wanted to include, and have not included any unnecessary baggage. I can only think that, perhaps, you have a class X that you would like to reuse, because it does all that you want. The only problem is that, for your specific problem, it carries a lot of excess baggage with it. You only need a few of the attributes and methods. Am I correct?
Such a class reuse will certainly incur some overheads, but let us try to analyse where they are:
1. Extra Code. The 'big' class is already defined and probably already loaded, so there should not be any overheads for the code.
2. Extra Data. Certainly creating a new instance of the 'big' class will require more memory. The question is how big is 'big' class, and how many instances do you want to create or have in existance at any one time? If the class is less than a few kB big and you only need a few instances at any one time, then you can afford to ignore the overhead.
3. Performance. Every time that you create an instance of the 'big' class, the processor must do some work to initialize it. The question is, what is required to initialize the class? This depends on what is in the constructor.
4. Programmer Time. If there is an existing class, then it will (probably, depending on documentation) take less time to reuse the class
than to write another, streamlined class. Someone else will already (hopefully) have debugged the 'big' class.
I think my view would be to reuse 'big' class unless there good grounds not to do so (see above). Your time is more important than a few overheads. -
Error in Java Program when passing table to RFC function . JCO is used
Hai All,
I developed a JAVA application to update data into SAP using JCO via RFC. When i pass table to the function module i am getting the below error
com.sap.mw.jco.JCO$Exception: (104) RFC_ERROR_SYSTEM_FAILURE: Conversion from type T to D not supported.
Please let me know how to solve this.
Below is my code
IRepository m_Repository;
IFunctionTemplate ftemplate;
JCO.Table PwdReq;
JCO.Function function;
m_Repository = JCO.createRepository("MYRepository", client);
ftemplate = m_Repository.getFunctionTemplate("Z_GESEFM_UPD_PWD_RESET_REQUEST");
// Create a function from the template
function = new JCO.Function(ftemplate);
// Feeding in input parameters
PwdReq = function.getTableParameterList().getTable("RESULT2");
String userid = "PATCHTEST14 ", reqDate = "",reqNo = "01",reqStatus = "03", boxID = "09",ind2 = "X",
lcode = "abcd",rem = "One record testing";
PwdReq.appendRow();
PwdReq.setValue(userid, "USERID");
PwdReq.setValue(reqNo,"REQ_NO");
PwdReq.setValue(reqStatus,"REQ_STATUS");
PwdReq.setValue(boxID,"BOX_ID");
PwdReq.setValue(ind2,"IND2");
PwdReq.setValue(lcode,"LCODE");
PwdReq.setValue(rem,"OTHER_REMARKS");
// execute the function with the input parameters
client.execute(function);
Thanks & Regards,
H.K.Hayath Basha.hi,
I am not very good in Java.
but try this code to giving input parameter.
function.getImportParameterList().setValue(userid, "USERID");
if you are not using Try and Catch blok then use Try and Catch blok,
Regards
Manoj -
Whats the difference betweeen passing the table variable and table valued parameter?
Hi Everbody
Can someone one tell me what's the difference between passing a table variable and table valued parameter to a stored procedure or function? Can both be used to pass a table to a stored procedure/function?
Regards
RegardsThey are essentially the same. What we call a table variable is a local
variable. A table-valued parameter is an incoming parameter to the
procedure. The only difference is that the parameter is readonly.
When you call a stored procedure, you can pass a table variable as the
actual parameter. Or a table-valued parameter that you pass on.
CREATE PROCEDURE nisse_sp @tvp sometype READONLY AS
DECLARE @local someothertabletype
EXEC pelle_sp @tvp, @local
Erland Sommarskog, SQL Server MVP, [email protected] -
Query in passing value to a function module
Hi All ,
I have a small query in the below code about the way i have passed value into a function module :
CALL FUNCTION 'AUTHORITY_CHECK'
EXPORTING
USER = SY-UNAME
OBJECT = 'E_INVOICE'
FIELD1 = 'BEGRU'
VALUE1 = ' '
FIELD2 = 'BUKRS'
VALUE2 = '$BUKRS'
FIELD3 = 'ISU_ACTIVT'
VALUE3 = '1,2,5,6'
FIELD4 = 'VKTYP_KK'
VALUE4 = ' '
EXCEPTIONS
USER_DONT_EXIST = 1
USER_IS_AUTHORIZED = 2
USER_NOT_AUTHORIZED = 3
USER_IS_LOCKED = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE 'User doesnt have sufficient authorizations' TYPE 'E'.
EXIT.
The query is on the field VALUE3 = '1,2,5,6' , is the format correct. If this is not right could someone please suggest the correct approach.
thanksHi Balaji,
as that is parameter you can use at a time only one value..
if you check in that FM we have other parameters VALUE1 to VALUE10..
why don't you use those...
Thanks! -
The 'argumentname' argument passed to the 'Methodename 'function is not of type 'Dto name'
Hi, there!
Sr for that question, because it should be pretty easy to answer, but i'm totally new to coldfusion
and googled for about an hour now. I have a orm DTO.cfc:
<cfcomponent entityname="testDTO" persistent="true" table="test" schema="informix" output="false">
<!---- properties ---->
</cfcomponent>
and have a service Methode in test.cfc
<!---- Add test---->
<cffunction name="createTest" returntype="testDTO" access="remote">
<cfargument name="item" type="testDTO" required="true" />
<!---- Auto-generated method
Insert a new record in test---->
<cfset entitysave(item) />
<!---- return created item ---->
<cfreturn item/>
</cffunction>
i try to call via the the <cfInvoke>-Tag
<cfset lieferant = entityNew('test')>
<cfinvoke
component="#request.componentbase#.test"
method="createTest"
item="#test#"
returnvariable="test">
but the error
'The ITEM argument passed to the createLieferant function is not of type testDTO.'
appears on function call. I just can't find a way to tell cf that lieferant is of type testDTO.
When i type the methodes parameter to struct the methode call works well.
Thanks for your help in advance!
FlorianI'm assuming your extract there isn't quite right:
<cfset lieferant = entityNew('test')>
<cfinvoke
component="#request.componentbase#.test"
method="createTest"
item="#test#"
returnvariable="test">
You're doing item="#test#", surely this should be item="#lieferant#"?
In which case, you've done <cfset lieferant = entityNew('test')>, which is of type "test", not "testDTO"?
If you're still having trouble, remove the item="" attribute from CFINVOKE and use CFINVOKEARGUMENTs instead. -
How to pass joint in a function
hi,
i want to pass Right Hand joint in a function and want to store last 5 position of joint in an point array. but when i pass the joint as below :-
Point point = ExponentialWeightedAvg(Joint HandRight)
it tells that joint is a type not a variable.
so,
how can i pass right hand joint and do some calculations.
thanks !!The syntax you wrote is incorrect. As with any programming language, you should be familiar how to write the correct syntax in the language of choice, since that would be a pre-requisite for using the SDK.
We already provide a BodyBasics sample that demonstrates how you can pass joint information to other functions. The key will be to get the joint position and pass that to the function you want:
CameraSpacePoint position = joints[JointType.HandRight].Position;
Carmine Sirignano - MSFT
Maybe you are looking for
-
I cant find photo booth anywhere where and how can i get it back?
i looked in finder and spotlight and NOTHING
-
its not working... what I did is..... I start I tunes ,make connection with IPAD,(hear a signe ) but cannot see on my screen(pc-screen)where the IPAD is ???? I see only an externe disk and a dvd .......but NO IPAD Ican see up( in the corner)...."I
-
Why aren't photos in iPhoto photo library showing up in iPhoto camera roll?
Hi, I downloaded all the photos on my Camera Roll on my iPhone into my AirBook computer because when I went to take a photo today with my iPhone it told me I had no space left. But, now there are 300 photos in Photo Library that never showed up in C
-
Printing out a receipt for an app purchase
I bought an app for my ipad. I must have deleted the emailed receipt. When I go into my account I can find the app and bring it up on my screen but cannot print it out. I can access the "print setup" but the print button is greyed out. I need to
-
Hi all; I am facing a problem , please help. I am working on a B2B scenario . As the messages are to be received from the third party system which is presently not sending out the messages , we have simulated the same system as a third party system .