Saturday, December 18, 2010

Scenario on making input enabled table using Web Dynpro for ABAP

Summary: Simple example to make an input enabled table during run time. Here we will create one Application name ‘zwd_input_enable_tab’ in which we will create one table with the dictionary structure MARA and will make it input enabled so that the user can enter data in the table during runtime.

1. Go to the transaction SE80. Select “WebDynpro Comp./Intf” from the list (as shown below.

2. Create a new WebDynpro component by the name ‘zwd_input_enable_tab’. Give the description as ‘Input Enable Table’.

3. Double click on the Component Controller. And go to the Context tab of the Component Controller.

4. Check if the application is in change mode. Then create a node as shown below.

5. Create a node by the name ‘Material’. In this example we are taking the Dictionary Structure as ‘Mara’. And the Cardinality is 0..n.

6. Now create attributes of the node ‘Material’ by clicking on ‘Add Attribute From Structure’. And then select the required fields of Mara and then click on ‘Continue’.

7. Now double click in the default view that is ‘Main’ in this example & then click on the Context tab of that view as shown below.

8. Now drag and drop the Node on the right side (Component Controller Node) to the context on the left side (View Node).

9. Go to the Layout tab of the View and then right click on the ‘ROOTUIELEMENTCONTAINER’ and click on ‘Insert Element’. And then create a table as shown below.

10. Right click on the table and click on ‘Create Binding’, the following screen will appear.

11. Here click on the ‘Context’ button. And bind the table with the node (Here the Node is Material).

12. Now change the ‘Standard Cell Editor’ from ‘Textview’ which will come as default to ‘Input Field’ as shown below:

13. Click on Continue. And we will be back to the Layout page of the View.

14. Now click on the ‘Methods’ tab of the same View and then double click on the WDDOINIT method.

15. Write the following Code in this method.

Types : Begin of ty_mara,
MATNR type mara-matnr,
ERSDA type mara-ERSDA,
ERNAM type mara-ERNAM,
LAEDA type mara-LAEDA,
AENAM type mara-AENAM,
end of ty_mara.
*Creating internal table and Work Area of the same structure
*as that of the Node created.
Data : lt_material type standard table of ty_mara,
wa_mara type ty_mara.
*Appending Blank Work Area to Internal table.
Do 10 times.
Append wa_mara to lt_material.
"Binding the table
 DATA lo_nd_material TYPE REF TO if_wd_context_node.
*  DATA lt_material TYPE wd_this->Elements_material.
* navigate from  to  via lead selection
lo_nd_material = wd_context->get_child_node( name = wd_this->wdctx_material ).
* @TODO handle non existant child
* IF lo_nd_material IS INITIAL.
** @TODO compute values
** e.g. call a model function

lo_nd_material->bind_table( new_items = lt_material set_initial_elements = abap_true ).

In the above Code We will just create an internal table and Work Area that should have the same structure as that of the Node created in the Component Controller. And then we have to just append blank Work Area to the Internal Table in order to get Input Enabled Table. Once done we will bind the table.

16. Now Right Click on the Component (ZWD_INPUT_ENABLE_TAB) and create WebDynpro Application as shown below, give a description.

17. Now save and activate and then Right click on Application and test it. Now you will see that your table is input enabled & user can enter data in it.

No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)


Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

Blog Archive