sapdev logo background
sapdev logo sapdev logo
Comments

Read ABAP Web dynpro table context on action / button click




Once you have added a table to your web dynpro for ABAP application you may need to read this table and get the data as it is presented to the user, especially if this an ALV table which allows the user to change values or add and delete new rows. Here are the simple steps required to implement this functionality so that you can retrieve this table data.

The code also shows you how to read a specific row of your abap web dynpro table.


Step 1 - Create the basics
Make sure you have a working web dynpro application which conatians a table and a button

Step 2 - Add code to your button action method

From the actions tab you can double click on your ACTION to view its associated method and add your own ABAP code to it.

* create local data variable to access context information
  Data: context_node type ref to if_wd_context_node.

  Data: it_scarr type STANDARD TABLE OF if_view1=>element_CARRIERS,
        wa_scarr like line of it_scarr.

  DATA: index type i.

  context_node = wd_context->get_child_node( name = 'CARRIERS').
  refresh: it_scarr.

* Get data contained within ABAP web dynpro table
  context_node->get_static_attributes_table(
    importing
      table = it_scarr ).

* Get data contained in a Specific row of an ABAP web dynpro table
  index = 3.  "Get row 3
  context_node->GET_STATIC_ATTRIBUTES(
     exporting index = index
     importing STATIC_ATTRIBUTES = wa_scarr ).




comments powered by Disqus