ABAP web dynpro ALV report table

Source: Internet
Author: User

Here are the simple instruction of how to insert an ALV report table into your web dynpro for ABAP application. implementing an interactive ALV report is a very simple process but once added provides extensive functionality such as sorting, edit, printing,
Export to excel, various views of same data... it also allows the final user to manipulate the report to their liking by re-ordering fields and even hiding some altogether!

Before following these steps you need to have created a basic web dynpro, which will only take about 5 mins as it does not need to do anything, all the one
Linked to here does is displaying the text 'helloworld '. once you have your basic web dynpro which contains a simply view, window and application you can follow the steps below to insert an ALV table into it.


Step 1-create a view container uielement
Within the layout tab of your view Add a new element of Type viewcontaineruielement and give it a name, such as viewcont1. this will be used to display your ALV table.
 

Step 2-create your context node
Now create your context which will be used to generate your ALV grid table. i. e. the fields in this context will make up the columns of your ALV table. double click on the componentcontroller and select the 'context' tab. now add a new node to the context node
(Right click the context and select create-> node ).
 

Step 2-populate properties of your context node
Give the new node A name and enter which table structure you want to base it on (I. e. structure you want your ALV grid based on ). also rememeber to set the cardinality to 0: n (OR 1: N) to denote a table.
 

Step 3-add field attributes to your context node
Now click on the 'Add attributes from structuring 'button, and select your desired table fields.
 

Step 4-context node created!
Press the green tick on both the new popup screens to return to your context section, your new context node shoshould now have been added.
 

Step 5-populate context used by ALV within view
Go to the context tab of your view and drag the ALV table context (alv_table) from the right hand side to the left hand conext node.
 

Step 6-assign ALV component usage
Within the used components tab of the Web dynpro main properties screen Add a new component usage salv_wd_table and give it a usage name of your choice (alv_comp ).
 

Step 7-access the component usage
Within the left hand Object Tree expand component usages and then the usage you just created (alv_comp). Now double click on interfacecontroller_usage
 

Step 8-assign controller usage to ALV usage
Click on the 'controller usage' button and select your web dynpro component
 

Step 9-assign context to ALV usage data
A second context view will open on the right hand side containing the context node you created earlier for your ALV table. Simply drag this node from the right hand side to the left hand side data node.
 

Step 10-embed the ALV into view container
Go to your main window where the view (view1) has been embeded. Expand the view until you reach the view container viewcont1. now right click on the view container and select 'embedded view'
 

Step 11-choose View to embed
Click the Drop Down Option of the 'view to be embedded 'field and select the table view of your ALV component usage (alv_comp ).
 

Step 12-add ABAP code to populate ALV table
Within the wddointinit method of your view (view1) enter the following code.

* create local data variable to access context information  Data: context_node type ref to if_wd_context_node.* create table based on context structure  data: it_scarr type STANDARD TABLE OF if_view1=>element_ALV_TABLE,        wa_scarr like line of it_scarr.*select data from required SAP table  select *    from scarr    into table it_scarr.* bind data to context used by ALV  context_node = wd_context->get_child_node( name = 'ALV_TABLE').  context_node->BIND_table( it_scarr ).

Step 13-all done!
Well thats it your all done, simply save and activate everything and execute the application. You shocould see something like the following...
 

Step 14-populate context used by ALV within view
Note: you will notice that client is displayed within the alav even though you did not select the client field during the context creation stage. this is just to demonstrate that all fields from the route structure are brought through to the ALV despite how
Please you actually choose.

If you dont want certain fields to appear you can create a structure which does not contain them or insert some code to hide fields of the Web dynpro
ALV you do not want to see.

Check out web dynpro ALV select options if you want to add user selection to your ALV report. This allows the user to resrict the output results
Based on select option input fields.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.