Dynamic Method call with CHANGING

Hi,
I have the following method call:
      CALL METHOD o_salv->DISPLAY_SALV
        CHANGING
          it_data = it_ekko.
I would like to make this dynamic so that I can call it multiple times from my program with the came set of code.
I have this working for other Method calls, but the use the same parameters on both sides such as:
      CALL METHOD o_main->get_date
        IMPORTING
          it_ekko = it_ekko.
being coded as such:
      CALL METHOD o_main->(v_method)
        PARAMETER-TABLE
          ptab.
Can someone please give me some guidance on how to code the top example dynamically when the 2 variables are different?
Hope that makes sense...thanks for your help!
Andy

Hello Bjorn
I would suggest the following approach:
(1) Collect all your GUI control instances in an itab whose line type is TYPE REF TO cl_gui_control.
(2) Define your "free" method:
LOOP AT mt_gui_controls INTO lo_gui_control.
* See if gui control was text editor
  TRY.
    lo_textedit ?= lo_gui_control.
  CATCH cx_sy_move_cast_error INTO lo_error.
  ENDTRY.
  IF ( lo_error IS NOT BOUND ).
    lo_textedit->free.
*   ... your coding
    CONTINUE.
  ENDIF.
* See if gui control was tree
  TRY.
    lo_tree ?= lo_gui_control.
  CATCH cx_sy_move_cast_error INTO lo_error.
  ENDTRY.
ENDLOOP.
The FREE methods are redefined in the subclasses. However, you could try to call lo_gui_control->free directly because I am not sure if the coding of the superclass or subclass is called (I cannot test this at the moment).
Regards
  Uwe

