In macro call method of object
Hi,
is it possible to call method provides in parameter to macro ?
From the call of my macro i provide object instancied and the name of my method. In my macro i wanted to do : CALL METHOD &1->&2 but it don't work.
I provided you my code which does not function :
REPORT z_erca_test.
CLASS lcl_ee_data DEFINITION
CLASS lcl_ee_data DEFINITION.
PUBLIC SECTION.
METHODS:
get_data_list,
get_data_list_suisse.
ENDCLASS. "lcl_ee_data DEFINITION
CLASS lcl_ee_data IMPLEMENTATION
CLASS lcl_ee_data IMPLEMENTATION.
METHOD get_data_list.
WRITE 'Default'.
ENDMETHOD. "get_data_list
METHOD get_data_list_suisse.
WRITE 'Suisse'.
ENDMETHOD. "get_data_list_suisse
ENDCLASS. "lcl_ee_data IMPLEMENTATION
DEFINE MACRO
DEFINE launch.
data: l_method type string.
l_method = 'get_data_list'.
concatenate l_method &2 into l_method separated by '_'.
write l_method.
call method &1->&2.
END-OF-DEFINITION.
START-OF-SELECTION.
DATA : l_ee TYPE REF TO lcl_ee_data.
CREATE OBJECT l_ee.
launch l_ee 'suisse'.
Hi,
partly...
From the ABAP documentation:
+Using the standard ABAP parenthesis semantics you can call methods dynamically.
· Calling an instance method meth:
CALL METHOD ref->(f)
· Calling a static method meth:
CALL METHOD class=>(f)
CALL METHOD (c)=>meth
CALL METHOD (c)=>(f)
· Calling a user-defined method meth:
CALL METHOD (f)
CALL METHOD ME->(f)
+
Regards,
Gianpietro
Similar Messages
-
Problem in calling method with object in another class
Hi All,
Please tell me the solution, I have problem in calling a method I am posting the code also
First Program:-
import java.io.*;
public class One
public One()
System.out.println("One:Object created");
public void display()
System.out.println("One:executing the display method");
static
System.out.println("One:executing the static block");
Second Program:-
import java.io.*;
public class Two
public Two()
System.out.println("Two:Object created");
public static void main(String arg[])throws Exception
System.out.println("Two:executing the main method");
System.out.println("Two:loading the class and creating the object::One");
Object o=Class.forName("One").newInstance();
System.out.println(o);
o.display(); //displaying error here in compile time.
static
System.out.println("Two:executing the static block");
waiting for your answer,
thanks in advance,bye.Hi All,
Please tell me the solution, I have problem in
calling a method I am posting the code also
First Program:-
import java.io.*;
public class One
public One()
System.out.println("One:Object created");
public void display()
System.out.println("One:executing the display
method");
static
System.out.println("One:executing the static
block");
Second Program:-
import java.io.*;
public class Two
public Two()
System.out.println("Two:Object created");
public static void main(String arg[])throws
Exception
System.out.println("Two:executing the main
method");
System.out.println("Two:loading the class and
creating the object::One");
Object o=Class.forName("One").newInstance();
System.out.println(o);
o.display(); //displaying error here in compile
time.
static
System.out.println("Two:executing the static
block");
waiting for your answer,
hanks in advance,bye.the line
o.display()
could be written as
((One)o).display(); -
ABAP OOP / Calling Method ...Help
Trying out few oop codes....
While calling class instance methods and passing parameters, when to use the following syntax.
data: cvar type ref to class1.
cvar->method( exporting variable1 = value )
(or) some time i see sample codes with out key word 'exporting'
cvar->method( variable1 = value ) .
(or)
cvar->method( value ) .
(or) some times with key word CALL METHOD
CREATE OBJECT cvar
CALL METHOD cvar->method
EXPORTING
variable1 = value.
Tried out a uniform way of calling ,but getting errors.Any inputs please..
Thanks,
BvanBhavan,
First declare the class.
Implement the class.
Declare the Class reference variable
Create the class object.
call the method.
data: cvar type ref to class1.
CREATE OBJECT cvar
Calling Methods
To call a method, use the following statement:
CALL METHOD <meth> EXPORTING... <ii> =.<f i>...
IMPORTING... <ei> =.<g i>...
CHANGING ... <ci> =.<f i>...
RECEIVING r = h
EXCEPTIONS... <ei> = rc i...
The way in which you address the method <method> depends on the method itself and from where you are calling it. Within the implementation part of a class, you can call the methods of the same class directly using their name <meth>.
CALL METHOD <meth>...
Outside the class, the visibility of the method depends on whether you can call it at all. Visible instance methods can be called from outside the class using
CALL METHOD <ref>-><meth>...
where <ref> is a reference variable whose value points to an instance of the class. Visible instance methods can be called from outside the class using
CALL METHOD <class>=><meth>...
where <class> is the name of the relevant class.
When you call a method, you must pass all non-optional input parameters using the EXPORTING or CHANGING addition in the CALL METHOD statement. You can (but do not have to) import the output parameters into your program using the IMPORTING or RECEIVING addition. Equally, you can (but do not have to) handle any exceptions triggered by the exceptions using the EXCEPTIONS addition. However, this is recommended.
You pass and receive values to and from methods in the same way as with function modules, that is, with the syntax:
... <Formal parameter> = <Actual parameter>
after the corresponding addition. The interface parameters (formal parameters) are always on the left-hand side of the equals sign. The actual parameters are always on the right. The equals sign is not an assignment operator in this context; it merely serves to assign program variables to the interface parameters of the method.
If the interface of a method consists only of a single IMPORTING parameter, you can use the following shortened form of the method call:
CALL METHOD <method>( f).
The actual parameter <f> is passed to the input parameters of the method.
If the interface of a method consists only of IMPORTING parameters, you can use the following shortened form of the method call:
CALL METHOD <method>(....<ii> =.<f i>...).
Each actual parameter <f i > is passed to the corresponding formal parameter <i i >.
Pls. mark if useful -
Pass Class Object To FMS Using NetConnection.call Method
Hello All,
I have a custom class that defines several methods on itself
to retrieve its data. This class object is then sent to FMS via the
NetConnection.call method. Once received by FMS, FMS calls the
remote method to dispaly the class object on connected clients
(minus the originator).
Now, standard properties are displayed correctly, but when I
call the class method to retrieve the class data, no data is
retrieved.
My question is, can FMS handle class objects as parameters in
a NetConnection call. If not, is there a better practice of
applying methods to retrieve the class data? Example below...
class com.QuizItem
var numOfAnswers;
var getAnswer;
function QuizItem(question)
this.numOfAnswers = 0;//<-- Returns correct number of
answers
this.getAnswer = function(answerNumberToGet)//<-- Does
not return any data when called by client side script
return this.answers[answerNumberToGet];//Already populated
array
Regards,
ShackFirst, I know JAVA does not working "pass by
reference". It's only working pass by value. (or call
by value)But obviously you don't fully understand what it means.
Isn't main_a and method_a alias?
if there is not alias, why? please explain to me.No. They're two independent references coincidentally pointing to the same object. In your swap method, you move method_a to point to something else. This does not affect main_a.
and why main_a.hashcode() is main_a's value?why not? What else should it be?
I think It's mean copy object. but main_a and
method_a, they have same object id! @_@;;;It means "copy reference", same object. -
Error on Calling Methods Using an Object of a Class
I keep getting the error cannot resolve variable addStud . I can't figure out why. I've created objects of classes before this way, then called methods within that class like this and it worked fine. I can't discern any difference between the syntax of the program that worked successfully and this one. I commented the parts where the error is when I tried to send a variable to a method in the class Recieve of which addStud is an object of. If you can see something that I can't I'd appreciate it. I've checked the obvious things like making sure the class name and method name is spelled the same way in both my frame and the class file.
import java.awt.event.*;
import java.awt.*; /* Used by IntroTest3.java. */
import javax.swing.*;
public class RegFrame extends JInternalFrame
{ // Begin class RegFrame
static final int xOffset = 30, yOffset = 30;
private JLabel nameLabel, displayLabel;
private JTextField nameField;
private JTextArea displayText;
private JButton addButton;
private String name;
private int numStu;
public RegFrame() { // Begin RegFrame constructor
super(" Register a New Student ",
true, //resizable
true, //closable
true, //maximizable
true);//iconifiable
//...Create the GUI and put it in the window...
//...Then set the window size or call pack...
setSize(400,300); //Set the window's location.
setLocation(xOffset, yOffset);
Container content = getContentPane();
setBackground(Color.white);
content.setBackground(Color.white);
content.setLayout( new FlowLayout());
//* CREATE LABELS AND TEST ENTRY FIELDS FOR REGISTERING A NEW STUDENT *
* HERE IS WHERE OBJECT OF RECIEVE IS CREATED *
Recieve addStud = new Recieve();
nameLabel = new JLabel(" Enter student name: ");
nameField = new JTextField(20);
content.add ( nameLabel );
content.add ( nameField );
addButton = new JButton( "Add Student" );
content.add( addButton );
addButton.addActionListener(
new ActionListener()
{ // Open ActionListener
public void actionPerformed (ActionEvent e)
getInput();
} // Close ActionListener
} // End RegFrame Constructor
// get input
private void getInput()
numStu++;
name = nameField.getText();
JOptionPane.showMessageDialog( null, "NAME: " + name + "\n"
+ "Student number:"+ numStu );
addStud.addName( name ); /** <--- HERE IS ERROR **/
} // End class RegFrame;This is the class:
public class Recieve
{ // Begin class Recieve
private double stAssign[];
private double stLab[];
private double stProject[];
private double stQuiz[];
private double stTest[];
private String stNames[];
int snc;
public Recieve ()
stAssign = new double[10];
stLab = new double[10];
stProject = new double[10];
stQuiz = new double[10];
stTest = new double[10];
stNames = new String[10];
snc = 0; // Student Name Counter
public void addName (String stName)
stNames[snc] = stName;
snc++;
} // End class Recieve1- Add the following class variable declaration for RegFrame:
private Recieve addStud;2- Change in the RegFrame constructor:
addStud = new Recieve(); -
Calling methods located inside ActiveX objects from Java
Hi folks,
I understand that I can wrap ActiveX methods in C and call using JNI, but I am looking for an elegant way to call methods inside of Active X controls directly. There are a set of classes in com.ms.ActiveX package that allow this, but I am receiving a java.lang.UnsatisfiedLinkError: initPolicyEngine at runtime. I can't find any documentation from Microsoft on this (go figure). Has anyone ever used the com.ms packages, or does anyone know of an elegant solution avoiding wrappers and JNI? I have sucessfully used the neva objects vendor classes, but I find them too bulky for mainstream use. Any thoughts are appreciated. Thanks.Hi,
- If you use the package com.ms.* You'll need to run your application in the Microsoft VM (jview.exe).
- If you run it inside the browser you cannot use the java plugin, and your applet needs to be signed.
If this doesn't help, please provide the version of your msjava.dll.
Regards,
Kurt. -
Is it possible to call methods of JAVA objects from ABAP?
Hi all,
Does anyone know if it is possible to call methods of java classes from ABAP?
Regards,
SukruHi,
Yes we can access the classes of JAVA in ABP.
This is posible from version ECC 6 onward with NETWEAVER atrhcitecuture.
Pls go through this link-
http://help.sap.com/saphelp_nw04s/helpdata/en/84/54953fc405330ee10000000a114084/frameset.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/e1/b5443e02a9ab4186a6e1240a9a2455/frameset.htm
Here also we use the JCO connector objects
These clearly show the methods to use JAVA.
<removed_by_moderator_together_with_points>
Regards
Chandralekha
Edited by: Julius Bussche on Jul 8, 2008 5:58 PM -
Error calling method of a PBNI object
Dear All,
We are facing issue of "Error calling method of a PBNI object". We are calling web services of WCF after some time to refresh data.We need help to solve this issue as we have to go live with client.
It's really urgent!
Regards
Imran ZaheerHi Chris,
Thanks for your concern.
1) PB version & Build?
PB builder 12.5.2 build 5609
2) MS-Window version?
Windows 7 professional.
3) Why are you using PBNI and what kind of class are you utilizing in that context?
We are calling webservices through soap objects.
4) What error(s) codes and messages are you getting?
we get "Error calling method of a PBNI object"
5) Why are you not using PB.net that supports WCF natively (I wish PB classic did)?
For this we need to convert our whole application in PB.Net which is not feasible for us.
6) Can you lightly describe your over-all architecture and application approach to Web Services?
We have replace EASERVER with WCFserver and we are calling webservices for fetching( pulling) data from WCF server. It's a soft of 3 tier architecture.
Regards .... Imran -
Tracking every time a method is called in some object?
Hi,
I would like to use reflection to log every time some method is called in an object.
Example;
public class A {
public void x () { }
public void y () { }
I would like some automatic mechanism that would allow me to register this object such that every time method x() is called, I have a System.out.println (or some other logging) saying "method 'x' called" and the same for every time method y() is called ... without having to modify the body of each method I want to track. If I have to put my logging calls into every method, then it defeats the purpose of what I'm trying to accomplish.
Thank you,
GeneIf your method calls are through an interface, set up a proxy that logs the calls using java.lang.reflect.Proxy.
If they're through a class, you can't use reflection and need to either use code generation or bytecode manipulation (either roll your own or use an aspect oriented programming kit - logging is the canonical AOP example).
Pete -
Call the CALL METHOD and CREATE OBJECT
Hi Friends,
How to call the CALL METHOD and CALL OBJECT in the se38 edit program.For example for calling the FUNCTION MODULE we can use the pattern in that using the call function we can get the function module in the se38 edit.but in METHOD hoe to call if you explain me in detail it would be very much usefulfor me.
Thanks,
Regards,
Rajendra KumarHi rajendra,
its the same way we do. call pattern ..there will be another radiobutton whcich says 'ABAP objects' , give the method name and the class name there.. this will call the method similar to function module..
we can also write our own classes and methods...
say..you created your own class c1 and method m1
then first create the instance of the object..
data:obj1 type ref to c1.
create object obj1.
call method obj1->m1.
Regards,
Vidya. -
Calling methods of business objects
hi
pls post some docs on calling methods in business obj's from abap programs.
thkx
P.SDo you share your solution?
For other people interested, example for FMPSO object:
INCLUDE <cntn01>.
DATA : l_lotkz TYPE bkpf-lotkz,
l_order TYPE swc_object,
lt_fimsg LIKE fimsg1 OCCURS 0.
DATA : BEGIN OF ls_key,
sourcecompanycode LIKE vbkpf-ausbk,
requestnumber LIKE vbkpf-lotkz,
END OF ls_key.
swc_container lt_container.
ls_key-sourcecompanycode = 'value'.
ls_key-requestnumber = 'value'.
swc_create_object l_order 'FMPSO' ls_key.
IF sy-subrc EQ 0.
* Validate
swc_call_method l_order 'FlagReleaseSet' lt_container.
IF sy-subrc NE 0.
MESSAGE e000(zz).
ELSE.
* Post
swc_call_method l_order 'PostAll' lt_container.
swc_get_table lt_container 'TFimsg' lt_fimsg.
IF sy-subrc NE 4 AND sy-subrc NE 0.
MESSAGE e000(zz).
ENDIF.
ENDIF.
ENDIF. -
Calling methods from the Business Object BUS2032
Hi all,
Is it possible to call methods from the Business Object BUS2032.
If so, how can it be done??
Regards,Hi Marv,
you sure can. Here is an extract from the SAP Help. I found it at http://help.sap.com/saphelp_46c/helpdata/en/c5/e4ad71453d11d189430000e829fbbd/frameset.htm
<b>Programmed Method Call</b>
Call (fictitious) method Print of object type VBAK (sales document). The method receives the parameters Paperformat and Printertype as input.
* Call method Print of object type VBAK
* Data declarations
DATA: VBAK_REF TYPE SWC_OBJECT.
SWC_CONTAINER CONTAINER.
* Create object reference to sales document
SWC_CREATE_OBJECT VBAK_REF 'VBAK' <KeySalesDoc>
* Fill input parameters
SWC_CREATE_CONTAINER CONTAINER.
SWC_SET_ELEMENT CONTAINER 'Paperformat' 'A4'.
SWC_SET_ELEMENT CONTAINER 'Printertype' 'Lineprinter'.
* Call Print method
SWC_CALL_METHOD VBAK_REF 'Print' CONTAINER.
* Error handling
IF SY-SUBRC NE 0.
ENDIF.
Cheers
Graham -
Calling Methods from Business Object BUS2032
Hi all,
Is it possible to call methods from the Business Object BUS2032.
If so, how can it be done??
Regards,Hi Marv,
you sure can. Here is an extract from the SAP Help. I found it at http://help.sap.com/saphelp_46c/helpdata/en/c5/e4ad71453d11d189430000e829fbbd/frameset.htm
<b>Programmed Method Call</b>
Call (fictitious) method Print of object type VBAK (sales document). The method receives the parameters Paperformat and Printertype as input.
* Call method Print of object type VBAK
* Data declarations
DATA: VBAK_REF TYPE SWC_OBJECT.
SWC_CONTAINER CONTAINER.
* Create object reference to sales document
SWC_CREATE_OBJECT VBAK_REF 'VBAK' <KeySalesDoc>
* Fill input parameters
SWC_CREATE_CONTAINER CONTAINER.
SWC_SET_ELEMENT CONTAINER 'Paperformat' 'A4'.
SWC_SET_ELEMENT CONTAINER 'Printertype' 'Lineprinter'.
* Call Print method
SWC_CALL_METHOD VBAK_REF 'Print' CONTAINER.
* Error handling
IF SY-SUBRC NE 0.
ENDIF.
Cheers
Graham -
Calling inherited method of object
Dears,
I have this problem:
test case
-- base type
create or replace type T_integer as object
val Number,
member procedure set_value( pValue Number)
) not final instantiable
create or replace type body T_integer IS
member procedure set_value( pValue Number) is
begin
if( abs(mod(pValue,1)) > 0 ) then -- not whole number
raise value_error;
else
self.val := pValue;
end if;
end;
END T_integer;
-- subtype
create or replace type T_integer_positive under T_integer
overriding member procedure set_value( pValue Number)
) not final instantiable
create or replace type body T_integer_positive IS
overriding member procedure set_value( pValue Number) is
begin
if( pValue < 0 ) then -- not positive number
raise value_error;
else
/** HERE IS THE PROBLEM *******/
T_integer.set_value(self, pValue);
end if;
end;
END T_integer;
I need to call supertype's method in subtype but it leads to recurse.
declare
foo T_integer_positive := T_integer_positive(1);
begin
foo.set_value(58);
dbms_output.put_line(foo.val);
end;
this pl/sql block never ends.
Please can somebody help me how to call method of supertype in overriden method of subtype.
In Pascal there is reserved word "inherited", what is in Oracle ?
Many thanks fo any suggestion.
afThanks to all.
I found in Metalink that this is really NOT supported by Oracle Objects : http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=FOR&p_id=189601.995
Zlatko, your solution is pretty but i am not sure it is usable for my wide object hierarchy (very wide) which i have to rewrite. -
Do I have to implement "Call" method of SOAPConnection object?
I was trying the example "saaj-simple" that comes with "jwsdp".
But it gave me NoSuchMethodError for the method "call" of "SOAPConnection" object.
I opened the "saaj-api.jar" and found that the "call" method is abstract.
Am I supposed to be implementing this method? I thought I should be using this method as it is.Yup! I already have that.
In fact I have both the jars associated with SAAJ plus other jars related to javax.
But still it ain't working. It gives runtime error.
It compiled successfully.
Maybe you are looking for
-
How do I remove a search bar from Firefox?
A search engine bar was installed on my Firefox browser somehow. I do not want it. I have looked under plug-ins and extensions, but it is not listed there. I tried looking under control panel > uninstall program, but it's not listed there either. How
-
Working with 72dpi mockups in new Retina supported Photoshop?
I just started a new job and they gave me a new Macbook Pro with Retina. I'm accustomed to designing all of my website mockups at 72dpi, but when I open any of their already designed files, they're super small on the Retina screen. I have to plug i
-
Error in JMS Communication Channel not raising alert
Processing Errors in JMS Communication Channel are not raising alerts. The settings on the communication channel retires are set at 3 and 5min interval. In RWB the JMS communication channel shows processing errors but an alert is not raised. The aler
-
How to Add and delete a row while using Abstract Table Model
Hi, I need to do the following functionalities in JTable.I've done tht but a small problem. 1. Adding a row (Using addRow() method from DefaultTableModel). 2. Deleting a row(Using setRowCount() method from Default Table Model). 3. Sorting the table b
-
PC laptop card to work with 802.11n?
I'm thinking of getting the new Extreme for my wife's Late 2006 Macbook Pro, but her sister is often on the same network with her PC laptop, an Acer Aspire 5100-5022 on which the current card is only g/b. Anyone know @ how much for an upgraded card f