In the earlier example, we have created a WebDynpro application to populate the data into the custom table ZDEPT. In this, we would display the data from the ZDEPT using ABAP WebDynpro.
Following are the contents of the table:
Create a table type ‘ZDEPTTBL’ for table ‘ZDEPT’
Go to transaction SFP and create a from interface ‘ZDEPTINF’ as shown below
Select the Interface type as ‘ABAP Dictionary-Based Interface’, this time we are not going to use the ‘XML schema based interface’, this is to demonstrate that we can make use of any of the existing forms inside the Web Dynpro.
Save the Interface
Create Transport for the Interface
Enter the Import parameter ‘ZDEPT’ and type ‘ZDEPTTBL’. Save and activate the interface
Create the form ‘ZDEPFRM’
Enter the Interface Name as ‘ZDEPTINF’
Save the form
Drag and drop the Node ‘ZDEPT’ onto the context
Go to the Layout tab and Drag & Drop the ‘ZDEPT’ node on to the form layout, Save and Activate the form
You can also create a Report program (Print Program) and call the above mentioned form, but we are going to write the print program logic in the Web Dynpro.
Go to transaction SE80 and create a Web Dynpro component ‘Z_NON_INT_FRM’.
Press ‘Yes’ to create the object
Enter the details as show below and press enter
Save and enter a workbench request
You can see the Component Controller, Interface controller and window being created
Create a view as shown below:
Give the Name of the View as ‘MAIN_VIEW’
Go to the layout tab of the ‘MAIN_VIEW’ and create a place holder for the adobe form as shown below
Give the name of the node as adobe and type Interactive form
In the properties list set the Height and width and the template source as ‘ZDEPFRM’ this is the actual name of the adobe form which we have created earlier, you can see the interface context is automatically mapped to the data source.
You can see the mapped data source in the context tab of the ‘MAIN_VIEW’
Go to the Methods table of the ‘MAIN_VIEW’ and double click on the ‘WDDOINIT’ method,
We are going to write the print program’s logic in this method, we are not going to use the standard function modules that we use normally in the Report print program such as
FP_JOB_OPEN, FP_FUNCTION_MODULE_NAME, FP_JOB_CLOSE.
Copy and Paste the below given code in the method.
method WDDOINIT .
data:
Node_Zdepfrm type ref to If_Wd_Context_Node,
Elem_Zdepfrm type ref to If_Wd_Context_Element,
Stru_Zdepfrm type If_Main_View=>Element_Zdepfrm ,
Item_ZDEPT like Stru_Zdepfrm-ZDEPT,
i_dept type zdepttbl.
* navigate from
Node_Zdepfrm = wd_Context->get_Child_Node
( Name = IF_MAIN_VIEW=>wdctx_Zdepfrm ).
* @TODO handle not set lead selection
if ( Node_Zdepfrm is initial ).
endif.
* get element via lead selection
Elem_Zdepfrm = Node_Zdepfrm->get_Element( ).
* @TODO handle not set lead selection
if ( Elem_Zdepfrm is initial ).
Elem_Zdepfrm = Node_Zdepfrm->create_element( ).
endif.
select * from zdept into table i_dept.
Item_Zdept = i_dept.
* get single attribute
Elem_Zdepfrm->set_Attribute(
exporting
Value = Item_Zdept
Name = `ZDEPT`
).
Node_Zdepfrm->bind_element( Elem_Zdepfrm ).
endmethod.
Go to the window ‘Z_NON_INT_FRM’ and select the window tab as shown below
Drag and Drop the ‘MAIN_VIEW’ on to the window
Save and activate the Web Dynpro
Create a Web Dynpro application as show below
Enter the name of the application ‘Z_NON_INT_FRM’ and save the application
Test the Web Dynpro application
Logon with you credentials enter the username and password.
You can see the output in the form below.
No comments:
Post a Comment