Similar Messages

  • Dynamic method calls in bounded task flows?

    Hi!
    I have the following scenario:
    We are developing a framework in which we would include modules as ADF libraries (as JAR files) with bounded task flows. This framework contains a bean class with bindings for some UI components in framework which I enable or disable (depends on user action). That is the main reason bean class should be present in framework application.
    I have a bounded task flow in every module which needs to call a method in bean with UI component's bindings that would enable or disable that component.
    How can I achieve that? To pass bean as a parameter into bounded task flow and then call its methods? That is dynamic method calls for bean.
    I'm using JDeveloper 11.1.2.1.0
    Thanks for your help
    Regards, Marko

    Hi,
    I explained this; +"I have a bounded task flow in every module which needs to call a method in bean with UI component's bindings that would enable or disable that component. How can I achieve that? To pass bean as a parameter into bounded task flow and then call its methods?"+ a couple of times already (not sure if it was all for you) and don't think I change my position here. I also explained how to use a ValueExpression to lookp a managed bean containing component bindings (should be in requestscope).
    Frank

  • Type conflict during dynamic method call.

    While executing the following program I get the error "Type conflict during dynamic method call.":
    DATA: container_r  TYPE REF TO object,
          grid_r       TYPE REF TO object,
          itab_saplane TYPE TABLE OF saplane.
    * IMPORTANT NOTE: class names must be in UPPER CASE
    DATA: str_cnt TYPE seoclsname VALUE 'CL_GUI_CUSTOM_CONTAINER',
          str_gui TYPE seoclsname VALUE 'CL_GUI_ALV_GRID',
          meth_name TYPE STRING VALUE 'SET_TABLE_FOR_FIRST_DISPLAY'.
    TYPE-POOLS abap.
    DATA: ptab    TYPE abap_parmbind_tab,
          wa_ptab LIKE LINE OF ptab,
          ref     TYPE REF TO data.
    CREATE OBJECT container_r TYPE (str_cnt)
      EXPORTING container_name = 'CUSTOM_CONTROL1'. " Name of the custom control area (UC!)
    * Construct parameter itab
    GET REFERENCE OF container_r INTO ref.
    wa_ptab-name  = 'I_PARENT'.  " Must be upper-case
    wa_ptab-value = ref.
    INSERT wa_ptab INTO TABLE ptab.
    *   EXPORTING i_parent = container_r.
    CREATE OBJECT grid_r TYPE (str_gui)
      PARAMETER-TABLE ptab.
    SELECT * FROM saplane INTO CORRESPONDING FIELDS OF TABLE itab_saplane.
    * Cannot call set_table_for_first_display directly...
    CALL METHOD grid_r->(meth_name)
      EXPORTING I_STRUCTURE_NAME = 'SAPLANE'  " Type of the rows in the internal table  (UC!)
      CHANGING  IT_OUTTAB = itab_saplane.     " The internal table itself
    CALL SCREEN 100.
    Any help would be appreciated!

    Hi ...
    Apologies ... for confusion ... actually both are required ...
    the type 'E' as well as CL_GUI_CONTAINER.
    The below code worked for me ...
    check out how I cast it to the parent class type ...
      DATA : lv_container   TYPE seoclsname VALUE 'CL_GUI_CUSTOM_CONTAINER',
             lv_control     TYPE seoclsname VALUE 'CL_GUI_ALV_GRID',
             lv_method      TYPE string VALUE 'SET_TABLE_FOR_FIRST_DISPLAY',
             lt_par_tab     TYPE abap_parmbind_tab,
             ls_param       LIKE LINE OF lt_par_tab,
             lref_cont      TYPE REF TO cl_gui_container,
             lv_data        TYPE REF TO data.
    CREATE OBJECT lref_container
          TYPE
            (lv_container)
          EXPORTING
            container_name = 'ALV_AREA'.
        ls_param-name = 'I_PARENT'.
        ls_param-kind = 'E'.
        lref_cont ?= lref_container.
        GET REFERENCE OF lref_cont INTO lv_data.
        ls_param-value = lv_data.
        INSERT ls_param INTO TABLE lt_par_tab.
    **  Now create ALV Control.
        CREATE OBJECT lref_alv_ctrl
          TYPE
            (lv_control)
          PARAMETER-TABLE
            lt_par_tab.
    **  Set table for 1st display
        DATA : lv.
        lv = lref_alv_ctrl->mc_fc_print.
        CALL METHOD lref_alv_ctrl->(lv_method)
          EXPORTING
            i_structure_name = 'T001'
          CHANGING
            it_outtab        = lt_company.
    Cheers
    Edited by: Varun Verma on Aug 12, 2008 4:19 PM

  • ADF Mobile: WebService data control method call with array

    JDev 11.1.2.3
    ADF Mobile deployed to Android emulator
    Hello All,
    I am trying to invoke a method in my Web Service data control and get the following exception
    Caused by: ERROR [oracle.adfmf.framework.exception.AdfInvocationRuntimeException] - Cannot serialize: [I@1dbae822
            at oracle.adfmf.dc.ws.soap.SoapTransportLayer.invokeSoapRequest(Lorg/ksoap2/SoapEnvelope;)Ljava/lang/Object;(Unknown Source)
            at oracle.adfmf.dc.ws.soap.SoapWebServiceOperation.invoke(Ljava/lang/String;Loracle/adfmf/dc/ws/soap/SoapGenericType;)Ljava/lang/Object;(Unknown Source)
            at oracle.adfmf.dc.ws.soap.SoapWebServiceOperation.invoke(Ljava/lang/String;Ljava/util/Map;)Ljava/lang/Object;(Unknown Source)
            at oracle.adfmf.dc.JavaBeanOperation.execute(Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;(Unknown Source)
            at oracle.adfmf.dc.ws.WebServiceDataControlAdapter.invokeOperation(Ljava/util/Map;Loracle/adfmf/bindings/OperationBinding;)Z(Unknown Source)
            at oracle.adfmf.bindings.dbf.AmxMethodActionBinding.execute()Ljava/lang/Object;(Unknown Source) This method is an AppModule method exposed as a service interface and the parameter for this method is a List<oracle.jbo.domain.Number>. The schema definition for the input is as follows:
    <element name="acceptTask">
       <complexType>
         <sequence>
                <element maxOccurs="unbounded" minOccurs="0" name="taskID" type="decimal"/>
         </sequence>
       </complexType>
    </element>For the input to my binding, I have tried int[], Integer[] and List<Integer>. All of these result in similar errors.
    I have also tried invoking this through a regular ADF application and that works fine with an int[]. It looks like something specific to the ADF Mobile SOAP layer.
    Is this a bug or a restriction in the framework? Any workarounds that has worked for anyone?

    No luck. A WS DC method call with a simple parameter (java.lang.String or java.lang.Integer) works fine but I can't get it to work when there is an array input.
    I have tried WS methods with int arrays and simple string arrays without any luck. All of them result in a cannot serialize error.
    I can't figure out what I am doing wrong. Are there any working WS Datacontrol samples with array inputs?

  • 11g Task flow - Method call with router Issue

    Hi, I am using bounded task flow method call - which is default activity. The outcome of method call will go to a router and that decides which method/page fragment has to be selected. But when ever i try to call the default activity only the default out come of the router (Page fragment) is shown in the jspx. When click on some button which is binded with the default activity - the task flow is not working as i expected. Pls find the code of my task flow below.
    <?xml version="1.0" encoding="windows-1252" ?>
    <adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
    <task-flow-definition id="methodcall2task-flow-definition">
    <default-activity>initiatetaskflow</default-activity>
    <data-control-scope>
    <shared/>
    </data-control-scope>
    <input-parameter-definition>
    <name>methodname</name>
    <value>#{CompanyBean.methodname}</value>
    </input-parameter-definition>
    <managed-bean>
    <managed-bean-name>CompanyBean</managed-bean-name>
    <managed-bean-class>com.boeing.seds.view.company.CompanyBean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <method-call id="initiatetaskflow">
    <method>#{CompanyBean.test}</method>
    <outcome>
    <fixed-outcome>#{CompanyBean.methodname}</fixed-outcome>
    </outcome>
    </method-call>
    <router id="selectMethod">
    <case>
    <expression>#{CompanyBean.methodname eq 'default'}</expression>
    <outcome>default</outcome>
    </case>
    <case>
    <expression>#{CompanyBean.methodname eq 'addcompany'}</expression>
    <outcome>addcompany</outcome>
    </case>
    <case>
    <expression>#{CompanyBean.methodname eq 'gotoAddress'}</expression>
    <outcome>gotoAddress</outcome>
    </case>
    <case>
    <expression>#{CompanyBean.methodname eq 'gotoDist'}</expression>
    <outcome>gotoDist</outcome>
    </case>
    <default-outcome>gotoAddress</default-outcome>
    </router>
    <view id="default">
    <page>/includes/company/default.jsff</page>
    </view>
    <view id="addnewcompanyFrgmt">
    <page>/includes/company/addnewcompanyFrgmt.jsff</page>
    </view>
    <method-call id="methodCall1">
    <method>#{CompanyBean.addCompany}</method>
    <outcome>
    <to-string/>
    </outcome>
    </method-call>
    <view id="supplierAddressFrgmt">
    <page>/includes/company/supplierAddressFrgmt.jsff</page>
    </view>
    <view id="supplierDistributorFrgmt">
    <page>/includes/company/supplierDistributorFrgmt.jsff</page>
    </view>
    <control-flow-rule>
    <from-activity-id>initiatetaskflow</from-activity-id>
    <control-flow-case>
    <from-outcome>#{CompanyBean.methodname}</from-outcome>
    <to-activity-id>selectMethod</to-activity-id>
    </control-flow-case>
    </control-flow-rule>
    <control-flow-rule>
    <from-activity-id>selectMethod</from-activity-id>
    <control-flow-case>
    <from-outcome>default</from-outcome>
    <to-activity-id>default</to-activity-id>
    </control-flow-case>
    <control-flow-case>
    <from-outcome>addcompany</from-outcome>
    <to-activity-id>methodCall1</to-activity-id>
    </control-flow-case>
    <control-flow-case>
    <from-outcome>gotoAddress</from-outcome>
    <to-activity-id>supplierAddressFrgmt</to-activity-id>
    </control-flow-case>
    <control-flow-case>
    <from-outcome>gotoDist</from-outcome>
    <to-activity-id>supplierDistributorFrgmt</to-activity-id>
    </control-flow-case>
    </control-flow-rule>
    <control-flow-rule>
    <from-activity-id>methodCall1</from-activity-id>
    <control-flow-case>
    <from-outcome>goAddNew</from-outcome>
    <to-activity-id>addnewcompanyFrgmt</to-activity-id>
    </control-flow-case>
    </control-flow-rule>
    <use-page-fragments/>
    </task-flow-definition>
    </adfc-config>
    Kindly let me know what may be the issue and help me to resolve it.
    Thanks!
    Sankari Kannan

    Hi Sankari,
    Since after the initial method call, your control flow has the router as its next stop, the //method-call/method/outcome/fixed-outcome can be set to a literal value(go to router) instead of an EL.
    And let router decide where to go next(by EL).
    Or you can discard your router activity, let the method-call activity decide where to go directly by setting //method-call/method/outcome/to-string to "true". Then the return value of the method decide the next stop.
    Todd

  • Why are static methods called with null references,valid ?

    This is my code :
    package inheritance;
    public class inh6{
         public static void method(){
         System.out.println("Called");
         public static void main(String[] args){
              inh6 t4 = null;
         t4.method();
    O/P :
    CalledHere t4 is a null reference and yet we are able to call a method on it,why is null pointerexception not thrown.Why are we able to call static methods using null references ?
    t4 is null means it doesnot refer to any memeory address,hence how is method() called correctly.
    I hope i am clear. :)
    Thank you for your consideration.

    punter wrote:
    jverd wrote:
    Memory addresses have nothing to do with it. I doubt memory addresses are even mentioned once in the JLS.
    By memory address i mean the memory location the reference is pointing to.I know what you mean. But if you think it's relevant, can you show me where in the JLS it says anything about memory locations?
    >
    You can do that because a) t4's type is "reference to inh6" and b) method() is declared static, which means that you don't need an object to call it, just the class. That class comes from the compile time type of t4. The fact that t4 is null at runtime is irrelevant.
    So at compile time the type of t4 is inh6 and hence the method is called.Is it ? Had method() not been static a NullPointerException would have been thrown.Correct.
    With non-static, non-private, non-final methods, which implementation of the method gets called is determined at runtime, buy the class of the object on which it's being called. If any one of those "non"s goes away, then the method is entirely determined at compile time, and in the case of static methods, there's no instance necessary to call the method in the first place.

  • Working with class based exception and dynamic method calls

    Hi Gurus,
    we just changed out ERP from EHP6 to EHP7.
    Since we did so we are facing an issue with an Z-Report we are using quite often.
    This reports looks up Workitems and executes the according methods so that we can go into debugging if we were facing any problems or errors.
    since the EHP Upgrade this statement has problems:
      data:        lt_parmbind   type abap_parmbind_tab,         lt_excpbind   type abap_excpbind_tab,         lo_runtime    type ref to object.     call method lo_runtime->(iv_cls_method)       parameter-table       lt_parmbind       exception-table       lt_excpbind.this CALL METHOD Statement has Problem with the Exception Table. We are quite often getting DYN_CALL_METH_EXCP_NOT_FOUND short dumps with Exception "CX_SY_DYN_CALL_EXCP_NOT_FOUND".
    The system has problems handling the content of lt_excpbind. if i clear this table the CALL METHOD statement works fine.
    AS an example we are trying to call /IDXGC/CL_PD_PROCESS_STEPS-->CREATE_DATA. This method has 2 exceptions
    /IDXGC/CX_PROCESS_ERROR
    Process Layer Exception
    CX_BO_TEMPORARY
    Temporary Business Exception
    The Content of LT_EXCPBIND is
    INDEX
    NAME
    VALUE
    2
    /IDXGC/CX_PROCESS_ERROR
    1
    2
    CX_BO_TEMPORARY
    2
    From my point of view the Problem ist, that they are marked as "class based". I think so because if you looked up the SAP Help for the EXCEPTION-TABLE Statement it is written that is statement only works for none-classbased exception.
    I think that restriction is quiet clear. But what i am wondering about is.. that restriction also exists for EHP6. And in EHP6 it work. Does anyone know why? Or how i can change me CALL METHOD Statement that i will work again?
    Best Regards
    Udo

    Class-based exceptions must be caught using try/catch statement.
    Calling dynamically a method catchable exceptions are:
    CX_SY_DYN_CALL_EXCP_NOT_FOUND
    CX_SY_DYN_CALL_ILLEGAL_CLASS 
    CX_SY_DYN_CALL_ILLEGAL_METHOD
    CX_SY_DYN_CALL_PARAM_MISSING 
    CX_SY_DYN_CALL_PARAM_NOT_FOUND 
    CX_SY_REF_IS_INITIAL
    Anyway catching cx_root (as shown by Matthias) will catch everything is catchable.

  • Dynamic constructor call with arguments

    hey all i am quite new to this dynamic creation stuff
    basically i have an array of class literals i.e One.class Two.class Three.class
    etc
    i then loop through this array using the isInstance() method to find the objects correct type
    when i find this type i want to then create an object of this type with arguments passed to the constructor
    i know there is a way to create the object using a defualt non arg constructor call using newInstance()...
    so to repeat is there a way to dynamically create an object while passing arguments to the constructor?
    thanx rob

    Call getContstructor() on the class passing it an array of argument types. Then call newInstance() on the Constructor object that gets returned passing it an array of the arguments.

  • Dynamic method call

    Hello Gurus,
    is there any possibility to write something like this in ABAP ??
      CALL METHOD zz_but050=>get_but050
        EXPORTING
        IF X = 1.  i_var_partner1 = l_var_partner1 ENDIF.
        IF X = 2.  i_var_partner2 = l_var_partner2 ENDIF.
        IMPORTING
          e_tab_but050   = l_tab_but050
        EXCEPTIONS
          keine_daten    = 1.
    Best regards,
    Ioan Constantin.

    Yes there is. The simplest would be
    data: lv_partner  type ...
    IF X = 1.  lv_partner = l_var_partner1 ENDIF.
    IF X = 2.  lv_partner = l_var_partner2 ENDIF.
    CALL METHOD zz_but050=>get_but050
        EXPORTING
         i_var_partner1 = lv_partner
        IMPORTING
          e_tab_but050   = l_tab_but050
        EXCEPTIONS
          keine_daten    = 1.
    Or you can use dynamic form of CALL METHOD where you pass your parameters by means of PARAMETER-TABLE addition. Please refer [CALL METHOD|http://help.sap.com/abapdocu_70/en/ABAPCALL_METHOD_SHORTREF.htm] -> dynamic form.
    Regards
    Marcin

  • Dynamic method call needs reflection class?

    Hi,
    First of all, this is my first post so go easy on me ;)
    I would like to have something like this in Java:
    String name = "number1";
    int temp = name + getme();
    the integer temp should now be the result of the method "number1getme()".
    By changing the value of 'name' I could get the value of number2, number3 etc. etc.
    Hope you understand and can help.
    Yours Sincerely,
    GrandiJoos

    If you really want to do it this way, you will indeed need to use reflection. Have you considered other options, such as storing values in a Map or creating one getme() method that takes a name argument?Map<String, Integer> temps = new HashMap<String, Integer>();
    .. fill the map with temperatures
    String name="number1";
    int temp = temps.get(name);orString name="number1";
    public int getme(String name) {
    int result = ...;
    if(name.equals("number1")) {
      result = <some temp here>;
    return result;
    }

  • Njawin method call with arrays

    I have a problem when calling this method in NJAWIN
    Sub AddItems(NumItems As Long, ItemIDs() As String, ClientHandles() As Long, ServerHandles() As Long, Errors() As Long, [RequestedDataTypes], [AccessPaths])The njawin created code signature looks like this:
    public void AddItems(int NumItems, ObjectRef  ItemIDs, ObjectRef  ClientHandles, ObjectRef  ServerHandles, ObjectRef  Errors) throws COMException {
            invokeN("AddItems", new Object[]{new java.lang.Integer(NumItems), ItemIDs, ClientHandles, ServerHandles, Errors}, 5);
    public void AddItems(int NumItems, ObjectRef  ItemIDs, ObjectRef  ClientHandles, ObjectRef  ServerHandles, ObjectRef  Errors, java.lang.Object RequestedDataTypes) throws COMException {
            invokeN("AddItems", new Object[]{new java.lang.Integer(NumItems), ItemIDs, ClientHandles, ServerHandles, Errors, RequestedDataTypes}, 6);
    public void AddItems(int NumItems, ObjectRef  ItemIDs, ObjectRef  ClientHandles, ObjectRef  ServerHandles, ObjectRef  Errors, java.lang.Object RequestedDataTypes, java.lang.Object AccessPaths) throws COMException {
            invokeN("AddItems", new Object[]{new java.lang.Integer(NumItems), ItemIDs, ClientHandles, ServerHandles, Errors, RequestedDataTypes, AccessPaths}, 7);
        }I tried to call one of this methodes in many different ways, but i always got this Exception.
    Exception:
    Exception in thread "main" java.lang.Error: Type cannot be marshalled to variant: class com.develop.jawin.Variant
         at com.develop.jawin.Variant.marshalInRef(Unknown Source)
         at com.develop.jawin.Variant.marshalIn(Unknown Source)
         at com.develop.jawin.UnknownPtr.invokeN(Unknown Source)
         at OPCSiemensDAAutomation.OPCItems.AddItems(OPCItems.java:131)
         at OPCSiemensDAAutomation.TestNew.<init>(TestNew.java:47)
         at OPCSiemensDAAutomation.TestNew.main(TestNew.java:56)
    Can anybody tell me, how to call this method in the right way??
    How do i create the proper ObjectRef types??
    Thx in advance...

    I have a problem when calling this method in NJAWIN
    Sub AddItems(NumItems As Long, ItemIDs() As String, ClientHandles() As Long, ServerHandles() As Long, Errors() As Long, [RequestedDataTypes], [AccessPaths])The njawin created code signature looks like this:
    public void AddItems(int NumItems, ObjectRef  ItemIDs, ObjectRef  ClientHandles, ObjectRef  ServerHandles, ObjectRef  Errors) throws COMException {
            invokeN("AddItems", new Object[]{new java.lang.Integer(NumItems), ItemIDs, ClientHandles, ServerHandles, Errors}, 5);
    public void AddItems(int NumItems, ObjectRef  ItemIDs, ObjectRef  ClientHandles, ObjectRef  ServerHandles, ObjectRef  Errors, java.lang.Object RequestedDataTypes) throws COMException {
            invokeN("AddItems", new Object[]{new java.lang.Integer(NumItems), ItemIDs, ClientHandles, ServerHandles, Errors, RequestedDataTypes}, 6);
    public void AddItems(int NumItems, ObjectRef  ItemIDs, ObjectRef  ClientHandles, ObjectRef  ServerHandles, ObjectRef  Errors, java.lang.Object RequestedDataTypes, java.lang.Object AccessPaths) throws COMException {
            invokeN("AddItems", new Object[]{new java.lang.Integer(NumItems), ItemIDs, ClientHandles, ServerHandles, Errors, RequestedDataTypes, AccessPaths}, 7);
        }I tried to call one of this methodes in many different ways, but i always got this Exception.
    Exception:
    Exception in thread "main" java.lang.Error: Type cannot be marshalled to variant: class com.develop.jawin.Variant
         at com.develop.jawin.Variant.marshalInRef(Unknown Source)
         at com.develop.jawin.Variant.marshalIn(Unknown Source)
         at com.develop.jawin.UnknownPtr.invokeN(Unknown Source)
         at OPCSiemensDAAutomation.OPCItems.AddItems(OPCItems.java:131)
         at OPCSiemensDAAutomation.TestNew.<init>(TestNew.java:47)
         at OPCSiemensDAAutomation.TestNew.main(TestNew.java:56)
    Can anybody tell me, how to call this method in the right way??
    How do i create the proper ObjectRef types??
    Thx in advance...

  • A tricky way to twick ValueBinding language to bind a method call

    Here is the scenario:
    I'd like component can bind value to method call(with parameters) to a java instance, of course including backingBean.
    I wish this solution would be useful, especially when you are working in iteration component such as ForEach, TreeView or DataTable, EL ValueBinging language might be too restricted to complex expression. This way, you can pass iteration items as parameters into a method can and return a value to you page by valuebinding language
    In JSP:
        <h:outputText value="#{Page1.callHelper[Page1]['targetMethod']['James'][Page1.callEnd]}"/>In PageBean:
         public String targetMethod(String name){
             return "Hello, " + name +"!";
        private CallHelper callHelper = new CallHelper();
         public CallHelper getCallHelper() {
              return callHelper;
         public void setCallHelper(CallHelper callHelper) {
              this.callHelper = callHelper;
         private CallEnd callEnd = new CallEnd();
         public CallEnd getCallEnd() {
              return callEnd;
         public void setCallEnd(CallEnd callEnd) {
              this.callEnd = callEnd;
         }Util classes:
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    import java.util.ArrayList;
    import java.util.LinkedHashMap;
    import java.util.List;
    import java.util.Map;
    public class CallHelper extends LinkedHashMap {
         private CallHelper parent;
         public Object get(Object key){
              if(key instanceof CallEnd)return getRoot().methodCall();
              else{
                   Object value = super.get(key);          
                   if(value == null){
                        value = new CallHelper();
                        put(key, value);
                        ((CallHelper)value).parent = this;
                   return value;
         public boolean containsKey(Object key){
              return true;
         public boolean realContainsKey(Object key){
              return super.containsKey(key);
        protected CallHelper getRoot(){
             CallHelper root = this;
             if(root.parent==null)return root;
             else return root.parent.getRoot();
         protected Object methodCall(){
              Object result = null;
             List callParameters = new ArrayList(2);
             listCallParameters(callParameters, this);
             if(callParameters.size()>1){
                  Object instance = callParameters.get(0);
                  String methodName = callParameters.get(1).toString();
                  List methodParameters = new ArrayList();
                  for(int i=2; i<callParameters.size(); i++){
                       methodParameters.add(callParameters.get(i));
                  Method method = findMethod(instance, methodName, methodParameters);
                  if(method != null){
                       try {
                             result = method.invoke(instance, methodParameters.toArray());
                        } catch (IllegalArgumentException e) {
                        } catch (IllegalAccessException e) {
                        } catch (InvocationTargetException e) {
              this.clear();
              return result;
         private void listCallParameters(List list, Map map){
              if(map==null || !map.keySet().iterator().hasNext())return;
              Object key = map.keySet().iterator().next();
              if(key instanceof CallEnd)return;
              list.add(key);
              listCallParameters(list, (Map)map.get(key));
         private Method findMethod(Object instance, String methodName, List parameters){
              Method result = null;
              Method[] methods = instance.getClass().getMethods();
              for(int i=0; i<methods.length; i++){
                   if(methods.getName().equals(methodName)){
                        System.out.println(methodName);
                        Class[] paraClasses = methods[i].getParameterTypes();
                        if(paraClasses.length==parameters.size()){
                             boolean match = true;
                             for(int j=0; j<paraClasses.length; j++){
                                  if(parameters.get(j)!=null && !paraClasses[j].isInstance(parameters.get(j))){
                                       match = false;
                                       break;
                             if(match){
                                  result = methods[i];
                                  break;
              return result;
    public class CallEnd {
    Improvement:
    Anyone can make it thread safety and bind callhelper and callend directly to FacesContext properties rather than each backingBean.
    Have fun!
    And feel free to contect me at:
    [email protected]
    [email protected]

    You must seperate your parameter preparing and action method calling for sure.
    It depends on what kind of parameters you need to pass in:
    1. If action method is bound to several buttons, and it just wants to know which button was clicked, you can set actionListener to prepare it for you. Because the event includes the information you need.
    2. For other kinds of parameters, you can use ValueBinding Language to bind parameter values to backingBean, then the action method(without parameters) can pick parameters up from backingBean.

  • Using a dynamic variable in the Import command of a Method call

    Hi,
    I am trying to make a Method call fully dynamic.
    I have found out how to make the Method name dynamic, but I am having trouble figuring out how to make the Importing statement dynamic.
    in my code below:
          CALL METHOD o_main->(v_call)
            IMPORTING
              it_ekko = i_ekko.
    I would like to know if it's possible to make both "it_ekko" AND "i_ekko" dynamic so I can use this same call for various tables.
    Hope that makes sense...thanks for your help.
    Andy

    Hi Andrew,
    The method call is fully dynamic; not only the parameters can be specified dynamically but also the method name.
    This is a help extract:
    DATA: line     TYPE c LENGTH 80,
          text_tab LIKE STANDARD TABLE OF line,
          filename TYPE string,
          filetype TYPE c LENGTH 10,
          fleng    TYPE i.
    DATA: meth  TYPE string,
          class TYPE string,
          ptab TYPE abap_parmbind_tab,
          ptab_line TYPE abap_parmbind,
          etab TYPE abap_excpbind_tab,
          etab_line TYPE abap_excpbind.
    DATA: exc_ref TYPE REF TO cx_sy_dyn_call_error,
          exc_text TYPE string.
    class    = 'CL_GUI_FRONTEND_SERVICES'.
    meth     = 'GUI_DOWNLOAD'.
    filename = 'c:\temp\text.txt'.
    filetype = 'ASC'.
    ptab_line-name = 'FILENAME'.
    ptab_line-kind = cl_abap_objectdescr=>exporting.
    GET REFERENCE OF filename INTO ptab_line-value.
    INSERT ptab_line INTO TABLE ptab.
    ptab_line-name = 'FILETYPE'.
    ptab_line-kind = cl_abap_objectdescr=>exporting.
    GET REFERENCE OF filetype INTO ptab_line-value.
    INSERT ptab_line INTO TABLE ptab.
    ptab_line-name = 'DATA_TAB'.
    ptab_line-kind = cl_abap_objectdescr=>changing.
    GET REFERENCE OF text_tab INTO ptab_line-value.
    INSERT ptab_line INTO TABLE ptab.
    ptab_line-name = 'FILELENGTH'.
    ptab_line-kind = cl_abap_objectdescr=>importing.
    GET REFERENCE OF fleng INTO ptab_line-value.
    INSERT ptab_line INTO TABLE ptab.
    etab_line-name = 'OTHERS'.
    etab_line-value = 4.
    INSERT etab_line INTO TABLE etab.
    TRY.
        CALL METHOD (class)=>(meth)
          PARAMETER-TABLE
            ptab
          EXCEPTION-TABLE
            etab.
        CASE sy-subrc.
          WHEN 1.
        ENDCASE.
      CATCH cx_sy_dyn_call_error INTO exc_ref.
        exc_text = exc_ref->get_text( ).
        MESSAGE exc_text TYPE 'I'.
    ENDTRY.
    BR,
    Valentin

  • Error: The AcquireConnection method call to the connection manager failed with error code 0xC0202009 using DB2 connection

    I have a SSIS project that I am newly running on the SQL server (2005) .  It was previously run on my PC.  I am importing data from a DB2 server to the SQL server.
    I am in the SA group on the server
    My connection to DB2 works
    When open the package and run it in preview mode, I can retrieve the data.
    When I execute the package I get the below errors:
    [MIDAS OLE DB Source [1]] Error: The AcquireConnection method call to the connection manager "NGMDSPA.alharris" failed with error code 0xC0202009.
    [DTS.Pipeline] Error: component "MIDAS OLE DB Source" (1) failed validation and returned error code 0xC020801C.
    What I have already done that has not worked:
    The original Protection level was set to EncryptSensitiveWithPassword. 
    I have reset the Package Password.
    I have set the protection level to DontSaveSensitive
    I saved the package on the server and set a Package Password.
    I created a new package, set the Protection level to DontSaveSensitive, set a package password in a configuration file using the Package Configuration Wizard.
    Error continues

    Yes.  The Drivers are installed and I have a successfull connection.  I am trouble shooting the issue on the server in BIDS.  I can connect to the DB2 server via the Connectionmanager.  I can also preview the data in the OLE
    DB source connection.  Therefore I know that I have a proper connection
    If you're setting option as DontSaveSensitive then you need to pass the connection information from configuration file/ config table. Otherwise it wont be able to use it for connecting to your source/destination servers. This is the recommended way as it
    will enable you to change connection info at runtime.
    If you want connection info to persist you need to use protection level as EncryptSensitiveUsingUserKey or EncryptSensitiveUsingPassword and set a password.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Im new to java can someone please help me with external method calls

    I have only been doing java for a couple of months using bluej, I really dont understand external method calls, this is for an assignment and i have managed the bulk of the code, ineed to make external calls to the other classes to return and input data.
    this is the code i have writen so far.
    class CD
    // The fields.
    public Artist performer;
    private String album;
    private String genre;
    private int numberOfTracks;
    private int yearReleased;
    *Please enter CD details, text entry requires quote marks "Greatest Hits"
    public CD (String album_Name){
    album = album_Name;
    numberOfTracks = 0;
    yearReleased = 0;
    performer = new Artist();
    /**blank constructor*/
    public CD ()
    {album = "";
                genre = "";
                numberOfTracks = 0;
                yearReleased = 0;
                performer = new Artist();}
    * accessor methods
    /** method to return album details to the output window*/
    public void print_albumDetails(){
    System.out.println("Album: " + album);
    System.out.println("Genre: " + genre);
    System.out.println("Number of Tracks: " + numberOfTracks);}
    /** accessor method to return the name of the album*/
    public String show_album(){
    return album;}
    /** accessor method to show artist details from artist class*/
    public void print_details(){
    performer.print_details();}
    * mutator methods
    /** mutator method to change album name please enter name with quotes*/
    public void change_album(String newAlbum){
    album = newAlbum;}
    /**mutator method for adding the album year and checking it correct
    * please enter a year between 1900 and 2005*/
    public void album_year (int year){
    if ((year < 1900) || (year > 2005))
    System.out.println("sorry the year is incorrect please enter a year between 1900 and 2005");
    else yearReleased = year;}
    /** mutator method to alter the number of tracks and check if the ammount is greater
    * than zero*/
    public void change_Number_Of_Tracks(int no_Of_Tracks){
    if (no_Of_Tracks > 0)
    numberOfTracks = no_Of_Tracks;
    else System.out.println("you have not entered a correct number");}
    /** mutator method to change the genre and check it has been entered correctly
    * Please enter 1 for Soul
    * 2 for Blues
    * 3 for Jazz*/
    public void change_Genre(int Change_Genre){
    if ((Change_Genre <= 0) || (Change_Genre > 3)){
    System.out.println("You have not entered the correct available genres");
    System.out.println("which are 1 for Soul,2 for Blues or 3 for Jazz");}
    else if (Change_Genre == 1)
    genre = "Soul";
    else if (Change_Genre == 2)
    genre = "Blues";
    else if (Change_Genre == 3)
    genre = "Jazz";
    to this i need to add an external call to the class Artist to be able to enter firstname and second name, I know that external calls use dot notation
    and the instance of Artist is called performer but i cant get the call to these methods in the Artist class to work
    Artist class
    /** mutator method to change or add artist first name, remember to add quotes*/
    public void cName(String name){
    firstname = name;}
    /** mutator method to change or add artist surname remember to add quotes*/
    public void csurName(String surname){
    lastname = surname;}
    can some please give me some help

    Also, if you can't get them to work, what is the error message you are getting?
    Baron Samedi

Maybe you are looking for

  • CD/DVD drive not recognized on my HP laptop

    Hi all, Sorry to post yet another thread on the issue but I've tried just about everything that I've read up on I think.  I have a HP Pavilion DV6809wm, running Vista 32 bit.  I go into Device Manager and there is no Optical drive listed.  I have rem

  • Project as an Investment measure - Unable to settle

    Hi, Request help on the below situation. 1.We have created a project as an Investment project using tcode CJ20N and a WBS element in the project also. The WBS element when released, creates an AUC automatically. However the AUC created does not have

  • HT6058 I can't update my iPad retina to iOS 7.0.4

    How can I update my iPad. Coz it always says occurred error

  • SmartBand in offline mode

    How many hours activity can store SmartBand stay disconnected from the phone?

  • Reorder of Columns in Voyager

    Hi, Can you please let me know how to move the columns on Voyager workspaces. What i can see is, Voyager workspace by default arranges the columns in the same sequence that of listed measures in data provider. I am not able to re-arrange the column a