cancel
Showing results for 
Search instead for 
Did you mean: 

How to get each instace of the node with cardinality 1-n

Former Member
0 Kudos

Hi Experts,

I need your help in realizing my requirement.

I have a typical requirement like, a selection screen, a ALV list screen and a detailed screen.

If multiple rows are selected in ALV list screen and press 'SHOW DETAIL' button, then first record should be shown in detail view.

I have managed till get the multiple selected rows of ALV and bind the internal table to context of Detail view.

Detail view is showing the first record of the context.

Detail view node context - cardinality 1-n and selection 1-n.

I have two buttons on the tool bar like <<Previous and Next>>.

I have to show the next record on pressing Next>> button. How wil i get the record of next index in detail view node.

How will i know the current index of the Node context?

how to handle the previous and next buttons. Any clue will be greately appreciated.

Regards,

Ajay

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Are these buttons on toolbar custom ones...

Have you tried using the paginator.

Is there any leadselection for the ALV of detail view being set.

Regards,

Lekha.

Former Member
0 Kudos

Yes these buttons are custom ones.

I have not used the pagenator. Any example application available for pagenator?

Detail view is not a ALV, its a normal screen.

Regards,

Ajay

Former Member
0 Kudos

Hi,

In the 2nd view, ie Details how are you displaying the details. What UI element have you used.

Regards,

Lekha.

Former Member
0 Kudos

Detail view has only labels and input fields to show the data of the node , with a toolbar for actions.

My idea is to show the next instance of the node on the pres of Next button by reading the next instance using index.

I am struck at knowing the current index and how to query the instance of node based on required index.

Is my approach correct?

Edited by: ajay matam on Sep 22, 2009 5:19 PM

Former Member
0 Kudos

Hi,

It's like a applcation form with those buttons right.....

Now on PREV/NEXT you want to show those records...right...

Create a node with 1:1 cardinality and for this node use the CREATE CONTAINER form to dispaly the fields

as per your requirement.

From the ALV first view you might have got data into some internal table for detail view right. As you already did.

In the PREV/NEXT buttons,

For example now lt_table has all the detailed data pertaning to one or more parent record right.

Get the number of records in this table.

One more thing, add a counter variable to the detail view node.

When 1st time this detailed view is displayed,

Read the table lt_table with index 1 and you can use the set_attributes_table of if_wd_context_node and pass this record.

As this lt_table has counter in it, you can read the counter and can get the value.

Regards,

Lekha.

Former Member
0 Kudos

but the internal table lt_table is specific to alv view and will not be present in detail view.

Currently on button click 'SHOW_Detail' action, i am getting all the selected rows of ALV, binding it to detail node and firing the outbound plug to navigate to detail view.

I have ALV node with cardinality 0-n and Detail Node with cardinality 1-n.

Detail node(say Node_detail1) will be populated with selected rows of ALV ( as more than one row can be selected )

Now you say that i need to create another node (say Node_Detail2) for Detail view with cardinality 1-1 and use this to show data in detail view.

on Next and Prev button, read the node Node_Detail1 with the help of index and populate that into Node_Detail2 by using set_attributes_table.

am i correct in my understanding?

Former Member
0 Kudos

Hi,

Yes, you are right. But the Lt_table should be made global. You can move it to gloabl table and use the same in next view.

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

Many thanks for your prompt replies, but i am confused here.

1. If i have two nodes for detail - one with cardinality 1-n to store the detail data selected in alv, another one with cardinality 1-1 to show the data on view. - If this is the case, why do i need to make lt_table as global? i can get the index from detail_node1 right.

2. what do you mean by making lt_table global? you mean declare an attribute lt_table in controller context?

  • or if i make lt_table as global and populate it with data in ALV view, i need not have the detail_node1 with cardinality 1-n right?*

pls clarify

thanks,

Ajay

Edited by: ajay matam on Sep 22, 2009 6:07 PM

Former Member
0 Kudos

Hi,

For example:

There are 3 nodes VBAK(0:N),VBAP(0:N), VBAP_ONE(1:1).

VBAK - Main ALV for view.

Now, based on the VBAK entires of lt_vbak (selected records) you were able to get the VBAP details (items-lt_vbap).

To this VBAP node, have a counter varible called INDEX/COUNTER and based on the lt_vbap entries try to modify the table for this counter by incrementing like Serial Number. Also have this counter in the VBAP_ONE.

You have bound both these Internal tables to respective ones.

Now, Using the CREATECONTAINER FORM UI element bound to VBAP_ONE.

Now in the buttons prev/next I can either store the lt_vbap in the component controller attributes or

You can use the GET_STATIC_ATTRIBUTES_TABLE of the VBAP node so that you can get the entries.

Now,

PREV button, get the record of VBAP_ONE using get_static_attributes of vbap_one, yuo can get the counter right.

Based on tis counter, read the next record from lt_vbak table and again using the SET_STATIC_ATTRIBUTES of vbap_one

set to this record.

Hope this is clear.

