Generics in a dynamic context - solutions?

Let's assume that we have a two level hierarchy of gizmos. Say the parent class is called AbstractGizmo, with children Gizmo1, Gizmo2, Gizmo3, .....
In addition you have a Gizmo generator class to generate gizmos in a variety of ways, here is one of them
public class GizmoGenerator
   public <T extends AbstractGizmo> static T create(Class<T> cls, AdditionalParms parms)
}So to create a Gizmo you would do
Gizmo1 g1 = GizmoGenerator.create(Gizmo.class, parms );
Of course, you realize that you want to be able to substitute generators, for unit testing, and other reasons, so you decide to use a factory, and make the generator an instance with instance methods, such as
Gizmo1 g1 = GizmoFactory.getGenerator().create(Gizmo1.class, parms );
You find however that having just one generator is a pain especially for unit testing, and so you'd rather specialize at the factory, and do
Gizmo1 g1 = GizmoFactory.getGenerator(Gizmo1.class).create(parms);
The problem is, now, tho, create doesn't know how to specialize, and so this instruction has compile problems <can't cast AbstractGizmo to Gizmo1>.
Now one could pass the class to the create method as well as the factory, but that is real hinky in my mind, and what happens if you pass two different classes to the two parts... so that seems bad.
So what does one do here?
I don't want to do
Gimzo1 g1 = *(Gizmo1)*GizmoFactory.getGenerator(Gizmo1.class).create(parms);
What is the suggested solution here?

I don't know if this is a good solution, but here's what I came up with.
First off, I've made GizmoGenerator an interface, and added a getGizmoClass() method:
public interface GizmoGenerator<T extends AbstractGizmo>
  public Class<T> getGizmoClass();
  public T create(Object[] params);
  public T copy(T original);
}The factory methods to set the gizmo generator now only passes the generator, and the method pulls the class from the generator. I had to add type parameters to the method to make it work:
import java.util.HashMap;
public class GizmoFactory
  private static HashMap<Class, GizmoGenerator> classMap = new HashMap<Class, GizmoGenerator>();
  public static <T extends AbstractGizmo> GizmoGenerator<T> getGenerator(Class<T> clazz)
    return (GizmoGenerator<T>)classMap.get(clazz);
  public static <T extends AbstractGizmo> void setGenerator(GizmoGenerator<T> generator)
    classMap.put(generator.getGizmoClass(), generator);
  public static <T extends AbstractGizmo> void main(String[] argv)
    try
      T gz = (T)(new Gizmo1());
      Class<T> clazz = (Class<T>)Class.forName("Gizmo1");
      getGenerator(clazz).copy(gz);
    catch (Exception e)
    {  e.printStackTrace();  }
}Frankly, I don't like it. With all the casting going on, the generics are not adding any type-safety in this case. I think the root of the problem is Class.forName(), which breaks compile-time type safety. As long as that's there, everything else breaks down.

Similar Messages

  • Dynamic Context Mapping in Web Dynpro ABAP

    Hi Experts,
    How can I create two dynamic Context nodes, one in ViewController and the other in Component Controller and finally create a context mapping between them?
    Regards,
    Johan Kriek.

    Hi Johan,
    I found a method IF_WD_CONTEXT_NODE_INFO~ADD_NEW_MAPPED_CHILD_NODE that seems to be the one that I am looking for.
    I do have same idea but i have been trying to give solution by using above method,unfortunately here my server is down.check the below code. i didnt check this code due to server down.
    DATA: lo_nd_purchase_header TYPE REF TO if_wd_context_node,
          lo_el_purchase_header TYPE REF TO if_wd_context_element,
    ls_purchase_header TYPE wd_this->element_purchase_header,
          lo_node_info type ref to if_wd_context_node_info,
          lo_child_node_info type ref to if_wd_context_node_info,
          MAPPING_INFO type WDR_CONTEXT_MAPPING_INFO.
    * navigate from <CONTEXT> to <PURCHASE_HEADER> via lead selection
      lo_nd_purchase_header = wd_context->get_child_node( name = wd_this->wdctx_purchase_header ).
                  CALL METHOD LO_ND_PURCHSE_HEADER->GET_NODE_INFO
                    RECEIVING
                      NODE_INFO = lo_node_info.
           MAPPING_INFO-controller = 'ZWDC_ALV'. "conponent name
           MAPPING_INFO-path = 'PURCHASE_HEADER'. "Controller context node name
          CALL METHOD LO_NODE_INFO->ADD_NEW_MAPPED_CHILD_NODE
            EXPORTING
              CHILD_NAME      = 'PURCHASE_HEADER'
              MAPPING_INFO    =  MAPPING_INFO
    *          IS_STATIC       = ABAP_TRUE
            RECEIVING
              CHILD_NODE_INFO = lo_child_node_info

  • Set Data from a Dynamic Context in ALV

    Hi,
    I've created an dynamic context and have binded the data. When I want to show this data in an dynamicly table with the following code, it works well.
    cl_wd_dynamic_tool=>create_table_from_node( EXPORTING ui_parent      = lo_container
                                                              table_id       = 'DYN_ML_TABLE'
                                                              node           = lo_nd_dyn_ml
                                                    RECEIVING table          = lo_table ).
    Unfortunately when I want to show the context data in an ALV table with the method set_data I will see the structure, but the binded data are lost.
    lo_comp_alv = wd_this->wd_cpuse_usage_alv_dyn_ml( ).
      IF lo_comp_alv->has_active_component( ) IS INITIAL.
        lo_comp_alv->create_component( ).
      ENDIF.
      lo_comp_if_alv = wd_this->wd_cpifc_usage_alv_dyn_ml( ).
      lo_comp_if_alv->set_data( lo_nd_dyn_ml ).
    I've tested an manually created context node with this method, and I will see the data.
    Could anybody help me?
    Best Regards,
    Sascha

    I created the node with rtti. Now, it works:
    "Beschreibung zu interner Tabelle lesen
       lo_tab_descr ?= cl_abap_typedescr=>describe_by_data( it_matchlist ).
       "Zeilentyp zu interner Tabelle ermitteln
       lo_str_descr ?= lo_tab_descr->get_table_line_type( ).
       "Komponente der Zeile ausgeben, welche für die Erstellung der Knotenattribute benötigt werden
       lt_comp = lo_str_descr->get_components( ).
       data: ls_component type cl_abap_structdescr=>component,
             lr_type type ref to cl_abap_datadescr,
             lt_components type cl_abap_structdescr=>component_table,
             lr_structdescr type ref to cl_abap_structdescr.
       "Loop über Komponente und Einfügen in Attributenliste
       loop at lt_comp into ls_comp.
         lv_abs_name = ls_comp-type->absolute_name.
         "Folgende Zeichen werden entfernt: '/TYPE='
         shift lv_abs_name left by 6 places.
         lr_type ?= cl_abap_typedescr=>describe_by_name( p_name = lv_abs_name ).
         ls_component-name = ls_comp-name.
         ls_component-type = lr_type .
         append ls_component to lt_components.
       endloop.
       "Strukturtyp anhand der definierten Kompententen der internen Tabelle erzeugen
       lr_structdescr = cl_abap_structdescr=>create( p_components = lt_components ).
    *  "Neuen Kindknoten anlegen
       lo_nd_dyn_info = lo_nd_root_info->add_new_child_node( name                         = wd_this->gd_matchlist_nd_name
                                                             is_mandatory                 = abap_false
                                                             is_mandatory_selection       = abap_false
                                                             is_multiple                  = abap_true
                                                             is_multiple_selection        = abap_false
                                                             is_singleton                 = abap_false
                                                             is_initialize_lead_selection = abap_true
    *                                                        attributes                   = lt_attributes
                                                             is_static                    = abap_false
                                                             static_element_rtti          = lr_structdescr
                                                             "supply_method                =
                                                             "supply_object                =
                                                             "dispose_method               =
                                                             "dispose_object               =
                                                             "static_element_type          =

  • Error creating dynamic context node in Webdynpro for ABAP. Plesae help!

    Hi
       I am getting the following error while creating a dynamic context node with 2 attributes. Please help me resolve this problem.
    Note
    The following error text was processed in the system PET : Line types of an internal table and a work area not compatible.
    The error occurred on the application server FMSAP995_PET_02 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Method: IF_WD_CONTEXT_NODE~GET_STATIC_ATTRIBUTES_TABLE of program CL_WDR_CONTEXT_NODE_VAL=======CP
    Method: GET_REF_TO_TABLE of program CL_SALV_WD_DATA_TABLE=========CP
    Method: EXECUTE of program CL_SALV_WD_SERVICE_MANAGER====CP
    Method: APPLY_SERVICES of program CL_SALV_BS_RESULT_DATA_TABLE==CP
    Method: REFRESH of program CL_SALV_BS_RESULT_DATA_TABLE==CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~MAP_FROM_SOURCE_DATA of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~MAP_FROM_SOURCE of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~UPDATE of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_VIEW~MODIFY of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMPONENT~VIEW_MODIFY of program CL_SALV_WD_A_COMPONENT========CP
    My code is like the following:
    TYPES: BEGIN OF t_type,
                CARRID TYPE sflight-carrid,
                CONNID TYPE sflight-connid,
             END OF t_type.
      Data:  i_struc type table of t_type,
      dyn_node   type ref to if_wd_context_node,
      rootnode_info   type ref to if_wd_context_node_info,
      i_node_att type wdr_context_attr_info_map,
      wa_node_att type line of wdr_context_attr_info_map.
          wa_node_att-name = 'CARRID'.
          wa_node_att-TYPE_NAME = 'SFLIGHT-CARRID'.
          insert wa_node_att into table i_node_att.
          wa_node_att-name = 'CONNID'.
          wa_node_att-TYPE_NAME = 'SFLIGHT-CONNID'.
          insert wa_node_att into table i_node_att.
    clear i_struc. refresh i_struc.
      select carrid connid into corresponding fields of table i_struc from sflight where carrid = 'AA'.
    rootnode_info = wd_context->get_node_info( ).
    rootnode_info->add_new_child_node( name = 'DYNFLIGHT'
                                       attributes = i_node_att
                                       is_multiple = abap_true ).
    dyn_node = wd_context->get_child_node( 'DYNFLIGHT' ).
    dyn_node->bind_table( i_struc ).
    l_ref_interfacecontroller->set_data( dyn_node ).
    I am trying to create a new node. That is
    CONTEXT
    - DYNFLIGHT
    CARRID
    CONNID
    As you see above I am trying to create 'DYNFLIGHT' along with the 2 attributes which are inside this node. The structure of the node that is, no.of attributes may vary based on some condition. Thats why I am trying to create a node dynamically.
    Also I cannot define the structure in the ABAP dictionary because it changes based on condition

    Ok, I think I found a bug... It seems for adobe forms in WD4A, the root context node must be 1-1 and you must nest the 1-n node within that... Not sure why, but it worked. So in my case my context would look like this:
    FOO_NODE (1-1)
         Widget (1-N)
              -Widget_info (1-1)
                   *Name
                   *Sku
                   *Description
              -Widget_plant (1-M)
                   *Plant_Code
                   *Plant_State
                   *Plant_City
              -Widget_pic (1-1)
                   *Picture

  • How to create dynamic context based on a structure defined in the program?

    Hi Experts,
             I need to create a dynamic context based on a structure wa_struc which i have define programatically.
    When I pass wa_struc to structure_name parameter of create_nodeinfo_from_struc, i get a runtime error:
    "Parameter STRUCTURE_NAME contains an invalid value wa_struc."
    How to create dynamic context based on a structure defined in the program?
    I have written the code like this:
    TYPES: BEGIN OF t_type,
                v_carrid TYPE sflight-carrid,
                v_connid TYPE sflight-connid,
             END OF t_type.
      Data:  i_struc type table of t_type,
             wa_struc type t_type.
      data: dyn_node   type ref to if_wd_context_node.
      data: rootnode_info   type ref to if_wd_context_node_info.
      rootnode_info = wd_context->get_node_info( ).
      clear i_struc. refresh i_struc.
      select carrid connid into corresponding fields of table i_struc from sflight where carrid = 'AA'.
    cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
      parent_info = rootnode_info
      node_name = 'dynflight'
      structure_name = 'wa_struc'
      is_multiple = abap_true ).
    dyn_node = wd_context->get_child_node( name = 'dynflight' ).
    dyn_node->bind_table( i_struc ).
    Thanks
    Gopal
    Message was edited by: gopalkrishna baliga

    Hi Michelle,
              First of all Special thanks for your informative answers to my other forum questions. I really appreciate your help.
    Coming back to this question I am still waiting for an answer. Please help. Note that my structure is not in a dictionary.
    I am trying to create a new node. That is
    CONTEXT
    - DYNFLIGHT
    CARRID
    CONNID
    As you see above I am trying to create 'DYNFLIGHT' along with the 2 attributes which are inside this node. The structure of the node that is, no.of attributes may vary based on some condition. Thats why I am trying to create a node dynamically.
    Also I cannot define the structure in the ABAP dictionary because it changes based on condition
    I have updated my code like the following and I am getting error:
    TYPES: BEGIN OF t_type,
    CARRID TYPE sflight-carrid,
    CONNID TYPE sflight-connid,
    END OF t_type.
    Data: i_struc type table of t_type,
    dyn_node type ref to if_wd_context_node,
    rootnode_info type ref to if_wd_context_node_info,
    i_node_att type wdr_context_attr_info_map,
    wa_node_att type line of wdr_context_attr_info_map.
    wa_node_att-name = 'CARRID'.
    wa_node_att-TYPE_NAME = 'SFLIGHT-CARRID'.
    insert wa_node_att into table i_node_att.
    wa_node_att-name = 'CONNID'.
    wa_node_att-TYPE_NAME = 'SFLIGHT-CONNID'.
    insert wa_node_att into table i_node_att.
    clear i_struc. refresh i_struc.
    select carrid connid into corresponding fields of table i_struc from sflight where carrid = 'AA'.
    rootnode_info = wd_context->get_node_info( ).
    rootnode_info->add_new_child_node( name = 'DYNFLIGHT'
    attributes = i_node_att
    is_multiple = abap_true ).
    dyn_node = wd_context->get_child_node( 'DYNFLIGHT' ).
    dyn_node->bind_table( i_struc ).
    l_ref_interfacecontroller->set_data( dyn_node ).
    But now I am getting the following error :
    The following error text was processed in the system PET : Line types of an internal table and a work area not compatible.
    The error occurred on the application server FMSAP995_PET_02 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Method: IF_WD_CONTEXT_NODE~GET_STATIC_ATTRIBUTES_TABLE of program CL_WDR_CONTEXT_NODE_VAL=======CP
    Method: GET_REF_TO_TABLE of program CL_SALV_WD_DATA_TABLE=========CP
    Method: EXECUTE of program CL_SALV_WD_SERVICE_MANAGER====CP
    Method: APPLY_SERVICES of program CL_SALV_BS_RESULT_DATA_TABLE==CP
    Method: REFRESH of program CL_SALV_BS_RESULT_DATA_TABLE==CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~MAP_FROM_SOURCE_DATA of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~MAP_FROM_SOURCE of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~UPDATE of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_VIEW~MODIFY of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMPONENT~VIEW_MODIFY of program CL_SALV_WD_A_COMPONENT========CP
    -Gopal
    Message was edited by: gopalkrishna baliga

  • Dynamic context binding in web dynpro alv

    I use dynamic context binding (see code below to show and edit the ALV table.
    'DB_TABLE' is a tranparent table. It works fine.
    But now this table should be expanded with additional fields which are only known at runtime and could be different from case to case.
    How can I get these fields in the context dynamically?
      DATA:
            rootnode_info TYPE REF TO if_wd_context_node_info,
            dyn_node      TYPE REF TO if_wd_context_node,
            tablename   TYPE string.
      rootnode_info = wd_context->get_node_info( ).
      tablename = 'DB_TABLE'.
      cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
        parent_info = rootnode_info
        node_name = tablename
        structure_name = tablename
        is_multiple = abap_true ).
      DATA:
            stru_tab TYPE REF TO data.
      FIELD-SYMBOLS: <tab> TYPE table.
      CREATE DATA stru_tab TYPE TABLE OF (tablename).
      ASSIGN stru_tab->* TO <tab>.
      SELECT * FROM (tablename) INTO CORRESPONDING FIELDS OF TABLE <tab>.
      dyn_node = wd_context->get_child_node( name = tablename ).
      dyn_node->bind_table( <tab> ).

    You should create a structure dynamically and use this as the context structure. See the coding below, where a structure is created, which contains CARRID and CONNID.
    DATA: node_info type ref to if_wd_context_node_info,
          struct_type TYPE REF TO cl_abap_structdescr,
          table_type  type ref to cl_abap_tabledescr,
          comp_tab    TYPE cl_abap_structdescr=>component_table,
          comp        LIKE LINE OF comp_tab,
          my_table    type ref to data,
          my_row      type ref to data.
      field-symbols: <table> type table,
                     <row> type data,
                     <flight> type sflight.
    * build a structure description from the list of single fields
      comp-name = 'CARRID'.
      comp-type ?= cl_abap_datadescr=>describe_by_name( 'S_CARR_ID' ).
      APPEND comp TO comp_tab.
      comp-name = 'CONNID'.
      comp-type ?= cl_abap_datadescr=>describe_by_name( 'S_CONN_ID' ).
      APPEND comp TO comp_tab.
    * note this structure contains the fields "CONNID" and "CARRID"
      struct_type = cl_abap_structdescr=>create( comp_tab ).
    * now the nodeinfo is created
      node_info = wd_context->get_node_info( ).
      node_info = node_info->add_new_child_node(
        name                         = 'MY_NODE'
        IS_MANDATORY                 = ABAP_true
        IS_MULTIPLE                  = ABAP_true
        STATIC_ELEMENT_RTTI          = struct_type
        IS_STATIC                    = ABAP_false
    * fill new node;
      data: l_node type ref to if_wd_context_node,
            l_flight type STANDARD TABLE OF sflight.
      l_node = wd_context->get_child_node( 'MY_NODE' ).
      l_flight = wd_assist->get_flights( ).
    *  if you could create a local data type, would be fine, but if you have to do it dynamically ...
      struct_type = node_info->GET_STATIC_ATTRIBUTES_TYPE( ).
    * create tabledescriptor from structdescription (standard table, no keys)
      table_type = cl_abap_tabledescr=>create( p_line_type = struct_type ).
      create data my_table type handle table_type.
      assign my_table->* to <table>.
      loop at l_flight assigning <flight>.
        create data my_row type handle struct_type.
        assign my_row->* to <row>.
        move-corresponding <flight> to <row>.
        append <row> to <table>.
      endloop.
      l_node->bind_table( <table> ).

  • Dynamic Recovery Solutions and odd DOFD

    So I have a new collection on EQ Dynamic Recovery Solutions, and the OC is Checksmart. It was reported 7/2015 with a DOFD of 10/2014.   Roughly 7 to 10 years ago, I was stuck in the payday advance loop and routinely got advances from Checksmart. So I was a customer at one point. I got my last advance probably over 7 years ago, and can't recall if I ever paid it back or not. There's a good chance that I didn't, since at the time I was going thru a foreclosure and moved across the country.   My question is .. how can they have a DOFD of 10/2014 when I would have defaulted no later than 2008? I started a dispute on EQ's website immediately after learning of this .. should I do anything else?

    When I look at EQ's online dispute tool, I see the following: Agency Address:135 Interstate Blvd Unit 6
    Greenville, SC  29615-5720
    (877) 821-1659 Date Reported:07/2015  Date Assigned:07/2015  Creditor Classification:Financial  Creditor Name:CHECKSMART  Account Number:3935XXXX  Account Owner:Individual Account.  Original Amount Owned:$481  Date of 1 st Delinquency:10/2014  Balance Date:07/2015  Balance Owned:$481  Last Payment Date: Status Date:07/2015  Status:D - Unpaid  Comments:N/A

  • Structural authorization with Context Solution

    Hey Guys,
    I have a requirement. For an example, I would like to restrict IT 0001 access for write access. A Manager should have read and write access to IT 0001 only for personnel#s under his org unit (for which he has a 'chief' position). For other personnel#s, he should have only read access for IT 0001.
    We would like to use Context Solution (P_ORGINCON authorization object). I have created a PD profile with O-S-P evaluation path and RH_GET_MANAGER_ASSIGNMENT as function module.
    In role, authorization object P_ORGINCON would be having following values (which gives read and write access to IT 0001 for Manager's org unit):
    Authorization Level - R, M, W, E, D, S
    Infotype - 0001
    Personnel Area - *
    Employee Group - *
    Employee Subgroup - *
    Subtype - *
    Organizational Key - *
    Authorization Profile - PD_PROFILE_1
    PD profile (PD_PROFILE_1) is restricted by RH_GET_MANAGER_ASSIGNMENT function module and so it gives list of personnel#s, a Manager is authorized for his org unit.
    My questions:
    1: For my requirement, what values should be in second authorization object, to have read only access for IT 0001 for all personnel#s? Do I have to use P_ORGINCON authorization object with Authorization Profile as '*'?
    2: At the time of turning on HR switch (transaction OOAC, table T77S0) for INCON (HR: Master Data (Context)) to 1, do we have to turn off switch for ORGIN (HR: Master Data)?
    3: If yes to question 2, do we have to update all transactions in SU24 to reflect P_ORGINCON for check/maintain instead of P_ORGIN? So, whenever we enter transaction code in a role thru PGCF, P_ORGINCON would be entered in authorization or it is not required.
    Thanks,
    Karan.

    Hi Karan,
    1: For my requirement, what values should be in second authorization object, to have read only access for IT 0001 for all personnel#s? Do I have to use P_ORGINCON authorization object with Authorization Profile as '*'?
    I think you can use it.
    2: At the time of turning on HR switch (transaction OOAC, table T77S0) for INCON (HR: Master Data (Context)) to 1, do we have to turn off switch for ORGIN (HR: Master Data)?
    Yes you need to turn off the switch for ORGIN
    3: If yes to question 2, do we have to update all transactions in SU24 to reflect P_ORGINCON for check/maintain instead of P_ORGIN? So, whenever we enter transaction code in a role thru PGCF, P_ORGINCON would be entered in authorization or it is not required.
    You dont need to update in SU24

  • To access a dynamic context node defined in a Used Component

    Hi Gurus,
    I need your help with something.
    I have a dynamic context node in ComponentA. I want it in Component B too.
    Component B uses Component A, but I am not able to get access to the context node.
    Is it possible to do this? Any suggestions how to proceed.
    PS: I am trying to do a dynamic mapping. The initial scenario was here, Set data into Model Node on Navigating from a View
    Thanks in advance,
    Anjana R.
    Message was edited by:
            Anjana Raghav

    Hi Gurus,
    Its working now. Earlier, the code was something like this....
    IWDNodeInfo compNode = wdThis.wdGet<i>Comp</i>Interface().wdGetAPI().getContext().getRootNodeInfo().getChild(nodeNm);
    viewNodeInfo.setMapping(compNode,true);
    and was trying to map it using
    iewNodeInfo.addMappedAttribute("order",".<i>Comp</i>."+ nodeNm + ".order");     
    Now, I am mapping like this.
    viewNodeInfo.addMappedAttribute("order","order");
    Thanks,
    Anjana R.

  • Adding dynamic context node

    Hello,
    I having problems with creating a dynamic context node.
    How can i add a new node to the context on runtime and not on design time.
    Best Regards,
    Smadar.

    Hi,
    IWDNodeInfo nodeinfo=wdContext.getNodeInfo();
    /* This will add a ValueNode */
    IWDNodeInfo customerNode=nodeinfo.addChild("Customer",null,true,true,true,false,false,true,null,null,null);
    /* This will add  a Attribute to the above Node */
    IWDAttributeInfo custAttr=customerNode.addAttribute("AttribName","com.sap.dictionary.string");
    Regards, Anilkumar

  • Dynamic Context Dynamic and UI table Dynamic

    Hello,
    I created a dynamic context and a dynamic table that use this dynamic context.  I have the following error:*     *   The following error text was processed in the system XAP : Could not find attribute AMOUNT2009**
    The error occurred on the application server sat190_XAP_00 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
          Method: IF_WD_CONTEXT_NODE_INFO~GET_ATTRIBUTE of program CL_WDR_CONTEXT_NODE_INFO======CP
          Method: GET_ATTRIBUTE_INFO of program CL_WDR_VIEW_ELEMENT_ADAPTER===CP
          Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L3STANDARD==============CP
          Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L3STANDARD==============CP
          Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L3STANDARD==============CP
          Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L3STANDARD==============CP
          Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L8STANDARD==============CP
          Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L8STANDARD==============CP
          Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L8STANDARD==============CP
          Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L7STANDARD==============CP
    AMOUNT2009 is a new attribute that add to my context, i made the next code, can you review and say me where i have the error?  I start with the second year is for this reason that i use a count.
    Reading FINCATYGROUP
      DATA lo_nd_fincatygroup TYPE REF TO if_wd_context_node.
      DATA lo_el_fincatygroup TYPE REF TO if_wd_context_element.
      DATA ls_fincatygroup TYPE wd_this->element_fincatygroup.
      DATA :  lv_year   type STRING,
              ls_attribute         type wdr_context_attribute_info, "To create dynamic node in the context
              lr_container         TYPE REF TO CL_WD_UIELEMENT_CONTAINER,
              lr_table             TYPE REF TO CL_WD_TABLE,
              lr_input_field       TYPE REF TO CL_WD_INPUT_FIELD,
              lr_cell_editor       TYPE REF TO if_wd_table_cell_editor,
              lr_column            TYPE REF TO CL_WD_TABLE_COLUMN,
              lr_column_header     TYPE REF TO CL_WD_CAPTION,
              lv_headerColumn      TYPE STRING,
              lv_id_input_field    TYPE STRING,
              lv_name              TYPE STRING,
              lv_id_table_column   TYPE STRING.
      DATA: lr_node_info TYPE REF TO if_wd_context_node_info, "To get node info
      lr_table_type TYPE REF TO cl_abap_tabledescr, "To get table and stuct descriptor
      lr_line_type TYPE REF TO cl_abap_structdescr,
      lt_components TYPE cl_abap_structdescr=>component_table, "To get component table
      ls_components_line LIKE LINE OF lt_components, "One line of component table
      lr_elem_type TYPE REF TO cl_abap_elemdescr.
        LOOP AT lv_periods_tt INTO lv_periods_ts.
      get all declared attributes
          lv_periods_ts->get_static_attributes(
            IMPORTING
              static_attributes = ls_wa_period ).
      navigate from <CONTEXT> to <FINCATYGROUP> via lead selection
          lo_nd_fincatygroup = wd_context->get_child_node( name = wd_this->wdctx_fincatygroup ).
          IF lv_cont = 1 OR lv_cont = 2.
            lv_cont = lv_cont + 1.
          ELSE.
      Create dynamic context and dynamic view
      get node_info
            lr_rootnodeinfo = lo_nd_fincatygroup->get_node_info( ).
            lv_year = ls_wa_period-zyear.
            SHIFT lv_year BY 15 PLACES LEFT.
            CONCATENATE 'AMOUNT' lv_year INTO lv_name.
      put attributes of add_attrbute node
            CONCATENATE 'Y' lv_year INTO ls_attribute-name.
            ls_attribute-name = lv_name.
            ls_attribute-type_name = '\TYPE=/RPM/TV_CURR_AMOUNT'.
            lr_rootnodeinfo->add_attribute( "Add attribute for amount of year
              EXPORTING
                attribute_info = ls_attribute ).
    ********************* table *******************************************************
    Get ROOTUIELEMENTCONTAINER
            lr_container ?= view1->get_element( 'ROOTUIELEMENTCONTAINER ' ).
    Get TABLEFCG
            lr_table ?= view1->get_element( 'TABLEFCG' ).
    Create cell_editor
            CONCATENATE 'TABLEFCGIF_Y' lv_year '_EDITOR' INTO lv_id_input_field.
            lr_input_field = cl_wd_input_field=>new_input_field(
                                  id = lv_id_input_field bind_value = ls_attribute-name ).
            CONCATENATE 'TABLEFCG_Y' lv_year '_EDITOR' INTO lv_headerColumn.
            lr_column_header = cl_wd_caption=>new_caption( id = lv_headerColumn ).
            lr_column_header->set_text( ls_attribute-name ).
    Create table column
            CONCATENATE 'TABLEFCG_' lv_year 'COLUMN' INTO lv_id_table_column.
            lr_column = cl_wd_table_column=>new_table_column( id = lv_id_table_column ).
            lr_column->set_table_cell_editor( lr_input_field ).
            lr_column->set_header( lr_column_header ).
            lr_table->add_grouped_column( lr_column ).
    ********************* end table *******************************************************
          ENDIF.
        ENDLOOP.
    Thanx.

    1.
    Code if the Transparent container's layout is Matrix ( method WDDOMODIFYVIEW )
    data lr_container type ref to cl_wd_transparent_container.
    data lr_input        type ref to cl_wd_input_field.
    data lr_layout_data type ref to cl_wd_matrix_head_data.
       lr_container ?= view->get_element( '<Transparent container ID>' ).
       lr_input = cl_wd_input_field=>new_input_field( bind_value = '<node>.<attribute>'                                                                               
    view = view
                                                                                    ID = 'INP' ).
       lr_layout_data = cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_input width = '100%' ).
    2.
    Dynamic Context Attribute in a node.
    data lr_node     type ref to if_wd_context_node.
    data lr_info       type ref to if_wd_context_node_info.
    data ls_attr       type WDR_CONTEXT_ATTRIBUTE_INFO.
    lr_node = wd_context->get_child_node( '<Node_name>' ).
    lr_info   = lr_node->get_node_info( ).
    ls_attr-name = '<attribute_name>'.
    ls_attr-type_name = 'STRING'.
    lr_info->add_attribute( ls_attr ).

  • Dynamic context nodes

    Hi all,
    I want to create a dynamic context in this way.  But in this example I always need a data element in the dictionary for the describe by name method --> here ZREMARK
    I can use here describe_by_name( 'STRING' ) but then the column headerline is empty.
    How can I set the column headerline when I use this coding?
    comp-name = 'REMARK'.
    comp-type ?= cl_abap_datadescr=>describe_by_name( 'ZREMARK' ).
    APPEND comp TO comp_tab.
    not this structure contains the fields "CONNID" and "CARRID"
      struct_type = cl_abap_structdescr=>create( comp_tab ).
    now the nodeinfo is created
      node_info = wd_context->get_node_info( ).
      node_info = node_info->add_new_child_node(
        name                         = 'MY_NODE'
        is_mandatory                 = abap_false
        is_multiple                  = abap_true
        static_element_rtti          = struct_type
        is_static                    = abap_false
    regards

    >Is it possible to create the columns of the table control in a similar way?
    Yes you can create the table and its columns dynamically in WDDOMODIFYVIEW.  Here is a sample - I'm only creating one column, but it would be easy to adapt this logic to loop through some list of fields to create the columns.
    DATA lr_container TYPE REF TO cl_wd_uielement_container.
      DATA lr_input TYPE REF TO cl_wd_input_field.
      DATA lr_table TYPE REF TO cl_wd_table.
      DATA lr_caption TYPE REF TO cl_wd_caption.
      DATA lr_table_column TYPE REF TO cl_wd_table_column.
      DATA lr_table_standard_cell TYPE REF TO cl_wd_table_standard_cell.
      IF first_time = abap_true.
        lr_container  ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
        cl_wd_table=>new_table(
          EXPORTING
            bind_data_source              = 'SFLIGHT.SFLIGHT'
            id                            = 'DYNTABLE'
          RECEIVING
             control                       = lr_table ).
        cl_wd_input_field=>new_input_field(
          EXPORTING
             bind_value             = 'SFLIGHT.SFLIGHT.CARRID'
             id                     = 'INPUT1'
          RECEIVING
            control                = lr_input ).
        lr_table_column = cl_wd_table_column=>new_table_column( ).
        lr_table_column->set_table_cell_editor( lr_input ).
        lr_caption = cl_wd_caption=>new_caption( ).
        lr_caption->set_text( 'Some text' ).
        lr_table_column->set_header( EXPORTING the_header = lr_caption ).
        lr_table->add_column( EXPORTING the_column = lr_table_column ).
    *       create the layout data of the text view
        DATA lr_grid_data TYPE REF TO cl_wd_grid_data.
        lr_grid_data = cl_wd_grid_data=>new_grid_data( lr_table ).
        lr_table->set_layout_data( lr_grid_data ).
        lr_container->add_child(
          EXPORTING
            the_child = lr_table ).
      ENDIF.

  • Slow response for HR tcodes PA30/PA20 - impact of Context Solution?

    We just implemented the Context Solution for Structural Authorization in our production environment. Through out our testing phase we were aware of somewhat slower performance with the context solution that without it.
    However in production we came across a user who needs 30-45 minutes just to get to the PA30 initial screen. As far as I have seen CSSA only impacts data retrieval times and not simply opening the transaction. So we are surprised at this behaviour. She can however run HR reports without any such issues.
    Its not a problem with the GUI version for the user as she gets the same error from a different PC as well. The only thing that we could find about this user is that she had access to a huge amount of HR data/objects. Does the context solution have a hard limit on the number of HR objects that a person can have access to?
    I would appreciate any ideas!!!............Regards.

    Hi everyone,
    Sorry for not updating this thread for so long. I was aware of and using the RHBAUS00 and RHBAUS02 reports while posting. Somehow the performance was still very slow while using those reports.
    The issue turned out to be related to custom coding for HRBAS00_GET_PROFL where we were not getting rid of duplicate profile values. Now, after a coding change the situation has improved a lot.
    I am closing the thread. Thanks to everyone who took the time to comment!

  • Create dynamic context node

    Hi Experts,
    I have tried the given example for Dynamic Context Node in Webdynpro ABAP
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4c70444a-0801-0010-7688-9e4bd844b783
    But getting the Error when executing this application
    Note
    The following error text was processed in the system ISP : Adapter error in &VIEW_ELEMENT_TYPE& "TABLENAME" of view "ZWD_SACHIN_DYN_ALV.MAIN_VIEW": Context binding of property VALUE cannot be resolved: Node MAIN_VIEW.1.INPUT does not contain any elements
    The error occurred on the application server usirs254_ISP_01 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Method: RAISE_FOR of program CX_WDR_ADAPTER_EXCEPTION======CP
    Method: RAISE_BINDING_EXCEPTION of program CL_WDR_VIEW_ELEMENT_ADAPTER===CP
    Method: GET_BOUND_ELEMENT of program CL_WDR_VIEW_ELEMENT_ADAPTER===CP
    Please resolve this issue because when I am mapping the Attribute TableName in the InputGroup, it is throwing above Error.
    Thanks in advance
    Regards
    Sachin

    Hi Sachin,
    I am unable to understand why you are getting an error. I have tried the same tutorial myself and it works fine for me. Make sure that the TABLENAME attribute (which is of string type) is properly binded to the value property of the input field.
    Regards
    Arjun
    Edited by: Arjun Thakur on Mar 17, 2009 1:46 PM

  • Using Search Help with ALV and Dynamic context node

    The topic subject already describes my situation.
    I have to create, populate and remove context nodes at runtime, and bind them to an ALV, to let user display the data or modify the data. The nodes I create are always typed with a table name, but the table name is of course, dynamic.
    This is all working: what's not working is help for entries inside the ALV; since the table has foreign keys and domains with check tables or fixed values, I expected that search helps were detected and managed by the framework.
    Instead, no help search is displayed except the input help based on data-type of the one "Date" input fields.
    I think I have to work on the dynamic node creation, and not on the ALV itself, since the latter only takes the node/attributes information, but i could be wrong. I tried with both the two following codings:
      CALL METHOD lo_nd_info_root->add_new_child_node
        EXPORTING
          static_element_type          = vs_tabname
          name                         = 'SAMPLE_NODE_NAME'
    *    is_mandatory                 = abap_false
    *    is_mandatory_selection       = abap_false
         is_multiple                  = abap_true
         is_multiple_selection        = abap_false
    *    is_singleton                 = abap_false
          is_initialize_lead_selection = abap_false
          is_static                    = abap_false
        RECEIVING
          child_node_info              = lo_nd_info_data .
    cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
          parent_info = lo_nd_info_root
          node_name = 'SAMPLE_NODE_NAME'
          structure_name = vs_tabname
          is_multiple = abap_true ).
    The result is the same...is there any way to let the ALV know what search helps it has to use, and doesn't force me to manually build a VALUE_SET to be bound on the single attributes? There are many tables, with many fields, and maintaining this solution would be very costly.

    I have checked with method GET_ATTRIBUTE_VALUEHELP_TYPE of interface IF_WD_CONTEXT_NODE_INFO, on an attribute which i know to have a search help (Foreign key of a check table).
    The method returns 'N', that is the constant IF_WD_VALUE_HELP_HANDLER~CO_VH_TYPE_NO_HELP. So, the framework was not able to find a suitable search help.
    Using method GET_ATTRIBUTE_VALUE_HELP of the same interface, on the same attribute, returns me '111', which is constant C_VALUE_HELP_MODE-AUTOMATIC.
    Therefore, the WD framework knows it has to automatically detect a value help, but fails to find one.
    Also, this means in my opinion that the ALV and the dynamic external mapping are not the culprits: since node creation, no help is detected for any attribute but the date. Honestly, I don't have a clue on what's happening.

Maybe you are looking for

  • CONFIG of KE30 report

    Hi, SAP FICO EXPERTS, We have configured the report KE30, and we want a new field to added as SALES GROUPS in it. We created 3 sales groups, and raised sales order using a particular sales grp, and invoiced it. now we want to view the value in KE30 r

  • Calling GuidedProcess from WebDynpro ABAP

    Hi all can anybody tell me that how to call GP from webdynpro ABAP. and what are the advantages and disadvantages in this scenario?? if anyone reply then it would be the great help to me Regards Suresh babu

  • ALSB passing NTLM security credentials to end point URL in business service

    Hi, We are using AXIS API to pass NTLM authentication details to SharePoint Web Service by setting the user name and password details as below. call.setUsername call.setPassword This is working fine when we invoke the MOSS search WSDL directly. Howev

  • Problem in Creating Segments in WE31

    When i am creating a Z.. segement it says the segment already exists when i try to change now it says segment not found... This is in ECC 6 ... please let me know how to resolve this i need these Z segments  because i have to add them in my basic ido

  • B9180 Printing w/ paper longer than 19"

    Is there a way to print on paper up to 44 inches long?  I thought I read somewhere that this printer could accept paper up to 13 x 44 using the specialty media tray.  I have a panorama that is 42 x 12 just waiting to come to life.