Skip to Content
avatar image
Former Member

dynamic text edit

Hi,

I am dynamically creating node NODECOMMENTS with atriibute COMMENTS .Now I want to bind it with the TEXT EDIT

created dynamically . I am doing the following coding :


  DATA: ls_component    TYPE cl_abap_structdescr=>component,
        lr_type         TYPE REF TO cl_abap_datadescr,
       lt_components   TYPE cl_abap_structdescr=>component_table.

* build a structure description from the list of single fields
    ls_component-name = 'COMMENTS'.
    ls_component-type ?= cl_abap_datadescr=>describe_by_name(
                        'STRING_TABLE' ).

    APPEND ls_component TO lt_components.

  DATA :struct_type TYPE REF TO CL_ABAP_STRUCTDESCR .
  struct_type = cl_abap_structdescr=>create( lt_components ).


 DATA: lr_node_info TYPE REF TO if_wd_context_node_info.

 *dynamic node generation
   CALL METHOD wd_context->get_node_info
      RECEIVING
        node_info = lr_node_info.
    data : lv_node type string value 'NODECOMMENTS'.
*unique id for each dynamic node
  CONCATENATE lv_node wd_this->count1 INTO lv_node.
 wd_this->count1 = wd_this->count1 + 1.

  CALL METHOD lr_node_info->add_new_child_node
     EXPORTING
        name                        = lv_node
        is_multiple                 = abap_true
       static_element_rtti         = struct_type
        is_static                   = abap_false .

* get instance of new node
 DATA: dyn_node TYPE REF TO if_wd_context_node.
   dyn_node = wd_context->get_child_node( name = lv_node ).

 *dynamic transparent container and text edit

 DATA: lo_container TYPE REF TO cl_wd_uielement_container,
        lo_text_edit TYPE REF TO cl_wd_text_edit .

*    lo_matrix_data TYPE REF TO cl_wd_row_data.
  DATA : tedit_indx_id TYPE string.
     lo_container ?= wd_this->mr_view->get_element( 'TC_TEXTEDIT' ).
     wd_this->count = wd_this->count + 1.
      tedit_indx_id = 'TE_1'.
*      unique text edit id
  CONCATENATE tedit_indx_id wd_this->count INTO tedit_indx_id.
  DATA : LV_SAP TYPE STRING.
  CONCATENATE lv_node '.COMMENTS' INTO LV_SAP.

  lo_text_edit        = cl_wd_text_edit=>new_text_edit(
 bind_value          = LV_SAP ) .

  cl_wd_row_head_data=>new_row_head_data( element = lo_text_edit ).
  lo_container->add_child( lo_text_edit ).

But it is giving me the exception " Context binding of property VALUE cannot be resolved: Node V_EDIT.1.NODECOMMENTS00 does not contain any elements " .

I am doing the coding in V_EDIT view .