Regards,

Lekha.

Former Member
0 Kudos

Hi

Thanks for the example, but here when i have the global Internal table, i don't need VBAP(0:N). right.

so LT_VBAP with index as first field and i will populate lt_vbap in alv view. Also node VBAP(1:1) also has index.

so node VBAP(1:1) will be set by reading LT_VBAP. right.

Then no need to have VBAP(0:N) right.

Former Member
0 Kudos

Hi,

Check this code -

DATA lo_nd_vbak TYPE REF TO if_wd_context_node.

  DATA lt_vbak TYPE wd_this->elements_vbak.
  DATA ls_vbak TYPE wd_this->element_vbak.

  DATA lo_nd_vbap TYPE REF TO if_wd_context_node.

  DATA lt_vbap TYPE wd_this->elements_vbap.
  DATA ls_vbap TYPE wd_this->element_vbap.

* navigate from <CONTEXT> to <VBAK> via lead selection
  lo_nd_vbak = wd_context->get_child_node( name = wd_this->wdctx_vbak ).

* navigate from <CONTEXT> to <VBAK> via lead selection
  lo_nd_vbap = wd_context->get_child_node( name = wd_this->wdctx_vbap ).

  SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE lt_vbak
  WHERE vbeln = lv_vbeln.

  SELECT * FROM vbap INTO CORRESPONDING FIELDS OF TABLE lt_vbap  WHERE vbeln = lv_vbeln.

* @TODO handle non existant child
  IF lo_nd_vbak IS NOT INITIAL.
    lo_nd_vbak->bind_table( lt_vbak ).
  ENDIF.

* @TODO handle non existant child
  IF lo_nd_vbap IS NOT INITIAL.

lo_nd_vbap->bind_table( lt_vbap ). "before you bind, try to modfy table for counter.

ENDIF.

data ls_vbap1 type vbap.
  LOOP AT lt_vbap INTO ls_vbap.
    move-corresponding ls_vbap to ls_vbap1.
        append ls_vbap1 to wd_this->lt_vbap.
  ENDLOOP.
  DATA lo_nd_vbap_one TYPE REF TO if_wd_context_node.

  DATA lo_el_vbap_one TYPE REF TO if_wd_context_element.
  DATA ls_vbap_one TYPE wd_this->element_vbap_one.

* navigate from <CONTEXT> to <VBAP_ONE> via lead selection
  lo_nd_vbap_one = wd_context->get_child_node( name = wd_this->wdctx_vbap_one ).

* @TODO handle non existant child
* IF lo_nd_vbap_one IS INITIAL.
* ENDIF.

* get element via lead selection
  lo_el_vbap_one = lo_nd_vbap_one->get_element( ).

* @TODO handle not set lead selection
  IF lo_el_vbap_one IS INITIAL.
  ENDIF.

* @TODO fill static attributes
* ls_vbap_one = xxx->get_yyy( ).


  READ TABLE lt_vbap INTO ls_vbap INDEX 1.   "for Initial display
* set all declared attributes
  lo_el_vbap_one->set_static_attributes(
     static_attributes = ls_vbap ).

Regards,

Lekha.

Former Member
0 Kudos

Hi,

In the PREV,NEXT button handlers here is the code-

PREV button  -
  DATA lo_nd_vbap_one TYPE REF TO if_wd_context_node.

  DATA lo_el_vbap_one TYPE REF TO if_wd_context_element.
  DATA ls_vbap_one TYPE wd_this->element_vbap_one.

* navigate from <CONTEXT> to <VBAP_ONE> via lead selection
  lo_nd_vbap_one = wd_context->get_child_node( name = wd_this->wdctx_vbap_one ).

* @TODO handle non existant child
* IF lo_nd_vbap_one IS INITIAL.
* ENDIF.

* get element via lead selection
  lo_el_vbap_one = lo_nd_vbap_one->get_element( ).

* @TODO handle not set lead selection
  IF lo_el_vbap_one IS INITIAL.
  ENDIF.

* @TODO fill static attributes
* ls_vbap_one = xxx->get_yyy( ).

DATA ls_vbap type vbap.

*First using the GET_STATIC_ATTRIBUTES of lo_el_vbap_one get the counter value into lv_counter
* replace the 2 below with this counter.
* SAME as in NEXT button.


  READ TABLE wd_this->lt_vbap INTO ls_vbap INDEX 2.  "You can get the counter value
* set all declared attributes
  lo_el_vbap_one->set_static_attributes(
     static_attributes = ls_vbap ).

In VBAP_ONE also have the counter attribute. This VBAP_ONE is like an work area of VBAP.

Hope this makes clear.

Regards,

Lekha.

Former Member
0 Kudos

Hi,

You can have a global internal table for vbap and no need of using the VBAP node with 0:N cardinality. You can direclty have the VBAP_ONE with 1:1 cardinality. And can display record by record.

My code snippet have three nodes. You can enhance it.

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

Many thanks for your prompt replies.

regards,

Ajay

Answers (0)