Skip to Content
author's profile photo Former Member
Former Member

Context Node.....

hello Friends,

What is the simple way to get the element of node where I know the value of one attribute...

e.g I have a node with 10 attributes ( 0....n i.e. containg may be around 1000 values ) and if I know the value of one attribute ( which is also key ) how I can get easily this ELEMENT ?

right now I am doing something like this...: but I guess there will be more simple and stright forward way or ?


    CALL METHOD lo_nd_exp_notifheader_2->get_element_count
      RECEIVING
        count = i.

CALL METHOD lo_nd_exp_notifheader_2->get_lead_selection_index
  receiving
    index  = index
    .


    DO  i TIMES .

        CALL METHOD lo_nd_exp_notifheader_2->get_element
          EXPORTING
            index        = index
          receiving
            node_element = lo_el_exp_notifheader_2
            .

*      lo_el_exp_notifheader_2 = lo_nd_exp_notifheader_2->get_element(  ).

       CALL METHOD lo_el_exp_notifheader_2->get_attribute
        EXPORTING
          name  = 'NOTIF_NO'
        IMPORTING
          value = lv_notif_no.

      IF lv_notif_no EQ lv_sel_notif_no .
        WRITE 'equal'.
        exit.
      ELSE.
        index = index + 1 .
*        CALL METHOD lo_nd_exp_notifheader_2->move_next
*          receiving
*          new_lead_selection = index.
       ENDIF.

    ENDDO.

Secondly if I have two nodes in same context which have same attributes how I can copy the values of one node to the other node ( in the same context ) ?

e.g If node lets say, Imp_header_node have 5 attribtues ( I search one element ) and then copy this "search element" of imp_header_node to exp_header_node ?

Thanks and regards,

Edited by: Shah H on Dec 22, 2008 2:37 PM

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 02:41 PM

    ok I have a method bind_table in if_context_node so If i fill the internal table I can bind it to the node... but what is the way around like if I have a node how I can bring the values of particular element in my internal table ?

    my modified code...

        DO  i TIMES .
    
          CALL METHOD lo_nd_exp_notifheader_2->get_element
            EXPORTING
              index        = index
            RECEIVING
              node_element = lo_el_exp_notifheader_2.
    
    *      lo_el_exp_notifheader_2 = lo_nd_exp_notifheader_2->get_element(  ).
    
          CALL METHOD lo_el_exp_notifheader_2->get_attribute
            EXPORTING
              name  = 'NOTIF_NO'
            IMPORTING
              value = lv_notif_no.
    
          IF lv_notif_no EQ lv_sel_notif_no .
    
    *          Read attributes
            
            CALL METHOD lo_el_exp_notifheader_2->get_attribute
              EXPORTING
                name  = 'FUNCT_LOC'
              IMPORTING
                value = lv_funct_loc.
    
            CALL METHOD lo_el_exp_notifheader_2->get_attribute
              EXPORTING
                name  = 'PLANGROUP'
              IMPORTING
                value = lv_plangroup.
        
    *       ...
    
    *       set attributes
            ls_imp_notifheader-funct_loc = lv_funct_loc.
            ls_imp_notifheader-plangroup = lv_plangroup.
    *       ...
            
            APPEND ls_imp_notifheader TO lt_imp_notifheader.
    
    *       bind table
            CALL METHOD lo_nd_imp_notifheader->bind_table
              EXPORTING
                new_items            = lt_imp_notifheader
    *            set_initial_elements = ABAP_TRUE
    *            index                =
                .
    
            lo_el_exp_notifheader->set_attribute(
                EXPORTING
                    name  =  `NOTIF_NO`
                    value =  lv_sel_notif_no ).
    
    
            EXIT.
          ELSE.
            index = index + 1 .
    *        CALL METHOD lo_nd_exp_notifheader_2->move_next
    *          receiving
    *          new_lead_selection = index.
          ENDIF.
    
        ENDDO.
    

    So my query is: do i have only one option using method "get_attribute" of element to retrieve single attributes or I can get all attributes values in one internal table of this particular element ?

    Pls suggest ?

    Edited by: Shah H on Dec 22, 2008 4:10 PM

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Shah,

      it will be knowledgeable for me as well to see if there is any way around as i was looking for it but not able to get it right....

      but i can provide you with an alternative...... say every time you when the view loads you must be setting attributes using any internal table..... so what you can do is you can make that internal table global so that you can access it anywhere just like context attribute..........

      regards

      Pranav

  • Posted on Dec 23, 2008 at 05:32 AM

    Hi Shah,

    Try go through this code snippet in which am copying selected rows from 1 table to another table. This involves getting the selected rows from 1st table (one context node) and then copying them to another table (another context node in the same view. Both these nodes have the same attributes).

    METHOD onactioncopy_selected_rows .
      DATA:  wd_node TYPE REF TO if_wd_context_node,
             ls_node1 TYPE ig_componentcontroller=>element_node1,
             lt_node1 TYPE ig_componentcontroller=>elements_node1,
             lt_node2 TYPE ig_componentcontroller=>elements_node2,
             wa_temp  TYPE REF TO if_wd_context_element,
             lt_temp  TYPE wdr_context_element_set.
    
    
      wd_node = wd_context->get_child_node( name = 'NODE1' ).
    
      CALL METHOD wd_node->get_selected_elements
        RECEIVING
          set = lt_temp.
    
      wd_node = wd_context->get_child_node( name = 'NODE2' ).
    
      LOOP AT lt_temp INTO wa_temp.
        CALL METHOD wa_temp->get_static_attributes
          IMPORTING
            static_attributes = ls_node1.
        APPEND ls_node1 TO lt_node1.
        CLEAR ls_node1.
      ENDLOOP.
    
      wd_node->bind_table( new_items = lt_node1 ).
    ENDMETHOD.

    Regards,

    Uday

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.