Can any1 tell me where m I missing , I want to generate text edit dynamically .

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Jul 22, 2009 at 07:53 AM
    cl_wd_row_layout=>new_row_layout( container = lo_container ).
    
    ** Prepare properties of attribute & add to context node CHILD
      lr_attribute_info-name = 'COMMENTS'.
      lr_attribute_info-type_name = 'STRING'.
      lr_attribute_info-value_help_mode = '0'.
    
      lr_node_info->add_attribute( EXPORTING attribute_info = lr_attribute_info ).
    
      lr_element = dyn_node->create_element( ).
    
      lr_element->set_attribute( name  = 'COMMENTS'
                                 value = 'This is my TextEdits text!' ).
    
      dyn_node->bind_element( new_item             = lr_element
                             set_initial_elements = abap_false ).
    
      lo_text_edit = cl_wd_text_edit=>new_text_edit( bind_value = 'NODECOMMENTS.COMMENTS' ) .
    
      cl_wd_row_head_data=>new_row_head_data( element = lo_text_edit ).
    
      lo_container->add_child( lo_text_edit ).
    ENDMETHOD.
    Add comment
    10|10000 characters needed characters exceeded

  • Jul 22, 2009 at 06:25 AM

    Hi Amit,

    The code you have pasted has lost all its formatting and is quite difficult to understand. Try go through this code snippet which am pasting below in which I am dynamically creating a group & its associated caption & am embedding 4 TextEdit UI elements within this group. Also I am dynamically creating a context node & 4 attributes to bind to the 4 TextEdit's. Just try copy & paste the code within your WDDOMODIFYVIEW & try to analyze as to where you might have gone wrong.

    Regards,

    Uday

    METHOD wddomodifyview.
      DATA: lr_container TYPE REF TO cl_wd_uielement_container,
            lr_group TYPE REF TO cl_wd_group,
            lr_caption_group TYPE REF TO cl_wd_caption,
            lr_textedit TYPE REF TO cl_wd_text_edit,
            lr_node_info TYPE REF TO if_wd_context_node_info,
            lr_node TYPE REF TO if_wd_context_node,
            lr_element TYPE REF TO if_wd_context_element,
            lr_attribute_info TYPE wdr_context_attribute_info,
            content TYPE string,
            attribute_name TYPE string,
    	lv_textview_id TYPE string.
    
      CHECK first_time = abap_true.
    
      lr_node_info = wd_context->get_node_info( ).
    
      CALL METHOD lr_node_info->add_new_child_node
        EXPORTING
          name                         = 'CHILD'
          is_mandatory                 = abap_false
          is_multiple                  = abap_true
          is_multiple_selection        = abap_true
          is_singleton                 = abap_false
          is_initialize_lead_selection = abap_true
          is_static                    = abap_false
        RECEIVING
          child_node_info              = lr_node_info.
    
    
      lr_container ?= view->get_root_element( ).
    
      cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 22, 2009 at 06:25 AM
    lr_group = cl_wd_group=>new_group( id = 'GROUP' ).
      lr_group->set_width( value = '50%' ).
    
      cl_wd_matrix_layout=>new_matrix_layout( container = lr_group ).
      cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_group ).
      lr_caption_group = cl_wd_caption=>new_caption( text = 'Group Header' ).
      lr_group->set_header( the_header = lr_caption_group ).
    
    
      DO 4 TIMES.
        MOVE sy-index TO attribute_name.
    
    ** Preparing the data to be displayed in the textEdit i.e, data for context attribute
        CONCATENATE 'This'
                    'is the'
                    'data for textEdit number: '
                     attribute_name  INTO content SEPARATED BY cl_abap_char_utilities=>newline.
    
        CONCATENATE 'ATTR'
                    attribute_name INTO attribute_name.
    
    ** Condense the ID to ensure that the format is consistent with SAP standard
        CONDENSE attribute_name NO-GAPS.
    
    ** Prepare properties of attribute & add to context node CHILD
        lr_attribute_info-name = attribute_name.
        lr_attribute_info-type_name = 'STRING'.
        lr_attribute_info-value_help_mode = '0'.
    
        lr_node_info->add_attribute( EXPORTING attribute_info = lr_attribute_info ).
    
        lr_node = wd_context->get_child_node( name = 'CHILD' ).
        lr_element = lr_node->create_element( ).
    
        lr_element->set_attribute( name  = attribute_name
                                   value = content ).
    
        lr_node->bind_element( new_item             = lr_element
                               set_initial_elements = abap_false ).
    
    ** Compute the attribute path dynamically i.e, like CHILD.ATTR1
        CONCATENATE 'CHILD.'
                    attribute_name INTO attribute_name.
        CONDENSE attribute_name NO-GAPS.
        lr_textedit = cl_wd_text_edit=>new_text_edit( cols  = 10
                                                      rows  = 5
                                                      width = '90%'
                                                      bind_value = attribute_name ).
    
        cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_textedit ).
    
        lr_group->add_child( the_child = lr_textedit ).
      ENDDO.
      		
    lr_container->add_child( the_child = lr_group ).
    ENDMETHOD.
    Add comment
    10|10000 characters needed characters exceeded

  • Jul 22, 2009 at 07:53 AM

    Hi Amit,

    I have gone through your coding and made changes wherever necessary. Try copy & paste the same coding into your WDDOMODIFYVIEW method & you should be able to:

    1) Create a dynamic node by name NODECOMMENTS & an attribute by name COMMENTS under this.

    2) Create a dynamic TextEdit & bind it to the context attribute COMMENTS (i.e., NODECOMMENTS.COMMENTS)

    Regards,

    Uday

    METHOD wddomodifyview .
      DATA: struct_type TYPE REF TO cl_abap_structdescr,
            lr_node_info TYPE REF TO if_wd_context_node_info.
    
    * dynamic node generation
      CALL METHOD wd_context->get_node_info
        RECEIVING
          node_info = lr_node_info.
    
      CALL METHOD lr_node_info->add_new_child_node
        EXPORTING
          name                         = 'NODECOMMENTS'
          is_mandatory                 = abap_false
          is_multiple                  = abap_false
          is_multiple_selection        = abap_true
          is_singleton                 = abap_false
          is_initialize_lead_selection = abap_true
          static_element_rtti          = struct_type
          is_static                    = abap_false
        RECEIVING
          child_node_info              = lr_node_info.
    
    * Get instance of new node
    
      DATA: dyn_node TYPE REF TO if_wd_context_node.
    
      dyn_node = wd_context->get_child_node( name = 'NODECOMMENTS' ).
    
    * Dynamic transparent container and text edit
      DATA: lo_container TYPE REF TO cl_wd_uielement_container,
            lo_text_edit TYPE REF TO cl_wd_text_edit,
            lr_attribute_info TYPE wdr_context_attribute_info,
            lr_element TYPE REF TO if_wd_context_element.
    
      lo_container ?= view->get_root_element( ).

    Add comment
    10|10000 characters needed characters exceeded