sapdev logo background
sapdev logo sapdev logo
Comments

ABAP Web dynpro populate table on action / button click




Once you have added a table to your web dynpro for ABAP application you may need to populate or re-populate when a user performs a certain action like clicking a button. Here are the simple steps required to implement this functionality so that the ABAP web dynpro application updates the table at the appropriate time.


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


Step 2 - Fill in the properties
Within the properties section of the button fill in the properties you require such as text, imageSource etc.


Step 3 - Assign Action to your button
If you have not already done this Within the properties section of the new button create an Action for it by clicking on the create button, and typing the name of the action into the following popup.


Step 4 - View your new action
Your new action will now have been created within the actions tab of your view.


Step 5 - Add code to your action
From the actions tab you can double click into it and add your own ABAP code.

Data: it_scarr type standard table of scarr,
      context_node type ref to if_wd_context_node.

* Retrieve new data
select *
  from scarr
  into table it_scarr
 where CARRID = 'AA' .

* Re-bind this data to the context of the table and it should be updated with th ene data
  if sy-subrc eq 0.
    context_node = wd_context->get_child_node( name = 'CARRIERS').
*                   Note: CARRIERS' is the name you gave you new node in the context
    context_node->bind_table( it_scarr ).
  endif.


Step 6 - What the ABAP Web dynpro looks like now
When you now execute the ABAP web dynpro you are presented with the following screen, same as before but the button details have been changed.


Step 6 - Pressing the button
When you click on the button within the web dynpro for ABAP application the table is updated as follows, based on the the code you inserted into the ACTION method.




comments powered by Disqus