cancel
Showing results for 
Search instead for 
Did you mean: 

How to increment the index by pressing on button in webdynpro?

former_member210804
Active Participant
0 Kudos

Hi sir,

I have a scenario.

I have 3 or more history master records. I want to fetch one by one record by pressing on NEXT button.

I have added the screen shots below. Pls . check the same and reply me.

Thanks & regards,

Narasimha Rao Putturi.

Accepted Solutions (0)

Answers (5)

Answers (5)

chengalarayulu
Active Contributor
0 Kudos

Narasimha,

You can write like below: you can achieve this by using two methods GET_LEAD_SELECTION_INDEX and SET_LEAD_SELECTION_INDEX

Note: You should enable InitialLeadSelection to the node.

data: lv_count type i.

lv_count = lo_nd_node->get_element_count( ).

1. in Back Action.

     data: lv_index type i.

    

     **** lv_index = lo_nd_node->get_lead_selection_Index( ).

     if lv_index = 1.

          *** lo_nd_node->set_lead_selection_index( lv_count ). """ Sets last record.

     else.

          lv_index = lv_index - 1.

          lo_nd_node->set_lead_selection_index( lv_index ). """" Sets previous record.

     endif.

********* Now you can read the node and bind to form.

2. in Next Action.

     **** lv_index = lo_nd_node->get_lead_selection_Index( ).

     if lv_index = lv_count.

          *** lo_nd_node->set_lead_selection_index( 1 ). """ Sets last record.

     else.

          lv_index = lv_index + 1.

          lo_nd_node->set_lead_selection_index( lv_index ). """" Sets previous record.

     endif.

***** Now you can read the node and bind to form.

former_member210804
Active Participant
0 Kudos

Hi thanks you all.

CALL METHOD lo_nd_emp->get_static_attributes_table
   IMPORTING table  = lt_emp.


here LT_EMP has 3 records as mentioned above. i can able to fetch only 2records ;the last record is not fetching. the node is bind with the 2record bcoz LT_EMP has only 2record. How to get the 3 records into LT_EMP.

Thanks & regards,

Narasimha Rao Putturi.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Use the internal table which is used for populating table data.

Then make the SCREEN1.jpg fields bound to that node's attributes.

If you keep incrementing the count in NEXT button, you can achieve populating data as below.

   data lv_value type pa0001-pernr.
CALL METHOD lo_nd_empdetails->get_attribute
  EXPORTING
    index  =  3 "incremented index
    name   = 'PERNR'
  IMPORTING
    value  = lv_value
    .

* get element via lead selection
  lo_el_empdetails = lo_nd_empdetails->get_element( ).

* @TODO handle not set lead selection
  IF lo_el_empdetails IS NOT INITIAL.
* set single attribute
  lo_el_empdetails->set_attribute(
    name =  `PERNR`
    value = lv_value ).
  ENDIF.

former_member210804
Active Participant
0 Kudos

Hi , thank you for your quick reply.

I want to get the incremented index for each action( i.e; by pressing on NEXT button )

Pls. provide me the correct solution

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

You can keep the index incrementing manually by index = index + 1 provided if you don't have any lead selection in the table. You can find out the no. of lines in internal table using DESCRIBE statement and you keep the incrementing till that index.

Former Member
0 Kudos

Hi narasimha,

That is initially.... Lead selection on first record.. ok...

when u clik next...

in program u write

get_LEAD_SELECTION_INDEX( ).

u get an index number then incremented by one  and use

SET_LEAD_SELECTION_INDEX( ).  method to lead select...

if click next again u will get lead selection index and it increments by one and setleadselection....

Regards,

Venkat

Former Member
0 Kudos

Hi narasimha,

by using lead selection u will get result like..

initialy put lead selection on first record .by using..

lo_nd_context->SET_LEAD_SELECTION_INDEX( ).

if u put the lead selection on first element then when u call get_attribute.( ) it automatically calls the first record..that lead selection record..

after click on next increment index......

like that u can do u r requirementr..

regards,

Venkat

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

There can be many ways.

1.     One way is to increment the index when Next button is pressed.

2.     And then get the attributes using GET_ATTRIBUTE by passing the incremented index.

3.     Make the display fields(Screen1.jpg) binded to the attribute value under the node.

4.     Make sure you can make the read possible only till the no. of records.

data lv_value type pa0001-pernr.
CALL METHOD lo_nd_empdetails->get_attribute
  EXPORTING
    index  = lv_index "Incremented index
    name   = 'PERNR' 'Attribute in the node
  IMPORTING
    value  = lv_value
    .