Summary:We can use the firstVisibleRow property of Table element in Webdynpro ABAP to provide explicite Page Up and Page Down functionality of Table  for user convinience.

Steps:

1. Create a attribute PAGE_NO of type I in the main view context.

/wp-content/uploads/2014/03/hai1_408652.png

2. Bind the Table property firstVisibleRow to context attribute PAGE_NO.

/wp-content/uploads/2014/03/hai2_408651.png

3. Write below code in WDDOINIT().

method WDDOINIT.

DATA lo_nd_vbak

TYPE REF TO if_wd_context_node.

data lv_no_of_records type i. “to count no of records in internal table

TYPES :

BEGIN OF type_vbak,
           vbeln type vbak-vbeln,
           erdat type vbak-erdat,
           erzet type vbak-erzet,     

                    checkbox(1) type c,

         END OF type_vbak.

data lt_vbak type TABLE OF type_vbak.

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

SELECT vbeln erdat erzet from vbak INTO CORRESPONDING FIELDS OF TABLE lt_vbak UP TO 18 ROWS.if sy-subrc = 0.
  no_of_records = sy-dbcnt.
  ENDIF.

lo_nd_vbak->bind_table( lt_vbak ).

  DATA lo_el_context TYPE REF TO if_wd_context_element.
  DATA ls_context TYPE wd_this->element_context.
  * get element via lead selection
  lo_el_context = wd_context->get_element(  ).
* get single attribute
  CALL METHOD LO_EL_CONTEXT->SET_ATTRIBUTE
    EXPORTING
      VALUE  = lv_no_of_records
      NAME   = ‘NO_OF_RECORDS’
      .
endmethod.

4. Create Two buttons Page Up and Page Down and attach the Action method BUTTON_EVENT on action properties of these buttons.

/wp-content/uploads/2014/03/hai3_408662.png

5. Now write the below code in ONACTIONBUTTON_EVENT( ) as below.

method ONACTIONBUTTON_ACTION .

data element_id type string.CALL METHOD WDEVENT->GET_STRING
  EXPORTING
    NAME   = ‘ID’
  RECEIVING
    VALUE  = element_id.

  DATA lo_el_context TYPE REF TO if_wd_context_element.
  DATA ls_context TYPE wd_this->element_context.
  DATA lv_page_no LIKE ls_context-page_no.
  data lv_no_of_records LIKE ls_context-no_of_records.
* get element via lead selection
  lo_el_context = wd_context->get_element(  ).
* get single attribute
  lo_el_context->get_attribute(
    EXPORTING
      name =  `PAGE_NO`
    IMPORTING
      value = lv_page_no ).
* get single attribute
  lo_el_context->get_attribute(
    EXPORTING
      name =  `NO_OF_RECORDS`
    IMPORTING
      value = lv_no_of_records ).

case element_id.

   when ‘PAGE_UP’.
if lv_page_no <= 0.

exit.

  else.

    lv_page_no = lv_page_no – 5.

endif.

   WHEN ‘PAGE_DOWN’.

if lv_page_no >= lv_no_of_records.
  exit.

  else.

    lv_page_no = lv_page_no + 5 . “5 is default size of the table element
ENDIF.
  ENDCASE.

CALL METHOD lo_el_context->set_attribute
  EXPORTING
    value  = lv_page_no
    name   = ‘PAGE_NO’
    .

endmethod.

6 . Now activate the webdynpro component and create the application for this webdynpro component and test it.

/wp-content/uploads/2014/03/hai4_408663.png

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply